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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 return false; | 82 return false; |
83 } | 83 } |
84 | 84 |
85 const std::string& extension_id = extension()->id(); | 85 const std::string& extension_id = extension()->id(); |
86 | 86 |
87 // Make sure either we have been granted permission to capture through an | 87 // Make sure either we have been granted permission to capture through an |
88 // extension icon click or our extension is whitelisted. | 88 // extension icon click or our extension is whitelisted. |
89 if (!extension()->permissions_data()->HasAPIPermissionForTab( | 89 if (!extension()->permissions_data()->HasAPIPermissionForTab( |
90 SessionTabHelper::IdForTab(target_contents), | 90 SessionTabHelper::IdForTab(target_contents), |
91 APIPermission::kTabCaptureForTab) && | 91 APIPermission::kTabCaptureForTab) && |
92 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 92 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
93 switches::kWhitelistedExtensionID) != extension_id && | 93 switches::kWhitelistedExtensionID) != extension_id && |
94 !SimpleFeature::IsIdInList( | 94 !SimpleFeature::IsIdInList( |
95 extension_id, | 95 extension_id, |
96 std::set<std::string>( | 96 std::set<std::string>( |
97 whitelisted_extensions, | 97 whitelisted_extensions, |
98 whitelisted_extensions + arraysize(whitelisted_extensions)))) { | 98 whitelisted_extensions + arraysize(whitelisted_extensions)))) { |
99 error_ = kGrantError; | 99 error_ = kGrantError; |
100 return false; | 100 return false; |
101 } | 101 } |
102 | 102 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 extensions::TabCaptureRegistry* registry = | 162 extensions::TabCaptureRegistry* registry = |
163 extensions::TabCaptureRegistry::Get(GetProfile()); | 163 extensions::TabCaptureRegistry::Get(GetProfile()); |
164 base::ListValue* const list = new base::ListValue(); | 164 base::ListValue* const list = new base::ListValue(); |
165 if (registry) | 165 if (registry) |
166 registry->GetCapturedTabs(extension()->id(), list); | 166 registry->GetCapturedTabs(extension()->id(), list); |
167 SetResult(list); | 167 SetResult(list); |
168 return true; | 168 return true; |
169 } | 169 } |
170 | 170 |
171 } // namespace extensions | 171 } // namespace extensions |
OLD | NEW |