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