| 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 Extension* extension = GetExtension(); | 85 const Extension* extension = GetExtension(); |
| 86 const std::string& extension_id = extension->id(); | 86 const std::string& extension_id = extension->id(); |
| 87 | 87 |
| 88 const int tab_id = SessionID::IdForTab(target_contents); | 88 const int tab_id = SessionID::IdForTab(target_contents); |
| 89 | 89 |
| 90 // Make sure either we have been granted permission to capture through an | 90 // Make sure either we have been granted permission to capture through an |
| 91 // extension icon click or our extension is whitelisted. | 91 // extension icon click or our extension is whitelisted. |
| 92 if (!PermissionsData::HasAPIPermissionForTab( | 92 if (!PermissionsData::ForExtension(extension) |
| 93 extension, tab_id, APIPermission::kTabCaptureForTab) && | 93 ->HasAPIPermissionForTab(tab_id, APIPermission::kTabCaptureForTab) && |
| 94 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 94 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 95 switches::kWhitelistedExtensionID) != extension_id && | 95 switches::kWhitelistedExtensionID) != extension_id && |
| 96 !SimpleFeature::IsIdInList( | 96 !SimpleFeature::IsIdInList( |
| 97 extension_id, | 97 extension_id, |
| 98 std::set<std::string>( | 98 std::set<std::string>( |
| 99 whitelisted_extensions, | 99 whitelisted_extensions, |
| 100 whitelisted_extensions + arraysize(whitelisted_extensions)))) { | 100 whitelisted_extensions + arraysize(whitelisted_extensions)))) { |
| 101 error_ = kGrantError; | 101 error_ = kGrantError; |
| 102 return false; | 102 return false; |
| 103 } | 103 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 info->tab_id = it->first; | 177 info->tab_id = it->first; |
| 178 info->status = it->second; | 178 info->status = it->second; |
| 179 list->Append(info->ToValue().release()); | 179 list->Append(info->ToValue().release()); |
| 180 } | 180 } |
| 181 | 181 |
| 182 SetResult(list); | 182 SetResult(list); |
| 183 return true; | 183 return true; |
| 184 } | 184 } |
| 185 | 185 |
| 186 } // namespace extensions | 186 } // namespace extensions |
| OLD | NEW |