diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-05 20:41:44 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-05 20:41:44 +0000 |
commit | d4a66c99465e0e42a75741220171057761ce073e (patch) | |
tree | 31295b3448d73b9288d0079edebe30f1e52cbd28 | |
parent | 6b723f8690dcdbdc4071a235aa67483dc18de329 (diff) | |
download | chromium_src-d4a66c99465e0e42a75741220171057761ce073e.zip chromium_src-d4a66c99465e0e42a75741220171057761ce073e.tar.gz chromium_src-d4a66c99465e0e42a75741220171057761ce073e.tar.bz2 |
Add chrome.windows.update({focused:true});
BUG=31434
TEST=browser_tests --gtest_filter=ExtensionApiTest.*Tabs
Review URL: http://codereview.chromium.org/3584010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61555 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/extensions/extension_tabs_module.cc | 12 | ||||
-rw-r--r-- | chrome/common/extensions/api/extension_api.json | 3 | ||||
-rw-r--r-- | chrome/common/extensions/docs/windows.html | 58 | ||||
-rw-r--r-- | chrome/test/data/extensions/api_test/tabs/basics/test.js | 12 |
4 files changed, 83 insertions, 2 deletions
diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc index a81de9d..ca4136b 100644 --- a/chrome/browser/extensions/extension_tabs_module.cc +++ b/chrome/browser/extensions/extension_tabs_module.cc @@ -446,8 +446,18 @@ bool UpdateWindowFunction::RunImpl() { &bounds_val)); bounds.set_height(bounds_val); } - browser->window()->SetBounds(bounds); + + bool selected_val = false; + if (update_props->HasKey(keys::kFocusedKey)) { + EXTENSION_FUNCTION_VALIDATE(update_props->GetBoolean( + keys::kFocusedKey, &selected_val)); + if (selected_val) + browser->window()->Activate(); + else + browser->window()->Deactivate(); + } + result_.reset(ExtensionTabUtil::CreateWindowValue(browser, false)); return true; diff --git a/chrome/common/extensions/api/extension_api.json b/chrome/common/extensions/api/extension_api.json index 732f417..142b3a4 100644 --- a/chrome/common/extensions/api/extension_api.json +++ b/chrome/common/extensions/api/extension_api.json @@ -728,7 +728,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": "It true, brings the window to the front. If false, brings the next window in the z-order to the front."} } }, { diff --git a/chrome/common/extensions/docs/windows.html b/chrome/common/extensions/docs/windows.html index 0ed4523..2da60a3 100644 --- a/chrome/common/extensions/docs/windows.html +++ b/chrome/common/extensions/docs/windows.html @@ -2557,6 +2557,64 @@ For other examples and for help in viewing the source code, see </dd> </div> + </div><div> + <div> + <dt> + <var>focused</var> + <em> + + <!-- TYPE --> + <div style="display:inline"> + ( + <span class="optional">optional</span> + <span class="enum" style="display: none; ">enumerated</span> + <span id="typeTemplate"> + <span style="display: none; "> + <a> Type</a> + </span> + <span> + <span style="display: none; "> + array of <span><span></span></span> + </span> + <span>boolean</span> + <span style="display: none; "></span> + </span> + </span> + ) + </div> + + </em> + </dt> + <dd class="todo" style="display: none; "> + Undocumented. + </dd> + <dd>It true, brings the window to the front. If false, brings the next window in the z-order to the front.</dd> + <dd style="display: none; "> + This parameter was added in version + <b><span></span></b>. + You must omit this parameter in earlier versions, + and you may omit it in any version. If you require this + parameter, the manifest key + <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a> + can ensure that your extension won't be run in an earlier browser version. + </dd> + + <!-- OBJECT PROPERTIES --> + <dd style="display: none; "> + <dl> + <div> + <div> + </div> + </div> + </dl> + </dd> + + <!-- FUNCTION PARAMETERS --> + <dd style="display: none; "> + <div></div> + </dd> + + </div> </div> </dl> </dd> 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 7b4c375..095bf40 100644 --- a/chrome/test/data/extensions/api_test/tabs/basics/test.js +++ b/chrome/test/data/extensions/api_test/tabs/basics/test.js @@ -440,6 +440,18 @@ chrome.test.runTests([ chrome.windows.create({"url": pageUrl("a")}, pass(function(tab) {})); }, + function windowSetFocused() { + chrome.windows.getCurrent(function(oldWin) { + chrome.windows.create({}, function(newWin) { + assertTrue(newWin.focused); + chrome.windows.update(oldWin.id, {focused:true}); + chrome.windows.get(oldWin.id, pass(function(oldWin2) { + assertTrue(oldWin2.focused); + })); + }); + }); + }, + /* TODO: Enable this test when crbug.com/28055 is fixed. This bug causes a newly created window not to be set as the current window, if Chrome was not the foreground window when the create call was made. |