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_api.h" | 5 #include "chrome/browser/extensions/api/tabs/tabs_api.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 } | 127 } |
128 } | 128 } |
129 | 129 |
130 if (error_message) | 130 if (error_message) |
131 *error_message = ErrorUtils::FormatErrorMessage( | 131 *error_message = ErrorUtils::FormatErrorMessage( |
132 keys::kWindowNotFoundError, base::IntToString(window_id)); | 132 keys::kWindowNotFoundError, base::IntToString(window_id)); |
133 | 133 |
134 return NULL; | 134 return NULL; |
135 } | 135 } |
136 | 136 |
137 bool GetBrowserFromWindowID(ChromeAsyncExtensionFunction* function, | 137 bool GetBrowserFromWindowID(ChromeUIThreadExtensionFunction* function, |
138 int window_id, | 138 int window_id, |
139 Browser** browser) { | 139 Browser** browser) { |
140 if (window_id == extension_misc::kCurrentWindowId) { | 140 if (window_id == extension_misc::kCurrentWindowId) { |
141 *browser = function->GetCurrentBrowser(); | 141 *browser = function->GetCurrentBrowser(); |
142 if (!(*browser) || !(*browser)->window()) { | 142 if (!(*browser) || !(*browser)->window()) { |
143 function->SetError(keys::kNoCurrentWindowError); | 143 function->SetError(keys::kNoCurrentWindowError); |
144 return false; | 144 return false; |
145 } | 145 } |
146 } else { | 146 } else { |
147 std::string error; | 147 std::string error; |
(...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1180 if (*active_index == -1) | 1180 if (*active_index == -1) |
1181 *active_index = index; | 1181 *active_index = index; |
1182 | 1182 |
1183 selection->AddIndexToSelection(index); | 1183 selection->AddIndexToSelection(index); |
1184 return true; | 1184 return true; |
1185 } | 1185 } |
1186 | 1186 |
1187 TabsUpdateFunction::TabsUpdateFunction() : web_contents_(NULL) { | 1187 TabsUpdateFunction::TabsUpdateFunction() : web_contents_(NULL) { |
1188 } | 1188 } |
1189 | 1189 |
1190 bool TabsUpdateFunction::RunImpl() { | 1190 bool TabsUpdateFunction::RunAsync() { |
1191 scoped_ptr<tabs::Update::Params> params(tabs::Update::Params::Create(*args_)); | 1191 scoped_ptr<tabs::Update::Params> params(tabs::Update::Params::Create(*args_)); |
1192 EXTENSION_FUNCTION_VALIDATE(params.get()); | 1192 EXTENSION_FUNCTION_VALIDATE(params.get()); |
1193 | 1193 |
1194 int tab_id = -1; | 1194 int tab_id = -1; |
1195 WebContents* contents = NULL; | 1195 WebContents* contents = NULL; |
1196 if (!params->tab_id.get()) { | 1196 if (!params->tab_id.get()) { |
1197 Browser* browser = GetCurrentBrowser(); | 1197 Browser* browser = GetCurrentBrowser(); |
1198 if (!browser) { | 1198 if (!browser) { |
1199 error_ = keys::kNoCurrentWindowError; | 1199 error_ = keys::kNoCurrentWindowError; |
1200 return false; | 1200 return false; |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1650 } | 1650 } |
1651 | 1651 |
1652 void TabsCaptureVisibleTabFunction::RegisterProfilePrefs( | 1652 void TabsCaptureVisibleTabFunction::RegisterProfilePrefs( |
1653 user_prefs::PrefRegistrySyncable* registry) { | 1653 user_prefs::PrefRegistrySyncable* registry) { |
1654 registry->RegisterBooleanPref( | 1654 registry->RegisterBooleanPref( |
1655 prefs::kDisableScreenshots, | 1655 prefs::kDisableScreenshots, |
1656 false, | 1656 false, |
1657 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 1657 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
1658 } | 1658 } |
1659 | 1659 |
1660 bool TabsDetectLanguageFunction::RunImpl() { | 1660 bool TabsDetectLanguageFunction::RunAsync() { |
1661 scoped_ptr<tabs::DetectLanguage::Params> params( | 1661 scoped_ptr<tabs::DetectLanguage::Params> params( |
1662 tabs::DetectLanguage::Params::Create(*args_)); | 1662 tabs::DetectLanguage::Params::Create(*args_)); |
1663 EXTENSION_FUNCTION_VALIDATE(params.get()); | 1663 EXTENSION_FUNCTION_VALIDATE(params.get()); |
1664 | 1664 |
1665 int tab_id = 0; | 1665 int tab_id = 0; |
1666 Browser* browser = NULL; | 1666 Browser* browser = NULL; |
1667 WebContents* contents = NULL; | 1667 WebContents* contents = NULL; |
1668 | 1668 |
1669 // If |tab_id| is specified, look for it. Otherwise default to selected tab | 1669 // If |tab_id| is specified, look for it. Otherwise default to selected tab |
1670 // in the current window. | 1670 // in the current window. |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1871 execute_tab_id_ = tab_id; | 1871 execute_tab_id_ = tab_id; |
1872 details_ = details.Pass(); | 1872 details_ = details.Pass(); |
1873 return true; | 1873 return true; |
1874 } | 1874 } |
1875 | 1875 |
1876 bool TabsInsertCSSFunction::ShouldInsertCSS() const { | 1876 bool TabsInsertCSSFunction::ShouldInsertCSS() const { |
1877 return true; | 1877 return true; |
1878 } | 1878 } |
1879 | 1879 |
1880 } // namespace extensions | 1880 } // namespace extensions |
OLD | NEW |