@@ -29,6 +29,10 @@ class ActionUrlHandlerAndroid;
29
29
namespace {
30
30
31
31
bool IsRenderFrameHostSupported (content::RenderFrameHost* rfh) {
32
+ if (!rfh) {
33
+ return false ;
34
+ }
35
+
32
36
if (rfh->GetLifecycleState () ==
33
37
content::RenderFrameHost::LifecycleState::kPendingCommit ) {
34
38
return true ;
@@ -46,13 +50,21 @@ bool IsRenderFrameHostSupported(content::RenderFrameHost* rfh) {
46
50
ContentActionUrlDriver::ContentActionUrlDriver (
47
51
content::RenderFrameHost* render_frame_host)
48
52
: render_frame_host_(render_frame_host) {
53
+ if (!render_frame_host_) {
54
+ LOG (ERROR) << " AMIT ContentActionUrlDriver: render_frame_host is null!" ;
55
+ return ;
56
+ }
49
57
static unsigned next_free_id = 0 ;
50
58
id_ = next_free_id++;
51
59
handler_processing_remaining_ = 0 ;
52
60
action_block_draw_remaining_ = 0 ;
53
61
requested_for_header_ = false ;
54
62
55
- LOG (INFO) << " AMIT ContentActionUrlDriver constructor before get interface" ;
63
+ if (!render_frame_host_->GetRemoteAssociatedInterfaces ()) {
64
+ LOG (ERROR) << " AMIT ContentActionUrlDriver: RemoteAssociatedInterfaces is null!" ;
65
+ return ;
66
+ }
67
+
56
68
render_frame_host_->GetRemoteAssociatedInterfaces ()->GetInterface (
57
69
&action_url_agent_);
58
70
LOG (INFO) << " AMIT action_url_agent_ is bound: " << action_url_agent_.is_bound ();
@@ -64,12 +76,23 @@ ContentActionUrlDriver::~ContentActionUrlDriver() = default;
64
76
void ContentActionUrlDriver::BindPendingReceiver (
65
77
mojo::PendingAssociatedReceiver<action_url::mojom::ActionUrlDriver>
66
78
pending_receiver) {
79
+ if (!render_frame_host_) {
80
+ LOG (ERROR) << " AMIT BindPendingReceiver: render_frame_host_ is null!" ;
81
+ return ;
82
+ }
83
+
67
84
if (IsRenderFrameHostSupported (render_frame_host_)) {
68
85
action_url_receiver_.Bind (std::move (pending_receiver));
69
86
}
70
87
}
71
88
72
89
void ContentActionUrlDriver::DidNavigate () {
90
+ if (!render_frame_host_) {
91
+ LOG (ERROR) << " AMIT DidNavigate: render_frame_host_ is null!" ;
92
+ action_url_receiver_.reset ();
93
+ return ;
94
+ }
95
+
73
96
if (!IsRenderFrameHostSupported (render_frame_host_)) {
74
97
action_url_receiver_.reset ();
75
98
}
@@ -83,6 +106,11 @@ int ContentActionUrlDriver::GetId() const {
83
106
void ContentActionUrlDriver::AllAnchorsParsed (
84
107
const std::vector<action_url::AnchorData>& anchors_data) {
85
108
109
+ if (!render_frame_host_) {
110
+ LOG (ERROR) << " AMIT AllAnchorsParsed: render_frame_host_ is null!" ;
111
+ return ;
112
+ }
113
+
86
114
Profile* profile = Profile::FromBrowserContext (render_frame_host_->GetBrowserContext ());
87
115
if (!profile->GetPrefs ()->GetBoolean (action_url::prefs::kBlinksEnabled )) {
88
116
LOG (INFO) << " AMIT Blinks are disabled" ;
@@ -165,6 +193,11 @@ void ContentActionUrlDriver::ActionUrlFetched(action_url::AnchorData anchor,
165
193
void ContentActionUrlDriver::ProcessActionUrl (GURL action_url,
166
194
action_url::AnchorData anchor,
167
195
std::string tag) {
196
+ if (!render_frame_host_) {
197
+ LOG (ERROR) << " AMIT ProcessActionUrl: render_frame_host_ is null!" ;
198
+ return ;
199
+ }
200
+
168
201
std::unique_ptr<network::ResourceRequest> request =
169
202
std::make_unique<network::ResourceRequest>();
170
203
request->url = action_url;
@@ -228,6 +261,12 @@ void ContentActionUrlDriver::OnDownloadedJson(
228
261
const mojo::AssociatedRemote<action_url::mojom::ActionUrlAgent>&
229
262
ContentActionUrlDriver::GetActionUrlAgent () {
230
263
LOG (INFO) << " AMIT GetActionUrlAgent" ;
264
+
265
+ if (!render_frame_host_) {
266
+ LOG (ERROR) << " AMIT GetActionUrlAgent: render_frame_host_ is null!" ;
267
+ return action_url_agent_unbound_;
268
+ }
269
+
231
270
CHECK_NE (render_frame_host_->GetLifecycleState (),
232
271
content::RenderFrameHost::LifecycleState::kPendingCommit );
233
272
LOG (INFO) << " AMIT GetActionUrlAgent 2" ;
0 commit comments