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 #include <set> | 14 #include <set> |
15 | 15 |
16 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
17 #include "chrome/browser/extensions/extension_function.h" | 17 #include "chrome/browser/extensions/extension_function.h" |
18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
19 #include "content/browser/tab_contents/tab_contents_observer.h" | 19 #include "content/browser/tab_contents/tab_contents_observer.h" |
20 #include "content/public/browser/notification_observer.h" | 20 #include "content/public/browser/notification_observer.h" |
21 #include "content/public/browser/notification_registrar.h" | 21 #include "content/public/browser/notification_registrar.h" |
22 #include "googleurl/src/gurl.h" | 22 #include "googleurl/src/gurl.h" |
23 | 23 |
24 namespace content { | |
25 struct RetargetingDetails; | 24 struct RetargetingDetails; |
26 } | |
27 class TabContents; | 25 class TabContents; |
28 | 26 |
29 // 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 |
30 // 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 |
31 // occurred so no further events for this frame are being sent. | 29 // occurred so no further events for this frame are being sent. |
32 class FrameNavigationState { | 30 class FrameNavigationState { |
33 public: | 31 public: |
34 typedef std::set<int64>::const_iterator const_iterator; | 32 typedef std::set<int64>::const_iterator const_iterator; |
35 | 33 |
36 FrameNavigationState(); | 34 FrameNavigationState(); |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 }; | 199 }; |
202 | 200 |
203 // content::NotificationObserver implementation. | 201 // content::NotificationObserver implementation. |
204 virtual void Observe(int type, | 202 virtual void Observe(int type, |
205 const content::NotificationSource& source, | 203 const content::NotificationSource& source, |
206 const content::NotificationDetails& details) OVERRIDE; | 204 const content::NotificationDetails& details) OVERRIDE; |
207 | 205 |
208 // Handler for the NOTIFICATION_RETARGETING event. The method takes the | 206 // Handler for the NOTIFICATION_RETARGETING event. The method takes the |
209 // details of such an event and stores them for the later | 207 // details of such an event and stores them for the later |
210 // NOTIFICATION_TAB_ADDED event. | 208 // NOTIFICATION_TAB_ADDED event. |
211 void Retargeting(const content::RetargetingDetails* details); | 209 void Retargeting(const RetargetingDetails* details); |
212 | 210 |
213 // Handler for the NOTIFICATION_TAB_ADDED event. The method takes the details | 211 // Handler for the NOTIFICATION_TAB_ADDED event. The method takes the details |
214 // of such an event and creates a JSON formated extension event from it. | 212 // of such an event and creates a JSON formated extension event from it. |
215 void TabAdded(TabContents* tab_contents); | 213 void TabAdded(TabContents* tab_contents); |
216 | 214 |
217 // Handler for NOTIFICATION_TAB_CONTENTS_DESTROYED. If |tab_contents| is | 215 // Handler for NOTIFICATION_TAB_CONTENTS_DESTROYED. If |tab_contents| is |
218 // in |pending_tab_contents_|, it is removed. | 216 // in |pending_tab_contents_|, it is removed. |
219 void TabDestroyed(TabContents* tab_contents); | 217 void TabDestroyed(TabContents* tab_contents); |
220 | 218 |
221 // Mapping pointers to TabContents objects to information about how they got | 219 // Mapping pointers to TabContents objects to information about how they got |
(...skipping 17 matching lines...) Expand all Loading... |
239 }; | 237 }; |
240 | 238 |
241 // API function that returns the states of all frames in a given tab. | 239 // API function that returns the states of all frames in a given tab. |
242 class GetAllFramesFunction : public SyncExtensionFunction { | 240 class GetAllFramesFunction : public SyncExtensionFunction { |
243 virtual ~GetAllFramesFunction() {} | 241 virtual ~GetAllFramesFunction() {} |
244 virtual bool RunImpl() OVERRIDE; | 242 virtual bool RunImpl() OVERRIDE; |
245 DECLARE_EXTENSION_FUNCTION_NAME("webNavigation.getAllFrames") | 243 DECLARE_EXTENSION_FUNCTION_NAME("webNavigation.getAllFrames") |
246 }; | 244 }; |
247 | 245 |
248 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WEBNAVIGATION_API_H_ | 246 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WEBNAVIGATION_API_H_ |
OLD | NEW |