| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 | 6 // intercepting navigation events, as specified in |
| 7 // chrome/common/extensions/api/extension_api.json. | 7 // chrome/common/extensions/api/extension_api.json. |
| 8 | 8 |
| 9 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_WEBNAVIGATION_API_H_ | 9 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_WEBNAVIGATION_API_H_ |
| 10 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_WEBNAVIGATION_API_H_ | 10 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_WEBNAVIGATION_API_H_ |
| 11 #pragma once | 11 #pragma once |
| 12 | 12 |
| 13 #include <map> | 13 #include <map> |
| 14 | 14 |
| 15 #include "base/memory/singleton.h" | |
| 16 #include "chrome/browser/extensions/extension_function.h" | 15 #include "chrome/browser/extensions/extension_function.h" |
| 17 #include "content/browser/tab_contents/tab_contents_observer.h" | 16 #include "content/browser/tab_contents/tab_contents_observer.h" |
| 18 #include "content/common/notification_observer.h" | 17 #include "content/common/notification_observer.h" |
| 19 #include "content/common/notification_registrar.h" | 18 #include "content/common/notification_registrar.h" |
| 20 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
| 21 | 20 |
| 22 class TabContents; | 21 class TabContents; |
| 23 struct ViewHostMsg_CreateWindow_Params; | 22 struct ViewHostMsg_CreateWindow_Params; |
| 24 | 23 |
| 25 // Tracks the navigation state of all frames currently known to the | 24 // Tracks the navigation state of all frames currently known to the |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 // Tracks the state of the frames we are sending events for. | 124 // Tracks the state of the frames we are sending events for. |
| 126 FrameNavigationState navigation_state_; | 125 FrameNavigationState navigation_state_; |
| 127 | 126 |
| 128 DISALLOW_COPY_AND_ASSIGN(ExtensionWebNavigationTabObserver); | 127 DISALLOW_COPY_AND_ASSIGN(ExtensionWebNavigationTabObserver); |
| 129 }; | 128 }; |
| 130 | 129 |
| 131 // Observes navigation notifications and routes them as events to the extension | 130 // Observes navigation notifications and routes them as events to the extension |
| 132 // system. | 131 // system. |
| 133 class ExtensionWebNavigationEventRouter : public NotificationObserver { | 132 class ExtensionWebNavigationEventRouter : public NotificationObserver { |
| 134 public: | 133 public: |
| 135 // Returns the singleton instance of the event router. | 134 explicit ExtensionWebNavigationEventRouter(); |
| 136 static ExtensionWebNavigationEventRouter* GetInstance(); | 135 virtual ~ExtensionWebNavigationEventRouter(); |
| 137 | 136 |
| 138 // Invoked by the extensions service once the extension system is fully set | |
| 139 // up and can start dispatching events to extensions. | |
| 140 void Init(); | 137 void Init(); |
| 141 | 138 |
| 142 private: | 139 private: |
| 143 friend struct DefaultSingletonTraits<ExtensionWebNavigationEventRouter>; | |
| 144 | |
| 145 ExtensionWebNavigationEventRouter(); | |
| 146 virtual ~ExtensionWebNavigationEventRouter(); | |
| 147 | |
| 148 // NotificationObserver implementation. | 140 // NotificationObserver implementation. |
| 149 virtual void Observe(NotificationType type, | 141 virtual void Observe(NotificationType type, |
| 150 const NotificationSource& source, | 142 const NotificationSource& source, |
| 151 const NotificationDetails& details); | 143 const NotificationDetails& details); |
| 152 | 144 |
| 153 // Handler for the CREATING_NEW_WINDOW event. The method takes the details of | 145 // Handler for the CREATING_NEW_WINDOW event. The method takes the details of |
| 154 // such an event and constructs a suitable JSON formatted extension event from | 146 // such an event and constructs a suitable JSON formatted extension event from |
| 155 // it. | 147 // it. |
| 156 void CreatingNewWindow(TabContents* tab_content, | 148 void CreatingNewWindow(TabContents* tab_content, |
| 157 const ViewHostMsg_CreateWindow_Params* details); | 149 const ViewHostMsg_CreateWindow_Params* details); |
| 158 | 150 |
| 159 // Used for tracking registrations to navigation notifications. | 151 // Used for tracking registrations to navigation notifications. |
| 160 NotificationRegistrar registrar_; | 152 NotificationRegistrar registrar_; |
| 161 | 153 |
| 162 DISALLOW_COPY_AND_ASSIGN(ExtensionWebNavigationEventRouter); | 154 DISALLOW_COPY_AND_ASSIGN(ExtensionWebNavigationEventRouter); |
| 163 }; | 155 }; |
| 164 | 156 |
| 165 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WEBNAVIGATION_API_H_ | 157 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WEBNAVIGATION_API_H_ |
| OLD | NEW |