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

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

Issue 10964048: Switch WebNavigationTabObserver to use WebContentsUserData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 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/web_navigation/frame_navigation_state.h" 15 #include "chrome/browser/extensions/api/web_navigation/frame_navigation_state.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/tab_contents/web_contents_user_data.h"
18 #include "chrome/browser/ui/browser_list_observer.h" 19 #include "chrome/browser/ui/browser_list_observer.h"
19 #include "chrome/browser/ui/tabs/tab_strip_model.h" 20 #include "chrome/browser/ui/tabs/tab_strip_model.h"
20 #include "content/public/browser/notification_observer.h" 21 #include "content/public/browser/notification_observer.h"
21 #include "content/public/browser/notification_registrar.h" 22 #include "content/public/browser/notification_registrar.h"
22 #include "content/public/browser/web_contents_observer.h" 23 #include "content/public/browser/web_contents_observer.h"
23 #include "googleurl/src/gurl.h" 24 #include "googleurl/src/gurl.h"
24 25
25 struct RetargetingDetails; 26 struct RetargetingDetails;
26 27
27 namespace extensions { 28 namespace extensions {
28 29
29 // Tab contents observer that forwards navigation events to the event router. 30 // Tab contents observer that forwards navigation events to the event router.
30 class WebNavigationTabObserver : public content::NotificationObserver, 31 class WebNavigationTabObserver
31 public content::WebContentsObserver { 32 : public content::NotificationObserver,
33 public content::WebContentsObserver,
34 public WebContentsUserData<WebNavigationTabObserver> {
32 public: 35 public:
33 explicit WebNavigationTabObserver(content::WebContents* web_contents);
34 virtual ~WebNavigationTabObserver(); 36 virtual ~WebNavigationTabObserver();
35 37
36 // Returns the object for the given |tab_contents|. 38 // Returns the object for the given |tab_contents|.
37 static WebNavigationTabObserver* Get(content::WebContents* web_contents); 39 static WebNavigationTabObserver* Get(content::WebContents* web_contents);
38 40
39 const FrameNavigationState& frame_navigation_state() const { 41 const FrameNavigationState& frame_navigation_state() const {
40 return navigation_state_; 42 return navigation_state_;
41 } 43 }
42 44
43 content::RenderViewHost* GetRenderViewHostInProcess(int process_id) const; 45 content::RenderViewHost* GetRenderViewHostInProcess(int process_id) const;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 content::RenderViewHost* render_view_host) OVERRIDE; 89 content::RenderViewHost* render_view_host) OVERRIDE;
88 virtual void DidOpenRequestedURL(content::WebContents* new_contents, 90 virtual void DidOpenRequestedURL(content::WebContents* new_contents,
89 const GURL& url, 91 const GURL& url,
90 const content::Referrer& referrer, 92 const content::Referrer& referrer,
91 WindowOpenDisposition disposition, 93 WindowOpenDisposition disposition,
92 content::PageTransition transition, 94 content::PageTransition transition,
93 int64 source_frame_num) OVERRIDE; 95 int64 source_frame_num) OVERRIDE;
94 virtual void WebContentsDestroyed(content::WebContents* tab) OVERRIDE; 96 virtual void WebContentsDestroyed(content::WebContents* tab) OVERRIDE;
95 97
96 private: 98 private:
99 explicit WebNavigationTabObserver(content::WebContents* web_contents);
100 static int kUserDataKey;
101 friend class WebContentsUserData<WebNavigationTabObserver>;
102
97 // True if the transition and target url correspond to a reference fragment 103 // True if the transition and target url correspond to a reference fragment
98 // navigation. 104 // navigation.
99 bool IsReferenceFragmentNavigation(FrameNavigationState::FrameID frame_id, 105 bool IsReferenceFragmentNavigation(FrameNavigationState::FrameID frame_id,
100 const GURL& url); 106 const GURL& url);
101 107
102 // Creates and sends onErrorOccurred events for all on-going navigations. If 108 // Creates and sends onErrorOccurred events for all on-going navigations. If
103 // |render_view_host| is non-NULL, only generates events for frames in this 109 // |render_view_host| is non-NULL, only generates events for frames in this
104 // render view host. If |id_to_skip| is given, no events are sent for that 110 // render view host. If |id_to_skip| is given, no events are sent for that
105 // frame. 111 // frame.
106 void SendErrorEvents(content::WebContents* web_contents, 112 void SendErrorEvents(content::WebContents* web_contents,
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 // API function that returns the states of all frames in a given tab. 211 // API function that returns the states of all frames in a given tab.
206 class GetAllFramesFunction : public SyncExtensionFunction { 212 class GetAllFramesFunction : public SyncExtensionFunction {
207 virtual ~GetAllFramesFunction() {} 213 virtual ~GetAllFramesFunction() {}
208 virtual bool RunImpl() OVERRIDE; 214 virtual bool RunImpl() OVERRIDE;
209 DECLARE_EXTENSION_FUNCTION_NAME("webNavigation.getAllFrames") 215 DECLARE_EXTENSION_FUNCTION_NAME("webNavigation.getAllFrames")
210 }; 216 };
211 217
212 } // namespace extensions 218 } // namespace extensions
213 219
214 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_NAVIGATION_WEB_NAVIGATION_API_H_ 220 #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