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

Side by Side Diff: chrome/browser/ui/extensions/shell_window.cc

Issue 11198044: Make tab capture media stream requests verify that the request came from extension API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 1 month 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
« no previous file with comments | « chrome/browser/media/media_stream_devices_controller.cc ('k') | chrome/chrome_common.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 const extensions::DraggableRegion& region = *iter; 470 const extensions::DraggableRegion& region = *iter;
492 sk_region->op( 471 sk_region->op(
493 region.bounds.x(), 472 region.bounds.x(),
494 region.bounds.y(), 473 region.bounds.y(),
495 region.bounds.right(), 474 region.bounds.right(),
496 region.bounds.bottom(), 475 region.bounds.bottom(),
497 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); 476 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op);
498 } 477 }
499 return sk_region; 478 return sk_region;
500 } 479 }
OLDNEW
« no previous file with comments | « chrome/browser/media/media_stream_devices_controller.cc ('k') | chrome/chrome_common.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698