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

Side by Side Diff: chrome/browser/guest_view/guest_view_base.h

Issue 426593007: Refactor guest view availability to be API not permission based. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: again Created 6 years, 4 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
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 CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ 5 #ifndef CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_
6 #define CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ 6 #define CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_
7 7
8 #include <queue> 8 #include <queue>
9 9
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "content/public/browser/browser_plugin_guest_delegate.h" 12 #include "content/public/browser/browser_plugin_guest_delegate.h"
13 #include "content/public/browser/render_process_host_observer.h" 13 #include "content/public/browser/render_process_host_observer.h"
14 #include "content/public/browser/web_contents.h" 14 #include "content/public/browser/web_contents.h"
15 #include "content/public/browser/web_contents_delegate.h" 15 #include "content/public/browser/web_contents_delegate.h"
16 #include "content/public/browser/web_contents_observer.h" 16 #include "content/public/browser/web_contents_observer.h"
17 17
18 struct RendererContentSettingRules; 18 struct RendererContentSettingRules;
19 19
20 namespace extensions {
21 class Feature;
22 }
23
20 // A GuestViewBase is the base class browser-side API implementation for a 24 // A GuestViewBase is the base class browser-side API implementation for a
21 // <*view> tag. GuestViewBase maintains an association between a guest 25 // <*view> tag. GuestViewBase maintains an association between a guest
22 // WebContents and an embedder WebContents. It receives events issued from 26 // WebContents and an embedder WebContents. It receives events issued from
23 // the guest and relays them to the embedder. GuestViewBase tracks the lifetime 27 // the guest and relays them to the embedder. GuestViewBase tracks the lifetime
24 // of its embedder render process until it is attached to a particular embedder 28 // of its embedder render process until it is attached to a particular embedder
25 // WebContents. At that point, its lifetime is restricted in scope to the 29 // WebContents. At that point, its lifetime is restricted in scope to the
26 // lifetime of its embedder WebContents. 30 // lifetime of its embedder WebContents.
27 class GuestViewBase : public content::BrowserPluginGuestDelegate, 31 class GuestViewBase : public content::BrowserPluginGuestDelegate,
28 public content::RenderProcessHostObserver, 32 public content::RenderProcessHostObserver,
29 public content::WebContentsDelegate, 33 public content::WebContentsDelegate,
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 // This method can be overriden by subclasses. This gives the derived class 138 // This method can be overriden by subclasses. This gives the derived class
135 // an opportunity to perform setup actions before attachment. 139 // an opportunity to perform setup actions before attachment.
136 virtual void WillAttachToEmbedder() {} 140 virtual void WillAttachToEmbedder() {}
137 141
138 // This method is called when the guest WebContents is about to be destroyed. 142 // This method is called when the guest WebContents is about to be destroyed.
139 // 143 //
140 // This gives the derived class an opportunity to perform some cleanup prior 144 // This gives the derived class an opportunity to perform some cleanup prior
141 // to destruction. 145 // to destruction.
142 virtual void WillDestroy() {} 146 virtual void WillDestroy() {}
143 147
144 // This method is to be implemented by the derived class. It determines 148 // This method is to be implemented by the derived class. Access to guest
145 // whether the guest view type of the derived class can be used by the 149 // views are determined by the availability of the extension Feature returned
146 // provided embedder extension ID. 150 // by GetFeature().
147 virtual bool CanEmbedderUseGuestView( 151 //
148 const std::string& embedder_extension_id) = 0; 152 // This Feature should be an API feature so that it can declare the contexts
not at google - send to devlin 2014/08/07 00:25:29 This comment, and the boilerplate, is making me co
153 // the guest view is available in, *not* a permission which contains no
154 // context information.
155 virtual extensions::Feature* GetFeature() = 0;
149 156
150 // This method is to be implemented by the derived class. Given a set of 157 // This method is to be implemented by the derived class. Given a set of
151 // initialization parameters, a concrete subclass of GuestViewBase can 158 // initialization parameters, a concrete subclass of GuestViewBase can
152 // create a specialized WebContents that it returns back to GuestViewBase. 159 // create a specialized WebContents that it returns back to GuestViewBase.
153 typedef base::Callback<void(content::WebContents*)> 160 typedef base::Callback<void(content::WebContents*)>
154 WebContentsCreatedCallback; 161 WebContentsCreatedCallback;
155 virtual void CreateWebContents( 162 virtual void CreateWebContents(
156 const std::string& embedder_extension_id, 163 const std::string& embedder_extension_id,
157 int embedder_render_process_id, 164 int embedder_render_process_id,
158 const base::DictionaryValue& create_params, 165 const base::DictionaryValue& create_params,
159 const WebContentsCreatedCallback& callback) = 0; 166 const WebContentsCreatedCallback& callback) = 0;
160 167
161 // This creates a WebContents and initializes |this| GuestViewBase to use the 168 // This creates a WebContents and initializes |this| GuestViewBase to use the
162 // newly created WebContents. 169 // newly created WebContents.
163 void Init(const std::string& embedder_extension_id, 170 void Init(const std::string& embedder_extension_id,
164 int embedder_render_process_id, 171 int embedder_render_process_id,
172 content::WebContents* web_contents,
not at google - send to devlin 2014/08/07 00:25:29 I think I'll just replace the |embedder_render_pro
165 const base::DictionaryValue& create_params, 173 const base::DictionaryValue& create_params,
166 const WebContentsCreatedCallback& callback); 174 const WebContentsCreatedCallback& callback);
167 175
168 void InitWithWebContents( 176 void InitWithWebContents(
169 const std::string& embedder_extension_id, 177 const std::string& embedder_extension_id,
170 int embedder_render_process_id, 178 int embedder_render_process_id,
171 content::WebContents* guest_web_contents); 179 content::WebContents* guest_web_contents);
172 180
173 bool IsViewType(const char* const view_type) const { 181 bool IsViewType(const char* const view_type) const {
174 return !strcmp(GetViewType(), view_type); 182 return !strcmp(GetViewType(), view_type);
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 gfx::Size min_auto_size_; 332 gfx::Size min_auto_size_;
325 333
326 // This is used to ensure pending tasks will not fire after this object is 334 // This is used to ensure pending tasks will not fire after this object is
327 // destroyed. 335 // destroyed.
328 base::WeakPtrFactory<GuestViewBase> weak_ptr_factory_; 336 base::WeakPtrFactory<GuestViewBase> weak_ptr_factory_;
329 337
330 DISALLOW_COPY_AND_ASSIGN(GuestViewBase); 338 DISALLOW_COPY_AND_ASSIGN(GuestViewBase);
331 }; 339 };
332 340
333 #endif // CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ 341 #endif // CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698