OLD | NEW |
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/web_view/web_view_permission_helper.h" | 5 #include "extensions/browser/guest_view/web_view/web_view_permission_helper.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
11 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
12 #include "base/threading/thread_task_runner_handle.h" | 12 #include "base/threading/thread_task_runner_handle.h" |
13 #include "components/guest_view/browser/guest_view_event.h" | 13 #include "components/guest_view/browser/guest_view_event.h" |
14 #include "content/public/browser/render_process_host.h" | 14 #include "content/public/browser/render_process_host.h" |
15 #include "content/public/browser/render_view_host.h" | 15 #include "content/public/browser/render_view_host.h" |
16 #include "content/public/browser/user_metrics.h" | 16 #include "content/public/browser/user_metrics.h" |
17 #include "extensions/browser/api/extensions_api_client.h" | 17 #include "extensions/browser/api/extensions_api_client.h" |
18 #include "extensions/browser/guest_view/web_view/web_view_constants.h" | 18 #include "extensions/browser/guest_view/web_view/web_view_constants.h" |
19 #include "extensions/browser/guest_view/web_view/web_view_guest.h" | 19 #include "extensions/browser/guest_view/web_view/web_view_guest.h" |
20 #include "extensions/browser/guest_view/web_view/web_view_permission_helper_dele
gate.h" | 20 #include "extensions/browser/guest_view/web_view/web_view_permission_helper_dele
gate.h" |
21 #include "extensions/browser/guest_view/web_view/web_view_permission_types.h" | 21 #include "extensions/browser/guest_view/web_view/web_view_permission_types.h" |
| 22 #include "ppapi/features/features.h" |
22 | 23 |
23 using content::BrowserPluginGuestDelegate; | 24 using content::BrowserPluginGuestDelegate; |
24 using content::RenderViewHost; | 25 using content::RenderViewHost; |
25 using guest_view::GuestViewEvent; | 26 using guest_view::GuestViewEvent; |
26 | 27 |
27 namespace extensions { | 28 namespace extensions { |
28 | 29 |
29 namespace { | 30 namespace { |
30 static std::string PermissionTypeToString(WebViewPermissionType type) { | 31 static std::string PermissionTypeToString(WebViewPermissionType type) { |
31 switch (type) { | 32 switch (type) { |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 | 176 |
176 // static | 177 // static |
177 WebViewPermissionHelper* WebViewPermissionHelper::FromWebContents( | 178 WebViewPermissionHelper* WebViewPermissionHelper::FromWebContents( |
178 content::WebContents* web_contents) { | 179 content::WebContents* web_contents) { |
179 WebViewGuest* web_view_guest = WebViewGuest::FromWebContents(web_contents); | 180 WebViewGuest* web_view_guest = WebViewGuest::FromWebContents(web_contents); |
180 if (!web_view_guest) | 181 if (!web_view_guest) |
181 return NULL; | 182 return NULL; |
182 return web_view_guest->web_view_permission_helper_.get(); | 183 return web_view_guest->web_view_permission_helper_.get(); |
183 } | 184 } |
184 | 185 |
185 #if defined(ENABLE_PLUGINS) | 186 #if BUILDFLAG(ENABLE_PLUGINS) |
186 bool WebViewPermissionHelper::OnMessageReceived( | 187 bool WebViewPermissionHelper::OnMessageReceived( |
187 const IPC::Message& message, | 188 const IPC::Message& message, |
188 content::RenderFrameHost* render_frame_host) { | 189 content::RenderFrameHost* render_frame_host) { |
189 return web_view_permission_helper_delegate_->OnMessageReceived( | 190 return web_view_permission_helper_delegate_->OnMessageReceived( |
190 message, render_frame_host); | 191 message, render_frame_host); |
191 } | 192 } |
192 | 193 |
193 bool WebViewPermissionHelper::OnMessageReceived(const IPC::Message& message) { | 194 bool WebViewPermissionHelper::OnMessageReceived(const IPC::Message& message) { |
194 return web_view_permission_helper_delegate_->OnMessageReceived(message); | 195 return web_view_permission_helper_delegate_->OnMessageReceived(message); |
195 } | 196 } |
196 #endif // defined(ENABLE_PLUGINS) | 197 #endif // BUILDFLAG(ENABLE_PLUGINS) |
197 | 198 |
198 void WebViewPermissionHelper::RequestMediaAccessPermission( | 199 void WebViewPermissionHelper::RequestMediaAccessPermission( |
199 content::WebContents* source, | 200 content::WebContents* source, |
200 const content::MediaStreamRequest& request, | 201 const content::MediaStreamRequest& request, |
201 const content::MediaResponseCallback& callback) { | 202 const content::MediaResponseCallback& callback) { |
202 base::DictionaryValue request_info; | 203 base::DictionaryValue request_info; |
203 request_info.SetString(guest_view::kUrl, request.security_origin.spec()); | 204 request_info.SetString(guest_view::kUrl, request.security_origin.spec()); |
204 RequestPermission( | 205 RequestPermission( |
205 WEB_VIEW_PERMISSION_TYPE_MEDIA, | 206 WEB_VIEW_PERMISSION_TYPE_MEDIA, |
206 request_info, | 207 request_info, |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 allowed_by_default(allowed_by_default) { | 408 allowed_by_default(allowed_by_default) { |
408 } | 409 } |
409 | 410 |
410 WebViewPermissionHelper::PermissionResponseInfo::PermissionResponseInfo( | 411 WebViewPermissionHelper::PermissionResponseInfo::PermissionResponseInfo( |
411 const PermissionResponseInfo& other) = default; | 412 const PermissionResponseInfo& other) = default; |
412 | 413 |
413 WebViewPermissionHelper::PermissionResponseInfo::~PermissionResponseInfo() { | 414 WebViewPermissionHelper::PermissionResponseInfo::~PermissionResponseInfo() { |
414 } | 415 } |
415 | 416 |
416 } // namespace extensions | 417 } // namespace extensions |
OLD | NEW |