| 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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 // |value| are equal. This function is used to check if a tab's parameters match | 182 // |value| are equal. This function is used to check if a tab's parameters match |
| 183 // those of the browser. | 183 // those of the browser. |
| 184 bool MatchesBool(bool* boolean, bool value) { | 184 bool MatchesBool(bool* boolean, bool value) { |
| 185 return !boolean || *boolean == value; | 185 return !boolean || *boolean == value; |
| 186 } | 186 } |
| 187 | 187 |
| 188 } // namespace | 188 } // namespace |
| 189 | 189 |
| 190 // Windows --------------------------------------------------------------------- | 190 // Windows --------------------------------------------------------------------- |
| 191 | 191 |
| 192 bool WindowsGetFunction::RunImpl() { | 192 bool WindowsGetFunction::RunSync() { |
| 193 scoped_ptr<windows::Get::Params> params(windows::Get::Params::Create(*args_)); | 193 scoped_ptr<windows::Get::Params> params(windows::Get::Params::Create(*args_)); |
| 194 EXTENSION_FUNCTION_VALIDATE(params.get()); | 194 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 195 | 195 |
| 196 bool populate_tabs = false; | 196 bool populate_tabs = false; |
| 197 if (params->get_info.get() && params->get_info->populate.get()) | 197 if (params->get_info.get() && params->get_info->populate.get()) |
| 198 populate_tabs = *params->get_info->populate; | 198 populate_tabs = *params->get_info->populate; |
| 199 | 199 |
| 200 WindowController* controller; | 200 WindowController* controller; |
| 201 if (!windows_util::GetWindowFromWindowID(this, | 201 if (!windows_util::GetWindowFromWindowID(this, |
| 202 params->window_id, | 202 params->window_id, |
| 203 &controller)) { | 203 &controller)) { |
| 204 return false; | 204 return false; |
| 205 } | 205 } |
| 206 | 206 |
| 207 if (populate_tabs) | 207 if (populate_tabs) |
| 208 SetResult(controller->CreateWindowValueWithTabs(GetExtension())); | 208 SetResult(controller->CreateWindowValueWithTabs(GetExtension())); |
| 209 else | 209 else |
| 210 SetResult(controller->CreateWindowValue()); | 210 SetResult(controller->CreateWindowValue()); |
| 211 return true; | 211 return true; |
| 212 } | 212 } |
| 213 | 213 |
| 214 bool WindowsGetCurrentFunction::RunImpl() { | 214 bool WindowsGetCurrentFunction::RunSync() { |
| 215 scoped_ptr<windows::GetCurrent::Params> params( | 215 scoped_ptr<windows::GetCurrent::Params> params( |
| 216 windows::GetCurrent::Params::Create(*args_)); | 216 windows::GetCurrent::Params::Create(*args_)); |
| 217 EXTENSION_FUNCTION_VALIDATE(params.get()); | 217 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 218 | 218 |
| 219 bool populate_tabs = false; | 219 bool populate_tabs = false; |
| 220 if (params->get_info.get() && params->get_info->populate.get()) | 220 if (params->get_info.get() && params->get_info->populate.get()) |
| 221 populate_tabs = *params->get_info->populate; | 221 populate_tabs = *params->get_info->populate; |
| 222 | 222 |
| 223 WindowController* controller; | 223 WindowController* controller; |
| 224 if (!windows_util::GetWindowFromWindowID(this, | 224 if (!windows_util::GetWindowFromWindowID(this, |
| 225 extension_misc::kCurrentWindowId, | 225 extension_misc::kCurrentWindowId, |
| 226 &controller)) { | 226 &controller)) { |
| 227 return false; | 227 return false; |
| 228 } | 228 } |
| 229 if (populate_tabs) | 229 if (populate_tabs) |
| 230 SetResult(controller->CreateWindowValueWithTabs(GetExtension())); | 230 SetResult(controller->CreateWindowValueWithTabs(GetExtension())); |
| 231 else | 231 else |
| 232 SetResult(controller->CreateWindowValue()); | 232 SetResult(controller->CreateWindowValue()); |
| 233 return true; | 233 return true; |
| 234 } | 234 } |
| 235 | 235 |
| 236 bool WindowsGetLastFocusedFunction::RunImpl() { | 236 bool WindowsGetLastFocusedFunction::RunSync() { |
| 237 scoped_ptr<windows::GetLastFocused::Params> params( | 237 scoped_ptr<windows::GetLastFocused::Params> params( |
| 238 windows::GetLastFocused::Params::Create(*args_)); | 238 windows::GetLastFocused::Params::Create(*args_)); |
| 239 EXTENSION_FUNCTION_VALIDATE(params.get()); | 239 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 240 | 240 |
| 241 bool populate_tabs = false; | 241 bool populate_tabs = false; |
| 242 if (params->get_info.get() && params->get_info->populate.get()) | 242 if (params->get_info.get() && params->get_info->populate.get()) |
| 243 populate_tabs = *params->get_info->populate; | 243 populate_tabs = *params->get_info->populate; |
| 244 | 244 |
| 245 // Note: currently this returns the last active browser. If we decide to | 245 // Note: currently this returns the last active browser. If we decide to |
| 246 // include other window types (e.g. panels), we will need to add logic to | 246 // include other window types (e.g. panels), we will need to add logic to |
| 247 // WindowControllerList that mirrors the active behavior of BrowserList. | 247 // WindowControllerList that mirrors the active behavior of BrowserList. |
| 248 Browser* browser = chrome::FindAnyBrowser( | 248 Browser* browser = chrome::FindAnyBrowser( |
| 249 GetProfile(), include_incognito(), chrome::GetActiveDesktop()); | 249 GetProfile(), include_incognito(), chrome::GetActiveDesktop()); |
| 250 if (!browser || !browser->window()) { | 250 if (!browser || !browser->window()) { |
| 251 error_ = keys::kNoLastFocusedWindowError; | 251 error_ = keys::kNoLastFocusedWindowError; |
| 252 return false; | 252 return false; |
| 253 } | 253 } |
| 254 WindowController* controller = | 254 WindowController* controller = |
| 255 browser->extension_window_controller(); | 255 browser->extension_window_controller(); |
| 256 if (populate_tabs) | 256 if (populate_tabs) |
| 257 SetResult(controller->CreateWindowValueWithTabs(GetExtension())); | 257 SetResult(controller->CreateWindowValueWithTabs(GetExtension())); |
| 258 else | 258 else |
| 259 SetResult(controller->CreateWindowValue()); | 259 SetResult(controller->CreateWindowValue()); |
| 260 return true; | 260 return true; |
| 261 } | 261 } |
| 262 | 262 |
| 263 bool WindowsGetAllFunction::RunImpl() { | 263 bool WindowsGetAllFunction::RunSync() { |
| 264 scoped_ptr<windows::GetAll::Params> params( | 264 scoped_ptr<windows::GetAll::Params> params( |
| 265 windows::GetAll::Params::Create(*args_)); | 265 windows::GetAll::Params::Create(*args_)); |
| 266 EXTENSION_FUNCTION_VALIDATE(params.get()); | 266 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 267 | 267 |
| 268 bool populate_tabs = false; | 268 bool populate_tabs = false; |
| 269 if (params->get_info.get() && params->get_info->populate.get()) | 269 if (params->get_info.get() && params->get_info->populate.get()) |
| 270 populate_tabs = *params->get_info->populate; | 270 populate_tabs = *params->get_info->populate; |
| 271 | 271 |
| 272 base::ListValue* window_list = new base::ListValue(); | 272 base::ListValue* window_list = new base::ListValue(); |
| 273 const WindowControllerList::ControllerList& windows = | 273 const WindowControllerList::ControllerList& windows = |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 if (urls->empty() && !first_url_erased.empty()) { | 327 if (urls->empty() && !first_url_erased.empty()) { |
| 328 error_ = ErrorUtils::FormatErrorMessage( | 328 error_ = ErrorUtils::FormatErrorMessage( |
| 329 keys::kURLsNotAllowedInIncognitoError, first_url_erased); | 329 keys::kURLsNotAllowedInIncognitoError, first_url_erased); |
| 330 *is_error = true; | 330 *is_error = true; |
| 331 return false; | 331 return false; |
| 332 } | 332 } |
| 333 } | 333 } |
| 334 return incognito; | 334 return incognito; |
| 335 } | 335 } |
| 336 | 336 |
| 337 bool WindowsCreateFunction::RunImpl() { | 337 bool WindowsCreateFunction::RunSync() { |
| 338 scoped_ptr<windows::Create::Params> params( | 338 scoped_ptr<windows::Create::Params> params( |
| 339 windows::Create::Params::Create(*args_)); | 339 windows::Create::Params::Create(*args_)); |
| 340 EXTENSION_FUNCTION_VALIDATE(params); | 340 EXTENSION_FUNCTION_VALIDATE(params); |
| 341 std::vector<GURL> urls; | 341 std::vector<GURL> urls; |
| 342 TabStripModel* source_tab_strip = NULL; | 342 TabStripModel* source_tab_strip = NULL; |
| 343 int tab_index = -1; | 343 int tab_index = -1; |
| 344 | 344 |
| 345 windows::Create::Params::CreateData* create_data = params->create_data.get(); | 345 windows::Create::Params::CreateData* create_data = params->create_data.get(); |
| 346 | 346 |
| 347 // Look for optional url. | 347 // Look for optional url. |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 SetResult(base::Value::CreateNullValue()); | 591 SetResult(base::Value::CreateNullValue()); |
| 592 } else { | 592 } else { |
| 593 SetResult( | 593 SetResult( |
| 594 new_window->extension_window_controller()->CreateWindowValueWithTabs( | 594 new_window->extension_window_controller()->CreateWindowValueWithTabs( |
| 595 GetExtension())); | 595 GetExtension())); |
| 596 } | 596 } |
| 597 | 597 |
| 598 return true; | 598 return true; |
| 599 } | 599 } |
| 600 | 600 |
| 601 bool WindowsUpdateFunction::RunImpl() { | 601 bool WindowsUpdateFunction::RunSync() { |
| 602 scoped_ptr<windows::Update::Params> params( | 602 scoped_ptr<windows::Update::Params> params( |
| 603 windows::Update::Params::Create(*args_)); | 603 windows::Update::Params::Create(*args_)); |
| 604 EXTENSION_FUNCTION_VALIDATE(params); | 604 EXTENSION_FUNCTION_VALIDATE(params); |
| 605 | 605 |
| 606 WindowController* controller; | 606 WindowController* controller; |
| 607 if (!windows_util::GetWindowFromWindowID(this, params->window_id, | 607 if (!windows_util::GetWindowFromWindowID(this, params->window_id, |
| 608 &controller)) | 608 &controller)) |
| 609 return false; | 609 return false; |
| 610 | 610 |
| 611 ui::WindowShowState show_state = ui::SHOW_STATE_DEFAULT; // No change. | 611 ui::WindowShowState show_state = ui::SHOW_STATE_DEFAULT; // No change. |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 } | 711 } |
| 712 | 712 |
| 713 if (params->update_info.draw_attention) | 713 if (params->update_info.draw_attention) |
| 714 controller->window()->FlashFrame(*params->update_info.draw_attention); | 714 controller->window()->FlashFrame(*params->update_info.draw_attention); |
| 715 | 715 |
| 716 SetResult(controller->CreateWindowValue()); | 716 SetResult(controller->CreateWindowValue()); |
| 717 | 717 |
| 718 return true; | 718 return true; |
| 719 } | 719 } |
| 720 | 720 |
| 721 bool WindowsRemoveFunction::RunImpl() { | 721 bool WindowsRemoveFunction::RunSync() { |
| 722 scoped_ptr<windows::Remove::Params> params( | 722 scoped_ptr<windows::Remove::Params> params( |
| 723 windows::Remove::Params::Create(*args_)); | 723 windows::Remove::Params::Create(*args_)); |
| 724 EXTENSION_FUNCTION_VALIDATE(params); | 724 EXTENSION_FUNCTION_VALIDATE(params); |
| 725 | 725 |
| 726 WindowController* controller; | 726 WindowController* controller; |
| 727 if (!windows_util::GetWindowFromWindowID(this, params->window_id, | 727 if (!windows_util::GetWindowFromWindowID(this, params->window_id, |
| 728 &controller)) | 728 &controller)) |
| 729 return false; | 729 return false; |
| 730 | 730 |
| 731 WindowController::Reason reason; | 731 WindowController::Reason reason; |
| 732 if (!controller->CanClose(&reason)) { | 732 if (!controller->CanClose(&reason)) { |
| 733 if (reason == WindowController::REASON_NOT_EDITABLE) | 733 if (reason == WindowController::REASON_NOT_EDITABLE) |
| 734 error_ = keys::kTabStripNotEditableError; | 734 error_ = keys::kTabStripNotEditableError; |
| 735 return false; | 735 return false; |
| 736 } | 736 } |
| 737 controller->window()->Close(); | 737 controller->window()->Close(); |
| 738 return true; | 738 return true; |
| 739 } | 739 } |
| 740 | 740 |
| 741 // Tabs ------------------------------------------------------------------------ | 741 // Tabs ------------------------------------------------------------------------ |
| 742 | 742 |
| 743 bool TabsGetSelectedFunction::RunImpl() { | 743 bool TabsGetSelectedFunction::RunSync() { |
| 744 // windowId defaults to "current" window. | 744 // windowId defaults to "current" window. |
| 745 int window_id = extension_misc::kCurrentWindowId; | 745 int window_id = extension_misc::kCurrentWindowId; |
| 746 | 746 |
| 747 scoped_ptr<tabs::GetSelected::Params> params( | 747 scoped_ptr<tabs::GetSelected::Params> params( |
| 748 tabs::GetSelected::Params::Create(*args_)); | 748 tabs::GetSelected::Params::Create(*args_)); |
| 749 EXTENSION_FUNCTION_VALIDATE(params.get()); | 749 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 750 if (params->window_id.get()) | 750 if (params->window_id.get()) |
| 751 window_id = *params->window_id; | 751 window_id = *params->window_id; |
| 752 | 752 |
| 753 Browser* browser = NULL; | 753 Browser* browser = NULL; |
| 754 if (!GetBrowserFromWindowID(this, window_id, &browser)) | 754 if (!GetBrowserFromWindowID(this, window_id, &browser)) |
| 755 return false; | 755 return false; |
| 756 | 756 |
| 757 TabStripModel* tab_strip = browser->tab_strip_model(); | 757 TabStripModel* tab_strip = browser->tab_strip_model(); |
| 758 WebContents* contents = tab_strip->GetActiveWebContents(); | 758 WebContents* contents = tab_strip->GetActiveWebContents(); |
| 759 if (!contents) { | 759 if (!contents) { |
| 760 error_ = keys::kNoSelectedTabError; | 760 error_ = keys::kNoSelectedTabError; |
| 761 return false; | 761 return false; |
| 762 } | 762 } |
| 763 SetResult(ExtensionTabUtil::CreateTabValue(contents, | 763 SetResult(ExtensionTabUtil::CreateTabValue(contents, |
| 764 tab_strip, | 764 tab_strip, |
| 765 tab_strip->active_index(), | 765 tab_strip->active_index(), |
| 766 GetExtension())); | 766 GetExtension())); |
| 767 return true; | 767 return true; |
| 768 } | 768 } |
| 769 | 769 |
| 770 bool TabsGetAllInWindowFunction::RunImpl() { | 770 bool TabsGetAllInWindowFunction::RunSync() { |
| 771 scoped_ptr<tabs::GetAllInWindow::Params> params( | 771 scoped_ptr<tabs::GetAllInWindow::Params> params( |
| 772 tabs::GetAllInWindow::Params::Create(*args_)); | 772 tabs::GetAllInWindow::Params::Create(*args_)); |
| 773 EXTENSION_FUNCTION_VALIDATE(params.get()); | 773 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 774 // windowId defaults to "current" window. | 774 // windowId defaults to "current" window. |
| 775 int window_id = extension_misc::kCurrentWindowId; | 775 int window_id = extension_misc::kCurrentWindowId; |
| 776 if (params->window_id.get()) | 776 if (params->window_id.get()) |
| 777 window_id = *params->window_id; | 777 window_id = *params->window_id; |
| 778 | 778 |
| 779 Browser* browser = NULL; | 779 Browser* browser = NULL; |
| 780 if (!GetBrowserFromWindowID(this, window_id, &browser)) | 780 if (!GetBrowserFromWindowID(this, window_id, &browser)) |
| 781 return false; | 781 return false; |
| 782 | 782 |
| 783 SetResult(ExtensionTabUtil::CreateTabList(browser, GetExtension())); | 783 SetResult(ExtensionTabUtil::CreateTabList(browser, GetExtension())); |
| 784 | 784 |
| 785 return true; | 785 return true; |
| 786 } | 786 } |
| 787 | 787 |
| 788 bool TabsQueryFunction::RunImpl() { | 788 bool TabsQueryFunction::RunSync() { |
| 789 scoped_ptr<tabs::Query::Params> params(tabs::Query::Params::Create(*args_)); | 789 scoped_ptr<tabs::Query::Params> params(tabs::Query::Params::Create(*args_)); |
| 790 EXTENSION_FUNCTION_VALIDATE(params.get()); | 790 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 791 | 791 |
| 792 bool loading_status_set = params->query_info.status != | 792 bool loading_status_set = params->query_info.status != |
| 793 tabs::Query::Params::QueryInfo::STATUS_NONE; | 793 tabs::Query::Params::QueryInfo::STATUS_NONE; |
| 794 bool loading = params->query_info.status == | 794 bool loading = params->query_info.status == |
| 795 tabs::Query::Params::QueryInfo::STATUS_LOADING; | 795 tabs::Query::Params::QueryInfo::STATUS_LOADING; |
| 796 | 796 |
| 797 // It is o.k. to use URLPattern::SCHEME_ALL here because this function does | 797 // It is o.k. to use URLPattern::SCHEME_ALL here because this function does |
| 798 // not grant access to the content of the tabs, only to seeing their URLs and | 798 // not grant access to the content of the tabs, only to seeing their URLs and |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 893 | 893 |
| 894 result->Append(ExtensionTabUtil::CreateTabValue( | 894 result->Append(ExtensionTabUtil::CreateTabValue( |
| 895 web_contents, tab_strip, i, GetExtension())); | 895 web_contents, tab_strip, i, GetExtension())); |
| 896 } | 896 } |
| 897 } | 897 } |
| 898 | 898 |
| 899 SetResult(result); | 899 SetResult(result); |
| 900 return true; | 900 return true; |
| 901 } | 901 } |
| 902 | 902 |
| 903 bool TabsCreateFunction::RunImpl() { | 903 bool TabsCreateFunction::RunSync() { |
| 904 scoped_ptr<tabs::Create::Params> params(tabs::Create::Params::Create(*args_)); | 904 scoped_ptr<tabs::Create::Params> params(tabs::Create::Params::Create(*args_)); |
| 905 EXTENSION_FUNCTION_VALIDATE(params.get()); | 905 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 906 | 906 |
| 907 // windowId defaults to "current" window. | 907 // windowId defaults to "current" window. |
| 908 int window_id = extension_misc::kCurrentWindowId; | 908 int window_id = extension_misc::kCurrentWindowId; |
| 909 if (params->create_properties.window_id.get()) | 909 if (params->create_properties.window_id.get()) |
| 910 window_id = *params->create_properties.window_id; | 910 window_id = *params->create_properties.window_id; |
| 911 | 911 |
| 912 Browser* browser = NULL; | 912 Browser* browser = NULL; |
| 913 if (!GetBrowserFromWindowID(this, window_id, &browser)) | 913 if (!GetBrowserFromWindowID(this, window_id, &browser)) |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1031 // Return data about the newly created tab. | 1031 // Return data about the newly created tab. |
| 1032 if (has_callback()) { | 1032 if (has_callback()) { |
| 1033 SetResult(ExtensionTabUtil::CreateTabValue( | 1033 SetResult(ExtensionTabUtil::CreateTabValue( |
| 1034 navigate_params.target_contents, | 1034 navigate_params.target_contents, |
| 1035 tab_strip, new_index, GetExtension())); | 1035 tab_strip, new_index, GetExtension())); |
| 1036 } | 1036 } |
| 1037 | 1037 |
| 1038 return true; | 1038 return true; |
| 1039 } | 1039 } |
| 1040 | 1040 |
| 1041 bool TabsDuplicateFunction::RunImpl() { | 1041 bool TabsDuplicateFunction::RunSync() { |
| 1042 scoped_ptr<tabs::Duplicate::Params> params( | 1042 scoped_ptr<tabs::Duplicate::Params> params( |
| 1043 tabs::Duplicate::Params::Create(*args_)); | 1043 tabs::Duplicate::Params::Create(*args_)); |
| 1044 EXTENSION_FUNCTION_VALIDATE(params.get()); | 1044 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 1045 int tab_id = params->tab_id; | 1045 int tab_id = params->tab_id; |
| 1046 | 1046 |
| 1047 Browser* browser = NULL; | 1047 Browser* browser = NULL; |
| 1048 TabStripModel* tab_strip = NULL; | 1048 TabStripModel* tab_strip = NULL; |
| 1049 int tab_index = -1; | 1049 int tab_index = -1; |
| 1050 if (!GetTabById(tab_id, | 1050 if (!GetTabById(tab_id, |
| 1051 GetProfile(), | 1051 GetProfile(), |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1074 } | 1074 } |
| 1075 | 1075 |
| 1076 // Return data about the newly created tab. | 1076 // Return data about the newly created tab. |
| 1077 SetResult(ExtensionTabUtil::CreateTabValue( | 1077 SetResult(ExtensionTabUtil::CreateTabValue( |
| 1078 new_contents, | 1078 new_contents, |
| 1079 new_tab_strip, new_tab_index, GetExtension())); | 1079 new_tab_strip, new_tab_index, GetExtension())); |
| 1080 | 1080 |
| 1081 return true; | 1081 return true; |
| 1082 } | 1082 } |
| 1083 | 1083 |
| 1084 bool TabsGetFunction::RunImpl() { | 1084 bool TabsGetFunction::RunSync() { |
| 1085 scoped_ptr<tabs::Get::Params> params(tabs::Get::Params::Create(*args_)); | 1085 scoped_ptr<tabs::Get::Params> params(tabs::Get::Params::Create(*args_)); |
| 1086 EXTENSION_FUNCTION_VALIDATE(params.get()); | 1086 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 1087 int tab_id = params->tab_id; | 1087 int tab_id = params->tab_id; |
| 1088 | 1088 |
| 1089 TabStripModel* tab_strip = NULL; | 1089 TabStripModel* tab_strip = NULL; |
| 1090 WebContents* contents = NULL; | 1090 WebContents* contents = NULL; |
| 1091 int tab_index = -1; | 1091 int tab_index = -1; |
| 1092 if (!GetTabById(tab_id, | 1092 if (!GetTabById(tab_id, |
| 1093 GetProfile(), | 1093 GetProfile(), |
| 1094 include_incognito(), | 1094 include_incognito(), |
| 1095 NULL, | 1095 NULL, |
| 1096 &tab_strip, | 1096 &tab_strip, |
| 1097 &contents, | 1097 &contents, |
| 1098 &tab_index, | 1098 &tab_index, |
| 1099 &error_)) | 1099 &error_)) |
| 1100 return false; | 1100 return false; |
| 1101 | 1101 |
| 1102 SetResult(ExtensionTabUtil::CreateTabValue(contents, | 1102 SetResult(ExtensionTabUtil::CreateTabValue(contents, |
| 1103 tab_strip, | 1103 tab_strip, |
| 1104 tab_index, | 1104 tab_index, |
| 1105 GetExtension())); | 1105 GetExtension())); |
| 1106 return true; | 1106 return true; |
| 1107 } | 1107 } |
| 1108 | 1108 |
| 1109 bool TabsGetCurrentFunction::RunImpl() { | 1109 bool TabsGetCurrentFunction::RunSync() { |
| 1110 DCHECK(dispatcher()); | 1110 DCHECK(dispatcher()); |
| 1111 | 1111 |
| 1112 WebContents* contents = dispatcher()->delegate()->GetAssociatedWebContents(); | 1112 WebContents* contents = dispatcher()->delegate()->GetAssociatedWebContents(); |
| 1113 if (contents) | 1113 if (contents) |
| 1114 SetResult(ExtensionTabUtil::CreateTabValue(contents, GetExtension())); | 1114 SetResult(ExtensionTabUtil::CreateTabValue(contents, GetExtension())); |
| 1115 | 1115 |
| 1116 return true; | 1116 return true; |
| 1117 } | 1117 } |
| 1118 | 1118 |
| 1119 bool TabsHighlightFunction::RunImpl() { | 1119 bool TabsHighlightFunction::RunSync() { |
| 1120 scoped_ptr<tabs::Highlight::Params> params( | 1120 scoped_ptr<tabs::Highlight::Params> params( |
| 1121 tabs::Highlight::Params::Create(*args_)); | 1121 tabs::Highlight::Params::Create(*args_)); |
| 1122 EXTENSION_FUNCTION_VALIDATE(params.get()); | 1122 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 1123 | 1123 |
| 1124 // Get the window id from the params; default to current window if omitted. | 1124 // Get the window id from the params; default to current window if omitted. |
| 1125 int window_id = extension_misc::kCurrentWindowId; | 1125 int window_id = extension_misc::kCurrentWindowId; |
| 1126 if (params->highlight_info.window_id.get()) | 1126 if (params->highlight_info.window_id.get()) |
| 1127 window_id = *params->highlight_info.window_id; | 1127 window_id = *params->highlight_info.window_id; |
| 1128 | 1128 |
| 1129 Browser* browser = NULL; | 1129 Browser* browser = NULL; |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1363 int32 on_page_id, | 1363 int32 on_page_id, |
| 1364 const GURL& url, | 1364 const GURL& url, |
| 1365 const base::ListValue& script_result) { | 1365 const base::ListValue& script_result) { |
| 1366 if (error.empty()) | 1366 if (error.empty()) |
| 1367 PopulateResult(); | 1367 PopulateResult(); |
| 1368 else | 1368 else |
| 1369 error_ = error; | 1369 error_ = error; |
| 1370 SendResponse(error.empty()); | 1370 SendResponse(error.empty()); |
| 1371 } | 1371 } |
| 1372 | 1372 |
| 1373 bool TabsMoveFunction::RunImpl() { | 1373 bool TabsMoveFunction::RunSync() { |
| 1374 scoped_ptr<tabs::Move::Params> params(tabs::Move::Params::Create(*args_)); | 1374 scoped_ptr<tabs::Move::Params> params(tabs::Move::Params::Create(*args_)); |
| 1375 EXTENSION_FUNCTION_VALIDATE(params.get()); | 1375 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 1376 | 1376 |
| 1377 int new_index = params->move_properties.index; | 1377 int new_index = params->move_properties.index; |
| 1378 int* window_id = params->move_properties.window_id.get(); | 1378 int* window_id = params->move_properties.window_id.get(); |
| 1379 scoped_ptr<base::ListValue> tab_values(new base::ListValue()); | 1379 scoped_ptr<base::ListValue> tab_values(new base::ListValue()); |
| 1380 | 1380 |
| 1381 size_t num_tabs = 0; | 1381 size_t num_tabs = 0; |
| 1382 if (params->tab_ids.as_integers) { | 1382 if (params->tab_ids.as_integers) { |
| 1383 std::vector<int>& tab_ids = *params->tab_ids.as_integers; | 1383 std::vector<int>& tab_ids = *params->tab_ids.as_integers; |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1510 source_tab_strip->MoveWebContentsAt(tab_index, *new_index, false); | 1510 source_tab_strip->MoveWebContentsAt(tab_index, *new_index, false); |
| 1511 | 1511 |
| 1512 if (has_callback()) { | 1512 if (has_callback()) { |
| 1513 tab_values->Append(ExtensionTabUtil::CreateTabValue( | 1513 tab_values->Append(ExtensionTabUtil::CreateTabValue( |
| 1514 contents, source_tab_strip, *new_index, GetExtension())); | 1514 contents, source_tab_strip, *new_index, GetExtension())); |
| 1515 } | 1515 } |
| 1516 | 1516 |
| 1517 return true; | 1517 return true; |
| 1518 } | 1518 } |
| 1519 | 1519 |
| 1520 bool TabsReloadFunction::RunImpl() { | 1520 bool TabsReloadFunction::RunSync() { |
| 1521 scoped_ptr<tabs::Reload::Params> params( | 1521 scoped_ptr<tabs::Reload::Params> params( |
| 1522 tabs::Reload::Params::Create(*args_)); | 1522 tabs::Reload::Params::Create(*args_)); |
| 1523 EXTENSION_FUNCTION_VALIDATE(params.get()); | 1523 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 1524 | 1524 |
| 1525 bool bypass_cache = false; | 1525 bool bypass_cache = false; |
| 1526 if (params->reload_properties.get() && | 1526 if (params->reload_properties.get() && |
| 1527 params->reload_properties->bypass_cache.get()) { | 1527 params->reload_properties->bypass_cache.get()) { |
| 1528 bypass_cache = *params->reload_properties->bypass_cache; | 1528 bypass_cache = *params->reload_properties->bypass_cache; |
| 1529 } | 1529 } |
| 1530 | 1530 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1564 GetCurrentBrowser()->OpenURL(params); | 1564 GetCurrentBrowser()->OpenURL(params); |
| 1565 } else if (bypass_cache) { | 1565 } else if (bypass_cache) { |
| 1566 web_contents->GetController().ReloadIgnoringCache(true); | 1566 web_contents->GetController().ReloadIgnoringCache(true); |
| 1567 } else { | 1567 } else { |
| 1568 web_contents->GetController().Reload(true); | 1568 web_contents->GetController().Reload(true); |
| 1569 } | 1569 } |
| 1570 | 1570 |
| 1571 return true; | 1571 return true; |
| 1572 } | 1572 } |
| 1573 | 1573 |
| 1574 bool TabsRemoveFunction::RunImpl() { | 1574 bool TabsRemoveFunction::RunSync() { |
| 1575 scoped_ptr<tabs::Remove::Params> params(tabs::Remove::Params::Create(*args_)); | 1575 scoped_ptr<tabs::Remove::Params> params(tabs::Remove::Params::Create(*args_)); |
| 1576 EXTENSION_FUNCTION_VALIDATE(params.get()); | 1576 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 1577 | 1577 |
| 1578 if (params->tab_ids.as_integers) { | 1578 if (params->tab_ids.as_integers) { |
| 1579 std::vector<int>& tab_ids = *params->tab_ids.as_integers; | 1579 std::vector<int>& tab_ids = *params->tab_ids.as_integers; |
| 1580 for (size_t i = 0; i < tab_ids.size(); ++i) { | 1580 for (size_t i = 0; i < tab_ids.size(); ++i) { |
| 1581 if (!RemoveTab(tab_ids[i])) | 1581 if (!RemoveTab(tab_ids[i])) |
| 1582 return false; | 1582 return false; |
| 1583 } | 1583 } |
| 1584 } else { | 1584 } else { |
| (...skipping 286 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 |