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/extensions/api/tabs/tabs.h" | 5 #include "chrome/browser/extensions/api/tabs/tabs.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 namespace GetLastFocused = extensions::api::windows::GetLastFocused; | 87 namespace GetLastFocused = extensions::api::windows::GetLastFocused; |
88 namespace errors = extension_manifest_errors; | 88 namespace errors = extension_manifest_errors; |
89 namespace keys = extensions::tabs_constants; | 89 namespace keys = extensions::tabs_constants; |
90 | 90 |
91 using content::NavigationController; | 91 using content::NavigationController; |
92 using content::NavigationEntry; | 92 using content::NavigationEntry; |
93 using content::OpenURLParams; | 93 using content::OpenURLParams; |
94 using content::Referrer; | 94 using content::Referrer; |
95 using content::RenderViewHost; | 95 using content::RenderViewHost; |
96 using content::WebContents; | 96 using content::WebContents; |
| 97 using extensions::APIPermission; |
97 using extensions::ScriptExecutor; | 98 using extensions::ScriptExecutor; |
98 | 99 |
99 const int CaptureVisibleTabFunction::kDefaultQuality = 90; | 100 const int CaptureVisibleTabFunction::kDefaultQuality = 90; |
100 | 101 |
101 namespace { | 102 namespace { |
102 | 103 |
103 // |error_message| can optionally be passed in a will be set with an appropriate | 104 // |error_message| can optionally be passed in a will be set with an appropriate |
104 // message if the window cannot be found by id. | 105 // message if the window cannot be found by id. |
105 Browser* GetBrowserInProfileWithId(Profile* profile, | 106 Browser* GetBrowserInProfileWithId(Profile* profile, |
106 const int window_id, | 107 const int window_id, |
(...skipping 1238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1345 if (!url.SchemeIs(chrome::kJavaScriptScheme)) | 1346 if (!url.SchemeIs(chrome::kJavaScriptScheme)) |
1346 DCHECK_EQ(url.spec(), tab_contents_->web_contents()->GetURL().spec()); | 1347 DCHECK_EQ(url.spec(), tab_contents_->web_contents()->GetURL().spec()); |
1347 | 1348 |
1348 return true; | 1349 return true; |
1349 } | 1350 } |
1350 | 1351 |
1351 void UpdateTabFunction::PopulateResult() { | 1352 void UpdateTabFunction::PopulateResult() { |
1352 if (!has_callback()) | 1353 if (!has_callback()) |
1353 return; | 1354 return; |
1354 | 1355 |
1355 if (GetExtension()->HasAPIPermission(ExtensionAPIPermission::kTab)) { | 1356 if (GetExtension()->HasAPIPermission(APIPermission::kTab)) { |
1356 result_.reset( | 1357 result_.reset( |
1357 ExtensionTabUtil::CreateTabValue(tab_contents_->web_contents())); | 1358 ExtensionTabUtil::CreateTabValue(tab_contents_->web_contents())); |
1358 } else { | 1359 } else { |
1359 result_.reset(Value::CreateNullValue()); | 1360 result_.reset(Value::CreateNullValue()); |
1360 } | 1361 } |
1361 } | 1362 } |
1362 | 1363 |
1363 void UpdateTabFunction::OnExecuteCodeFinished(bool success, | 1364 void UpdateTabFunction::OnExecuteCodeFinished(bool success, |
1364 int32 page_id, | 1365 int32 page_id, |
1365 const std::string& error) { | 1366 const std::string& error) { |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1824 // called for every API call the extension made. | 1825 // called for every API call the extension made. |
1825 GotLanguage(language); | 1826 GotLanguage(language); |
1826 } | 1827 } |
1827 | 1828 |
1828 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { | 1829 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { |
1829 result_.reset(Value::CreateStringValue(language.c_str())); | 1830 result_.reset(Value::CreateStringValue(language.c_str())); |
1830 SendResponse(true); | 1831 SendResponse(true); |
1831 | 1832 |
1832 Release(); // Balanced in Run() | 1833 Release(); // Balanced in Run() |
1833 } | 1834 } |
OLD | NEW |