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

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

Issue 9959097: Move webNavigation extension api into a separate directory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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 // 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_EXTENSION_WEBNAVIGATION_API_H_ 8 #ifndef CHROME_BROWSER_EXTENSIONS_API_WEB_NAVIGATION_WEB_NAVIGATION_API_H_
9 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_WEBNAVIGATION_API_H_ 9 #define CHROME_BROWSER_EXTENSIONS_API_WEB_NAVIGATION_WEB_NAVIGATION_API_H_
10 #pragma once 10 #pragma once
11 11
12 #include <map> 12 #include <map>
13 #include <set> 13 #include <set>
14 14
15 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
16 #include "chrome/browser/extensions/extension_function.h" 16 #include "chrome/browser/extensions/extension_function.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "content/public/browser/notification_observer.h" 18 #include "content/public/browser/notification_observer.h"
19 #include "content/public/browser/notification_registrar.h" 19 #include "content/public/browser/notification_registrar.h"
20 #include "content/public/browser/web_contents_observer.h" 20 #include "content/public/browser/web_contents_observer.h"
21 #include "googleurl/src/gurl.h" 21 #include "googleurl/src/gurl.h"
22 22
23 struct RetargetingDetails; 23 struct RetargetingDetails;
24 24
25 namespace extensions {
26
25 // Tracks the navigation state of all frames in a given tab currently known to 27 // Tracks the navigation state of all frames in a given tab currently known to
26 // the webNavigation API. It is mainly used to track in which frames an error 28 // the webNavigation API. It is mainly used to track in which frames an error
27 // occurred so no further events for this frame are being sent. 29 // occurred so no further events for this frame are being sent.
28 class FrameNavigationState { 30 class FrameNavigationState {
29 public: 31 public:
30 typedef std::set<int64>::const_iterator const_iterator; 32 typedef std::set<int64>::const_iterator const_iterator;
31 33
32 FrameNavigationState(); 34 FrameNavigationState();
33 ~FrameNavigationState(); 35 ~FrameNavigationState();
34 36
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 // The current main frame. 119 // The current main frame.
118 int64 main_frame_id_; 120 int64 main_frame_id_;
119 121
120 // If true, also allow events from chrome-extension:// URLs. 122 // If true, also allow events from chrome-extension:// URLs.
121 static bool allow_extension_scheme_; 123 static bool allow_extension_scheme_;
122 124
123 DISALLOW_COPY_AND_ASSIGN(FrameNavigationState); 125 DISALLOW_COPY_AND_ASSIGN(FrameNavigationState);
124 }; 126 };
125 127
126 // Tab contents observer that forwards navigation events to the event router. 128 // Tab contents observer that forwards navigation events to the event router.
127 class ExtensionWebNavigationTabObserver : public content::NotificationObserver, 129 class WebNavigationTabObserver : public content::NotificationObserver,
128 public content::WebContentsObserver { 130 public content::WebContentsObserver {
129 public: 131 public:
130 explicit ExtensionWebNavigationTabObserver( 132 explicit WebNavigationTabObserver(content::WebContents* web_contents);
131 content::WebContents* web_contents); 133 virtual ~WebNavigationTabObserver();
132 virtual ~ExtensionWebNavigationTabObserver();
133 134
134 // Returns the object for the given |tab_contents|. 135 // Returns the object for the given |tab_contents|.
135 static ExtensionWebNavigationTabObserver* Get( 136 static WebNavigationTabObserver* Get(content::WebContents* web_contents);
136 content::WebContents* web_contents);
137 137
138 const FrameNavigationState& frame_navigation_state() const { 138 const FrameNavigationState& frame_navigation_state() const {
139 return navigation_state_; 139 return navigation_state_;
140 } 140 }
141 141
142 // content::NotificationObserver implementation. 142 // content::NotificationObserver implementation.
143 virtual void Observe(int type, 143 virtual void Observe(int type,
144 const content::NotificationSource& source, 144 const content::NotificationSource& source,
145 const content::NotificationDetails& details) OVERRIDE; 145 const content::NotificationDetails& details) OVERRIDE;
146 146
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 // True if the transition and target url correspond to a reference fragment 179 // True if the transition and target url correspond to a reference fragment
180 // navigation. 180 // navigation.
181 bool IsReferenceFragmentNavigation(int64 frame_id, const GURL& url); 181 bool IsReferenceFragmentNavigation(int64 frame_id, const GURL& url);
182 182
183 // Tracks the state of the frames we are sending events for. 183 // Tracks the state of the frames we are sending events for.
184 FrameNavigationState navigation_state_; 184 FrameNavigationState navigation_state_;
185 185
186 // Used for tracking registrations to redirect notifications. 186 // Used for tracking registrations to redirect notifications.
187 content::NotificationRegistrar registrar_; 187 content::NotificationRegistrar registrar_;
188 188
189 DISALLOW_COPY_AND_ASSIGN(ExtensionWebNavigationTabObserver); 189 DISALLOW_COPY_AND_ASSIGN(WebNavigationTabObserver);
190 }; 190 };
191 191
192 // Observes navigation notifications and routes them as events to the extension 192 // Observes navigation notifications and routes them as events to the extension
193 // system. 193 // system.
194 class ExtensionWebNavigationEventRouter : public content::NotificationObserver { 194 class WebNavigationEventRouter : public content::NotificationObserver {
195 public: 195 public:
196 explicit ExtensionWebNavigationEventRouter(Profile* profile); 196 explicit WebNavigationEventRouter(Profile* profile);
197 virtual ~ExtensionWebNavigationEventRouter(); 197 virtual ~WebNavigationEventRouter();
198 198
199 // Invoked by the extensions service once the extension system is fully set 199 // Invoked by the extensions service once the extension system is fully set
200 // up and can start dispatching events to extensions. 200 // up and can start dispatching events to extensions.
201 void Init(); 201 void Init();
202 202
203 private: 203 private:
204 // Used to cache the information about newly created WebContents objects. 204 // Used to cache the information about newly created WebContents objects.
205 struct PendingWebContents{ 205 struct PendingWebContents{
206 PendingWebContents(); 206 PendingWebContents();
207 PendingWebContents(content::WebContents* source_web_contents, 207 PendingWebContents(content::WebContents* source_web_contents,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 // Mapping pointers to WebContents objects to information about how they got 239 // Mapping pointers to WebContents objects to information about how they got
240 // created. 240 // created.
241 std::map<content::WebContents*, PendingWebContents> pending_web_contents_; 241 std::map<content::WebContents*, PendingWebContents> pending_web_contents_;
242 242
243 // Used for tracking registrations to navigation notifications. 243 // Used for tracking registrations to navigation notifications.
244 content::NotificationRegistrar registrar_; 244 content::NotificationRegistrar registrar_;
245 245
246 // The profile that owns us via ExtensionService. 246 // The profile that owns us via ExtensionService.
247 Profile* profile_; 247 Profile* profile_;
248 248
249 DISALLOW_COPY_AND_ASSIGN(ExtensionWebNavigationEventRouter); 249 DISALLOW_COPY_AND_ASSIGN(WebNavigationEventRouter);
250 }; 250 };
251 251
252 // API function that returns the state of a given frame. 252 // API function that returns the state of a given frame.
253 class GetFrameFunction : public SyncExtensionFunction { 253 class GetFrameFunction : public SyncExtensionFunction {
254 virtual ~GetFrameFunction() {} 254 virtual ~GetFrameFunction() {}
255 virtual bool RunImpl() OVERRIDE; 255 virtual bool RunImpl() OVERRIDE;
256 DECLARE_EXTENSION_FUNCTION_NAME("webNavigation.getFrame") 256 DECLARE_EXTENSION_FUNCTION_NAME("webNavigation.getFrame")
257 }; 257 };
258 258
259 // API function that returns the states of all frames in a given tab. 259 // API function that returns the states of all frames in a given tab.
260 class GetAllFramesFunction : public SyncExtensionFunction { 260 class GetAllFramesFunction : public SyncExtensionFunction {
261 virtual ~GetAllFramesFunction() {} 261 virtual ~GetAllFramesFunction() {}
262 virtual bool RunImpl() OVERRIDE; 262 virtual bool RunImpl() OVERRIDE;
263 DECLARE_EXTENSION_FUNCTION_NAME("webNavigation.getAllFrames") 263 DECLARE_EXTENSION_FUNCTION_NAME("webNavigation.getAllFrames")
264 }; 264 };
265 265
266 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WEBNAVIGATION_API_H_ 266 } // namespace extensions
267
268 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_NAVIGATION_WEB_NAVIGATION_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698