From eb003245da4a579090d1e9bdee891587db451d4c Mon Sep 17 00:00:00 2001 From: "aa@chromium.org" Date: Fri, 15 Jan 2010 21:19:30 +0000 Subject: Re-land r36338: Add the ability to focus a window to chrome.window.update(). BUG=31434 TBR=rafaelw@chromium.org git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36407 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/extensions/extension_tabs_module.cc | 10 +++++++++- chrome/chrome_tests.gypi | 2 +- chrome/common/extensions/api/extension_api.json | 3 ++- chrome/test/data/extensions/api_test/tabs/basics/test.js | 9 ++++++++- 4 files changed, 20 insertions(+), 4 deletions(-) (limited to 'chrome') diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc index 19d2687..6f40ad6 100644 --- a/chrome/browser/extensions/extension_tabs_module.cc +++ b/chrome/browser/extensions/extension_tabs_module.cc @@ -386,7 +386,15 @@ bool UpdateWindowFunction::RunImpl() { } browser->window()->SetBounds(bounds); - // TODO(rafaelw): Support |focused|. + + if (update_props->HasKey(keys::kFocusedKey)) { + bool focused = false; + EXTENSION_FUNCTION_VALIDATE(update_props->GetBoolean(keys::kFocusedKey, + &focused)); + if (focused) + browser->window()->Activate(); + } + result_.reset(ExtensionTabUtil::CreateWindowValue(browser, false)); return true; diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index e82d3c9..026584f 100755 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -15,7 +15,6 @@ 'browser/extensions/extension_shelf_model_unittest.cc', 'browser/extensions/extension_startup_unittest.cc', 'browser/extensions/extension_storage_apitest.cc', - 'browser/extensions/extension_tabs_apitest.cc', 'browser/extensions/extension_popup_apitest.cc', # TODO(jam): http://crbug.com/15101 These tests fail on Linux and Mac. 'browser/child_process_security_policy_browser_test.cc', @@ -1115,6 +1114,7 @@ 'browser/extensions/extension_javascript_url_apitest.cc', 'browser/extensions/extension_messages_apitest.cc', 'browser/extensions/extension_override_apitest.cc', + 'browser/extensions/extension_tabs_apitest.cc', 'browser/extensions/extension_toolstrip_apitest.cc', 'browser/extensions/incognito_noscript_apitest.cc', 'browser/extensions/isolated_world_apitest.cc', diff --git a/chrome/common/extensions/api/extension_api.json b/chrome/common/extensions/api/extension_api.json index 1daeb09..a02895f 100755 --- a/chrome/common/extensions/api/extension_api.json +++ b/chrome/common/extensions/api/extension_api.json @@ -357,7 +357,8 @@ "left": {"type": "integer", "optional": true, "description": "The offset from the left edge of the screen to move the window to in pixels."}, "top": {"type": "integer", "optional": true, "description": "The offset from the top edge of the screen to move the window to in pixels."}, "width": {"type": "integer", "minimum": 0, "optional": true, "description": "The width to resize the window to in pixels."}, - "height": {"type": "integer", "minimum": 0, "optional": true, "description": "The height to resize the window to in pixels."} + "height": {"type": "integer", "minimum": 0, "optional": true, "description": "The height to resize the window to in pixels."}, + "focused": {"type": "boolean", "optional": true, "description": "Set to true to focus the window. Setting to false has no effect on the window (it doesn't blur it)."} } }, { diff --git a/chrome/test/data/extensions/api_test/tabs/basics/test.js b/chrome/test/data/extensions/api_test/tabs/basics/test.js index a516ddc..00f20dd 100644 --- a/chrome/test/data/extensions/api_test/tabs/basics/test.js +++ b/chrome/test/data/extensions/api_test/tabs/basics/test.js @@ -35,7 +35,6 @@ chrome.test.runTests([ assertTrue(tab.index > firstTabIndex); assertEq(firstWindowId, tab.windowId); assertEq(false, tab.selected); - assertEq("chrome://newtab/", tab.url); })); }, @@ -241,6 +240,14 @@ chrome.test.runTests([ })); }, + function focus() { + chrome.test.listenOnce(chrome.windows.onFocusChanged, function(winId) { + assertEq(firstWindowId, winId); + }); + + chrome.windows.update(firstWindowId, {focused: true}, pass()); + }, + /* // TODO(jcampan): http://crbug.com/30662 the detection language library // crashes on some sites and has been temporarily disabled. -- cgit v1.1