| 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 |
| 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" |
| 15 #include "chrome/browser/extensions/api/web_navigation/frame_navigation_state.h" | 16 #include "chrome/browser/extensions/api/web_navigation/frame_navigation_state.h" |
| 16 #include "chrome/browser/extensions/event_router.h" | 17 #include "chrome/browser/extensions/event_router.h" |
| 17 #include "chrome/browser/extensions/extension_function.h" | 18 #include "chrome/browser/extensions/extension_function.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/profiles/profile_keyed_service.h" | |
| 20 #include "chrome/browser/ui/browser_list_observer.h" | 20 #include "chrome/browser/ui/browser_list_observer.h" |
| 21 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 21 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 22 #include "content/public/browser/notification_observer.h" | 22 #include "content/public/browser/notification_observer.h" |
| 23 #include "content/public/browser/notification_registrar.h" | 23 #include "content/public/browser/notification_registrar.h" |
| 24 #include "content/public/browser/web_contents_observer.h" | 24 #include "content/public/browser/web_contents_observer.h" |
| 25 #include "content/public/browser/web_contents_user_data.h" | 25 #include "content/public/browser/web_contents_user_data.h" |
| 26 #include "googleurl/src/gurl.h" | 26 #include "googleurl/src/gurl.h" |
| 27 | 27 |
| 28 struct RetargetingDetails; | 28 struct RetargetingDetails; |
| 29 | 29 |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 DECLARE_EXTENSION_FUNCTION_NAME("webNavigation.getFrame") | 206 DECLARE_EXTENSION_FUNCTION_NAME("webNavigation.getFrame") |
| 207 }; | 207 }; |
| 208 | 208 |
| 209 // API function that returns the states of all frames in a given tab. | 209 // API function that returns the states of all frames in a given tab. |
| 210 class GetAllFramesFunction : public SyncExtensionFunction { | 210 class GetAllFramesFunction : public SyncExtensionFunction { |
| 211 virtual ~GetAllFramesFunction() {} | 211 virtual ~GetAllFramesFunction() {} |
| 212 virtual bool RunImpl() OVERRIDE; | 212 virtual bool RunImpl() OVERRIDE; |
| 213 DECLARE_EXTENSION_FUNCTION_NAME("webNavigation.getAllFrames") | 213 DECLARE_EXTENSION_FUNCTION_NAME("webNavigation.getAllFrames") |
| 214 }; | 214 }; |
| 215 | 215 |
| 216 class WebNavigationAPI : public ProfileKeyedService, | 216 class WebNavigationAPI : public ProfileKeyedAPI, |
| 217 public extensions::EventRouter::Observer { | 217 public extensions::EventRouter::Observer { |
| 218 public: | 218 public: |
| 219 explicit WebNavigationAPI(Profile* profile); | 219 explicit WebNavigationAPI(Profile* profile); |
| 220 virtual ~WebNavigationAPI(); | 220 virtual ~WebNavigationAPI(); |
| 221 | 221 |
| 222 // ProfileKeyedService implementation. | 222 // ProfileKeyedService implementation. |
| 223 virtual void Shutdown() OVERRIDE; | 223 virtual void Shutdown() OVERRIDE; |
| 224 | 224 |
| 225 // EventRouter::Observer implementation. | 225 // EventRouter::Observer implementation. |
| 226 virtual void OnListenerAdded(const extensions::EventListenerInfo& details) | 226 virtual void OnListenerAdded(const extensions::EventListenerInfo& details) |
| 227 OVERRIDE; | 227 OVERRIDE; |
| 228 | 228 |
| 229 private: | 229 private: |
| 230 friend class ProfileKeyedAPIFactory<WebNavigationAPI>; |
| 231 |
| 230 Profile* profile_; | 232 Profile* profile_; |
| 231 | 233 |
| 234 // ProfileKeyedAPI implementation. |
| 235 static const char* service_name() { |
| 236 return "WebNavigationAPI"; |
| 237 } |
| 238 static const bool kServiceIsNULLWhileTesting = true; |
| 239 |
| 232 // Created lazily upon OnListenerAdded. | 240 // Created lazily upon OnListenerAdded. |
| 233 scoped_ptr<WebNavigationEventRouter> web_navigation_event_router_; | 241 scoped_ptr<WebNavigationEventRouter> web_navigation_event_router_; |
| 242 |
| 243 DISALLOW_COPY_AND_ASSIGN(WebNavigationAPI); |
| 234 }; | 244 }; |
| 235 | 245 |
| 246 template <> |
| 247 ProfileKeyedAPIFactory<WebNavigationAPI>* |
| 248 ProfileKeyedAPIFactory<WebNavigationAPI>::GetInstance(); |
| 249 |
| 236 } // namespace extensions | 250 } // namespace extensions |
| 237 | 251 |
| 238 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_NAVIGATION_WEB_NAVIGATION_API_H_ | 252 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_NAVIGATION_WEB_NAVIGATION_API_H_ |
| OLD | NEW |