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 25 matching lines...) Expand all Loading... |
36 #include "content/public/browser/web_contents.h" | 36 #include "content/public/browser/web_contents.h" |
37 #include "content/public/browser/web_intents_dispatcher.h" | 37 #include "content/public/browser/web_intents_dispatcher.h" |
38 #include "content/public/common/renderer_preferences.h" | 38 #include "content/public/common/renderer_preferences.h" |
39 | 39 |
40 using content::BrowserThread; | 40 using content::BrowserThread; |
41 using content::ConsoleMessageLevel; | 41 using content::ConsoleMessageLevel; |
42 using content::RenderViewHost; | 42 using content::RenderViewHost; |
43 using content::ResourceDispatcherHost; | 43 using content::ResourceDispatcherHost; |
44 using content::SiteInstance; | 44 using content::SiteInstance; |
45 using content::WebContents; | 45 using content::WebContents; |
| 46 using extensions::APIPermission; |
46 | 47 |
47 namespace { | 48 namespace { |
48 const int kDefaultWidth = 512; | 49 const int kDefaultWidth = 512; |
49 const int kDefaultHeight = 384; | 50 const int kDefaultHeight = 384; |
50 | 51 |
51 void SuspendRenderViewHost(RenderViewHost* rvh) { | 52 void SuspendRenderViewHost(RenderViewHost* rvh) { |
52 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 53 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
53 base::Bind(&ResourceDispatcherHost::BlockRequestsForRoute, | 54 base::Bind(&ResourceDispatcherHost::BlockRequestsForRoute, |
54 base::Unretained(ResourceDispatcherHost::Get()), | 55 base::Unretained(ResourceDispatcherHost::Get()), |
55 rvh->GetProcess()->GetID(), rvh->GetRoutingID())); | 56 rvh->GetProcess()->GetID(), rvh->GetRoutingID())); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 | 148 |
148 void ShellWindow::RequestMediaAccessPermission( | 149 void ShellWindow::RequestMediaAccessPermission( |
149 content::WebContents* web_contents, | 150 content::WebContents* web_contents, |
150 const content::MediaStreamRequest* request, | 151 const content::MediaStreamRequest* request, |
151 const content::MediaResponseCallback& callback) { | 152 const content::MediaResponseCallback& callback) { |
152 content::MediaStreamDevices devices; | 153 content::MediaStreamDevices devices; |
153 | 154 |
154 content::MediaStreamDeviceMap::const_iterator iter = | 155 content::MediaStreamDeviceMap::const_iterator iter = |
155 request->devices.find(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE); | 156 request->devices.find(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE); |
156 if (iter != request->devices.end() && | 157 if (iter != request->devices.end() && |
157 extension()->HasAPIPermission(ExtensionAPIPermission::kAudioCapture) && | 158 extension()->HasAPIPermission(APIPermission::kAudioCapture) && |
158 !iter->second.empty()) { | 159 !iter->second.empty()) { |
159 devices.push_back(iter->second[0]); | 160 devices.push_back(iter->second[0]); |
160 } | 161 } |
161 | 162 |
162 iter = request->devices.find(content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE); | 163 iter = request->devices.find(content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE); |
163 if (iter != request->devices.end() && | 164 if (iter != request->devices.end() && |
164 extension()->HasAPIPermission(ExtensionAPIPermission::kVideoCapture) && | 165 extension()->HasAPIPermission(APIPermission::kVideoCapture) && |
165 !iter->second.empty()) { | 166 !iter->second.empty()) { |
166 devices.push_back(iter->second[0]); | 167 devices.push_back(iter->second[0]); |
167 } | 168 } |
168 | 169 |
169 callback.Run(devices); | 170 callback.Run(devices); |
170 } | 171 } |
171 | 172 |
172 WebContents* ShellWindow::OpenURLFromTab(WebContents* source, | 173 WebContents* ShellWindow::OpenURLFromTab(WebContents* source, |
173 const content::OpenURLParams& params) { | 174 const content::OpenURLParams& params) { |
174 DCHECK(source == web_contents_); | 175 DCHECK(source == web_contents_); |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 extension_function_dispatcher_.Dispatch(params, | 348 extension_function_dispatcher_.Dispatch(params, |
348 web_contents_->GetRenderViewHost()); | 349 web_contents_->GetRenderViewHost()); |
349 } | 350 } |
350 | 351 |
351 void ShellWindow::AddMessageToDevToolsConsole(ConsoleMessageLevel level, | 352 void ShellWindow::AddMessageToDevToolsConsole(ConsoleMessageLevel level, |
352 const std::string& message) { | 353 const std::string& message) { |
353 content::RenderViewHost* rvh = web_contents_->GetRenderViewHost(); | 354 content::RenderViewHost* rvh = web_contents_->GetRenderViewHost(); |
354 rvh->Send(new ExtensionMsg_AddMessageToConsole( | 355 rvh->Send(new ExtensionMsg_AddMessageToConsole( |
355 rvh->GetRoutingID(), level, message)); | 356 rvh->GetRoutingID(), level, message)); |
356 } | 357 } |
OLD | NEW |