diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-14 02:08:32 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-14 02:08:32 +0000 |
commit | e134d4541d47cc812f487e13dc16201dabf1a006 (patch) | |
tree | 5bf0f6881cca8e007d645fd9699fb0cc7ca5ecf4 | |
parent | ccac75726852954dbe516708c0b71d8e1e7e4fbb (diff) | |
download | chromium_src-e134d4541d47cc812f487e13dc16201dabf1a006.zip chromium_src-e134d4541d47cc812f487e13dc16201dabf1a006.tar.gz chromium_src-e134d4541d47cc812f487e13dc16201dabf1a006.tar.bz2 |
Revert "implemented extensions api windows.update()."
This reverts commit f2d9a44f3886aeab1378c8dbc1ce445202bc0ca5.
Review URL: http://codereview.chromium.org/115335
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16030 0039d316-1c4b-4281-b951-d872f2087c98
7 files changed, 10 insertions, 193 deletions
diff --git a/chrome/browser/extensions/extension_function_dispatcher.cc b/chrome/browser/extensions/extension_function_dispatcher.cc index b6943e9..bdc930a 100644 --- a/chrome/browser/extensions/extension_function_dispatcher.cc +++ b/chrome/browser/extensions/extension_function_dispatcher.cc @@ -61,7 +61,6 @@ FactoryRegistry::FactoryRegistry() { &NewExtensionFunction<GetLastFocusedWindowFunction>; factories_["GetAllWindows"] = &NewExtensionFunction<GetAllWindowsFunction>; factories_["CreateWindow"] = &NewExtensionFunction<CreateWindowFunction>; - factories_["UpdateWindow"] = &NewExtensionFunction<UpdateWindowFunction>; factories_["RemoveWindow"] = &NewExtensionFunction<RemoveWindowFunction>; // Tabs diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc index 09415f4..6e61976 100644 --- a/chrome/browser/extensions/extension_tabs_module.cc +++ b/chrome/browser/extensions/extension_tabs_module.cc @@ -253,55 +253,6 @@ bool CreateWindowFunction::RunImpl() { return true; } -bool UpdateWindowFunction::RunImpl() { - EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_LIST)); - const ListValue* args = static_cast<const ListValue*>(args_); - int window_id; - EXTENSION_FUNCTION_VALIDATE(args->GetInteger(0, &window_id)); - DictionaryValue* update_props; - EXTENSION_FUNCTION_VALIDATE(args->GetDictionary(1, &update_props)); - - Browser* browser = GetBrowserInProfileWithId(profile(), window_id, &error_); - if (!browser) - return false; - - gfx::Rect bounds = browser->window()->GetNormalBounds(); - // Any part of the bounds can optionally be set by the caller. - int bounds_val; - if (update_props->HasKey(kLeftKey)) { - EXTENSION_FUNCTION_VALIDATE(update_props->GetInteger(kLeftKey, - &bounds_val)); - bounds.set_x(bounds_val); - } - - if (update_props->HasKey(kTopKey)) { - EXTENSION_FUNCTION_VALIDATE(update_props->GetInteger(kTopKey, - &bounds_val)); - bounds.set_y(bounds_val); - } - - if (update_props->HasKey(kWidthKey)) { - EXTENSION_FUNCTION_VALIDATE(update_props->GetInteger(kWidthKey, - &bounds_val)); - bounds.set_width(bounds_val); - } - - if (update_props->HasKey(kHeightKey)) { - EXTENSION_FUNCTION_VALIDATE(update_props->GetInteger(kHeightKey, - &bounds_val)); - bounds.set_height(bounds_val); - } - - // TODO(rafaelw): This call to SetBounds() ends up resulting in the target - // window being activated (pushed to the front). On win32, this appears to be - // the result of HWND event handling. - browser->window()->SetBounds(bounds); - // TODO(rafaelw): Support |focused|. - result_.reset(CreateWindowValue(browser, false)); - - return true; -} - bool RemoveWindowFunction::RunImpl() { int window_id; EXTENSION_FUNCTION_VALIDATE(args_->GetAsInteger(&window_id)); @@ -625,10 +576,10 @@ static bool GetTabById(int tab_id, Profile* profile, Browser** browser, if (ExtensionTabUtil::GetTabById(tab_id, profile, browser, tab_strip, contents, tab_index)) return true; - + if (error_message) *error_message = ExtensionErrorUtils::FormatErrorMessage( kTabNotFoundError, IntToString(tab_id)); - + return false; } diff --git a/chrome/browser/extensions/extension_tabs_module.h b/chrome/browser/extensions/extension_tabs_module.h index 8a004185..b8763fc 100644 --- a/chrome/browser/extensions/extension_tabs_module.h +++ b/chrome/browser/extensions/extension_tabs_module.h @@ -45,9 +45,6 @@ class GetAllWindowsFunction : public SyncExtensionFunction { class CreateWindowFunction : public SyncExtensionFunction { virtual bool RunImpl(); }; -class UpdateWindowFunction : public SyncExtensionFunction { - virtual bool RunImpl(); -}; class RemoveWindowFunction : public SyncExtensionFunction { virtual bool RunImpl(); }; diff --git a/chrome/renderer/extensions/extension_api_client_unittest.cc b/chrome/renderer/extensions/extension_api_client_unittest.cc index 9689d95..6104bab 100644 --- a/chrome/renderer/extensions/extension_api_client_unittest.cc +++ b/chrome/renderer/extensions/extension_api_client_unittest.cc @@ -172,89 +172,6 @@ TEST_F(ExtensionAPIClientTest, GetAllWindows) { "GetAllWindows", "null"); } -TEST_F(ExtensionAPIClientTest, CreateWindow) { - ExpectJsFail("chrome.windows.create({url: 1}, function(){});", - "Uncaught Error: Invalid value for argument 0. Property " - "'url': Expected 'string' but got 'integer'."); - ExpectJsFail("chrome.windows.create({left: 'foo'}, function(){});", - "Uncaught Error: Invalid value for argument 0. Property " - "'left': Expected 'integer' but got 'string'."); - ExpectJsFail("chrome.windows.create({top: 'foo'}, function(){});", - "Uncaught Error: Invalid value for argument 0. Property " - "'top': Expected 'integer' but got 'string'."); - ExpectJsFail("chrome.windows.create({width: 'foo'}, function(){});", - "Uncaught Error: Invalid value for argument 0. Property " - "'width': Expected 'integer' but got 'string'."); - ExpectJsFail("chrome.windows.create({height: 'foo'}, function(){});", - "Uncaught Error: Invalid value for argument 0. Property " - "'height': Expected 'integer' but got 'string'."); - ExpectJsFail("chrome.windows.create({foo: 42}, function(){});", - "Uncaught Error: Invalid value for argument 0. Property " - "'foo': Unexpected property."); - - ExpectJsPass("chrome.windows.create({" - " url:'http://www.google.com/'," - " left:0," - " top: 10," - " width:100," - " height:200" - "})", - "CreateWindow", - "{\"url\":\"http://www.google.com/\"," - "\"left\":0," - "\"top\":10," - "\"width\":100," - "\"height\":200}"); -} - -TEST_F(ExtensionAPIClientTest, UpdateWindow) { - ExpectJsFail("chrome.windows.update(null);", - "Uncaught Error: Parameter 0 is required."); - ExpectJsFail("chrome.windows.update(42, {left: 'foo'});", - "Uncaught Error: Invalid value for argument 1. Property " - "'left': Expected 'integer' but got 'string'."); - ExpectJsFail("chrome.windows.update(42, {top: 'foo'});", - "Uncaught Error: Invalid value for argument 1. Property " - "'top': Expected 'integer' but got 'string'."); - ExpectJsFail("chrome.windows.update(42, {height: false});", - "Uncaught Error: Invalid value for argument 1. Property " - "'height': Expected 'integer' but got 'boolean'."); - ExpectJsFail("chrome.windows.update(42, {width: false});", - "Uncaught Error: Invalid value for argument 1. Property " - "'width': Expected 'integer' but got 'boolean'."); - ExpectJsFail("chrome.windows.update(42, {foo: false});", - "Uncaught Error: Invalid value for argument 1. Property " - "'foo': Unexpected property."); - - ExpectJsPass("chrome.windows.update(42, {" - " width:100," - " height:200" - "})", - "UpdateWindow", - "[42," - "{\"width\":100," - "\"height\":200}]"); -} - -TEST_F(ExtensionAPIClientTest, RemoveWindow) { - ExpectJsFail("chrome.windows.remove(32, function(){}, 20);", - "Uncaught Error: Too many arguments."); - - ExpectJsFail("chrome.windows.remove('abc', function(){});", - "Uncaught Error: Invalid value for argument 0. " - "Expected 'integer' but got 'string'."); - - ExpectJsFail("chrome.windows.remove(1, 1);", - "Uncaught Error: Invalid value for argument 1. " - "Expected 'function' but got 'integer'."); - - ExpectJsPass("chrome.windows.remove(2, function(){})", - "RemoveWindow", "2"); - - ExpectJsPass("chrome.windows.remove(2)", - "RemoveWindow", "2"); -} - // Tab API tests TEST_F(ExtensionAPIClientTest, GetTab) { diff --git a/chrome/renderer/renderer_resources.grd b/chrome/renderer/renderer_resources.grd index cda253b..c59e98c 100644 --- a/chrome/renderer/renderer_resources.grd +++ b/chrome/renderer/renderer_resources.grd @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- This comment is only here because changes to resources are not picked up -without changes to the corresponding grd file. --> +without changes to the corresponding grd file. --> <grit latest_public_release="0" current_release="1"> <outputs> <output filename="grit/renderer_resources.h" type="rc_header"> diff --git a/chrome/renderer/resources/extension_process_bindings.js b/chrome/renderer/resources/extension_process_bindings.js index 3828ee2..8b17e63 100644 --- a/chrome/renderer/resources/extension_process_bindings.js +++ b/chrome/renderer/resources/extension_process_bindings.js @@ -14,7 +14,6 @@ var chrome; native function GetCurrentWindow(); native function GetLastFocusedWindow(); native function CreateWindow(); - native function UpdateWindow(); native function RemoveWindow(); native function GetAllWindows(); native function GetTab(); @@ -166,25 +165,7 @@ var chrome; }, chrome.types.optFun ]; - - chrome.windows.update = function(windowId, updateData, callback) { - validate(arguments, arguments.callee.params); - sendRequest(UpdateWindow, [windowId, updateData], callback); - }; - chrome.windows.update.params = [ - chrome.types.pInt, - { - type: "object", - properties: { - left: chrome.types.optInt, - top: chrome.types.optInt, - width: chrome.types.optPInt, - height: chrome.types.optPInt - }, - }, - chrome.types.optFun - ]; - + chrome.windows.remove = function(windowId, callback) { validate(arguments, arguments.callee.params); sendRequest(RemoveWindow, windowId, callback); diff --git a/chrome/test/data/extensions/samples/tabs/tabs_api.html b/chrome/test/data/extensions/samples/tabs/tabs_api.html index a0b2dd23..7a60db7 100644 --- a/chrome/test/data/extensions/samples/tabs/tabs_api.html +++ b/chrome/test/data/extensions/samples/tabs/tabs_api.html @@ -19,10 +19,6 @@ function bootStrap() { }); } -function isInt(i) { - return (typeof i == "number") && !(i % 1) && !isNaN(i); -} - function loadWindowList() { chrome.windows.getAll(true, function(windowList) { tabs = {}; @@ -58,7 +54,8 @@ function updateTab(id){ } catch (e) { alert(e); } -} +} + function moveTabData(id) { return { @@ -185,6 +182,10 @@ chrome.tabs.onRemoved.addListener(function(tabId) { loadWindowList(); }); +function isInt(i) { + return (typeof i == "number") && !(i % 1) && !isNaN(i); +} + function createWindow() { var args = { 'left': parseInt(document.getElementById('new_window_left').value), @@ -225,34 +226,6 @@ function refreshWindow(windowId) { }); } -function updateWindowData(id) { - var retval = { - left: parseInt(document.getElementById('left_' + id).value), - top: parseInt(document.getElementById('top_' + id).value), - width: parseInt(document.getElementById('width_' + id).value), - height: parseInt(document.getElementById('height_' + id).value) - } - - if (!isInt(retval.left)) - delete retval.left; - if (!isInt(retval.top)) - delete retval.top; - if (!isInt(retval.width)) - delete retval.width; - if (!isInt(retval.height)) - delete retval.height; - - return retval; -} - -function updateWindow(id){ - try { - chrome.windows.update(id, updateWindowData(id)); - } catch (e) { - alert(e); - } -} - function removeWindow(windowId) { try { chrome.windows.remove(windowId, function() { @@ -327,7 +300,6 @@ function refreshSelectedTab(windowId) { </div> </div> </div> - <button onclick="updateWindow(this.jstdata);" jsvalues=".jstdata:id">Update Window</button> <button onclick="removeWindow(this.jstdata);" jsvalues=".jstdata:id">Close Window</button> <button onclick="refreshSelectedTab(this.jstdata);" jsvalues=".jstdata:id">Refresh Selected Tab</button> </div> |