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

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

Issue 666153002: Standardize usage of virtual/override/final in chrome/browser/extensions/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
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 17 matching lines...) Expand all
28 struct RetargetingDetails; 28 struct RetargetingDetails;
29 29
30 namespace extensions { 30 namespace extensions {
31 31
32 // Tab contents observer that forwards navigation events to the event router. 32 // Tab contents observer that forwards navigation events to the event router.
33 class WebNavigationTabObserver 33 class WebNavigationTabObserver
34 : public content::NotificationObserver, 34 : public content::NotificationObserver,
35 public content::WebContentsObserver, 35 public content::WebContentsObserver,
36 public content::WebContentsUserData<WebNavigationTabObserver> { 36 public content::WebContentsUserData<WebNavigationTabObserver> {
37 public: 37 public:
38 virtual ~WebNavigationTabObserver(); 38 ~WebNavigationTabObserver() override;
39 39
40 // Returns the object for the given |web_contents|. 40 // Returns the object for the given |web_contents|.
41 static WebNavigationTabObserver* Get(content::WebContents* web_contents); 41 static WebNavigationTabObserver* Get(content::WebContents* web_contents);
42 42
43 const FrameNavigationState& frame_navigation_state() const { 43 const FrameNavigationState& frame_navigation_state() const {
44 return navigation_state_; 44 return navigation_state_;
45 } 45 }
46 46
47 content::RenderViewHost* GetRenderViewHostInProcess(int process_id) const; 47 content::RenderViewHost* GetRenderViewHostInProcess(int process_id) const;
48 48
49 // content::NotificationObserver implementation. 49 // content::NotificationObserver implementation.
50 virtual void Observe(int type, 50 void Observe(int type,
51 const content::NotificationSource& source, 51 const content::NotificationSource& source,
52 const content::NotificationDetails& details) override; 52 const content::NotificationDetails& details) override;
53 53
54 // content::WebContentsObserver implementation. 54 // content::WebContentsObserver implementation.
55 virtual void RenderFrameDeleted( 55 void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override;
56 content::RenderFrameHost* render_frame_host) override; 56 void RenderViewDeleted(content::RenderViewHost* render_view_host) override;
57 virtual void RenderViewDeleted( 57 void AboutToNavigateRenderView(
58 content::RenderViewHost* render_view_host) override; 58 content::RenderViewHost* render_view_host) override;
59 virtual void AboutToNavigateRenderView( 59 void DidStartProvisionalLoadForFrame(
60 content::RenderViewHost* render_view_host) override;
61 virtual void DidStartProvisionalLoadForFrame(
62 content::RenderFrameHost* render_frame_host, 60 content::RenderFrameHost* render_frame_host,
63 const GURL& validated_url, 61 const GURL& validated_url,
64 bool is_error_page, 62 bool is_error_page,
65 bool is_iframe_srcdoc) override; 63 bool is_iframe_srcdoc) override;
66 virtual void DidCommitProvisionalLoadForFrame( 64 void DidCommitProvisionalLoadForFrame(
67 content::RenderFrameHost* render_frame_host, 65 content::RenderFrameHost* render_frame_host,
68 const GURL& url, 66 const GURL& url,
69 ui::PageTransition transition_type) override; 67 ui::PageTransition transition_type) override;
70 virtual void DidFailProvisionalLoad( 68 void DidFailProvisionalLoad(content::RenderFrameHost* render_frame_host,
71 content::RenderFrameHost* render_frame_host, 69 const GURL& validated_url,
72 const GURL& validated_url, 70 int error_code,
73 int error_code, 71 const base::string16& error_description) override;
74 const base::string16& error_description) override; 72 void DocumentLoadedInFrame(
75 virtual void DocumentLoadedInFrame(
76 content::RenderFrameHost* render_frame_host) override; 73 content::RenderFrameHost* render_frame_host) override;
77 virtual void DidFinishLoad(content::RenderFrameHost* render_frame_host, 74 void DidFinishLoad(content::RenderFrameHost* render_frame_host,
78 const GURL& validated_url) override; 75 const GURL& validated_url) override;
79 virtual void DidFailLoad(content::RenderFrameHost* render_frame_host, 76 void DidFailLoad(content::RenderFrameHost* render_frame_host,
80 const GURL& validated_url, 77 const GURL& validated_url,
81 int error_code, 78 int error_code,
82 const base::string16& error_description) override; 79 const base::string16& error_description) override;
83 virtual void DidGetRedirectForResourceRequest( 80 void DidGetRedirectForResourceRequest(
84 content::RenderViewHost* render_view_host, 81 content::RenderViewHost* render_view_host,
85 const content::ResourceRedirectDetails& details) override; 82 const content::ResourceRedirectDetails& details) override;
86 virtual void DidOpenRequestedURL(content::WebContents* new_contents, 83 void DidOpenRequestedURL(content::WebContents* new_contents,
87 const GURL& url, 84 const GURL& url,
88 const content::Referrer& referrer, 85 const content::Referrer& referrer,
89 WindowOpenDisposition disposition, 86 WindowOpenDisposition disposition,
90 ui::PageTransition transition, 87 ui::PageTransition transition,
91 int64 source_frame_num) override; 88 int64 source_frame_num) override;
92 virtual void WebContentsDestroyed() override; 89 void WebContentsDestroyed() override;
93 90
94 private: 91 private:
95 explicit WebNavigationTabObserver(content::WebContents* web_contents); 92 explicit WebNavigationTabObserver(content::WebContents* web_contents);
96 friend class content::WebContentsUserData<WebNavigationTabObserver>; 93 friend class content::WebContentsUserData<WebNavigationTabObserver>;
97 94
98 // True if the transition and target url correspond to a reference fragment 95 // True if the transition and target url correspond to a reference fragment
99 // navigation. 96 // navigation.
100 bool IsReferenceFragmentNavigation(content::RenderFrameHost* frame_host, 97 bool IsReferenceFragmentNavigation(content::RenderFrameHost* frame_host,
101 const GURL& url); 98 const GURL& url);
102 99
(...skipping 22 matching lines...) Expand all
125 DISALLOW_COPY_AND_ASSIGN(WebNavigationTabObserver); 122 DISALLOW_COPY_AND_ASSIGN(WebNavigationTabObserver);
126 }; 123 };
127 124
128 // Observes navigation notifications and routes them as events to the extension 125 // Observes navigation notifications and routes them as events to the extension
129 // system. 126 // system.
130 class WebNavigationEventRouter : public TabStripModelObserver, 127 class WebNavigationEventRouter : public TabStripModelObserver,
131 public chrome::BrowserListObserver, 128 public chrome::BrowserListObserver,
132 public content::NotificationObserver { 129 public content::NotificationObserver {
133 public: 130 public:
134 explicit WebNavigationEventRouter(Profile* profile); 131 explicit WebNavigationEventRouter(Profile* profile);
135 virtual ~WebNavigationEventRouter(); 132 ~WebNavigationEventRouter() override;
136 133
137 private: 134 private:
138 // Used to cache the information about newly created WebContents objects. 135 // Used to cache the information about newly created WebContents objects.
139 struct PendingWebContents{ 136 struct PendingWebContents{
140 PendingWebContents(); 137 PendingWebContents();
141 PendingWebContents(content::WebContents* source_web_contents, 138 PendingWebContents(content::WebContents* source_web_contents,
142 content::RenderFrameHost* source_frame_host, 139 content::RenderFrameHost* source_frame_host,
143 content::WebContents* target_web_contents, 140 content::WebContents* target_web_contents,
144 const GURL& target_url); 141 const GURL& target_url);
145 ~PendingWebContents(); 142 ~PendingWebContents();
146 143
147 content::WebContents* source_web_contents; 144 content::WebContents* source_web_contents;
148 content::RenderFrameHost* source_frame_host; 145 content::RenderFrameHost* source_frame_host;
149 content::WebContents* target_web_contents; 146 content::WebContents* target_web_contents;
150 GURL target_url; 147 GURL target_url;
151 }; 148 };
152 149
153 // TabStripModelObserver implementation. 150 // TabStripModelObserver implementation.
154 virtual void TabReplacedAt(TabStripModel* tab_strip_model, 151 void TabReplacedAt(TabStripModel* tab_strip_model,
155 content::WebContents* old_contents, 152 content::WebContents* old_contents,
156 content::WebContents* new_contents, 153 content::WebContents* new_contents,
157 int index) override; 154 int index) override;
158 155
159 // chrome::BrowserListObserver implementation. 156 // chrome::BrowserListObserver implementation.
160 virtual void OnBrowserAdded(Browser* browser) override; 157 void OnBrowserAdded(Browser* browser) override;
161 virtual void OnBrowserRemoved(Browser* browser) override; 158 void OnBrowserRemoved(Browser* browser) override;
162 159
163 // content::NotificationObserver implementation. 160 // content::NotificationObserver implementation.
164 virtual void Observe(int type, 161 void Observe(int type,
165 const content::NotificationSource& source, 162 const content::NotificationSource& source,
166 const content::NotificationDetails& details) override; 163 const content::NotificationDetails& details) override;
167 164
168 // Handler for the NOTIFICATION_RETARGETING event. The method takes the 165 // Handler for the NOTIFICATION_RETARGETING event. The method takes the
169 // details of such an event and stores them for the later 166 // details of such an event and stores them for the later
170 // NOTIFICATION_TAB_ADDED event. 167 // NOTIFICATION_TAB_ADDED event.
171 void Retargeting(const RetargetingDetails* details); 168 void Retargeting(const RetargetingDetails* details);
172 169
173 // Handler for the NOTIFICATION_TAB_ADDED event. The method takes the details 170 // Handler for the NOTIFICATION_TAB_ADDED event. The method takes the details
174 // of such an event and creates a JSON formated extension event from it. 171 // of such an event and creates a JSON formated extension event from it.
175 void TabAdded(content::WebContents* tab); 172 void TabAdded(content::WebContents* tab);
176 173
177 // Handler for NOTIFICATION_WEB_CONTENTS_DESTROYED. If |tab| is in 174 // Handler for NOTIFICATION_WEB_CONTENTS_DESTROYED. If |tab| is in
178 // |pending_web_contents_|, it is removed. 175 // |pending_web_contents_|, it is removed.
179 void TabDestroyed(content::WebContents* tab); 176 void TabDestroyed(content::WebContents* tab);
180 177
181 // Mapping pointers to WebContents objects to information about how they got 178 // Mapping pointers to WebContents objects to information about how they got
182 // created. 179 // created.
183 std::map<content::WebContents*, PendingWebContents> pending_web_contents_; 180 std::map<content::WebContents*, PendingWebContents> pending_web_contents_;
184 181
185 // Used for tracking registrations to navigation notifications. 182 // Used for tracking registrations to navigation notifications.
186 content::NotificationRegistrar registrar_; 183 content::NotificationRegistrar registrar_;
187 184
188 // The profile that owns us via ExtensionService. 185 // The profile that owns us via ExtensionService.
189 Profile* profile_; 186 Profile* profile_;
190 187
191 DISALLOW_COPY_AND_ASSIGN(WebNavigationEventRouter); 188 DISALLOW_COPY_AND_ASSIGN(WebNavigationEventRouter);
192 }; 189 };
193 190
194 // API function that returns the state of a given frame. 191 // API function that returns the state of a given frame.
195 class WebNavigationGetFrameFunction : public ChromeSyncExtensionFunction { 192 class WebNavigationGetFrameFunction : public ChromeSyncExtensionFunction {
196 virtual ~WebNavigationGetFrameFunction() {} 193 ~WebNavigationGetFrameFunction() override {}
197 virtual bool RunSync() override; 194 bool RunSync() override;
198 DECLARE_EXTENSION_FUNCTION("webNavigation.getFrame", WEBNAVIGATION_GETFRAME) 195 DECLARE_EXTENSION_FUNCTION("webNavigation.getFrame", WEBNAVIGATION_GETFRAME)
199 }; 196 };
200 197
201 // API function that returns the states of all frames in a given tab. 198 // API function that returns the states of all frames in a given tab.
202 class WebNavigationGetAllFramesFunction : public ChromeSyncExtensionFunction { 199 class WebNavigationGetAllFramesFunction : public ChromeSyncExtensionFunction {
203 virtual ~WebNavigationGetAllFramesFunction() {} 200 ~WebNavigationGetAllFramesFunction() override {}
204 virtual bool RunSync() override; 201 bool RunSync() override;
205 DECLARE_EXTENSION_FUNCTION("webNavigation.getAllFrames", 202 DECLARE_EXTENSION_FUNCTION("webNavigation.getAllFrames",
206 WEBNAVIGATION_GETALLFRAMES) 203 WEBNAVIGATION_GETALLFRAMES)
207 }; 204 };
208 205
209 class WebNavigationAPI : public BrowserContextKeyedAPI, 206 class WebNavigationAPI : public BrowserContextKeyedAPI,
210 public extensions::EventRouter::Observer { 207 public extensions::EventRouter::Observer {
211 public: 208 public:
212 explicit WebNavigationAPI(content::BrowserContext* context); 209 explicit WebNavigationAPI(content::BrowserContext* context);
213 virtual ~WebNavigationAPI(); 210 ~WebNavigationAPI() override;
214 211
215 // KeyedService implementation. 212 // KeyedService implementation.
216 virtual void Shutdown() override; 213 void Shutdown() override;
217 214
218 // BrowserContextKeyedAPI implementation. 215 // BrowserContextKeyedAPI implementation.
219 static BrowserContextKeyedAPIFactory<WebNavigationAPI>* GetFactoryInstance(); 216 static BrowserContextKeyedAPIFactory<WebNavigationAPI>* GetFactoryInstance();
220 217
221 // EventRouter::Observer implementation. 218 // EventRouter::Observer implementation.
222 virtual void OnListenerAdded(const extensions::EventListenerInfo& details) 219 void OnListenerAdded(const extensions::EventListenerInfo& details) override;
223 override;
224 220
225 private: 221 private:
226 friend class BrowserContextKeyedAPIFactory<WebNavigationAPI>; 222 friend class BrowserContextKeyedAPIFactory<WebNavigationAPI>;
227 223
228 content::BrowserContext* browser_context_; 224 content::BrowserContext* browser_context_;
229 225
230 // BrowserContextKeyedAPI implementation. 226 // BrowserContextKeyedAPI implementation.
231 static const char* service_name() { 227 static const char* service_name() {
232 return "WebNavigationAPI"; 228 return "WebNavigationAPI";
233 } 229 }
234 static const bool kServiceIsNULLWhileTesting = true; 230 static const bool kServiceIsNULLWhileTesting = true;
235 231
236 // Created lazily upon OnListenerAdded. 232 // Created lazily upon OnListenerAdded.
237 scoped_ptr<WebNavigationEventRouter> web_navigation_event_router_; 233 scoped_ptr<WebNavigationEventRouter> web_navigation_event_router_;
238 234
239 DISALLOW_COPY_AND_ASSIGN(WebNavigationAPI); 235 DISALLOW_COPY_AND_ASSIGN(WebNavigationAPI);
240 }; 236 };
241 237
242 } // namespace extensions 238 } // namespace extensions
243 239
244 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_NAVIGATION_WEB_NAVIGATION_API_H_ 240 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_NAVIGATION_WEB_NAVIGATION_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698