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

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: 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 // This method can be overriden by subclasses. This gives the derived class 118 // This method can be overriden by subclasses. This gives the derived class
115 // an opportunity to perform setup actions before attachment. 119 // an opportunity to perform setup actions before attachment.
116 virtual void WillAttachToEmbedder() {} 120 virtual void WillAttachToEmbedder() {}
117 121
118 // This method is called when the guest WebContents is about to be destroyed. 122 // This method is called when the guest WebContents is about to be destroyed.
119 // 123 //
120 // This gives the derived class an opportunity to perform some cleanup prior 124 // This gives the derived class an opportunity to perform some cleanup prior
121 // to destruction. 125 // to destruction.
122 virtual void WillDestroy() {} 126 virtual void WillDestroy() {}
123 127
124 // This method is to be implemented by the derived class. It determines 128 // This method is to be implemented by the derived class. Access to guest
125 // whether the guest view type of the derived class can be used by the 129 // views are determined by the availability of the extension Feature returned
126 // provided embedder extension ID. 130 // by GetFeature().
127 virtual bool CanEmbedderUseGuestView( 131 //
128 const std::string& embedder_extension_id) = 0; 132 // This Feature should be an API feature so that it can declare the contexts
133 // the guest view is available in, *not* a permission which contains no
134 // context information.
135 virtual extensions::Feature* GetFeature() = 0;
129 136
130 // This method is to be implemented by the derived class. Given a set of 137 // This method is to be implemented by the derived class. Given a set of
131 // initialization parameters, a concrete subclass of GuestViewBase can 138 // initialization parameters, a concrete subclass of GuestViewBase can
132 // create a specialized WebContents that it returns back to GuestViewBase. 139 // create a specialized WebContents that it returns back to GuestViewBase.
133 typedef base::Callback<void(content::WebContents*)> 140 typedef base::Callback<void(content::WebContents*)>
134 WebContentsCreatedCallback; 141 WebContentsCreatedCallback;
135 virtual void CreateWebContents( 142 virtual void CreateWebContents(
136 const std::string& embedder_extension_id, 143 const std::string& embedder_extension_id,
137 int embedder_render_process_id, 144 int embedder_render_process_id,
138 const base::DictionaryValue& create_params, 145 const base::DictionaryValue& create_params,
139 const WebContentsCreatedCallback& callback) = 0; 146 const WebContentsCreatedCallback& callback) = 0;
140 147
141 // This creates a WebContents and initializes |this| GuestViewBase to use the 148 // This creates a WebContents and initializes |this| GuestViewBase to use the
142 // newly created WebContents. 149 // newly created WebContents.
143 void Init(const std::string& embedder_extension_id, 150 void Init(const std::string& embedder_extension_id,
144 int embedder_render_process_id, 151 int embedder_render_process_id,
152 content::WebContents* web_contents,
145 const base::DictionaryValue& create_params, 153 const base::DictionaryValue& create_params,
146 const WebContentsCreatedCallback& callback); 154 const WebContentsCreatedCallback& callback);
147 155
148 void InitWithWebContents( 156 void InitWithWebContents(
149 const std::string& embedder_extension_id, 157 const std::string& embedder_extension_id,
150 int embedder_render_process_id, 158 int embedder_render_process_id,
151 content::WebContents* guest_web_contents); 159 content::WebContents* guest_web_contents);
152 160
153 bool IsViewType(const char* const view_type) const { 161 bool IsViewType(const char* const view_type) const {
154 return !strcmp(GetViewType(), view_type); 162 return !strcmp(GetViewType(), view_type);
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 scoped_ptr<EmbedderWebContentsObserver> embedder_web_contents_observer_; 286 scoped_ptr<EmbedderWebContentsObserver> embedder_web_contents_observer_;
279 287
280 // This is used to ensure pending tasks will not fire after this object is 288 // This is used to ensure pending tasks will not fire after this object is
281 // destroyed. 289 // destroyed.
282 base::WeakPtrFactory<GuestViewBase> weak_ptr_factory_; 290 base::WeakPtrFactory<GuestViewBase> weak_ptr_factory_;
283 291
284 DISALLOW_COPY_AND_ASSIGN(GuestViewBase); 292 DISALLOW_COPY_AND_ASSIGN(GuestViewBase);
285 }; 293 };
286 294
287 #endif // CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ 295 #endif // CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698