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

Side by Side Diff: extensions/browser/extension_web_contents_observer.h

Issue 2006013002: [Extensions] Determine NativeMessaging ID solely on the browser process (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ;; Created 4 years, 6 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef EXTENSIONS_BROWSER_EXTENSION_WEB_CONTENTS_OBSERVER_H_ 5 #ifndef EXTENSIONS_BROWSER_EXTENSION_WEB_CONTENTS_OBSERVER_H_
6 #define EXTENSIONS_BROWSER_EXTENSION_WEB_CONTENTS_OBSERVER_H_ 6 #define EXTENSIONS_BROWSER_EXTENSION_WEB_CONTENTS_OBSERVER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 class ExtensionWebContentsObserver 49 class ExtensionWebContentsObserver
50 : public content::WebContentsObserver, 50 : public content::WebContentsObserver,
51 public ExtensionFunctionDispatcher::Delegate { 51 public ExtensionFunctionDispatcher::Delegate {
52 public: 52 public:
53 // Returns the ExtensionWebContentsObserver for the given |web_contents|. 53 // Returns the ExtensionWebContentsObserver for the given |web_contents|.
54 static ExtensionWebContentsObserver* GetForWebContents( 54 static ExtensionWebContentsObserver* GetForWebContents(
55 content::WebContents* web_contents); 55 content::WebContents* web_contents);
56 56
57 ExtensionFunctionDispatcher* dispatcher() { return &dispatcher_; } 57 ExtensionFunctionDispatcher* dispatcher() { return &dispatcher_; }
58 58
59 // Returns the extension associated with the given |render_frame_host|, or
60 // null if there is none.
61 // If |verify_url| is false, only the SiteInstance is taken into account.
62 // If |verify_url| is true, the frame's last committed URL is also used to
63 // improve the classification of the frame.
64 const Extension* GetExtensionFromFrame(
65 content::RenderFrameHost* render_frame_host,
66 bool verify_url) const;
67
59 protected: 68 protected:
60 explicit ExtensionWebContentsObserver(content::WebContents* web_contents); 69 explicit ExtensionWebContentsObserver(content::WebContents* web_contents);
61 ~ExtensionWebContentsObserver() override; 70 ~ExtensionWebContentsObserver() override;
62 71
63 content::BrowserContext* browser_context() { return browser_context_; } 72 content::BrowserContext* browser_context() { return browser_context_; }
64 73
65 // Initializes a new render frame. Subclasses should invoke this 74 // Initializes a new render frame. Subclasses should invoke this
66 // implementation if extending. 75 // implementation if extending.
67 virtual void InitializeRenderFrame( 76 virtual void InitializeRenderFrame(
68 content::RenderFrameHost* render_frame_host); 77 content::RenderFrameHost* render_frame_host);
(...skipping 23 matching lines...) Expand all
92 // Per the documentation in WebContentsObserver, these two methods are invoked 101 // Per the documentation in WebContentsObserver, these two methods are invoked
93 // when a Pepper plugin instance is attached/detached in the page DOM. 102 // when a Pepper plugin instance is attached/detached in the page DOM.
94 void PepperInstanceCreated() override; 103 void PepperInstanceCreated() override;
95 void PepperInstanceDeleted() override; 104 void PepperInstanceDeleted() override;
96 105
97 // Returns the extension id associated with the given |render_frame_host|, or 106 // Returns the extension id associated with the given |render_frame_host|, or
98 // the empty string if there is none. 107 // the empty string if there is none.
99 std::string GetExtensionIdFromFrame( 108 std::string GetExtensionIdFromFrame(
100 content::RenderFrameHost* render_frame_host) const; 109 content::RenderFrameHost* render_frame_host) const;
101 110
102 // Returns the extension associated with the given |render_frame_host|, or
103 // null if there is none.
104 // If |verify_url| is false, only the SiteInstance is taken into account.
105 // If |verify_url| is true, the frame's last committed URL is also used to
106 // improve the classification of the frame.
107 const Extension* GetExtensionFromFrame(
108 content::RenderFrameHost* render_frame_host,
109 bool verify_url) const;
110
111 // TODO(devlin): Remove these once callers are updated to use the FromFrame 111 // TODO(devlin): Remove these once callers are updated to use the FromFrame
112 // equivalents. 112 // equivalents.
113 // Returns the extension or app associated with a render view host. Returns 113 // Returns the extension or app associated with a render view host. Returns
114 // NULL if the render view host is not for a valid extension. 114 // NULL if the render view host is not for a valid extension.
115 const Extension* GetExtension(content::RenderViewHost* render_view_host); 115 const Extension* GetExtension(content::RenderViewHost* render_view_host);
116 // Returns the extension or app ID associated with a render view host. Returns 116 // Returns the extension or app ID associated with a render view host. Returns
117 // the empty string if the render view host is not for a valid extension. 117 // the empty string if the render view host is not for a valid extension.
118 static std::string GetExtensionId(content::RenderViewHost* render_view_host); 118 static std::string GetExtensionId(content::RenderViewHost* render_view_host);
119 119
120 private: 120 private:
121 void OnRequest(content::RenderFrameHost* render_frame_host, 121 void OnRequest(content::RenderFrameHost* render_frame_host,
122 const ExtensionHostMsg_Request_Params& params); 122 const ExtensionHostMsg_Request_Params& params);
123 123
124 // A helper function for initializing render frames at the creation of the 124 // A helper function for initializing render frames at the creation of the
125 // observer. 125 // observer.
126 void InitializeFrameHelper(content::RenderFrameHost* render_frame_host); 126 void InitializeFrameHelper(content::RenderFrameHost* render_frame_host);
127 127
128 // The BrowserContext associated with the WebContents being observed. 128 // The BrowserContext associated with the WebContents being observed.
129 content::BrowserContext* browser_context_; 129 content::BrowserContext* browser_context_;
130 130
131 ExtensionFunctionDispatcher dispatcher_; 131 ExtensionFunctionDispatcher dispatcher_;
132 132
133 DISALLOW_COPY_AND_ASSIGN(ExtensionWebContentsObserver); 133 DISALLOW_COPY_AND_ASSIGN(ExtensionWebContentsObserver);
134 }; 134 };
135 135
136 } // namespace extensions 136 } // namespace extensions
137 137
138 #endif // EXTENSIONS_BROWSER_EXTENSION_WEB_CONTENTS_OBSERVER_H_ 138 #endif // EXTENSIONS_BROWSER_EXTENSION_WEB_CONTENTS_OBSERVER_H_
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/chrome_extension_message_filter.cc ('k') | extensions/common/extension_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698