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

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

Issue 10692097: Introduce webNavigation.onTabReplaced event that is fired when a tab from instant or prerender repl… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 8 years, 5 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
« no previous file with comments | « no previous file | chrome/browser/extensions/api/web_navigation/web_navigation_api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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 "chrome/browser/ui/browser_list.h"
19 #include "chrome/browser/ui/tabs/tab_strip_model.h"
18 #include "content/public/browser/notification_observer.h" 20 #include "content/public/browser/notification_observer.h"
19 #include "content/public/browser/notification_registrar.h" 21 #include "content/public/browser/notification_registrar.h"
20 #include "content/public/browser/web_contents_observer.h" 22 #include "content/public/browser/web_contents_observer.h"
21 #include "googleurl/src/gurl.h" 23 #include "googleurl/src/gurl.h"
22 24
23 struct RetargetingDetails; 25 struct RetargetingDetails;
24 26
25 namespace extensions { 27 namespace extensions {
26 28
27 // Tracks the navigation state of all frames in a given tab currently known to 29 // Tracks the navigation state of all frames in a given tab currently known to
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 FrameNavigationState navigation_state_; 188 FrameNavigationState navigation_state_;
187 189
188 // Used for tracking registrations to redirect notifications. 190 // Used for tracking registrations to redirect notifications.
189 content::NotificationRegistrar registrar_; 191 content::NotificationRegistrar registrar_;
190 192
191 DISALLOW_COPY_AND_ASSIGN(WebNavigationTabObserver); 193 DISALLOW_COPY_AND_ASSIGN(WebNavigationTabObserver);
192 }; 194 };
193 195
194 // Observes navigation notifications and routes them as events to the extension 196 // Observes navigation notifications and routes them as events to the extension
195 // system. 197 // system.
196 class WebNavigationEventRouter : public content::NotificationObserver { 198 class WebNavigationEventRouter : public TabStripModelObserver,
199 public BrowserList::Observer,
200 public content::NotificationObserver {
197 public: 201 public:
198 explicit WebNavigationEventRouter(Profile* profile); 202 explicit WebNavigationEventRouter(Profile* profile);
199 virtual ~WebNavigationEventRouter(); 203 virtual ~WebNavigationEventRouter();
200 204
201 // Invoked by the extensions service once the extension system is fully set 205 // Invoked by the extensions service once the extension system is fully set
202 // up and can start dispatching events to extensions. 206 // up and can start dispatching events to extensions.
203 void Init(); 207 void Init();
204 208
205 private: 209 private:
206 // Used to cache the information about newly created WebContents objects. 210 // Used to cache the information about newly created WebContents objects.
207 struct PendingWebContents{ 211 struct PendingWebContents{
208 PendingWebContents(); 212 PendingWebContents();
209 PendingWebContents(content::WebContents* source_web_contents, 213 PendingWebContents(content::WebContents* source_web_contents,
210 int64 source_frame_id, 214 int64 source_frame_id,
211 bool source_frame_is_main_frame, 215 bool source_frame_is_main_frame,
212 content::WebContents* target_web_contents, 216 content::WebContents* target_web_contents,
213 const GURL& target_url); 217 const GURL& target_url);
214 ~PendingWebContents(); 218 ~PendingWebContents();
215 219
216 content::WebContents* source_web_contents; 220 content::WebContents* source_web_contents;
217 int64 source_frame_id; 221 int64 source_frame_id;
218 bool source_frame_is_main_frame; 222 bool source_frame_is_main_frame;
219 content::WebContents* target_web_contents; 223 content::WebContents* target_web_contents;
220 GURL target_url; 224 GURL target_url;
221 }; 225 };
222 226
227 // TabStripModelObserver implementation.
228 virtual void TabReplacedAt(TabStripModel* tab_strip_model,
229 TabContents* old_contents,
230 TabContents* new_contents,
231 int index) OVERRIDE;
232
233 // BrowserList::Observer implementation.
234 virtual void OnBrowserAdded(Browser* browser) OVERRIDE;
235 virtual void OnBrowserRemoved(Browser* browser) OVERRIDE;
236
223 // content::NotificationObserver implementation. 237 // content::NotificationObserver implementation.
224 virtual void Observe(int type, 238 virtual void Observe(int type,
225 const content::NotificationSource& source, 239 const content::NotificationSource& source,
226 const content::NotificationDetails& details) OVERRIDE; 240 const content::NotificationDetails& details) OVERRIDE;
227 241
228 // Handler for the NOTIFICATION_RETARGETING event. The method takes the 242 // Handler for the NOTIFICATION_RETARGETING event. The method takes the
229 // details of such an event and stores them for the later 243 // details of such an event and stores them for the later
230 // NOTIFICATION_TAB_ADDED event. 244 // NOTIFICATION_TAB_ADDED event.
231 void Retargeting(const RetargetingDetails* details); 245 void Retargeting(const RetargetingDetails* details);
232 246
(...skipping 28 matching lines...) Expand all
261 // API function that returns the states of all frames in a given tab. 275 // API function that returns the states of all frames in a given tab.
262 class GetAllFramesFunction : public SyncExtensionFunction { 276 class GetAllFramesFunction : public SyncExtensionFunction {
263 virtual ~GetAllFramesFunction() {} 277 virtual ~GetAllFramesFunction() {}
264 virtual bool RunImpl() OVERRIDE; 278 virtual bool RunImpl() OVERRIDE;
265 DECLARE_EXTENSION_FUNCTION_NAME("webNavigation.getAllFrames") 279 DECLARE_EXTENSION_FUNCTION_NAME("webNavigation.getAllFrames")
266 }; 280 };
267 281
268 } // namespace extensions 282 } // namespace extensions
269 283
270 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_NAVIGATION_WEB_NAVIGATION_API_H_ 284 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_NAVIGATION_WEB_NAVIGATION_API_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/web_navigation/web_navigation_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698