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

Side by Side Diff: chrome/browser/extensions/api/tabs/tabs.cc

Issue 10829186: Tabs API is usable without tabs permission. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: . Created 8 years, 3 months 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
OLDNEW
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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 256
257 bool populate_tabs = false; 257 bool populate_tabs = false;
258 if (params->get_info.get() && params->get_info->populate.get()) 258 if (params->get_info.get() && params->get_info->populate.get())
259 populate_tabs = *params->get_info->populate; 259 populate_tabs = *params->get_info->populate;
260 260
261 WindowController* controller; 261 WindowController* controller;
262 if (!GetWindowFromWindowID(this, params->window_id, &controller)) 262 if (!GetWindowFromWindowID(this, params->window_id, &controller))
263 return false; 263 return false;
264 264
265 if (populate_tabs) 265 if (populate_tabs)
266 SetResult(controller->CreateWindowValueWithTabs()); 266 SetResult(controller->CreateWindowValueWithTabs(GetExtension()));
267 else 267 else
268 SetResult(controller->CreateWindowValue()); 268 SetResult(controller->CreateWindowValue());
269 return true; 269 return true;
270 } 270 }
271 271
272 bool GetCurrentWindowFunction::RunImpl() { 272 bool GetCurrentWindowFunction::RunImpl() {
273 scoped_ptr<GetCurrent::Params> params(GetCurrent::Params::Create(*args_)); 273 scoped_ptr<GetCurrent::Params> params(GetCurrent::Params::Create(*args_));
274 EXTENSION_FUNCTION_VALIDATE(params.get()); 274 EXTENSION_FUNCTION_VALIDATE(params.get());
275 275
276 bool populate_tabs = false; 276 bool populate_tabs = false;
277 if (params->get_info.get() && params->get_info->populate.get()) 277 if (params->get_info.get() && params->get_info->populate.get())
278 populate_tabs = *params->get_info->populate; 278 populate_tabs = *params->get_info->populate;
279 279
280 WindowController* controller; 280 WindowController* controller;
281 if (!GetWindowFromWindowID(this, 281 if (!GetWindowFromWindowID(this,
282 extension_misc::kCurrentWindowId, 282 extension_misc::kCurrentWindowId,
283 &controller)) { 283 &controller)) {
284 return false; 284 return false;
285 } 285 }
286 if (populate_tabs) 286 if (populate_tabs)
287 SetResult(controller->CreateWindowValueWithTabs()); 287 SetResult(controller->CreateWindowValueWithTabs(GetExtension()));
288 else 288 else
289 SetResult(controller->CreateWindowValue()); 289 SetResult(controller->CreateWindowValue());
290 return true; 290 return true;
291 } 291 }
292 292
293 bool GetLastFocusedWindowFunction::RunImpl() { 293 bool GetLastFocusedWindowFunction::RunImpl() {
294 scoped_ptr<GetLastFocused::Params> params( 294 scoped_ptr<GetLastFocused::Params> params(
295 GetLastFocused::Params::Create(*args_)); 295 GetLastFocused::Params::Create(*args_));
296 EXTENSION_FUNCTION_VALIDATE(params.get()); 296 EXTENSION_FUNCTION_VALIDATE(params.get());
297 297
298 bool populate_tabs = false; 298 bool populate_tabs = false;
299 if (params->get_info.get() && params->get_info->populate.get()) 299 if (params->get_info.get() && params->get_info->populate.get())
300 populate_tabs = *params->get_info->populate; 300 populate_tabs = *params->get_info->populate;
301 301
302 // Note: currently this returns the last active browser. If we decide to 302 // Note: currently this returns the last active browser. If we decide to
303 // include other window types (e.g. panels), we will need to add logic to 303 // include other window types (e.g. panels), we will need to add logic to
304 // WindowControllerList that mirrors the active behavior of BrowserList. 304 // WindowControllerList that mirrors the active behavior of BrowserList.
305 Browser* browser = browser::FindAnyBrowser( 305 Browser* browser = browser::FindAnyBrowser(
306 profile(), include_incognito()); 306 profile(), include_incognito());
307 if (!browser || !browser->window()) { 307 if (!browser || !browser->window()) {
308 error_ = keys::kNoLastFocusedWindowError; 308 error_ = keys::kNoLastFocusedWindowError;
309 return false; 309 return false;
310 } 310 }
311 WindowController* controller = 311 WindowController* controller =
312 browser->extension_window_controller(); 312 browser->extension_window_controller();
313 if (populate_tabs) 313 if (populate_tabs)
314 SetResult(controller->CreateWindowValueWithTabs()); 314 SetResult(controller->CreateWindowValueWithTabs(GetExtension()));
315 else 315 else
316 SetResult(controller->CreateWindowValue()); 316 SetResult(controller->CreateWindowValue());
317 return true; 317 return true;
318 } 318 }
319 319
320 bool GetAllWindowsFunction::RunImpl() { 320 bool GetAllWindowsFunction::RunImpl() {
321 scoped_ptr<GetAll::Params> params(GetAll::Params::Create(*args_)); 321 scoped_ptr<GetAll::Params> params(GetAll::Params::Create(*args_));
322 EXTENSION_FUNCTION_VALIDATE(params.get()); 322 EXTENSION_FUNCTION_VALIDATE(params.get());
323 323
324 bool populate_tabs = false; 324 bool populate_tabs = false;
325 if (params->get_info.get() && params->get_info->populate.get()) 325 if (params->get_info.get() && params->get_info->populate.get())
326 populate_tabs = *params->get_info->populate; 326 populate_tabs = *params->get_info->populate;
327 327
328 ListValue* window_list = new ListValue(); 328 ListValue* window_list = new ListValue();
329 const WindowControllerList::ControllerList& windows = 329 const WindowControllerList::ControllerList& windows =
330 WindowControllerList::GetInstance()->windows(); 330 WindowControllerList::GetInstance()->windows();
331 for (WindowControllerList::ControllerList::const_iterator iter = 331 for (WindowControllerList::ControllerList::const_iterator iter =
332 windows.begin(); 332 windows.begin();
333 iter != windows.end(); ++iter) { 333 iter != windows.end(); ++iter) {
334 if (!this->CanOperateOnWindow(*iter)) 334 if (!this->CanOperateOnWindow(*iter))
335 continue; 335 continue;
336 if (populate_tabs) 336 if (populate_tabs)
337 window_list->Append((*iter)->CreateWindowValueWithTabs()); 337 window_list->Append((*iter)->CreateWindowValueWithTabs(GetExtension()));
338 else 338 else
339 window_list->Append((*iter)->CreateWindowValue()); 339 window_list->Append((*iter)->CreateWindowValue());
340 } 340 }
341 SetResult(window_list); 341 SetResult(window_list);
342 return true; 342 return true;
343 } 343 }
344 344
345 bool CreateWindowFunction::ShouldOpenIncognitoWindow( 345 bool CreateWindowFunction::ShouldOpenIncognitoWindow(
346 const base::DictionaryValue* args, 346 const base::DictionaryValue* args,
347 std::vector<GURL>* urls, 347 std::vector<GURL>* urls,
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 Panel* panel = PanelManager::GetInstance()->CreatePanel( 579 Panel* panel = PanelManager::GetInstance()->CreatePanel(
580 title, window_profile, urls[0], panel_bounds.size()); 580 title, window_profile, urls[0], panel_bounds.size());
581 581
582 // Unlike other window types, Panels do not take focus by default. 582 // Unlike other window types, Panels do not take focus by default.
583 if (!saw_focus_key || !focused) 583 if (!saw_focus_key || !focused)
584 panel->ShowInactive(); 584 panel->ShowInactive();
585 else 585 else
586 panel->Show(); 586 panel->Show();
587 587
588 SetResult( 588 SetResult(
589 panel->extension_window_controller()->CreateWindowValueWithTabs()); 589 panel->extension_window_controller()->CreateWindowValueWithTabs(
590 GetExtension()));
590 return true; 591 return true;
591 } 592 }
592 #endif 593 #endif
593 // else fall through to create BrowserWindow 594 // else fall through to create BrowserWindow
594 } 595 }
595 596
596 // Create a new BrowserWindow. 597 // Create a new BrowserWindow.
597 Browser::CreateParams create_params(window_type, window_profile); 598 Browser::CreateParams create_params(window_type, window_profile);
598 if (extension_id.empty()) { 599 if (extension_id.empty()) {
599 create_params.initial_bounds = window_bounds; 600 create_params.initial_bounds = window_bounds;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 if (focused) 632 if (focused)
632 new_window->window()->Show(); 633 new_window->window()->Show();
633 else 634 else
634 new_window->window()->ShowInactive(); 635 new_window->window()->ShowInactive();
635 636
636 if (new_window->profile()->IsOffTheRecord() && !include_incognito()) { 637 if (new_window->profile()->IsOffTheRecord() && !include_incognito()) {
637 // Don't expose incognito windows if the extension isn't allowed. 638 // Don't expose incognito windows if the extension isn't allowed.
638 SetResult(Value::CreateNullValue()); 639 SetResult(Value::CreateNullValue());
639 } else { 640 } else {
640 SetResult( 641 SetResult(
641 new_window->extension_window_controller()->CreateWindowValueWithTabs()); 642 new_window->extension_window_controller()->CreateWindowValueWithTabs(
643 GetExtension()));
642 } 644 }
643 645
644 return true; 646 return true;
645 } 647 }
646 648
647 bool UpdateWindowFunction::RunImpl() { 649 bool UpdateWindowFunction::RunImpl() {
648 int window_id = extension_misc::kUnknownWindowId; 650 int window_id = extension_misc::kUnknownWindowId;
649 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &window_id)); 651 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &window_id));
650 DictionaryValue* update_props; 652 DictionaryValue* update_props;
651 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &update_props)); 653 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &update_props));
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 return false; 814 return false;
813 815
814 TabStripModel* tab_strip = browser->tab_strip_model(); 816 TabStripModel* tab_strip = browser->tab_strip_model();
815 TabContents* contents = tab_strip->GetActiveTabContents(); 817 TabContents* contents = tab_strip->GetActiveTabContents();
816 if (!contents) { 818 if (!contents) {
817 error_ = keys::kNoSelectedTabError; 819 error_ = keys::kNoSelectedTabError;
818 return false; 820 return false;
819 } 821 }
820 SetResult(ExtensionTabUtil::CreateTabValue(contents->web_contents(), 822 SetResult(ExtensionTabUtil::CreateTabValue(contents->web_contents(),
821 tab_strip, 823 tab_strip,
822 tab_strip->active_index())); 824 tab_strip->active_index(),
825 GetExtension()));
823 return true; 826 return true;
824 } 827 }
825 828
826 bool GetAllTabsInWindowFunction::RunImpl() { 829 bool GetAllTabsInWindowFunction::RunImpl() {
827 // windowId defaults to "current" window. 830 // windowId defaults to "current" window.
828 int window_id = extension_misc::kCurrentWindowId; 831 int window_id = extension_misc::kCurrentWindowId;
829 if (HasOptionalArgument(0)) 832 if (HasOptionalArgument(0))
830 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &window_id)); 833 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &window_id));
831 834
832 Browser* browser = NULL; 835 Browser* browser = NULL;
833 if (!GetBrowserFromWindowID(this, window_id, &browser)) 836 if (!GetBrowserFromWindowID(this, window_id, &browser))
834 return false; 837 return false;
835 838
836 SetResult(ExtensionTabUtil::CreateTabList(browser)); 839 SetResult(ExtensionTabUtil::CreateTabList(browser, GetExtension()));
837 840
838 return true; 841 return true;
839 } 842 }
840 843
841 bool QueryTabsFunction::RunImpl() { 844 bool QueryTabsFunction::RunImpl() {
842 DictionaryValue* query = NULL; 845 DictionaryValue* query = NULL;
843 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &query)); 846 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &query));
844 847
845 QueryArg active = ParseBoolQueryArg(query, keys::kActiveKey); 848 QueryArg active = ParseBoolQueryArg(query, keys::kActiveKey);
846 QueryArg pinned = ParseBoolQueryArg(query, keys::kPinnedKey); 849 QueryArg pinned = ParseBoolQueryArg(query, keys::kPinnedKey);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 UTF8ToUTF16(title))) 940 UTF8ToUTF16(title)))
938 continue; 941 continue;
939 942
940 if (!url_pattern.MatchesURL(web_contents->GetURL())) 943 if (!url_pattern.MatchesURL(web_contents->GetURL()))
941 continue; 944 continue;
942 945
943 if (!MatchesQueryArg(loading, web_contents->IsLoading())) 946 if (!MatchesQueryArg(loading, web_contents->IsLoading()))
944 continue; 947 continue;
945 948
946 result->Append(ExtensionTabUtil::CreateTabValue( 949 result->Append(ExtensionTabUtil::CreateTabValue(
947 web_contents, tab_strip, i)); 950 web_contents, tab_strip, i, GetExtension()));
948 } 951 }
949 } 952 }
950 953
951 SetResult(result); 954 SetResult(result);
952 return true; 955 return true;
953 } 956 }
954 957
955 bool CreateTabFunction::RunImpl() { 958 bool CreateTabFunction::RunImpl() {
956 DictionaryValue* args = NULL; 959 DictionaryValue* args = NULL;
957 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &args)); 960 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &args));
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 if (opener) 1077 if (opener)
1075 tab_strip->SetOpenerOfTabContentsAt(new_index, opener); 1078 tab_strip->SetOpenerOfTabContentsAt(new_index, opener);
1076 1079
1077 if (active) 1080 if (active)
1078 params.target_contents->web_contents()->GetView()->SetInitialFocus(); 1081 params.target_contents->web_contents()->GetView()->SetInitialFocus();
1079 1082
1080 // Return data about the newly created tab. 1083 // Return data about the newly created tab.
1081 if (has_callback()) { 1084 if (has_callback()) {
1082 SetResult(ExtensionTabUtil::CreateTabValue( 1085 SetResult(ExtensionTabUtil::CreateTabValue(
1083 params.target_contents->web_contents(), 1086 params.target_contents->web_contents(),
1084 tab_strip, new_index)); 1087 tab_strip, new_index, GetExtension()));
1085 } 1088 }
1086 1089
1087 return true; 1090 return true;
1088 } 1091 }
1089 1092
1090 bool GetTabFunction::RunImpl() { 1093 bool GetTabFunction::RunImpl() {
1091 int tab_id = -1; 1094 int tab_id = -1;
1092 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &tab_id)); 1095 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &tab_id));
1093 1096
1094 TabStripModel* tab_strip = NULL; 1097 TabStripModel* tab_strip = NULL;
1095 TabContents* contents = NULL; 1098 TabContents* contents = NULL;
1096 int tab_index = -1; 1099 int tab_index = -1;
1097 if (!GetTabById(tab_id, profile(), include_incognito(), 1100 if (!GetTabById(tab_id, profile(), include_incognito(),
1098 NULL, &tab_strip, &contents, &tab_index, &error_)) 1101 NULL, &tab_strip, &contents, &tab_index, &error_))
1099 return false; 1102 return false;
1100 1103
1101 SetResult(ExtensionTabUtil::CreateTabValue(contents->web_contents(), 1104 SetResult(ExtensionTabUtil::CreateTabValue(contents->web_contents(),
1102 tab_strip, 1105 tab_strip,
1103 tab_index)); 1106 tab_index,
1107 GetExtension()));
1104 return true; 1108 return true;
1105 } 1109 }
1106 1110
1107 bool GetCurrentTabFunction::RunImpl() { 1111 bool GetCurrentTabFunction::RunImpl() {
1108 DCHECK(dispatcher()); 1112 DCHECK(dispatcher());
1109 1113
1110 WebContents* contents = dispatcher()->delegate()->GetAssociatedWebContents(); 1114 WebContents* contents = dispatcher()->delegate()->GetAssociatedWebContents();
1111 if (contents) 1115 if (contents)
1112 SetResult(ExtensionTabUtil::CreateTabValue(contents)); 1116 SetResult(ExtensionTabUtil::CreateTabValue(contents, GetExtension()));
1113 1117
1114 return true; 1118 return true;
1115 } 1119 }
1116 1120
1117 bool HighlightTabsFunction::RunImpl() { 1121 bool HighlightTabsFunction::RunImpl() {
1118 DictionaryValue* info = NULL; 1122 DictionaryValue* info = NULL;
1119 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &info)); 1123 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &info));
1120 1124
1121 // Get the window id from the params; default to current window if omitted. 1125 // Get the window id from the params; default to current window if omitted.
1122 int window_id = extension_misc::kCurrentWindowId; 1126 int window_id = extension_misc::kCurrentWindowId;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1159 1163
1160 // Make sure they actually specified tabs to select. 1164 // Make sure they actually specified tabs to select.
1161 if (selection.empty()) { 1165 if (selection.empty()) {
1162 error_ = keys::kNoHighlightedTabError; 1166 error_ = keys::kNoHighlightedTabError;
1163 return false; 1167 return false;
1164 } 1168 }
1165 1169
1166 selection.set_active(active_index); 1170 selection.set_active(active_index);
1167 browser->tab_strip_model()->SetSelectionFromModel(selection); 1171 browser->tab_strip_model()->SetSelectionFromModel(selection);
1168 SetResult( 1172 SetResult(
1169 browser->extension_window_controller()->CreateWindowValueWithTabs()); 1173 browser->extension_window_controller()->CreateWindowValueWithTabs(
1174 GetExtension()));
1170 return true; 1175 return true;
1171 } 1176 }
1172 1177
1173 UpdateTabFunction::UpdateTabFunction() : tab_contents_(NULL) { 1178 UpdateTabFunction::UpdateTabFunction() : tab_contents_(NULL) {
1174 } 1179 }
1175 1180
1176 bool UpdateTabFunction::RunImpl() { 1181 bool UpdateTabFunction::RunImpl() {
1177 DictionaryValue* update_props = NULL; 1182 DictionaryValue* update_props = NULL;
1178 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &update_props)); 1183 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &update_props));
1179 1184
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1335 if (!url.SchemeIs(chrome::kJavaScriptScheme)) 1340 if (!url.SchemeIs(chrome::kJavaScriptScheme))
1336 DCHECK_EQ(url.spec(), tab_contents_->web_contents()->GetURL().spec()); 1341 DCHECK_EQ(url.spec(), tab_contents_->web_contents()->GetURL().spec());
1337 1342
1338 return true; 1343 return true;
1339 } 1344 }
1340 1345
1341 void UpdateTabFunction::PopulateResult() { 1346 void UpdateTabFunction::PopulateResult() {
1342 if (!has_callback()) 1347 if (!has_callback())
1343 return; 1348 return;
1344 1349
1345 if (GetExtension()->HasAPIPermission(extensions::APIPermission::kTab)) { 1350 SetResult(ExtensionTabUtil::CreateTabValue(tab_contents_->web_contents(),
1346 SetResult(ExtensionTabUtil::CreateTabValue(tab_contents_->web_contents())); 1351 GetExtension()));
1347 } else {
1348 SetResult(Value::CreateNullValue());
1349 }
1350 } 1352 }
1351 1353
1352 void UpdateTabFunction::OnExecuteCodeFinished(const std::string& error, 1354 void UpdateTabFunction::OnExecuteCodeFinished(const std::string& error,
1353 int32 on_page_id, 1355 int32 on_page_id,
1354 const GURL& url, 1356 const GURL& url,
1355 const ListValue& script_result) { 1357 const ListValue& script_result) {
1356 if (error.empty()) 1358 if (error.empty())
1357 PopulateResult(); 1359 PopulateResult();
1358 else 1360 else
1359 error_ = error; 1361 error_ = error;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1431 1433
1432 // Clamp move location to the last position. 1434 // Clamp move location to the last position.
1433 // This is ">" because it can append to a new index position. 1435 // This is ">" because it can append to a new index position.
1434 // -1 means set the move location to the last position. 1436 // -1 means set the move location to the last position.
1435 if (new_index > target_tab_strip->count() || new_index < 0) 1437 if (new_index > target_tab_strip->count() || new_index < 0)
1436 new_index = target_tab_strip->count(); 1438 new_index = target_tab_strip->count();
1437 1439
1438 target_tab_strip->InsertTabContentsAt( 1440 target_tab_strip->InsertTabContentsAt(
1439 new_index, contents, TabStripModel::ADD_NONE); 1441 new_index, contents, TabStripModel::ADD_NONE);
1440 1442
1441 if (has_callback()) 1443 if (has_callback()) {
1442 tab_values.Append(ExtensionTabUtil::CreateTabValue( 1444 tab_values.Append(ExtensionTabUtil::CreateTabValue(
1443 contents->web_contents(), target_tab_strip, new_index)); 1445 contents->web_contents(),
1446 target_tab_strip,
1447 new_index,
1448 GetExtension()));
1449 }
1444 1450
1445 continue; 1451 continue;
1446 } 1452 }
1447 } 1453 }
1448 1454
1449 // Perform a simple within-window move. 1455 // Perform a simple within-window move.
1450 // Clamp move location to the last position. 1456 // Clamp move location to the last position.
1451 // This is ">=" because the move must be to an existing location. 1457 // This is ">=" because the move must be to an existing location.
1452 // -1 means set the move location to the last position. 1458 // -1 means set the move location to the last position.
1453 if (new_index >= source_tab_strip->count() || new_index < 0) 1459 if (new_index >= source_tab_strip->count() || new_index < 0)
1454 new_index = source_tab_strip->count() - 1; 1460 new_index = source_tab_strip->count() - 1;
1455 1461
1456 if (new_index != tab_index) 1462 if (new_index != tab_index)
1457 source_tab_strip->MoveTabContentsAt(tab_index, new_index, false); 1463 source_tab_strip->MoveTabContentsAt(tab_index, new_index, false);
1458 1464
1459 if (has_callback()) 1465 if (has_callback()) {
1460 tab_values.Append(ExtensionTabUtil::CreateTabValue( 1466 tab_values.Append(ExtensionTabUtil::CreateTabValue(
1461 contents->web_contents(), source_tab_strip, new_index)); 1467 contents->web_contents(), source_tab_strip, new_index,
1468 GetExtension()));
1469 }
1462 } 1470 }
1463 1471
1464 if (!has_callback()) 1472 if (!has_callback())
1465 return true; 1473 return true;
1466 1474
1467 // Only return the results as an array if there are multiple tabs. 1475 // Only return the results as an array if there are multiple tabs.
1468 if (tab_ids.size() > 1) { 1476 if (tab_ids.size() > 1) {
1469 SetResult(tab_values.DeepCopy()); 1477 SetResult(tab_values.DeepCopy());
1470 } else if (tab_ids.size() == 1) { 1478 } else if (tab_ids.size() == 1) {
1471 Value* value = NULL; 1479 Value* value = NULL;
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
1822 // called for every API call the extension made. 1830 // called for every API call the extension made.
1823 GotLanguage(language); 1831 GotLanguage(language);
1824 } 1832 }
1825 1833
1826 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { 1834 void DetectTabLanguageFunction::GotLanguage(const std::string& language) {
1827 SetResult(Value::CreateStringValue(language.c_str())); 1835 SetResult(Value::CreateStringValue(language.c_str()));
1828 SendResponse(true); 1836 SendResponse(true);
1829 1837
1830 Release(); // Balanced in Run() 1838 Release(); // Balanced in Run()
1831 } 1839 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698