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 // 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 virtual 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 virtual void RenderFrameDeleted( |
56 content::RenderFrameHost* render_frame_host) OVERRIDE; | 56 content::RenderFrameHost* render_frame_host) override; |
57 virtual void RenderViewDeleted( | 57 virtual void RenderViewDeleted( |
58 content::RenderViewHost* render_view_host) OVERRIDE; | 58 content::RenderViewHost* render_view_host) override; |
59 virtual void AboutToNavigateRenderView( | 59 virtual void AboutToNavigateRenderView( |
60 content::RenderViewHost* render_view_host) OVERRIDE; | 60 content::RenderViewHost* render_view_host) override; |
61 virtual void DidStartProvisionalLoadForFrame( | 61 virtual void DidStartProvisionalLoadForFrame( |
62 content::RenderFrameHost* render_frame_host, | 62 content::RenderFrameHost* render_frame_host, |
63 const GURL& validated_url, | 63 const GURL& validated_url, |
64 bool is_error_page, | 64 bool is_error_page, |
65 bool is_iframe_srcdoc) OVERRIDE; | 65 bool is_iframe_srcdoc) override; |
66 virtual void DidCommitProvisionalLoadForFrame( | 66 virtual void DidCommitProvisionalLoadForFrame( |
67 content::RenderFrameHost* render_frame_host, | 67 content::RenderFrameHost* render_frame_host, |
68 const GURL& url, | 68 const GURL& url, |
69 ui::PageTransition transition_type) OVERRIDE; | 69 ui::PageTransition transition_type) override; |
70 virtual void DidFailProvisionalLoad( | 70 virtual void DidFailProvisionalLoad( |
71 content::RenderFrameHost* render_frame_host, | 71 content::RenderFrameHost* render_frame_host, |
72 const GURL& validated_url, | 72 const GURL& validated_url, |
73 int error_code, | 73 int error_code, |
74 const base::string16& error_description) OVERRIDE; | 74 const base::string16& error_description) override; |
75 virtual void DocumentLoadedInFrame( | 75 virtual void DocumentLoadedInFrame( |
76 content::RenderFrameHost* render_frame_host) OVERRIDE; | 76 content::RenderFrameHost* render_frame_host) override; |
77 virtual void DidFinishLoad(content::RenderFrameHost* render_frame_host, | 77 virtual void DidFinishLoad(content::RenderFrameHost* render_frame_host, |
78 const GURL& validated_url) OVERRIDE; | 78 const GURL& validated_url) override; |
79 virtual void DidFailLoad(content::RenderFrameHost* render_frame_host, | 79 virtual void DidFailLoad(content::RenderFrameHost* render_frame_host, |
80 const GURL& validated_url, | 80 const GURL& validated_url, |
81 int error_code, | 81 int error_code, |
82 const base::string16& error_description) OVERRIDE; | 82 const base::string16& error_description) override; |
83 virtual void DidGetRedirectForResourceRequest( | 83 virtual void DidGetRedirectForResourceRequest( |
84 content::RenderViewHost* render_view_host, | 84 content::RenderViewHost* render_view_host, |
85 const content::ResourceRedirectDetails& details) OVERRIDE; | 85 const content::ResourceRedirectDetails& details) override; |
86 virtual void DidOpenRequestedURL(content::WebContents* new_contents, | 86 virtual void DidOpenRequestedURL(content::WebContents* new_contents, |
87 const GURL& url, | 87 const GURL& url, |
88 const content::Referrer& referrer, | 88 const content::Referrer& referrer, |
89 WindowOpenDisposition disposition, | 89 WindowOpenDisposition disposition, |
90 ui::PageTransition transition, | 90 ui::PageTransition transition, |
91 int64 source_frame_num) OVERRIDE; | 91 int64 source_frame_num) override; |
92 virtual void WebContentsDestroyed() OVERRIDE; | 92 virtual void WebContentsDestroyed() override; |
93 | 93 |
94 private: | 94 private: |
95 explicit WebNavigationTabObserver(content::WebContents* web_contents); | 95 explicit WebNavigationTabObserver(content::WebContents* web_contents); |
96 friend class content::WebContentsUserData<WebNavigationTabObserver>; | 96 friend class content::WebContentsUserData<WebNavigationTabObserver>; |
97 | 97 |
98 // True if the transition and target url correspond to a reference fragment | 98 // True if the transition and target url correspond to a reference fragment |
99 // navigation. | 99 // navigation. |
100 bool IsReferenceFragmentNavigation(content::RenderFrameHost* frame_host, | 100 bool IsReferenceFragmentNavigation(content::RenderFrameHost* frame_host, |
101 const GURL& url); | 101 const GURL& url); |
102 | 102 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 content::WebContents* source_web_contents; | 147 content::WebContents* source_web_contents; |
148 content::RenderFrameHost* source_frame_host; | 148 content::RenderFrameHost* source_frame_host; |
149 content::WebContents* target_web_contents; | 149 content::WebContents* target_web_contents; |
150 GURL target_url; | 150 GURL target_url; |
151 }; | 151 }; |
152 | 152 |
153 // TabStripModelObserver implementation. | 153 // TabStripModelObserver implementation. |
154 virtual void TabReplacedAt(TabStripModel* tab_strip_model, | 154 virtual void TabReplacedAt(TabStripModel* tab_strip_model, |
155 content::WebContents* old_contents, | 155 content::WebContents* old_contents, |
156 content::WebContents* new_contents, | 156 content::WebContents* new_contents, |
157 int index) OVERRIDE; | 157 int index) override; |
158 | 158 |
159 // chrome::BrowserListObserver implementation. | 159 // chrome::BrowserListObserver implementation. |
160 virtual void OnBrowserAdded(Browser* browser) OVERRIDE; | 160 virtual void OnBrowserAdded(Browser* browser) override; |
161 virtual void OnBrowserRemoved(Browser* browser) OVERRIDE; | 161 virtual void OnBrowserRemoved(Browser* browser) override; |
162 | 162 |
163 // content::NotificationObserver implementation. | 163 // content::NotificationObserver implementation. |
164 virtual void Observe(int type, | 164 virtual void Observe(int type, |
165 const content::NotificationSource& source, | 165 const content::NotificationSource& source, |
166 const content::NotificationDetails& details) OVERRIDE; | 166 const content::NotificationDetails& details) override; |
167 | 167 |
168 // Handler for the NOTIFICATION_RETARGETING event. The method takes the | 168 // Handler for the NOTIFICATION_RETARGETING event. The method takes the |
169 // details of such an event and stores them for the later | 169 // details of such an event and stores them for the later |
170 // NOTIFICATION_TAB_ADDED event. | 170 // NOTIFICATION_TAB_ADDED event. |
171 void Retargeting(const RetargetingDetails* details); | 171 void Retargeting(const RetargetingDetails* details); |
172 | 172 |
173 // Handler for the NOTIFICATION_TAB_ADDED event. The method takes the details | 173 // 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. | 174 // of such an event and creates a JSON formated extension event from it. |
175 void TabAdded(content::WebContents* tab); | 175 void TabAdded(content::WebContents* tab); |
176 | 176 |
(...skipping 10 matching lines...) Expand all Loading... |
187 | 187 |
188 // The profile that owns us via ExtensionService. | 188 // The profile that owns us via ExtensionService. |
189 Profile* profile_; | 189 Profile* profile_; |
190 | 190 |
191 DISALLOW_COPY_AND_ASSIGN(WebNavigationEventRouter); | 191 DISALLOW_COPY_AND_ASSIGN(WebNavigationEventRouter); |
192 }; | 192 }; |
193 | 193 |
194 // API function that returns the state of a given frame. | 194 // API function that returns the state of a given frame. |
195 class WebNavigationGetFrameFunction : public ChromeSyncExtensionFunction { | 195 class WebNavigationGetFrameFunction : public ChromeSyncExtensionFunction { |
196 virtual ~WebNavigationGetFrameFunction() {} | 196 virtual ~WebNavigationGetFrameFunction() {} |
197 virtual bool RunSync() OVERRIDE; | 197 virtual bool RunSync() override; |
198 DECLARE_EXTENSION_FUNCTION("webNavigation.getFrame", WEBNAVIGATION_GETFRAME) | 198 DECLARE_EXTENSION_FUNCTION("webNavigation.getFrame", WEBNAVIGATION_GETFRAME) |
199 }; | 199 }; |
200 | 200 |
201 // API function that returns the states of all frames in a given tab. | 201 // API function that returns the states of all frames in a given tab. |
202 class WebNavigationGetAllFramesFunction : public ChromeSyncExtensionFunction { | 202 class WebNavigationGetAllFramesFunction : public ChromeSyncExtensionFunction { |
203 virtual ~WebNavigationGetAllFramesFunction() {} | 203 virtual ~WebNavigationGetAllFramesFunction() {} |
204 virtual bool RunSync() OVERRIDE; | 204 virtual bool RunSync() override; |
205 DECLARE_EXTENSION_FUNCTION("webNavigation.getAllFrames", | 205 DECLARE_EXTENSION_FUNCTION("webNavigation.getAllFrames", |
206 WEBNAVIGATION_GETALLFRAMES) | 206 WEBNAVIGATION_GETALLFRAMES) |
207 }; | 207 }; |
208 | 208 |
209 class WebNavigationAPI : public BrowserContextKeyedAPI, | 209 class WebNavigationAPI : public BrowserContextKeyedAPI, |
210 public extensions::EventRouter::Observer { | 210 public extensions::EventRouter::Observer { |
211 public: | 211 public: |
212 explicit WebNavigationAPI(content::BrowserContext* context); | 212 explicit WebNavigationAPI(content::BrowserContext* context); |
213 virtual ~WebNavigationAPI(); | 213 virtual ~WebNavigationAPI(); |
214 | 214 |
215 // KeyedService implementation. | 215 // KeyedService implementation. |
216 virtual void Shutdown() OVERRIDE; | 216 virtual void Shutdown() override; |
217 | 217 |
218 // BrowserContextKeyedAPI implementation. | 218 // BrowserContextKeyedAPI implementation. |
219 static BrowserContextKeyedAPIFactory<WebNavigationAPI>* GetFactoryInstance(); | 219 static BrowserContextKeyedAPIFactory<WebNavigationAPI>* GetFactoryInstance(); |
220 | 220 |
221 // EventRouter::Observer implementation. | 221 // EventRouter::Observer implementation. |
222 virtual void OnListenerAdded(const extensions::EventListenerInfo& details) | 222 virtual void OnListenerAdded(const extensions::EventListenerInfo& details) |
223 OVERRIDE; | 223 override; |
224 | 224 |
225 private: | 225 private: |
226 friend class BrowserContextKeyedAPIFactory<WebNavigationAPI>; | 226 friend class BrowserContextKeyedAPIFactory<WebNavigationAPI>; |
227 | 227 |
228 content::BrowserContext* browser_context_; | 228 content::BrowserContext* browser_context_; |
229 | 229 |
230 // BrowserContextKeyedAPI implementation. | 230 // BrowserContextKeyedAPI implementation. |
231 static const char* service_name() { | 231 static const char* service_name() { |
232 return "WebNavigationAPI"; | 232 return "WebNavigationAPI"; |
233 } | 233 } |
234 static const bool kServiceIsNULLWhileTesting = true; | 234 static const bool kServiceIsNULLWhileTesting = true; |
235 | 235 |
236 // Created lazily upon OnListenerAdded. | 236 // Created lazily upon OnListenerAdded. |
237 scoped_ptr<WebNavigationEventRouter> web_navigation_event_router_; | 237 scoped_ptr<WebNavigationEventRouter> web_navigation_event_router_; |
238 | 238 |
239 DISALLOW_COPY_AND_ASSIGN(WebNavigationAPI); | 239 DISALLOW_COPY_AND_ASSIGN(WebNavigationAPI); |
240 }; | 240 }; |
241 | 241 |
242 } // namespace extensions | 242 } // namespace extensions |
243 | 243 |
244 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_NAVIGATION_WEB_NAVIGATION_API_H_ | 244 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_NAVIGATION_WEB_NAVIGATION_API_H_ |
OLD | NEW |