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

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

Issue 178193030: Rename ProfileKeyedAPI to BrowserContextKeyedAPI and GetProfile to Get. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 6 years, 9 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_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
11 #include <map> 11 #include <map>
12 #include <set> 12 #include <set>
13 13
14 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h"
16 #include "chrome/browser/extensions/api/web_navigation/frame_navigation_state.h" 15 #include "chrome/browser/extensions/api/web_navigation/frame_navigation_state.h"
17 #include "chrome/browser/extensions/chrome_extension_function.h" 16 #include "chrome/browser/extensions/chrome_extension_function.h"
18 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/ui/browser_list_observer.h" 18 #include "chrome/browser/ui/browser_list_observer.h"
20 #include "chrome/browser/ui/tabs/tab_strip_model.h" 19 #include "chrome/browser/ui/tabs/tab_strip_model.h"
21 #include "content/public/browser/notification_observer.h" 20 #include "content/public/browser/notification_observer.h"
22 #include "content/public/browser/notification_registrar.h" 21 #include "content/public/browser/notification_registrar.h"
23 #include "content/public/browser/web_contents_observer.h" 22 #include "content/public/browser/web_contents_observer.h"
24 #include "content/public/browser/web_contents_user_data.h" 23 #include "content/public/browser/web_contents_user_data.h"
24 #include "extensions/browser/browser_context_keyed_api_factory.h"
25 #include "extensions/browser/event_router.h" 25 #include "extensions/browser/event_router.h"
26 #include "url/gurl.h" 26 #include "url/gurl.h"
27 27
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,
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 }; 216 };
217 217
218 // API function that returns the states of all frames in a given tab. 218 // API function that returns the states of all frames in a given tab.
219 class WebNavigationGetAllFramesFunction : public ChromeSyncExtensionFunction { 219 class WebNavigationGetAllFramesFunction : public ChromeSyncExtensionFunction {
220 virtual ~WebNavigationGetAllFramesFunction() {} 220 virtual ~WebNavigationGetAllFramesFunction() {}
221 virtual bool RunImpl() OVERRIDE; 221 virtual bool RunImpl() OVERRIDE;
222 DECLARE_EXTENSION_FUNCTION("webNavigation.getAllFrames", 222 DECLARE_EXTENSION_FUNCTION("webNavigation.getAllFrames",
223 WEBNAVIGATION_GETALLFRAMES) 223 WEBNAVIGATION_GETALLFRAMES)
224 }; 224 };
225 225
226 class WebNavigationAPI : public ProfileKeyedAPI, 226 class WebNavigationAPI : public BrowserContextKeyedAPI,
227 public extensions::EventRouter::Observer { 227 public extensions::EventRouter::Observer {
228 public: 228 public:
229 explicit WebNavigationAPI(content::BrowserContext* context); 229 explicit WebNavigationAPI(content::BrowserContext* context);
230 virtual ~WebNavigationAPI(); 230 virtual ~WebNavigationAPI();
231 231
232 // BrowserContextKeyedService implementation. 232 // BrowserContextKeyedService implementation.
233 virtual void Shutdown() OVERRIDE; 233 virtual void Shutdown() OVERRIDE;
234 234
235 // ProfileKeyedAPI implementation. 235 // BrowserContextKeyedAPI implementation.
236 static ProfileKeyedAPIFactory<WebNavigationAPI>* GetFactoryInstance(); 236 static BrowserContextKeyedAPIFactory<WebNavigationAPI>* GetFactoryInstance();
237 237
238 // EventRouter::Observer implementation. 238 // EventRouter::Observer implementation.
239 virtual void OnListenerAdded(const extensions::EventListenerInfo& details) 239 virtual void OnListenerAdded(const extensions::EventListenerInfo& details)
240 OVERRIDE; 240 OVERRIDE;
241 241
242 private: 242 private:
243 friend class ProfileKeyedAPIFactory<WebNavigationAPI>; 243 friend class BrowserContextKeyedAPIFactory<WebNavigationAPI>;
244 244
245 content::BrowserContext* browser_context_; 245 content::BrowserContext* browser_context_;
246 246
247 // ProfileKeyedAPI implementation. 247 // BrowserContextKeyedAPI implementation.
248 static const char* service_name() { 248 static const char* service_name() {
249 return "WebNavigationAPI"; 249 return "WebNavigationAPI";
250 } 250 }
251 static const bool kServiceIsNULLWhileTesting = true; 251 static const bool kServiceIsNULLWhileTesting = true;
252 252
253 // Created lazily upon OnListenerAdded. 253 // Created lazily upon OnListenerAdded.
254 scoped_ptr<WebNavigationEventRouter> web_navigation_event_router_; 254 scoped_ptr<WebNavigationEventRouter> web_navigation_event_router_;
255 255
256 DISALLOW_COPY_AND_ASSIGN(WebNavigationAPI); 256 DISALLOW_COPY_AND_ASSIGN(WebNavigationAPI);
257 }; 257 };
258 258
259 } // namespace extensions 259 } // namespace extensions
260 260
261 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_NAVIGATION_WEB_NAVIGATION_API_H_ 261 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_NAVIGATION_WEB_NAVIGATION_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698