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

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

Issue 257333002: Drive extension functions from ExtensionFunction::Run. The (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix comment Created 6 years, 7 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 | Annotate | Revision Log
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_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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 namespace extensions { 99 namespace extensions {
100 100
101 namespace windows = api::windows; 101 namespace windows = api::windows;
102 namespace keys = tabs_constants; 102 namespace keys = tabs_constants;
103 namespace tabs = api::tabs; 103 namespace tabs = api::tabs;
104 104
105 using api::tabs::InjectDetails; 105 using api::tabs::InjectDetails;
106 106
107 namespace { 107 namespace {
108 108
109 bool GetBrowserFromWindowID(ChromeAsyncExtensionFunction* function, 109 bool GetBrowserFromWindowID(ChromeUIThreadExtensionFunction* function,
110 int window_id, 110 int window_id,
111 Browser** browser) { 111 Browser** browser) {
112 std::string error; 112 std::string error;
113 Browser* result; 113 Browser* result;
114 result = 114 result =
115 ExtensionTabUtil::GetBrowserFromWindowID(function, window_id, &error); 115 ExtensionTabUtil::GetBrowserFromWindowID(function, window_id, &error);
116 if (!result) { 116 if (!result) {
117 function->SetError(error); 117 function->SetError(error);
118 return false; 118 return false;
119 } 119 }
(...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after
1045 if (*active_index == -1) 1045 if (*active_index == -1)
1046 *active_index = index; 1046 *active_index = index;
1047 1047
1048 selection->AddIndexToSelection(index); 1048 selection->AddIndexToSelection(index);
1049 return true; 1049 return true;
1050 } 1050 }
1051 1051
1052 TabsUpdateFunction::TabsUpdateFunction() : web_contents_(NULL) { 1052 TabsUpdateFunction::TabsUpdateFunction() : web_contents_(NULL) {
1053 } 1053 }
1054 1054
1055 bool TabsUpdateFunction::RunImpl() { 1055 bool TabsUpdateFunction::RunAsync() {
1056 scoped_ptr<tabs::Update::Params> params(tabs::Update::Params::Create(*args_)); 1056 scoped_ptr<tabs::Update::Params> params(tabs::Update::Params::Create(*args_));
1057 EXTENSION_FUNCTION_VALIDATE(params.get()); 1057 EXTENSION_FUNCTION_VALIDATE(params.get());
1058 1058
1059 int tab_id = -1; 1059 int tab_id = -1;
1060 WebContents* contents = NULL; 1060 WebContents* contents = NULL;
1061 if (!params->tab_id.get()) { 1061 if (!params->tab_id.get()) {
1062 Browser* browser = GetCurrentBrowser(); 1062 Browser* browser = GetCurrentBrowser();
1063 if (!browser) { 1063 if (!browser) {
1064 error_ = keys::kNoCurrentWindowError; 1064 error_ = keys::kNoCurrentWindowError;
1065 return false; 1065 return false;
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
1515 } 1515 }
1516 1516
1517 void TabsCaptureVisibleTabFunction::RegisterProfilePrefs( 1517 void TabsCaptureVisibleTabFunction::RegisterProfilePrefs(
1518 user_prefs::PrefRegistrySyncable* registry) { 1518 user_prefs::PrefRegistrySyncable* registry) {
1519 registry->RegisterBooleanPref( 1519 registry->RegisterBooleanPref(
1520 prefs::kDisableScreenshots, 1520 prefs::kDisableScreenshots,
1521 false, 1521 false,
1522 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 1522 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
1523 } 1523 }
1524 1524
1525 bool TabsDetectLanguageFunction::RunImpl() { 1525 bool TabsDetectLanguageFunction::RunAsync() {
1526 scoped_ptr<tabs::DetectLanguage::Params> params( 1526 scoped_ptr<tabs::DetectLanguage::Params> params(
1527 tabs::DetectLanguage::Params::Create(*args_)); 1527 tabs::DetectLanguage::Params::Create(*args_));
1528 EXTENSION_FUNCTION_VALIDATE(params.get()); 1528 EXTENSION_FUNCTION_VALIDATE(params.get());
1529 1529
1530 int tab_id = 0; 1530 int tab_id = 0;
1531 Browser* browser = NULL; 1531 Browser* browser = NULL;
1532 WebContents* contents = NULL; 1532 WebContents* contents = NULL;
1533 1533
1534 // If |tab_id| is specified, look for it. Otherwise default to selected tab 1534 // If |tab_id| is specified, look for it. Otherwise default to selected tab
1535 // in the current window. 1535 // in the current window.
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
1736 execute_tab_id_ = tab_id; 1736 execute_tab_id_ = tab_id;
1737 details_ = details.Pass(); 1737 details_ = details.Pass();
1738 return true; 1738 return true;
1739 } 1739 }
1740 1740
1741 bool TabsInsertCSSFunction::ShouldInsertCSS() const { 1741 bool TabsInsertCSSFunction::ShouldInsertCSS() const {
1742 return true; 1742 return true;
1743 } 1743 }
1744 1744
1745 } // namespace extensions 1745 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/tabs/tabs_api.h ('k') | chrome/browser/extensions/api/tabs/windows_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698