Chromium Code Reviews| 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 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 370 void WebNavigationTabObserver::DidCommitProvisionalLoadForFrame( | 370 void WebNavigationTabObserver::DidCommitProvisionalLoadForFrame( |
| 371 int64 frame_num, | 371 int64 frame_num, |
| 372 bool is_main_frame, | 372 bool is_main_frame, |
| 373 const GURL& url, | 373 const GURL& url, |
| 374 content::PageTransition transition_type, | 374 content::PageTransition transition_type, |
| 375 content::RenderViewHost* render_view_host) { | 375 content::RenderViewHost* render_view_host) { |
| 376 if (render_view_host != render_view_host_ && | 376 if (render_view_host != render_view_host_ && |
| 377 render_view_host != pending_render_view_host_) | 377 render_view_host != pending_render_view_host_) |
| 378 return; | 378 return; |
| 379 FrameNavigationState::FrameID frame_id(frame_num, render_view_host); | 379 FrameNavigationState::FrameID frame_id(frame_num, render_view_host); |
| 380 FrameNavigationState::FrameID id_to_skip; | |
| 381 if (render_view_host == render_view_host_) | |
| 382 id_to_skip = frame_id; | |
| 383 if (is_main_frame) | |
| 384 SendErrorEvents(web_contents(), render_view_host_, id_to_skip); | |
| 385 render_view_host_ = render_view_host; | |
| 386 pending_render_view_host_ = NULL; | |
| 387 | |
| 388 if (!navigation_state_.CanSendEvents(frame_id)) | |
| 389 return; | |
| 390 | 380 |
| 391 bool is_reference_fragment_navigation = | 381 bool is_reference_fragment_navigation = |
| 392 IsReferenceFragmentNavigation(frame_id, url); | 382 IsReferenceFragmentNavigation(frame_id, url); |
| 393 bool is_history_navigation = | 383 bool is_history_navigation = |
| 394 navigation_state_.GetNavigationCommitted(frame_id); | 384 navigation_state_.GetNavigationCommitted(frame_id); |
| 395 | 385 |
| 386 if (is_main_frame && | |
| 387 render_view_host_ == render_view_host && | |
| 388 !is_reference_fragment_navigation && | |
| 389 !is_history_navigation) { | |
| 390 SendErrorEvents(web_contents(), render_view_host_, frame_id); | |
|
Charlie Reis
2012/08/04 00:32:33
Sorry, I don't understand this function. Why is i
jochen (gone - plz use gerrit)
2012/08/04 19:28:38
iframes of a previous tab can still navigate while
| |
| 391 if (pending_render_view_host_) { | |
| 392 SendErrorEvents(web_contents(), | |
| 393 pending_render_view_host_, | |
| 394 FrameNavigationState::FrameID()); | |
| 395 pending_render_view_host_ = NULL; | |
| 396 } | |
| 397 } else if (pending_render_view_host_ == render_view_host) { | |
| 398 SendErrorEvents( | |
| 399 web_contents(), render_view_host_, FrameNavigationState::FrameID()); | |
| 400 render_view_host_ = pending_render_view_host_; | |
| 401 pending_render_view_host_ = NULL; | |
| 402 } | |
| 403 | |
| 404 if (!navigation_state_.CanSendEvents(frame_id)) | |
| 405 return; | |
| 406 | |
| 396 // Update the URL as it might have changed. | 407 // Update the URL as it might have changed. |
| 397 navigation_state_.UpdateFrame(frame_id, url); | 408 navigation_state_.UpdateFrame(frame_id, url); |
| 398 navigation_state_.SetNavigationCommitted(frame_id); | 409 navigation_state_.SetNavigationCommitted(frame_id); |
| 399 | 410 |
| 400 if (is_reference_fragment_navigation) { | 411 if (is_reference_fragment_navigation) { |
| 401 helpers::DispatchOnCommitted( | 412 helpers::DispatchOnCommitted( |
| 402 keys::kOnReferenceFragmentUpdated, | 413 keys::kOnReferenceFragmentUpdated, |
| 403 web_contents(), | 414 web_contents(), |
| 404 frame_num, | 415 frame_num, |
| 405 is_main_frame, | 416 is_main_frame, |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 679 navigation_state.IsMainFrame(frame_id), frame_id.frame_num); | 690 navigation_state.IsMainFrame(frame_id), frame_id.frame_num); |
| 680 frame->process_id = frame_id.render_view_host->GetProcess()->GetID(); | 691 frame->process_id = frame_id.render_view_host->GetProcess()->GetID(); |
| 681 frame->error_occurred = navigation_state.GetErrorOccurredInFrame(frame_id); | 692 frame->error_occurred = navigation_state.GetErrorOccurredInFrame(frame_id); |
| 682 result_list.push_back(frame); | 693 result_list.push_back(frame); |
| 683 } | 694 } |
| 684 results_ = GetAllFrames::Results::Create(result_list); | 695 results_ = GetAllFrames::Results::Create(result_list); |
| 685 return true; | 696 return true; |
| 686 } | 697 } |
| 687 | 698 |
| 688 } // namespace extensions | 699 } // namespace extensions |
| OLD | NEW |