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 // Implements the Chrome Extensions Tab Capture API. | 5 // Implements the Chrome Extensions Tab Capture API. |
6 | 6 |
7 #include "chrome/browser/extensions/api/tab_capture/tab_capture_api.h" | 7 #include "chrome/browser/extensions/api/tab_capture/tab_capture_api.h" |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 17 matching lines...) Expand all Loading... | |
28 #include "extensions/common/permissions/permissions_data.h" | 28 #include "extensions/common/permissions/permissions_data.h" |
29 #include "extensions/common/switches.h" | 29 #include "extensions/common/switches.h" |
30 | 30 |
31 using extensions::api::tab_capture::MediaStreamConstraint; | 31 using extensions::api::tab_capture::MediaStreamConstraint; |
32 | 32 |
33 namespace TabCapture = extensions::api::tab_capture; | 33 namespace TabCapture = extensions::api::tab_capture; |
34 namespace GetCapturedTabs = TabCapture::GetCapturedTabs; | 34 namespace GetCapturedTabs = TabCapture::GetCapturedTabs; |
35 | 35 |
36 namespace extensions { | 36 namespace extensions { |
37 | 37 |
38 // Whitelisted extensions that do not check for a browser action grant because | |
achuithb
2015/05/08 04:44:43
I'd move this code to below the anonymous namespac
hubbe
2015/05/12 17:25:41
I also think this should be moved.
jdufault
2015/05/12 18:08:54
Done.
jdufault
2015/05/12 18:16:38
This broke the build (since kChromecastExtensionId
| |
39 // they provide API's. If there are additional extension ids that need | |
40 // whitelisting and are *not* the Chromecast extension, add them to a new | |
41 // kWhitelist array. | |
42 const char* const kChromecastExtensionIds[] = { | |
43 "enhhojjnijigcajfphajepfemndkmdlo", // Dev | |
44 "pkedcjkdefgpdelpbcmbmeomcjbeemfm", // Dogfood | |
45 "fmfcbgogabcbclcofgocippekhfcmgfj", // Staging | |
46 "hfaagokkkhdbgiakmmlclaapfelnkoah", // Canary | |
47 "dliochdbjfkdbacpmhlcpmleaejidimm", // Google Cast Beta | |
48 "boadgeojelhgndaghljhdicfkmllpafd", // Google Cast Stable | |
49 }; | |
50 | |
38 namespace { | 51 namespace { |
39 | 52 |
40 const char kCapturingSameTab[] = "Cannot capture a tab with an active stream."; | 53 const char kCapturingSameTab[] = "Cannot capture a tab with an active stream."; |
41 const char kFindingTabError[] = "Error finding tab to capture."; | 54 const char kFindingTabError[] = "Error finding tab to capture."; |
42 const char kNoAudioOrVideo[] = "Capture failed. No audio or video requested."; | 55 const char kNoAudioOrVideo[] = "Capture failed. No audio or video requested."; |
43 const char kGrantError[] = | 56 const char kGrantError[] = |
44 "Extension has not been invoked for the current page (see activeTab " | 57 "Extension has not been invoked for the current page (see activeTab " |
45 "permission). Chrome pages cannot be captured."; | 58 "permission). Chrome pages cannot be captured."; |
46 | 59 |
47 // Keys/values for media stream constraints. | 60 // Keys/values for media stream constraints. |
48 const char kMediaStreamSource[] = "chromeMediaSource"; | 61 const char kMediaStreamSource[] = "chromeMediaSource"; |
49 const char kMediaStreamSourceId[] = "chromeMediaSourceId"; | 62 const char kMediaStreamSourceId[] = "chromeMediaSourceId"; |
50 const char kMediaStreamSourceTab[] = "tab"; | 63 const char kMediaStreamSourceTab[] = "tab"; |
51 | 64 |
52 // Whitelisted extensions that do not check for a browser action grant because | |
53 // they provide API's. | |
54 const char* const kWhitelist[] = { | |
55 "enhhojjnijigcajfphajepfemndkmdlo", // Dev | |
56 "pkedcjkdefgpdelpbcmbmeomcjbeemfm", // Trusted Tester | |
57 "fmfcbgogabcbclcofgocippekhfcmgfj", // Staging | |
58 "hfaagokkkhdbgiakmmlclaapfelnkoah", // Canary | |
59 "F155646B5D1CA545F7E1E4E20D573DFDD44C2540", // Trusted Tester (public) | |
60 "16CA7A47AAE4BE49B1E75A6B960C3875E945B264" // Release | |
61 }; | |
62 | |
63 } // namespace | 65 } // namespace |
64 | 66 |
65 bool TabCaptureCaptureFunction::RunSync() { | 67 bool TabCaptureCaptureFunction::RunSync() { |
66 scoped_ptr<api::tab_capture::Capture::Params> params = | 68 scoped_ptr<api::tab_capture::Capture::Params> params = |
67 TabCapture::Capture::Params::Create(*args_); | 69 TabCapture::Capture::Params::Create(*args_); |
68 EXTENSION_FUNCTION_VALIDATE(params.get()); | 70 EXTENSION_FUNCTION_VALIDATE(params.get()); |
69 | 71 |
70 // Figure out the active WebContents and retrieve the needed ids. | 72 // Figure out the active WebContents and retrieve the needed ids. |
71 Browser* target_browser = chrome::FindAnyBrowser( | 73 Browser* target_browser = chrome::FindAnyBrowser( |
72 GetProfile(), include_incognito(), chrome::GetActiveDesktop()); | 74 GetProfile(), include_incognito(), chrome::GetActiveDesktop()); |
(...skipping 11 matching lines...) Expand all Loading... | |
84 | 86 |
85 const std::string& extension_id = extension()->id(); | 87 const std::string& extension_id = extension()->id(); |
86 | 88 |
87 // Make sure either we have been granted permission to capture through an | 89 // Make sure either we have been granted permission to capture through an |
88 // extension icon click or our extension is whitelisted. | 90 // extension icon click or our extension is whitelisted. |
89 if (!extension()->permissions_data()->HasAPIPermissionForTab( | 91 if (!extension()->permissions_data()->HasAPIPermissionForTab( |
90 SessionTabHelper::IdForTab(target_contents), | 92 SessionTabHelper::IdForTab(target_contents), |
91 APIPermission::kTabCaptureForTab) && | 93 APIPermission::kTabCaptureForTab) && |
92 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 94 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
93 switches::kWhitelistedExtensionID) != extension_id && | 95 switches::kWhitelistedExtensionID) != extension_id && |
94 !SimpleFeature::IsIdInArray( | 96 !SimpleFeature::IsIdInArray(extension_id, kChromecastExtensionIds, |
95 extension_id, kWhitelist, arraysize(kWhitelist))) { | 97 arraysize(kChromecastExtensionIds))) { |
96 error_ = kGrantError; | 98 error_ = kGrantError; |
97 return false; | 99 return false; |
98 } | 100 } |
99 | 101 |
100 // Create a constraints vector. We will modify all the constraints in this | 102 // Create a constraints vector. We will modify all the constraints in this |
101 // vector to append our chrome specific constraints. | 103 // vector to append our chrome specific constraints. |
102 std::vector<MediaStreamConstraint*> constraints; | 104 std::vector<MediaStreamConstraint*> constraints; |
103 bool has_audio = params->options.audio.get() && *params->options.audio.get(); | 105 bool has_audio = params->options.audio.get() && *params->options.audio.get(); |
104 bool has_video = params->options.video.get() && *params->options.video.get(); | 106 bool has_video = params->options.video.get() && *params->options.video.get(); |
105 | 107 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
157 bool TabCaptureGetCapturedTabsFunction::RunSync() { | 159 bool TabCaptureGetCapturedTabsFunction::RunSync() { |
158 TabCaptureRegistry* registry = TabCaptureRegistry::Get(GetProfile()); | 160 TabCaptureRegistry* registry = TabCaptureRegistry::Get(GetProfile()); |
159 base::ListValue* const list = new base::ListValue(); | 161 base::ListValue* const list = new base::ListValue(); |
160 if (registry) | 162 if (registry) |
161 registry->GetCapturedTabs(extension()->id(), list); | 163 registry->GetCapturedTabs(extension()->id(), list); |
162 SetResult(list); | 164 SetResult(list); |
163 return true; | 165 return true; |
164 } | 166 } |
165 | 167 |
166 } // namespace extensions | 168 } // namespace extensions |
OLD | NEW |