| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/ui/extensions/shell_window.h" | 5 #include "chrome/browser/ui/extensions/shell_window.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/extensions/extension_process_manager.h" | 8 #include "chrome/browser/extensions/extension_process_manager.h" |
| 9 #include "chrome/browser/extensions/extension_system.h" | 9 #include "chrome/browser/extensions/extension_system.h" |
| 10 #include "chrome/browser/extensions/shell_window_geometry_cache.h" | 10 #include "chrome/browser/extensions/shell_window_geometry_cache.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "chrome/browser/ui/browser_tabstrip.h" | 21 #include "chrome/browser/ui/browser_tabstrip.h" |
| 22 #include "chrome/browser/ui/browser_window.h" | 22 #include "chrome/browser/ui/browser_window.h" |
| 23 #include "chrome/browser/ui/constrained_window_tab_helper.h" | 23 #include "chrome/browser/ui/constrained_window_tab_helper.h" |
| 24 #include "chrome/browser/ui/extensions/native_shell_window.h" | 24 #include "chrome/browser/ui/extensions/native_shell_window.h" |
| 25 #include "chrome/browser/ui/intents/web_intent_picker_controller.h" | 25 #include "chrome/browser/ui/intents/web_intent_picker_controller.h" |
| 26 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 26 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 27 #include "chrome/browser/view_type_utils.h" | 27 #include "chrome/browser/view_type_utils.h" |
| 28 #include "chrome/common/chrome_notification_types.h" | 28 #include "chrome/common/chrome_notification_types.h" |
| 29 #include "chrome/common/extensions/extension.h" | 29 #include "chrome/common/extensions/extension.h" |
| 30 #include "chrome/common/extensions/extension_messages.h" | 30 #include "chrome/common/extensions/extension_messages.h" |
| 31 #include "chrome/common/extensions/request_media_access_permission_helper.h" |
| 31 #include "content/public/browser/browser_thread.h" | 32 #include "content/public/browser/browser_thread.h" |
| 32 #include "content/public/browser/invalidate_type.h" | 33 #include "content/public/browser/invalidate_type.h" |
| 33 #include "content/public/browser/navigation_entry.h" | 34 #include "content/public/browser/navigation_entry.h" |
| 34 #include "content/public/browser/notification_details.h" | 35 #include "content/public/browser/notification_details.h" |
| 35 #include "content/public/browser/notification_service.h" | 36 #include "content/public/browser/notification_service.h" |
| 36 #include "content/public/browser/notification_source.h" | 37 #include "content/public/browser/notification_source.h" |
| 37 #include "content/public/browser/notification_types.h" | 38 #include "content/public/browser/notification_types.h" |
| 38 #include "content/public/browser/render_process_host.h" | 39 #include "content/public/browser/render_process_host.h" |
| 39 #include "content/public/browser/render_view_host.h" | 40 #include "content/public/browser/render_view_host.h" |
| 40 #include "content/public/browser/resource_dispatcher_host.h" | 41 #include "content/public/browser/resource_dispatcher_host.h" |
| 41 #include "content/public/browser/site_instance.h" | 42 #include "content/public/browser/site_instance.h" |
| 42 #include "content/public/browser/web_contents.h" | 43 #include "content/public/browser/web_contents.h" |
| 43 #include "content/public/browser/web_intents_dispatcher.h" | 44 #include "content/public/browser/web_intents_dispatcher.h" |
| 44 #include "content/public/common/media_stream_request.h" | 45 #include "content/public/common/media_stream_request.h" |
| 45 #include "content/public/common/renderer_preferences.h" | 46 #include "content/public/common/renderer_preferences.h" |
| 46 #include "third_party/skia/include/core/SkRegion.h" | 47 #include "third_party/skia/include/core/SkRegion.h" |
| 47 | 48 |
| 48 using content::BrowserThread; | 49 using content::BrowserThread; |
| 49 using content::ConsoleMessageLevel; | 50 using content::ConsoleMessageLevel; |
| 50 using content::RenderViewHost; | 51 using content::RenderViewHost; |
| 51 using content::ResourceDispatcherHost; | 52 using content::ResourceDispatcherHost; |
| 52 using content::SiteInstance; | 53 using content::SiteInstance; |
| 53 using content::WebContents; | 54 using content::WebContents; |
| 54 using extensions::APIPermission; | 55 using extensions::APIPermission; |
| 56 using extensions::RequestMediaAccessPermissionHelper; |
| 55 | 57 |
| 56 namespace { | 58 namespace { |
| 57 const int kDefaultWidth = 512; | 59 const int kDefaultWidth = 512; |
| 58 const int kDefaultHeight = 384; | 60 const int kDefaultHeight = 384; |
| 59 | 61 |
| 60 void SuspendRenderViewHost(RenderViewHost* rvh) { | 62 void SuspendRenderViewHost(RenderViewHost* rvh) { |
| 61 DCHECK(rvh); | 63 DCHECK(rvh); |
| 62 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 64 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
| 63 base::Bind(&ResourceDispatcherHost::BlockRequestsForRoute, | 65 base::Bind(&ResourceDispatcherHost::BlockRequestsForRoute, |
| 64 base::Unretained(ResourceDispatcherHost::Get()), | 66 base::Unretained(ResourceDispatcherHost::Get()), |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 registrar_.RemoveAll(); | 188 registrar_.RemoveAll(); |
| 187 | 189 |
| 188 // Remove shutdown prevention. | 190 // Remove shutdown prevention. |
| 189 browser::EndKeepAlive(); | 191 browser::EndKeepAlive(); |
| 190 } | 192 } |
| 191 | 193 |
| 192 void ShellWindow::RequestMediaAccessPermission( | 194 void ShellWindow::RequestMediaAccessPermission( |
| 193 content::WebContents* web_contents, | 195 content::WebContents* web_contents, |
| 194 const content::MediaStreamRequest* request, | 196 const content::MediaStreamRequest* request, |
| 195 const content::MediaResponseCallback& callback) { | 197 const content::MediaResponseCallback& callback) { |
| 196 content::MediaStreamDevices devices; | 198 RequestMediaAccessPermissionHelper::AuthorizeRequest( |
| 197 | 199 request, callback, extension(), true); |
| 198 // Auto-accept the first audio device and the first video device from the | |
| 199 // request when the appropriate API permissions exist. | |
| 200 bool accepted_an_audio_device = false; | |
| 201 bool accepted_a_video_device = false; | |
| 202 for (content::MediaStreamDeviceMap::const_iterator it = | |
| 203 request->devices.begin(); | |
| 204 it != request->devices.end(); ++it) { | |
| 205 if (!accepted_an_audio_device && | |
| 206 content::IsAudioMediaType(it->first) && | |
| 207 extension()->HasAPIPermission(APIPermission::kAudioCapture) && | |
| 208 !it->second.empty()) { | |
| 209 devices.push_back(it->second.front()); | |
| 210 accepted_an_audio_device = true; | |
| 211 } else if (!accepted_a_video_device && | |
| 212 content::IsVideoMediaType(it->first) && | |
| 213 extension()->HasAPIPermission(APIPermission::kVideoCapture) && | |
| 214 !it->second.empty()) { | |
| 215 devices.push_back(it->second.front()); | |
| 216 accepted_a_video_device = true; | |
| 217 } | |
| 218 } | |
| 219 | |
| 220 callback.Run(devices); | |
| 221 } | 200 } |
| 222 | 201 |
| 223 WebContents* ShellWindow::OpenURLFromTab(WebContents* source, | 202 WebContents* ShellWindow::OpenURLFromTab(WebContents* source, |
| 224 const content::OpenURLParams& params) { | 203 const content::OpenURLParams& params) { |
| 225 DCHECK(source == web_contents_); | 204 DCHECK(source == web_contents_); |
| 226 | 205 |
| 227 // Don't allow the current tab to be navigated. It would be nice to map all | 206 // Don't allow the current tab to be navigated. It would be nice to map all |
| 228 // anchor tags (even those without target="_blank") to new tabs, but right | 207 // anchor tags (even those without target="_blank") to new tabs, but right |
| 229 // now we can't distinguish between those and <meta> refreshes or window.href | 208 // now we can't distinguish between those and <meta> refreshes or window.href |
| 230 // navigations, which we don't want to allow. | 209 // navigations, which we don't want to allow. |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 const extensions::DraggableRegion& region = *iter; | 466 const extensions::DraggableRegion& region = *iter; |
| 488 sk_region->op( | 467 sk_region->op( |
| 489 region.bounds.x(), | 468 region.bounds.x(), |
| 490 region.bounds.y(), | 469 region.bounds.y(), |
| 491 region.bounds.right(), | 470 region.bounds.right(), |
| 492 region.bounds.bottom(), | 471 region.bounds.bottom(), |
| 493 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); | 472 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); |
| 494 } | 473 } |
| 495 return sk_region; | 474 return sk_region; |
| 496 } | 475 } |
| OLD | NEW |