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

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

Issue 2545133002: PlzNavigate: Fix ordering of onBeforeNavigate and onCreatedNavigationTarget. (Closed)
Patch Set: Created 4 years 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
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 // Defines the Chrome Extensions WebNavigation API functions for observing and 5 // Defines the Chrome Extensions WebNavigation API functions for observing and
6 // intercepting navigation events, as specified in the extension JSON API. 6 // intercepting navigation events, as specified in the extension JSON API.
7 7
8 #ifndef CHROME_BROWSER_EXTENSIONS_API_WEB_NAVIGATION_WEB_NAVIGATION_API_H_ 8 #ifndef CHROME_BROWSER_EXTENSIONS_API_WEB_NAVIGATION_WEB_NAVIGATION_API_H_
9 #define CHROME_BROWSER_EXTENSIONS_API_WEB_NAVIGATION_WEB_NAVIGATION_API_H_ 9 #define CHROME_BROWSER_EXTENSIONS_API_WEB_NAVIGATION_WEB_NAVIGATION_API_H_
10 10
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 const base::string16& error_description, 64 const base::string16& error_description,
65 bool was_ignored_by_handler) override; 65 bool was_ignored_by_handler) override;
66 void DidOpenRequestedURL(content::WebContents* new_contents, 66 void DidOpenRequestedURL(content::WebContents* new_contents,
67 content::RenderFrameHost* source_render_frame_host, 67 content::RenderFrameHost* source_render_frame_host,
68 const GURL& url, 68 const GURL& url,
69 const content::Referrer& referrer, 69 const content::Referrer& referrer,
70 WindowOpenDisposition disposition, 70 WindowOpenDisposition disposition,
71 ui::PageTransition transition) override; 71 ui::PageTransition transition) override;
72 void WebContentsDestroyed() override; 72 void WebContentsDestroyed() override;
73 73
74 // This method dispatches the already created onBeforeNavigate event.
75 void DispatchOnBeforeNavigate();
Devlin 2016/12/02 20:17:11 nit: Can we rename this to be DispatchPendingOnBef
nasko 2016/12/02 21:40:45 Acknowledged.
76
74 private: 77 private:
75 explicit WebNavigationTabObserver(content::WebContents* web_contents); 78 explicit WebNavigationTabObserver(content::WebContents* web_contents);
76 friend class content::WebContentsUserData<WebNavigationTabObserver>; 79 friend class content::WebContentsUserData<WebNavigationTabObserver>;
77 80
78 void HandleCommit(content::NavigationHandle* navigation_handle); 81 void HandleCommit(content::NavigationHandle* navigation_handle);
79 void HandleError(content::NavigationHandle* navigation_handle); 82 void HandleError(content::NavigationHandle* navigation_handle);
80 83
81 // True if the transition and target url correspond to a reference fragment 84 // True if the transition and target url correspond to a reference fragment
82 // navigation. 85 // navigation.
83 bool IsReferenceFragmentNavigation(content::RenderFrameHost* frame_host, 86 bool IsReferenceFragmentNavigation(content::RenderFrameHost* frame_host,
84 const GURL& url); 87 const GURL& url);
85 88
86 // Creates and sends onErrorOccurred events for all on-going navigations. If 89 // Creates and sends onErrorOccurred events for all on-going navigations. If
87 // |render_view_host| is non-NULL, only generates events for frames in this 90 // |render_view_host| is non-NULL, only generates events for frames in this
88 // render view host. If |frame_host_to_skip| is given, no events are sent for 91 // render view host. If |frame_host_to_skip| is given, no events are sent for
89 // that 92 // that
90 // frame. 93 // frame.
91 void SendErrorEvents(content::WebContents* web_contents, 94 void SendErrorEvents(content::WebContents* web_contents,
92 content::RenderViewHost* render_view_host, 95 content::RenderViewHost* render_view_host,
93 content::RenderFrameHost* frame_host_to_skip); 96 content::RenderFrameHost* frame_host_to_skip);
94 97
95 // Tracks the state of the frames we are sending events for. 98 // Tracks the state of the frames we are sending events for.
96 FrameNavigationState navigation_state_; 99 FrameNavigationState navigation_state_;
97 100
101 // The latest onBeforeNavigate event this frame has generated. It is stored
102 // as it might not be sent immediately, but delayed until the tab is added to
103 // the tab strip and is ready to dispatch events.
104 std::unique_ptr<Event> pending_on_before_navigate_event_;
105
98 // Used for tracking registrations to redirect notifications. 106 // Used for tracking registrations to redirect notifications.
99 content::NotificationRegistrar registrar_; 107 content::NotificationRegistrar registrar_;
100 108
101 DISALLOW_COPY_AND_ASSIGN(WebNavigationTabObserver); 109 DISALLOW_COPY_AND_ASSIGN(WebNavigationTabObserver);
102 }; 110 };
103 111
104 // Observes navigation notifications and routes them as events to the extension 112 // Observes navigation notifications and routes them as events to the extension
105 // system. 113 // system.
106 class WebNavigationEventRouter : public TabStripModelObserver, 114 class WebNavigationEventRouter : public TabStripModelObserver,
107 public BrowserTabStripTrackerDelegate, 115 public BrowserTabStripTrackerDelegate,
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 219
212 // Created lazily upon OnListenerAdded. 220 // Created lazily upon OnListenerAdded.
213 std::unique_ptr<WebNavigationEventRouter> web_navigation_event_router_; 221 std::unique_ptr<WebNavigationEventRouter> web_navigation_event_router_;
214 222
215 DISALLOW_COPY_AND_ASSIGN(WebNavigationAPI); 223 DISALLOW_COPY_AND_ASSIGN(WebNavigationAPI);
216 }; 224 };
217 225
218 } // namespace extensions 226 } // namespace extensions
219 227
220 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_NAVIGATION_WEB_NAVIGATION_API_H_ 228 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_NAVIGATION_WEB_NAVIGATION_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698