OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Implements the Chrome Extensions WebNavigation API. | 5 // Implements the Chrome Extensions WebNavigation API. |
6 | 6 |
7 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h" | 7 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h" |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api_consta
nts.h" | 10 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api_consta
nts.h" |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 // http://crbug.com/109464. | 175 // http://crbug.com/109464. |
176 DCHECK(chrome::GetViewType(details->source_web_contents) != | 176 DCHECK(chrome::GetViewType(details->source_web_contents) != |
177 chrome::VIEW_TYPE_TAB_CONTENTS); | 177 chrome::VIEW_TYPE_TAB_CONTENTS); |
178 return; | 178 return; |
179 } | 179 } |
180 const FrameNavigationState& frame_navigation_state = | 180 const FrameNavigationState& frame_navigation_state = |
181 tab_observer->frame_navigation_state(); | 181 tab_observer->frame_navigation_state(); |
182 | 182 |
183 FrameNavigationState::FrameID frame_id( | 183 FrameNavigationState::FrameID frame_id( |
184 details->source_frame_id, | 184 details->source_frame_id, |
185 details->source_web_contents->GetRenderViewHost()->GetProcess()->GetID()); | 185 details->source_web_contents->GetRenderViewHost()); |
186 if (!frame_navigation_state.CanSendEvents(frame_id)) | 186 if (!frame_navigation_state.CanSendEvents(frame_id)) |
187 return; | 187 return; |
188 | 188 |
189 // If the WebContents was created as a response to an IPC from a renderer | 189 // If the WebContents was created as a response to an IPC from a renderer |
190 // (and therefore doesn't yet have a TabContents), or if it isn't yet inserted | 190 // (and therefore doesn't yet have a TabContents), or if it isn't yet inserted |
191 // into a tab strip, we need to delay the extension event until the | 191 // into a tab strip, we need to delay the extension event until the |
192 // WebContents is fully initialized. | 192 // WebContents is fully initialized. |
193 if (TabContents::FromWebContents(details->target_web_contents) == NULL || | 193 if (TabContents::FromWebContents(details->target_web_contents) == NULL || |
194 details->not_yet_in_tabstrip) { | 194 details->not_yet_in_tabstrip) { |
195 pending_web_contents_[details->target_web_contents] = | 195 pending_web_contents_[details->target_web_contents] = |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 | 252 |
253 WebNavigationTabObserver::~WebNavigationTabObserver() {} | 253 WebNavigationTabObserver::~WebNavigationTabObserver() {} |
254 | 254 |
255 // static | 255 // static |
256 WebNavigationTabObserver* WebNavigationTabObserver::Get( | 256 WebNavigationTabObserver* WebNavigationTabObserver::Get( |
257 content::WebContents* web_contents) { | 257 content::WebContents* web_contents) { |
258 TabObserverMap::iterator i = g_tab_observer.Get().find(web_contents); | 258 TabObserverMap::iterator i = g_tab_observer.Get().find(web_contents); |
259 return i == g_tab_observer.Get().end() ? NULL : i->second; | 259 return i == g_tab_observer.Get().end() ? NULL : i->second; |
260 } | 260 } |
261 | 261 |
| 262 content::RenderViewHost* WebNavigationTabObserver::render_view_host_in_process( |
| 263 int process_id) const { |
| 264 if (render_view_host_ && |
| 265 render_view_host_->GetProcess()->GetID() == process_id) { |
| 266 return render_view_host_; |
| 267 } |
| 268 if (pending_render_view_host_ && |
| 269 pending_render_view_host_->GetProcess()->GetID() == process_id) { |
| 270 return pending_render_view_host_; |
| 271 } |
| 272 return NULL; |
| 273 } |
| 274 |
262 void WebNavigationTabObserver::Observe( | 275 void WebNavigationTabObserver::Observe( |
263 int type, | 276 int type, |
264 const content::NotificationSource& source, | 277 const content::NotificationSource& source, |
265 const content::NotificationDetails& details) { | 278 const content::NotificationDetails& details) { |
266 switch (type) { | 279 switch (type) { |
267 case content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT: { | 280 case content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT: { |
268 content::ResourceRedirectDetails* resource_redirect_details = | 281 content::ResourceRedirectDetails* resource_redirect_details = |
269 content::Details<content::ResourceRedirectDetails>(details).ptr(); | 282 content::Details<content::ResourceRedirectDetails>(details).ptr(); |
270 ResourceType::Type resource_type = | 283 ResourceType::Type resource_type = |
271 resource_redirect_details->resource_type; | 284 resource_redirect_details->resource_type; |
272 if (resource_type == ResourceType::MAIN_FRAME || | 285 if (resource_type == ResourceType::MAIN_FRAME || |
273 resource_type == ResourceType::SUB_FRAME) { | 286 resource_type == ResourceType::SUB_FRAME) { |
| 287 content::RenderViewHost* render_view_host = NULL; |
| 288 if (render_view_host_ && |
| 289 resource_redirect_details->origin_child_id == |
| 290 render_view_host_->GetProcess()->GetID()) { |
| 291 render_view_host = render_view_host_; |
| 292 } else if (pending_render_view_host_ && |
| 293 resource_redirect_details->origin_child_id == |
| 294 pending_render_view_host_->GetProcess()->GetID()) { |
| 295 render_view_host = pending_render_view_host_; |
| 296 } |
| 297 if (!render_view_host) |
| 298 return; |
274 FrameNavigationState::FrameID frame_id( | 299 FrameNavigationState::FrameID frame_id( |
275 resource_redirect_details->frame_id, | 300 resource_redirect_details->frame_id, render_view_host); |
276 resource_redirect_details->origin_child_id); | |
277 if (!navigation_state_.CanSendEvents(frame_id)) | 301 if (!navigation_state_.CanSendEvents(frame_id)) |
278 return; | 302 return; |
279 navigation_state_.SetIsServerRedirected(frame_id); | 303 navigation_state_.SetIsServerRedirected(frame_id); |
280 } | 304 } |
281 break; | 305 break; |
282 } | 306 } |
283 | 307 |
284 default: | 308 default: |
285 NOTREACHED(); | 309 NOTREACHED(); |
286 } | 310 } |
287 } | 311 } |
288 | 312 |
289 void WebNavigationTabObserver::AboutToNavigateRenderView( | 313 void WebNavigationTabObserver::AboutToNavigateRenderView( |
290 content::RenderViewHost* render_view_host) { | 314 content::RenderViewHost* render_view_host) { |
291 if (!render_view_host_) { | 315 if (!render_view_host_) { |
292 render_view_host_ = render_view_host; | 316 render_view_host_ = render_view_host; |
293 } else if (render_view_host != render_view_host_) { | 317 } else if (render_view_host != render_view_host_) { |
294 // TODO(jochen): If pending_render_view_host_ is non-NULL, send error events | 318 if (pending_render_view_host_) |
295 // for all ongoing navigations in that RVH. | 319 SendErrorEvents(web_contents(), pending_render_view_host_); |
296 pending_render_view_host_ = render_view_host; | 320 pending_render_view_host_ = render_view_host; |
297 } | 321 } |
298 } | 322 } |
299 | 323 |
300 void WebNavigationTabObserver::DidStartProvisionalLoadForFrame( | 324 void WebNavigationTabObserver::DidStartProvisionalLoadForFrame( |
301 int64 frame_num, | 325 int64 frame_num, |
302 bool is_main_frame, | 326 bool is_main_frame, |
303 const GURL& validated_url, | 327 const GURL& validated_url, |
304 bool is_error_page, | 328 bool is_error_page, |
305 content::RenderViewHost* render_view_host) { | 329 content::RenderViewHost* render_view_host) { |
306 if (!render_view_host_) | 330 if (!render_view_host_) |
307 render_view_host_ = render_view_host; | 331 render_view_host_ = render_view_host; |
308 if (render_view_host != render_view_host_ && | 332 if (render_view_host != render_view_host_ && |
309 render_view_host != pending_render_view_host_) | 333 render_view_host != pending_render_view_host_) |
310 return; | 334 return; |
311 | 335 |
312 FrameNavigationState::FrameID frame_id( | 336 FrameNavigationState::FrameID frame_id(frame_num, render_view_host); |
313 frame_num, render_view_host->GetProcess()->GetID()); | |
314 | 337 |
315 navigation_state_.TrackFrame(frame_id, | 338 navigation_state_.TrackFrame(frame_id, |
316 validated_url, | 339 validated_url, |
317 is_main_frame, | 340 is_main_frame, |
318 is_error_page); | 341 is_error_page); |
319 if (!navigation_state_.CanSendEvents(frame_id)) | 342 if (!navigation_state_.CanSendEvents(frame_id)) |
320 return; | 343 return; |
321 | 344 |
322 helpers::DispatchOnBeforeNavigate( | 345 helpers::DispatchOnBeforeNavigate( |
323 web_contents(), render_view_host->GetProcess()->GetID(), frame_num, | 346 web_contents(), render_view_host->GetProcess()->GetID(), frame_num, |
324 is_main_frame, validated_url); | 347 is_main_frame, validated_url); |
325 } | 348 } |
326 | 349 |
327 void WebNavigationTabObserver::DidCommitProvisionalLoadForFrame( | 350 void WebNavigationTabObserver::DidCommitProvisionalLoadForFrame( |
328 int64 frame_num, | 351 int64 frame_num, |
329 bool is_main_frame, | 352 bool is_main_frame, |
330 const GURL& url, | 353 const GURL& url, |
331 content::PageTransition transition_type, | 354 content::PageTransition transition_type, |
332 content::RenderViewHost* render_view_host) { | 355 content::RenderViewHost* render_view_host) { |
333 if (render_view_host != render_view_host_ && | 356 if (render_view_host != render_view_host_ && |
334 render_view_host != pending_render_view_host_) | 357 render_view_host != pending_render_view_host_) |
335 return; | 358 return; |
336 // TODO(jochen): If we switched the RVH, send error events for all ongoing | 359 if (render_view_host != render_view_host_) |
337 // navigations in the old RVH. | 360 SendErrorEvents(web_contents(), render_view_host_); |
338 render_view_host_ = render_view_host; | 361 render_view_host_ = render_view_host; |
339 pending_render_view_host_ = NULL; | 362 pending_render_view_host_ = NULL; |
340 | 363 |
341 FrameNavigationState::FrameID frame_id( | 364 FrameNavigationState::FrameID frame_id(frame_num, render_view_host); |
342 frame_num, render_view_host->GetProcess()->GetID()); | |
343 if (!navigation_state_.CanSendEvents(frame_id)) | 365 if (!navigation_state_.CanSendEvents(frame_id)) |
344 return; | 366 return; |
345 | 367 |
346 bool is_reference_fragment_navigation = | 368 bool is_reference_fragment_navigation = |
347 IsReferenceFragmentNavigation(frame_id, url); | 369 IsReferenceFragmentNavigation(frame_id, url); |
348 bool is_history_navigation = | 370 bool is_history_navigation = |
349 navigation_state_.GetNavigationCommitted(frame_id); | 371 navigation_state_.GetNavigationCommitted(frame_id); |
350 | 372 |
351 // Update the URL as it might have changed. | 373 // Update the URL as it might have changed. |
352 navigation_state_.UpdateFrame(frame_id, url); | 374 navigation_state_.UpdateFrame(frame_id, url); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 void WebNavigationTabObserver::DidFailProvisionalLoad( | 413 void WebNavigationTabObserver::DidFailProvisionalLoad( |
392 int64 frame_num, | 414 int64 frame_num, |
393 bool is_main_frame, | 415 bool is_main_frame, |
394 const GURL& validated_url, | 416 const GURL& validated_url, |
395 int error_code, | 417 int error_code, |
396 const string16& error_description, | 418 const string16& error_description, |
397 content::RenderViewHost* render_view_host) { | 419 content::RenderViewHost* render_view_host) { |
398 if (render_view_host != render_view_host_ && | 420 if (render_view_host != render_view_host_ && |
399 render_view_host != pending_render_view_host_) | 421 render_view_host != pending_render_view_host_) |
400 return; | 422 return; |
401 if (render_view_host == pending_render_view_host_) | 423 bool stop_tracking_frames = false; |
| 424 if (render_view_host == pending_render_view_host_) { |
402 pending_render_view_host_ = NULL; | 425 pending_render_view_host_ = NULL; |
| 426 stop_tracking_frames = true; |
| 427 } |
403 | 428 |
404 FrameNavigationState::FrameID frame_id( | 429 FrameNavigationState::FrameID frame_id(frame_num, render_view_host); |
405 frame_num, render_view_host->GetProcess()->GetID()); | 430 if (navigation_state_.CanSendEvents(frame_id)) { |
406 if (!navigation_state_.CanSendEvents(frame_id)) | 431 navigation_state_.SetErrorOccurredInFrame(frame_id); |
407 return; | 432 helpers::DispatchOnErrorOccurred( |
408 | 433 web_contents(), render_view_host->GetProcess()->GetID(), validated_url, |
409 navigation_state_.SetErrorOccurredInFrame(frame_id); | 434 frame_num, is_main_frame, error_code); |
410 helpers::DispatchOnErrorOccurred( | 435 } |
411 web_contents(), render_view_host->GetProcess()->GetID(), validated_url, | 436 if (stop_tracking_frames) |
412 frame_num, is_main_frame, error_code); | 437 navigation_state_.StopTrackingFramesInRVH(render_view_host); |
413 } | 438 } |
414 | 439 |
415 void WebNavigationTabObserver::DocumentLoadedInFrame( | 440 void WebNavigationTabObserver::DocumentLoadedInFrame( |
416 int64 frame_num, | 441 int64 frame_num, |
417 content::RenderViewHost* render_view_host) { | 442 content::RenderViewHost* render_view_host) { |
418 if (render_view_host != render_view_host_) | 443 if (render_view_host != render_view_host_) |
419 return; | 444 return; |
420 FrameNavigationState::FrameID frame_id( | 445 FrameNavigationState::FrameID frame_id(frame_num, render_view_host); |
421 frame_num, render_view_host->GetProcess()->GetID()); | |
422 if (!navigation_state_.CanSendEvents(frame_id)) | 446 if (!navigation_state_.CanSendEvents(frame_id)) |
423 return; | 447 return; |
424 helpers::DispatchOnDOMContentLoaded(web_contents(), | 448 helpers::DispatchOnDOMContentLoaded(web_contents(), |
425 navigation_state_.GetUrl(frame_id), | 449 navigation_state_.GetUrl(frame_id), |
426 navigation_state_.IsMainFrame(frame_id), | 450 navigation_state_.IsMainFrame(frame_id), |
427 frame_num); | 451 frame_num); |
428 } | 452 } |
429 | 453 |
430 void WebNavigationTabObserver::DidFinishLoad( | 454 void WebNavigationTabObserver::DidFinishLoad( |
431 int64 frame_num, | 455 int64 frame_num, |
432 const GURL& validated_url, | 456 const GURL& validated_url, |
433 bool is_main_frame, | 457 bool is_main_frame, |
434 content::RenderViewHost* render_view_host) { | 458 content::RenderViewHost* render_view_host) { |
435 if (render_view_host != render_view_host_) | 459 if (render_view_host != render_view_host_) |
436 return; | 460 return; |
437 FrameNavigationState::FrameID frame_id( | 461 FrameNavigationState::FrameID frame_id(frame_num, render_view_host); |
438 frame_num, render_view_host->GetProcess()->GetID()); | |
439 if (!navigation_state_.CanSendEvents(frame_id)) | 462 if (!navigation_state_.CanSendEvents(frame_id)) |
440 return; | 463 return; |
441 navigation_state_.SetNavigationCompleted(frame_id); | 464 navigation_state_.SetNavigationCompleted(frame_id); |
442 DCHECK_EQ(navigation_state_.GetUrl(frame_id), validated_url); | 465 DCHECK_EQ(navigation_state_.GetUrl(frame_id), validated_url); |
443 DCHECK_EQ(navigation_state_.IsMainFrame(frame_id), is_main_frame); | 466 DCHECK_EQ(navigation_state_.IsMainFrame(frame_id), is_main_frame); |
444 helpers::DispatchOnCompleted(web_contents(), | 467 helpers::DispatchOnCompleted(web_contents(), |
445 validated_url, | 468 validated_url, |
446 is_main_frame, | 469 is_main_frame, |
447 frame_num); | 470 frame_num); |
448 } | 471 } |
449 | 472 |
450 void WebNavigationTabObserver::DidFailLoad( | 473 void WebNavigationTabObserver::DidFailLoad( |
451 int64 frame_num, | 474 int64 frame_num, |
452 const GURL& validated_url, | 475 const GURL& validated_url, |
453 bool is_main_frame, | 476 bool is_main_frame, |
454 int error_code, | 477 int error_code, |
455 const string16& error_description, | 478 const string16& error_description, |
456 content::RenderViewHost* render_view_host) { | 479 content::RenderViewHost* render_view_host) { |
457 if (render_view_host != render_view_host_) | 480 if (render_view_host != render_view_host_) |
458 return; | 481 return; |
459 FrameNavigationState::FrameID frame_id( | 482 FrameNavigationState::FrameID frame_id(frame_num, render_view_host); |
460 frame_num, render_view_host->GetProcess()->GetID()); | |
461 if (!navigation_state_.CanSendEvents(frame_id)) | 483 if (!navigation_state_.CanSendEvents(frame_id)) |
462 return; | 484 return; |
463 navigation_state_.SetErrorOccurredInFrame(frame_id); | 485 navigation_state_.SetErrorOccurredInFrame(frame_id); |
464 helpers::DispatchOnErrorOccurred( | 486 helpers::DispatchOnErrorOccurred( |
465 web_contents(), render_view_host->GetProcess()->GetID(), validated_url, | 487 web_contents(), render_view_host->GetProcess()->GetID(), validated_url, |
466 frame_num, is_main_frame, error_code); | 488 frame_num, is_main_frame, error_code); |
467 } | 489 } |
468 | 490 |
469 void WebNavigationTabObserver::DidOpenRequestedURL( | 491 void WebNavigationTabObserver::DidOpenRequestedURL( |
470 content::WebContents* new_contents, | 492 content::WebContents* new_contents, |
471 const GURL& url, | 493 const GURL& url, |
472 const content::Referrer& referrer, | 494 const content::Referrer& referrer, |
473 WindowOpenDisposition disposition, | 495 WindowOpenDisposition disposition, |
474 content::PageTransition transition, | 496 content::PageTransition transition, |
475 int64 source_frame_num) { | 497 int64 source_frame_num) { |
476 FrameNavigationState::FrameID frame_id( | 498 FrameNavigationState::FrameID frame_id(source_frame_num, render_view_host_); |
477 source_frame_num, render_view_host_->GetProcess()->GetID()); | |
478 if (!navigation_state_.CanSendEvents(frame_id)) | 499 if (!navigation_state_.CanSendEvents(frame_id)) |
479 return; | 500 return; |
480 | 501 |
481 // We only send the onCreatedNavigationTarget if we end up creating a new | 502 // We only send the onCreatedNavigationTarget if we end up creating a new |
482 // window. | 503 // window. |
483 if (disposition != SINGLETON_TAB && | 504 if (disposition != SINGLETON_TAB && |
484 disposition != NEW_FOREGROUND_TAB && | 505 disposition != NEW_FOREGROUND_TAB && |
485 disposition != NEW_BACKGROUND_TAB && | 506 disposition != NEW_BACKGROUND_TAB && |
486 disposition != NEW_POPUP && | 507 disposition != NEW_POPUP && |
487 disposition != NEW_WINDOW && | 508 disposition != NEW_WINDOW && |
488 disposition != OFF_THE_RECORD) | 509 disposition != OFF_THE_RECORD) |
489 return; | 510 return; |
490 | 511 |
491 helpers::DispatchOnCreatedNavigationTarget( | 512 helpers::DispatchOnCreatedNavigationTarget( |
492 web_contents(), | 513 web_contents(), |
493 new_contents->GetBrowserContext(), | 514 new_contents->GetBrowserContext(), |
494 source_frame_num, | 515 source_frame_num, |
495 navigation_state_.IsMainFrame(frame_id), | 516 navigation_state_.IsMainFrame(frame_id), |
496 new_contents, | 517 new_contents, |
497 url); | 518 url); |
498 } | 519 } |
499 | 520 |
500 void WebNavigationTabObserver::WebContentsDestroyed(content::WebContents* tab) { | 521 void WebNavigationTabObserver::WebContentsDestroyed(content::WebContents* tab) { |
501 g_tab_observer.Get().erase(tab); | 522 g_tab_observer.Get().erase(tab); |
| 523 SendErrorEvents(tab, NULL); |
| 524 } |
| 525 |
| 526 void WebNavigationTabObserver::SendErrorEvents( |
| 527 content::WebContents* web_contents, |
| 528 content::RenderViewHost* render_view_host) { |
502 for (FrameNavigationState::const_iterator frame = navigation_state_.begin(); | 529 for (FrameNavigationState::const_iterator frame = navigation_state_.begin(); |
503 frame != navigation_state_.end(); ++frame) { | 530 frame != navigation_state_.end(); ++frame) { |
504 if (!navigation_state_.GetNavigationCompleted(*frame) && | 531 if (!navigation_state_.GetNavigationCompleted(*frame) && |
505 navigation_state_.CanSendEvents(*frame)) { | 532 navigation_state_.CanSendEvents(*frame) && |
| 533 (!render_view_host || frame->render_view_host == render_view_host)) { |
506 helpers::DispatchOnErrorOccurred( | 534 helpers::DispatchOnErrorOccurred( |
507 tab, | 535 web_contents, |
508 frame->render_process_id, | 536 frame->render_view_host->GetProcess()->GetID(), |
509 navigation_state_.GetUrl(*frame), | 537 navigation_state_.GetUrl(*frame), |
510 frame->frame_num, | 538 frame->frame_num, |
511 navigation_state_.IsMainFrame(*frame), | 539 navigation_state_.IsMainFrame(*frame), |
512 net::ERR_ABORTED); | 540 net::ERR_ABORTED); |
513 } | 541 } |
514 } | 542 } |
| 543 if (render_view_host) |
| 544 navigation_state_.StopTrackingFramesInRVH(render_view_host); |
515 } | 545 } |
516 | 546 |
517 // See also NavigationController::IsURLInPageNavigation. | 547 // See also NavigationController::IsURLInPageNavigation. |
518 bool WebNavigationTabObserver::IsReferenceFragmentNavigation( | 548 bool WebNavigationTabObserver::IsReferenceFragmentNavigation( |
519 FrameNavigationState::FrameID frame_id, | 549 FrameNavigationState::FrameID frame_id, |
520 const GURL& url) { | 550 const GURL& url) { |
521 GURL existing_url = navigation_state_.GetUrl(frame_id); | 551 GURL existing_url = navigation_state_.GetUrl(frame_id); |
522 if (existing_url == url) | 552 if (existing_url == url) |
523 return false; | 553 return false; |
524 | 554 |
(...skipping 27 matching lines...) Expand all Loading... |
552 WebNavigationTabObserver* observer = | 582 WebNavigationTabObserver* observer = |
553 WebNavigationTabObserver::Get(web_contents); | 583 WebNavigationTabObserver::Get(web_contents); |
554 DCHECK(observer); | 584 DCHECK(observer); |
555 | 585 |
556 const FrameNavigationState& frame_navigation_state = | 586 const FrameNavigationState& frame_navigation_state = |
557 observer->frame_navigation_state(); | 587 observer->frame_navigation_state(); |
558 | 588 |
559 if (frame_id == 0) | 589 if (frame_id == 0) |
560 frame_id = frame_navigation_state.GetMainFrameID().frame_num; | 590 frame_id = frame_navigation_state.GetMainFrameID().frame_num; |
561 | 591 |
562 FrameNavigationState::FrameID internal_frame_id(frame_id, process_id); | 592 content::RenderViewHost* render_view_host = |
| 593 observer->render_view_host_in_process(process_id); |
| 594 if (!render_view_host) |
| 595 return true; |
| 596 |
| 597 FrameNavigationState::FrameID internal_frame_id(frame_id, render_view_host); |
563 if (!frame_navigation_state.IsValidFrame(internal_frame_id)) | 598 if (!frame_navigation_state.IsValidFrame(internal_frame_id)) |
564 return true; | 599 return true; |
565 | 600 |
566 GURL frame_url = frame_navigation_state.GetUrl(internal_frame_id); | 601 GURL frame_url = frame_navigation_state.GetUrl(internal_frame_id); |
567 if (!frame_navigation_state.IsValidUrl(frame_url)) | 602 if (!frame_navigation_state.IsValidUrl(frame_url)) |
568 return true; | 603 return true; |
569 | 604 |
570 GetFrame::Results::Details frame_details; | 605 GetFrame::Results::Details frame_details; |
571 frame_details.url = frame_url.spec(); | 606 frame_details.url = frame_url.spec(); |
572 frame_details.error_occurred = | 607 frame_details.error_occurred = |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 it != navigation_state.end(); ++it) { | 641 it != navigation_state.end(); ++it) { |
607 FrameNavigationState::FrameID frame_id = *it; | 642 FrameNavigationState::FrameID frame_id = *it; |
608 GURL frame_url = navigation_state.GetUrl(frame_id); | 643 GURL frame_url = navigation_state.GetUrl(frame_id); |
609 if (!navigation_state.IsValidUrl(frame_url)) | 644 if (!navigation_state.IsValidUrl(frame_url)) |
610 continue; | 645 continue; |
611 linked_ptr<GetAllFrames::Results::DetailsElement> frame( | 646 linked_ptr<GetAllFrames::Results::DetailsElement> frame( |
612 new GetAllFrames::Results::DetailsElement()); | 647 new GetAllFrames::Results::DetailsElement()); |
613 frame->url = frame_url.spec(); | 648 frame->url = frame_url.spec(); |
614 frame->frame_id = helpers::GetFrameId( | 649 frame->frame_id = helpers::GetFrameId( |
615 navigation_state.IsMainFrame(frame_id), frame_id.frame_num); | 650 navigation_state.IsMainFrame(frame_id), frame_id.frame_num); |
616 frame->process_id = frame_id.render_process_id; | 651 frame->process_id = frame_id.render_view_host->GetProcess()->GetID(); |
617 frame->error_occurred = navigation_state.GetErrorOccurredInFrame(frame_id); | 652 frame->error_occurred = navigation_state.GetErrorOccurredInFrame(frame_id); |
618 result_list.push_back(frame); | 653 result_list.push_back(frame); |
619 } | 654 } |
620 results_ = GetAllFrames::Results::Create(result_list); | 655 results_ = GetAllFrames::Results::Create(result_list); |
621 return true; | 656 return true; |
622 } | 657 } |
623 | 658 |
624 } // namespace extensions | 659 } // namespace extensions |
OLD | NEW |