Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(330)

Side by Side Diff: chrome/browser/extensions/api/web_navigation/web_navigation_api.cc

Issue 10704225: Send an webNavigation event for navigations triggered by window.history (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 int64 frame_id, 652 int64 frame_id,
653 bool is_main_frame, 653 bool is_main_frame,
654 const GURL& url, 654 const GURL& url,
655 content::PageTransition transition_type, 655 content::PageTransition transition_type,
656 content::RenderViewHost* render_view_host) { 656 content::RenderViewHost* render_view_host) {
657 if (!navigation_state_.CanSendEvents(frame_id)) 657 if (!navigation_state_.CanSendEvents(frame_id))
658 return; 658 return;
659 659
660 bool is_reference_fragment_navigation = 660 bool is_reference_fragment_navigation =
661 IsReferenceFragmentNavigation(frame_id, url); 661 IsReferenceFragmentNavigation(frame_id, url);
662 bool is_history_navigation =
663 navigation_state_.GetNavigationCommitted(frame_id);
662 664
663 // Update the URL as it might have changed. 665 // Update the URL as it might have changed.
664 navigation_state_.UpdateFrame(frame_id, url); 666 navigation_state_.UpdateFrame(frame_id, url);
665 navigation_state_.SetNavigationCommitted(frame_id); 667 navigation_state_.SetNavigationCommitted(frame_id);
666 668
667 if (is_reference_fragment_navigation) { 669 if (is_reference_fragment_navigation) {
668 DispatchOnCommitted( 670 DispatchOnCommitted(
669 keys::kOnReferenceFragmentUpdated, 671 keys::kOnReferenceFragmentUpdated,
670 web_contents(), 672 web_contents(),
671 frame_id, 673 frame_id,
672 is_main_frame, 674 is_main_frame,
673 url, 675 url,
674 transition_type); 676 transition_type);
675 navigation_state_.SetNavigationCompleted(frame_id); 677 navigation_state_.SetNavigationCompleted(frame_id);
678 } else if (is_history_navigation) {
679 // Make the transition type match the one for reference fragment updates.
680 transition_type = static_cast<content::PageTransition>(
681 transition_type | content::PAGE_TRANSITION_CLIENT_REDIRECT);
682 DispatchOnCommitted(
683 keys::kOnHistoryStateUpdated,
684 web_contents(),
685 frame_id,
686 is_main_frame,
687 url,
688 transition_type);
689 navigation_state_.SetNavigationCompleted(frame_id);
676 } else { 690 } else {
677 if (navigation_state_.GetIsServerRedirected(frame_id)) { 691 if (navigation_state_.GetIsServerRedirected(frame_id)) {
678 transition_type = static_cast<content::PageTransition>( 692 transition_type = static_cast<content::PageTransition>(
679 transition_type | content::PAGE_TRANSITION_SERVER_REDIRECT); 693 transition_type | content::PAGE_TRANSITION_SERVER_REDIRECT);
680 } 694 }
681 DispatchOnCommitted( 695 DispatchOnCommitted(
682 keys::kOnCommitted, 696 keys::kOnCommitted,
683 web_contents(), 697 web_contents(),
684 frame_id, 698 frame_id,
685 is_main_frame, 699 is_main_frame,
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 frame->frame_id = GetFrameId(navigation_state.IsMainFrame(frame_id), 883 frame->frame_id = GetFrameId(navigation_state.IsMainFrame(frame_id),
870 frame_id); 884 frame_id);
871 frame->error_occurred = navigation_state.GetErrorOccurredInFrame(frame_id); 885 frame->error_occurred = navigation_state.GetErrorOccurredInFrame(frame_id);
872 result_list.push_back(frame); 886 result_list.push_back(frame);
873 } 887 }
874 SetResult(GetAllFrames::Result::Create(result_list)); 888 SetResult(GetAllFrames::Result::Create(result_list));
875 return true; 889 return true;
876 } 890 }
877 891
878 } // namespace extensions 892 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698