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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 FrameNavigationState::FrameID frame_id( | 316 FrameNavigationState::FrameID frame_id( |
317 resource_redirect_details->frame_id, render_view_host); | 317 resource_redirect_details->frame_id, render_view_host); |
318 navigation_state_.SetIsServerRedirected(frame_id); | 318 navigation_state_.SetIsServerRedirected(frame_id); |
319 } | 319 } |
320 break; | 320 break; |
321 } | 321 } |
322 | 322 |
323 case content::NOTIFICATION_RENDER_VIEW_HOST_DELETED: { | 323 case content::NOTIFICATION_RENDER_VIEW_HOST_DELETED: { |
324 content::RenderViewHost* render_view_host = | 324 content::RenderViewHost* render_view_host = |
325 content::Source<content::RenderViewHost>(source).ptr(); | 325 content::Source<content::RenderViewHost>(source).ptr(); |
326 if (render_view_host == render_view_host_) | 326 if (render_view_host == render_view_host_) { |
327 render_view_host_ = NULL; | 327 render_view_host_ = NULL; |
328 else if (render_view_host == pending_render_view_host_) | 328 if (pending_render_view_host_) { |
| 329 SendErrorEvents(web_contents(), |
| 330 pending_render_view_host_, |
| 331 FrameNavigationState::FrameID()); |
| 332 pending_render_view_host_ = NULL; |
| 333 } |
| 334 } else if (render_view_host == pending_render_view_host_) { |
329 pending_render_view_host_ = NULL; | 335 pending_render_view_host_ = NULL; |
330 else | 336 } else { |
331 return; | 337 return; |
| 338 } |
332 SendErrorEvents( | 339 SendErrorEvents( |
333 web_contents(), render_view_host, FrameNavigationState::FrameID()); | 340 web_contents(), render_view_host, FrameNavigationState::FrameID()); |
334 break; | 341 break; |
335 } | 342 } |
336 | 343 |
337 default: | 344 default: |
338 NOTREACHED(); | 345 NOTREACHED(); |
339 } | 346 } |
340 } | 347 } |
341 | 348 |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 } | 506 } |
500 | 507 |
501 void WebNavigationTabObserver::DidFinishLoad( | 508 void WebNavigationTabObserver::DidFinishLoad( |
502 int64 frame_num, | 509 int64 frame_num, |
503 const GURL& validated_url, | 510 const GURL& validated_url, |
504 bool is_main_frame, | 511 bool is_main_frame, |
505 content::RenderViewHost* render_view_host) { | 512 content::RenderViewHost* render_view_host) { |
506 if (render_view_host != render_view_host_) | 513 if (render_view_host != render_view_host_) |
507 return; | 514 return; |
508 FrameNavigationState::FrameID frame_id(frame_num, render_view_host); | 515 FrameNavigationState::FrameID frame_id(frame_num, render_view_host); |
| 516 // When showing replacement content, we might get load signals for frames |
| 517 // that weren't reguarly loaded. |
| 518 if (!navigation_state_.IsValidFrame(frame_id)) |
| 519 return; |
509 navigation_state_.SetNavigationCompleted(frame_id); | 520 navigation_state_.SetNavigationCompleted(frame_id); |
510 if (!navigation_state_.CanSendEvents(frame_id)) | 521 if (!navigation_state_.CanSendEvents(frame_id)) |
511 return; | 522 return; |
512 DCHECK_EQ(navigation_state_.GetUrl(frame_id), validated_url); | 523 DCHECK_EQ(navigation_state_.GetUrl(frame_id), validated_url); |
513 DCHECK_EQ(navigation_state_.IsMainFrame(frame_id), is_main_frame); | 524 DCHECK_EQ(navigation_state_.IsMainFrame(frame_id), is_main_frame); |
514 helpers::DispatchOnCompleted(web_contents(), | 525 helpers::DispatchOnCompleted(web_contents(), |
515 validated_url, | 526 validated_url, |
516 is_main_frame, | 527 is_main_frame, |
517 frame_num); | 528 frame_num); |
518 } | 529 } |
519 | 530 |
520 void WebNavigationTabObserver::DidFailLoad( | 531 void WebNavigationTabObserver::DidFailLoad( |
521 int64 frame_num, | 532 int64 frame_num, |
522 const GURL& validated_url, | 533 const GURL& validated_url, |
523 bool is_main_frame, | 534 bool is_main_frame, |
524 int error_code, | 535 int error_code, |
525 const string16& error_description, | 536 const string16& error_description, |
526 content::RenderViewHost* render_view_host) { | 537 content::RenderViewHost* render_view_host) { |
527 if (render_view_host != render_view_host_) | 538 if (render_view_host != render_view_host_) |
528 return; | 539 return; |
529 FrameNavigationState::FrameID frame_id(frame_num, render_view_host); | 540 FrameNavigationState::FrameID frame_id(frame_num, render_view_host); |
530 // A navigation might fail before we even started a provisional load. | 541 // When showing replacement content, we might get load signals for frames |
| 542 // that weren't reguarly loaded. |
531 if (!navigation_state_.IsValidFrame(frame_id)) | 543 if (!navigation_state_.IsValidFrame(frame_id)) |
532 return; | 544 return; |
533 if (navigation_state_.CanSendEvents(frame_id)) { | 545 if (navigation_state_.CanSendEvents(frame_id)) { |
534 helpers::DispatchOnErrorOccurred( | 546 helpers::DispatchOnErrorOccurred( |
535 web_contents(), render_view_host->GetProcess()->GetID(), validated_url, | 547 web_contents(), render_view_host->GetProcess()->GetID(), validated_url, |
536 frame_num, is_main_frame, error_code); | 548 frame_num, is_main_frame, error_code); |
537 } | 549 } |
538 navigation_state_.SetErrorOccurredInFrame(frame_id); | 550 navigation_state_.SetErrorOccurredInFrame(frame_id); |
539 } | 551 } |
540 | 552 |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 navigation_state.IsMainFrame(frame_id), frame_id.frame_num); | 716 navigation_state.IsMainFrame(frame_id), frame_id.frame_num); |
705 frame->process_id = frame_id.render_view_host->GetProcess()->GetID(); | 717 frame->process_id = frame_id.render_view_host->GetProcess()->GetID(); |
706 frame->error_occurred = navigation_state.GetErrorOccurredInFrame(frame_id); | 718 frame->error_occurred = navigation_state.GetErrorOccurredInFrame(frame_id); |
707 result_list.push_back(frame); | 719 result_list.push_back(frame); |
708 } | 720 } |
709 results_ = GetAllFrames::Results::Create(result_list); | 721 results_ = GetAllFrames::Results::Create(result_list); |
710 return true; | 722 return true; |
711 } | 723 } |
712 | 724 |
713 } // namespace extensions | 725 } // namespace extensions |
OLD | NEW |