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

Side by Side Diff: extensions/browser/guest_view/app_view/app_view_guest.cc

Issue 820583002: Adds support for media permission request handling on <appview> tag. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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 #include "extensions/browser/guest_view/app_view/app_view_guest.h" 5 #include "extensions/browser/guest_view/app_view/app_view_guest.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "content/public/browser/render_view_host.h" 8 #include "content/public/browser/render_view_host.h"
9 #include "content/public/common/renderer_preferences.h" 9 #include "content/public/common/renderer_preferences.h"
10 #include "extensions/browser/api/app_runtime/app_runtime_api.h" 10 #include "extensions/browser/api/app_runtime/app_runtime_api.h"
11 #include "extensions/browser/api/extensions_api_client.h" 11 #include "extensions/browser/api/extensions_api_client.h"
12 #include "extensions/browser/app_window/app_delegate.h"
12 #include "extensions/browser/event_router.h" 13 #include "extensions/browser/event_router.h"
13 #include "extensions/browser/extension_host.h" 14 #include "extensions/browser/extension_host.h"
14 #include "extensions/browser/extension_registry.h" 15 #include "extensions/browser/extension_registry.h"
15 #include "extensions/browser/extension_system.h" 16 #include "extensions/browser/extension_system.h"
16 #include "extensions/browser/guest_view/app_view/app_view_constants.h" 17 #include "extensions/browser/guest_view/app_view/app_view_constants.h"
17 #include "extensions/browser/guest_view/guest_view_manager.h" 18 #include "extensions/browser/guest_view/guest_view_manager.h"
18 #include "extensions/browser/lazy_background_task_queue.h" 19 #include "extensions/browser/lazy_background_task_queue.h"
19 #include "extensions/browser/process_manager.h" 20 #include "extensions/browser/process_manager.h"
20 #include "extensions/browser/view_type_utils.h" 21 #include "extensions/browser/view_type_utils.h"
21 #include "extensions/common/api/app_runtime.h" 22 #include "extensions/common/api/app_runtime.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 98
98 AppViewGuest::AppViewGuest(content::BrowserContext* browser_context, 99 AppViewGuest::AppViewGuest(content::BrowserContext* browser_context,
99 content::WebContents* owner_web_contents, 100 content::WebContents* owner_web_contents,
100 int guest_instance_id) 101 int guest_instance_id)
101 : GuestView<AppViewGuest>(browser_context, 102 : GuestView<AppViewGuest>(browser_context,
102 owner_web_contents, 103 owner_web_contents,
103 guest_instance_id), 104 guest_instance_id),
104 app_view_guest_delegate_( 105 app_view_guest_delegate_(
105 ExtensionsAPIClient::Get()->CreateAppViewGuestDelegate()), 106 ExtensionsAPIClient::Get()->CreateAppViewGuestDelegate()),
106 weak_ptr_factory_(this) { 107 weak_ptr_factory_(this) {
108 if (app_view_guest_delegate_)
109 app_delegate_.reset(app_view_guest_delegate_->CreateAppDelegate());
107 } 110 }
108 111
109 AppViewGuest::~AppViewGuest() { 112 AppViewGuest::~AppViewGuest() {
110 } 113 }
111 114
112 WindowController* AppViewGuest::GetExtensionWindowController() const { 115 WindowController* AppViewGuest::GetExtensionWindowController() const {
113 return NULL; 116 return NULL;
114 } 117 }
115 118
116 content::WebContents* AppViewGuest::GetAssociatedWebContents() const { 119 content::WebContents* AppViewGuest::GetAssociatedWebContents() const {
117 return web_contents(); 120 return web_contents();
118 } 121 }
119 122
120 bool AppViewGuest::OnMessageReceived(const IPC::Message& message) { 123 bool AppViewGuest::OnMessageReceived(const IPC::Message& message) {
121 bool handled = true; 124 bool handled = true;
122 IPC_BEGIN_MESSAGE_MAP(AppViewGuest, message) 125 IPC_BEGIN_MESSAGE_MAP(AppViewGuest, message)
123 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) 126 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest)
124 IPC_MESSAGE_UNHANDLED(handled = false) 127 IPC_MESSAGE_UNHANDLED(handled = false)
125 IPC_END_MESSAGE_MAP() 128 IPC_END_MESSAGE_MAP()
126 return handled; 129 return handled;
127 } 130 }
128 131
129 bool AppViewGuest::HandleContextMenu(const content::ContextMenuParams& params) { 132 bool AppViewGuest::HandleContextMenu(const content::ContextMenuParams& params) {
130 if (app_view_guest_delegate_) { 133 if (app_view_guest_delegate_) {
131 return app_view_guest_delegate_->HandleContextMenu(web_contents(), params); 134 return app_view_guest_delegate_->HandleContextMenu(web_contents(), params);
132 } 135 }
133 return false; 136 return false;
134 } 137 }
135 138
139 void AppViewGuest::RequestMediaAccessPermission(
140 content::WebContents* web_contents,
141 const content::MediaStreamRequest& request,
142 const content::MediaResponseCallback& callback) {
143 if (!app_delegate_) {
144 WebContentsDelegate::RequestMediaAccessPermission(web_contents, request,
145 callback);
146 return;
147 }
148 const ExtensionSet& enabled_extensions =
149 ExtensionRegistry::Get(browser_context())->enabled_extensions();
150 const Extension* guest_extension =
151 enabled_extensions.GetByID(guest_extension_id_);
152
153 app_delegate_->RequestMediaAccessPermission(web_contents, request, callback,
154 guest_extension);
155 }
156
157 bool AppViewGuest::CheckMediaAccessPermission(
158 content::WebContents* web_contents,
159 const GURL& security_origin,
160 content::MediaStreamType type) {
161 if (!app_delegate_) {
162 return WebContentsDelegate::CheckMediaAccessPermission(
163 web_contents, security_origin, type);
164 }
165 const ExtensionSet& enabled_extensions =
166 ExtensionRegistry::Get(browser_context())->enabled_extensions();
167 const Extension* guest_extension =
168 enabled_extensions.GetByID(guest_extension_id_);
169
170 return app_delegate_->CheckMediaAccessPermission(
171 web_contents, security_origin, type, guest_extension);
172 }
173
136 const char* AppViewGuest::GetAPINamespace() const { 174 const char* AppViewGuest::GetAPINamespace() const {
137 return appview::kEmbedderAPINamespace; 175 return appview::kEmbedderAPINamespace;
138 } 176 }
139 177
140 int AppViewGuest::GetTaskPrefix() const { 178 int AppViewGuest::GetTaskPrefix() const {
141 return IDS_EXTENSION_TASK_MANAGER_APPVIEW_TAG_PREFIX; 179 return IDS_EXTENSION_TASK_MANAGER_APPVIEW_TAG_PREFIX;
142 } 180 }
143 181
144 void AppViewGuest::CreateWebContents( 182 void AppViewGuest::CreateWebContents(
145 const base::DictionaryValue& create_params, 183 const base::DictionaryValue& create_params,
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 } 289 }
252 290
253 scoped_ptr<base::DictionaryValue> embed_request(new base::DictionaryValue()); 291 scoped_ptr<base::DictionaryValue> embed_request(new base::DictionaryValue());
254 embed_request->SetInteger(appview::kGuestInstanceID, guest_instance_id()); 292 embed_request->SetInteger(appview::kGuestInstanceID, guest_instance_id());
255 embed_request->SetString(appview::kEmbedderID, owner_extension_id()); 293 embed_request->SetString(appview::kEmbedderID, owner_extension_id());
256 embed_request->Set(appview::kData, data.release()); 294 embed_request->Set(appview::kData, data.release());
257 AppRuntimeEventRouter::DispatchOnEmbedRequestedEvent( 295 AppRuntimeEventRouter::DispatchOnEmbedRequestedEvent(
258 browser_context(), embed_request.Pass(), extension_host->extension()); 296 browser_context(), embed_request.Pass(), extension_host->extension());
259 } 297 }
260 298
299 void AppViewGuest::SetAppDelegateForTest(AppDelegate* delegate) {
300 app_delegate_.reset(delegate);
301 }
302
261 } // namespace extensions 303 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698