Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: chrome/browser/extensions/extension_tabs_module.cc

Issue 8969011: Added populate parameter to chrome.windows.get, chrome.windows.getCurrent, (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/extension_tabs_module.h" 5 #include "chrome/browser/extensions/extension_tabs_module.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 } 182 }
183 183
184 } // namespace 184 } // namespace
185 185
186 // Windows --------------------------------------------------------------------- 186 // Windows ---------------------------------------------------------------------
187 187
188 bool GetWindowFunction::RunImpl() { 188 bool GetWindowFunction::RunImpl() {
189 int window_id; 189 int window_id;
190 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &window_id)); 190 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &window_id));
191 191
192 bool populate_tabs = false;
193 if (HasOptionalArgument(1)) {
194 DictionaryValue* args;
Aaron Boodman 2011/12/17 07:12:58 Always initialize primitives (to NULL in this case
195 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &args));
196
197 if (args->HasKey(keys::kPopulateKey)) {
198 EXTENSION_FUNCTION_VALIDATE(args->GetBoolean(keys::kPopulateKey,
199 &populate_tabs));
200 }
201 }
202
192 Browser* browser = GetBrowserInProfileWithId(profile(), window_id, 203 Browser* browser = GetBrowserInProfileWithId(profile(), window_id,
193 include_incognito(), &error_); 204 include_incognito(), &error_);
194 if (!browser || !browser->window()) { 205 if (!browser || !browser->window()) {
195 error_ = ExtensionErrorUtils::FormatErrorMessage( 206 error_ = ExtensionErrorUtils::FormatErrorMessage(
196 keys::kWindowNotFoundError, base::IntToString(window_id)); 207 keys::kWindowNotFoundError, base::IntToString(window_id));
197 return false; 208 return false;
198 } 209 }
199 210
200 result_.reset(ExtensionTabUtil::CreateWindowValue(browser, false)); 211 result_.reset(ExtensionTabUtil::CreateWindowValue(browser, populate_tabs));
201 return true; 212 return true;
202 } 213 }
203 214
204 bool GetCurrentWindowFunction::RunImpl() { 215 bool GetCurrentWindowFunction::RunImpl() {
216 bool populate_tabs = false;
217 if (HasOptionalArgument(0)) {
218 DictionaryValue* args;
219 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &args));
220
221 if (args->HasKey(keys::kPopulateKey)) {
222 EXTENSION_FUNCTION_VALIDATE(args->GetBoolean(keys::kPopulateKey,
223 &populate_tabs));
224 }
225 }
226
205 Browser* browser = GetCurrentBrowser(); 227 Browser* browser = GetCurrentBrowser();
206 if (!browser || !browser->window()) { 228 if (!browser || !browser->window()) {
207 error_ = keys::kNoCurrentWindowError; 229 error_ = keys::kNoCurrentWindowError;
208 return false; 230 return false;
209 } 231 }
210 result_.reset(ExtensionTabUtil::CreateWindowValue(browser, false)); 232 result_.reset(ExtensionTabUtil::CreateWindowValue(browser, populate_tabs));
211 return true; 233 return true;
212 } 234 }
213 235
214 bool GetLastFocusedWindowFunction::RunImpl() { 236 bool GetLastFocusedWindowFunction::RunImpl() {
237 bool populate_tabs = false;
238 if (HasOptionalArgument(0)) {
239 DictionaryValue* args;
240 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &args));
241
242 if (args->HasKey(keys::kPopulateKey)) {
243 EXTENSION_FUNCTION_VALIDATE(args->GetBoolean(keys::kPopulateKey,
244 &populate_tabs));
245 }
246 }
247
215 Browser* browser = BrowserList::FindAnyBrowser( 248 Browser* browser = BrowserList::FindAnyBrowser(
216 profile(), include_incognito()); 249 profile(), include_incognito());
217 if (!browser || !browser->window()) { 250 if (!browser || !browser->window()) {
218 error_ = keys::kNoLastFocusedWindowError; 251 error_ = keys::kNoLastFocusedWindowError;
219 return false; 252 return false;
220 } 253 }
221 result_.reset(ExtensionTabUtil::CreateWindowValue(browser, false)); 254 result_.reset(ExtensionTabUtil::CreateWindowValue(browser, populate_tabs));
222 return true; 255 return true;
223 } 256 }
224 257
225 bool GetAllWindowsFunction::RunImpl() { 258 bool GetAllWindowsFunction::RunImpl() {
226 bool populate_tabs = false; 259 bool populate_tabs = false;
227 if (HasOptionalArgument(0)) { 260 if (HasOptionalArgument(0)) {
228 DictionaryValue* args; 261 DictionaryValue* args;
229 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &args)); 262 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &args));
230 263
231 if (args->HasKey(keys::kPopulateKey)) { 264 if (args->HasKey(keys::kPopulateKey)) {
(...skipping 1389 matching lines...) Expand 10 before | Expand all | Expand 10 after
1621 // called for every API call the extension made. 1654 // called for every API call the extension made.
1622 GotLanguage(language); 1655 GotLanguage(language);
1623 } 1656 }
1624 1657
1625 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { 1658 void DetectTabLanguageFunction::GotLanguage(const std::string& language) {
1626 result_.reset(Value::CreateStringValue(language.c_str())); 1659 result_.reset(Value::CreateStringValue(language.c_str()));
1627 SendResponse(true); 1660 SendResponse(true);
1628 1661
1629 Release(); // Balanced in Run() 1662 Release(); // Balanced in Run()
1630 } 1663 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698