| 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/shell_window_registry.h" | 9 #include "chrome/browser/extensions/shell_window_registry.h" |
| 10 #include "chrome/browser/file_select_helper.h" | 10 #include "chrome/browser/file_select_helper.h" |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 // Remove shutdown prevention. | 145 // Remove shutdown prevention. |
| 146 browser::EndKeepAlive(); | 146 browser::EndKeepAlive(); |
| 147 } | 147 } |
| 148 | 148 |
| 149 void ShellWindow::RequestMediaAccessPermission( | 149 void ShellWindow::RequestMediaAccessPermission( |
| 150 content::WebContents* web_contents, | 150 content::WebContents* web_contents, |
| 151 const content::MediaStreamRequest* request, | 151 const content::MediaStreamRequest* request, |
| 152 const content::MediaResponseCallback& callback) { | 152 const content::MediaResponseCallback& callback) { |
| 153 content::MediaStreamDevices devices; | 153 content::MediaStreamDevices devices; |
| 154 | 154 |
| 155 content::MediaStreamDeviceMap::const_iterator iter = | 155 // Auto-accept the first audio device and the first video device from the |
| 156 request->devices.find(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE); | 156 // request when the appropriate API permissions exist. |
| 157 if (iter != request->devices.end() && | 157 bool accepted_an_audio_device = false; |
| 158 extension()->HasAPIPermission(APIPermission::kAudioCapture) && | 158 bool accepted_a_video_device = false; |
| 159 !iter->second.empty()) { | 159 for (content::MediaStreamDeviceMap::const_iterator it = |
| 160 devices.push_back(iter->second[0]); | 160 request->devices.begin(); |
| 161 } | 161 it != request->devices.end(); ++it) { |
| 162 | 162 if (!accepted_an_audio_device && |
| 163 iter = request->devices.find(content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE); | 163 content::IsAudioMediaStreamDeviceType(it->first) && |
| 164 if (iter != request->devices.end() && | 164 extension()->HasAPIPermission(APIPermission::kAudioCapture) && |
| 165 extension()->HasAPIPermission(APIPermission::kVideoCapture) && | 165 !it->second.empty()) { |
| 166 !iter->second.empty()) { | 166 devices.push_back(it->second.front()); |
| 167 devices.push_back(iter->second[0]); | 167 accepted_an_audio_device = true; |
| 168 } else if (!accepted_a_video_device && |
| 169 content::IsVideoMediaStreamDeviceType(it->first) && |
| 170 extension()->HasAPIPermission(APIPermission::kVideoCapture) && |
| 171 !it->second.empty()) { |
| 172 devices.push_back(it->second.front()); |
| 173 accepted_a_video_device = true; |
| 174 } |
| 168 } | 175 } |
| 169 | 176 |
| 170 callback.Run(devices); | 177 callback.Run(devices); |
| 171 } | 178 } |
| 172 | 179 |
| 173 WebContents* ShellWindow::OpenURLFromTab(WebContents* source, | 180 WebContents* ShellWindow::OpenURLFromTab(WebContents* source, |
| 174 const content::OpenURLParams& params) { | 181 const content::OpenURLParams& params) { |
| 175 DCHECK(source == web_contents_); | 182 DCHECK(source == web_contents_); |
| 176 | 183 |
| 177 if (params.url.host() == extension_->id()) { | 184 if (params.url.host() == extension_->id()) { |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 extension_function_dispatcher_.Dispatch(params, | 376 extension_function_dispatcher_.Dispatch(params, |
| 370 web_contents_->GetRenderViewHost()); | 377 web_contents_->GetRenderViewHost()); |
| 371 } | 378 } |
| 372 | 379 |
| 373 void ShellWindow::AddMessageToDevToolsConsole(ConsoleMessageLevel level, | 380 void ShellWindow::AddMessageToDevToolsConsole(ConsoleMessageLevel level, |
| 374 const std::string& message) { | 381 const std::string& message) { |
| 375 content::RenderViewHost* rvh = web_contents_->GetRenderViewHost(); | 382 content::RenderViewHost* rvh = web_contents_->GetRenderViewHost(); |
| 376 rvh->Send(new ExtensionMsg_AddMessageToConsole( | 383 rvh->Send(new ExtensionMsg_AddMessageToConsole( |
| 377 rvh->GetRoutingID(), level, message)); | 384 rvh->GetRoutingID(), level, message)); |
| 378 } | 385 } |
| OLD | NEW |