| 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> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry.h" | 16 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry.h" |
| 17 #include "chrome/browser/extensions/extension_renderer_state.h" | 17 #include "chrome/browser/extensions/extension_renderer_state.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/sessions/session_id.h" | 19 #include "chrome/browser/sessions/session_tab_helper.h" |
| 20 #include "chrome/browser/ui/browser.h" | 20 #include "chrome/browser/ui/browser.h" |
| 21 #include "chrome/browser/ui/browser_finder.h" | 21 #include "chrome/browser/ui/browser_finder.h" |
| 22 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 22 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 23 #include "content/public/browser/render_frame_host.h" | 23 #include "content/public/browser/render_frame_host.h" |
| 24 #include "content/public/browser/render_process_host.h" | 24 #include "content/public/browser/render_process_host.h" |
| 25 #include "extensions/common/features/feature.h" | 25 #include "extensions/common/features/feature.h" |
| 26 #include "extensions/common/features/feature_provider.h" | 26 #include "extensions/common/features/feature_provider.h" |
| 27 #include "extensions/common/features/simple_feature.h" | 27 #include "extensions/common/features/simple_feature.h" |
| 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" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 if (!target_contents) { | 80 if (!target_contents) { |
| 81 error_ = kFindingTabError; | 81 error_ = kFindingTabError; |
| 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 SessionID::IdForTab(target_contents), | 90 SessionTabHelper::IdForTab(target_contents), |
| 91 APIPermission::kTabCaptureForTab) && | 91 APIPermission::kTabCaptureForTab) && |
| 92 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 92 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; |
| (...skipping 61 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 |