diff options
author | jennb@chromium.org <jennb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-11 22:18:37 +0000 |
---|---|---|
committer | jennb@chromium.org <jennb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-11 22:18:37 +0000 |
commit | 08aa0c3b4114d5dd9cef1650f862374c68086b7d (patch) | |
tree | 2293cfe350071464e871fee3f33b2d92c72a2d7b | |
parent | 536a17e499a44faabf0039de8a550843f7e4e03e (diff) | |
download | chromium_src-08aa0c3b4114d5dd9cef1650f862374c68086b7d.zip chromium_src-08aa0c3b4114d5dd9cef1650f862374c68086b7d.tar.gz chromium_src-08aa0c3b4114d5dd9cef1650f862374c68086b7d.tar.bz2 |
Add type 'panel' to chrome.windows.create.
BUG=None
TEST=New extension API test.
Review URL: http://codereview.chromium.org/6740030
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81165 0039d316-1c4b-4281-b951-d872f2087c98
10 files changed, 58 insertions, 8 deletions
diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc index fe2e678..d7773096 100644 --- a/chrome/browser/extensions/extension_tabs_module.cc +++ b/chrome/browser/extensions/extension_tabs_module.cc @@ -24,6 +24,7 @@ #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/browser/ui/window_sizer.h" +#include "chrome/common/chrome_switches.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension_error_utils.h" #include "chrome/common/extensions/extension_messages.h" @@ -43,6 +44,7 @@ #include "ui/gfx/codec/png_codec.h" namespace keys = extension_tabs_module_constants; +namespace errors = extension_manifest_errors; const int CaptureVisibleTabFunction::kDefaultQuality = 90; @@ -471,6 +473,14 @@ bool CreateWindowFunction::RunImpl() { window_type = Browser::TYPE_NORMAL; } else if (type_str == keys::kWindowTypeValuePopup) { window_type = Browser::TYPE_APP_POPUP; + } else if (type_str == keys::kWindowTypeValuePanel) { + if (GetExtension()->HasApiPermission( + Extension::kExperimentalPermission)) { + window_type = Browser::TYPE_APP_PANEL; + } else { + error_ = errors::kExperimentalFeature; + return false; + } } else { EXTENSION_FUNCTION_VALIDATE(false); } @@ -1336,6 +1346,11 @@ static bool GetTabById(int tab_id, Profile* profile, } static std::string GetWindowTypeText(Browser::Type type) { + if (type == Browser::TYPE_APP_PANEL && + CommandLine::ForCurrentProcess()->HasSwitch( + switches::kEnableExperimentalExtensionApis)) + return keys::kWindowTypeValuePanel; + if ((type & Browser::TYPE_POPUP) == Browser::TYPE_POPUP) return keys::kWindowTypeValuePopup; diff --git a/chrome/browser/extensions/extension_tabs_module_constants.cc b/chrome/browser/extensions/extension_tabs_module_constants.cc index 98f26f3..6fa6a6e 100644 --- a/chrome/browser/extensions/extension_tabs_module_constants.cc +++ b/chrome/browser/extensions/extension_tabs_module_constants.cc @@ -50,6 +50,7 @@ const char kStatusValueLoading[] = "loading"; // panel, etc? const char kWindowTypeValueNormal[] = "normal"; const char kWindowTypeValuePopup[] = "popup"; +const char kWindowTypeValuePanel[] = "panel"; const char kWindowTypeValueApp[] = "app"; const char kCanOnlyMoveTabsWithinNormalWindowsError[] = "Tabs can only be " diff --git a/chrome/browser/extensions/extension_tabs_module_constants.h b/chrome/browser/extensions/extension_tabs_module_constants.h index 1a979ae..4226494 100644 --- a/chrome/browser/extensions/extension_tabs_module_constants.h +++ b/chrome/browser/extensions/extension_tabs_module_constants.h @@ -55,6 +55,7 @@ extern const char kStatusValueComplete[]; extern const char kStatusValueLoading[]; extern const char kWindowTypeValueNormal[]; extern const char kWindowTypeValuePopup[]; +extern const char kWindowTypeValuePanel[]; extern const char kWindowTypeValueApp[]; // Error messages. diff --git a/chrome/browser/extensions/window_open_apitest.cc b/chrome/browser/extensions/window_open_apitest.cc index 4be4b93..5be059b 100644 --- a/chrome/browser/extensions/window_open_apitest.cc +++ b/chrome/browser/extensions/window_open_apitest.cc @@ -99,3 +99,14 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WindowOpenFocus) { ASSERT_TRUE(RunExtensionTest("window_open/focus")) << message_; } #endif + +class WindowOpenPanelTest : public ExtensionApiTest { + virtual void SetUpCommandLine(CommandLine* command_line) { + ExtensionApiTest::SetUpCommandLine(command_line); + command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); + } +}; + +IN_PROC_BROWSER_TEST_F(WindowOpenPanelTest, WindowOpenPanel) { + ASSERT_TRUE(RunExtensionTest("window_open/panel")) << message_; +} diff --git a/chrome/common/extensions/api/extension_api.json b/chrome/common/extensions/api/extension_api.json index eabdda5..de69542 100644 --- a/chrome/common/extensions/api/extension_api.json +++ b/chrome/common/extensions/api/extension_api.json @@ -718,8 +718,8 @@ "incognito": {"type": "boolean", "description": "Whether the window is incognito."}, "type": { "type": "string", - "description": "The type of browser window this is.", - "enum": ["normal", "popup", "app"] + "description": "The type of browser window this is. The 'panel' type requires the 'experimental' permission.", + "enum": ["normal", "popup", "panel", "app"] } } } @@ -834,8 +834,8 @@ "type": { "type": "string", "optional": true, - "description": "Specifies what type of browser window to create.", - "enum": ["normal", "popup"] + "description": "Specifies what type of browser window to create. The 'panel' type requires the 'experimental' permission.", + "enum": ["normal", "popup", "panel"] } }, "optional": true diff --git a/chrome/common/extensions/docs/windows.html b/chrome/common/extensions/docs/windows.html index c4b54fc..ba96d58 100644 --- a/chrome/common/extensions/docs/windows.html +++ b/chrome/common/extensions/docs/windows.html @@ -1139,7 +1139,7 @@ For other examples and for help in viewing the source code, see array of <span><span></span></span> </span> <span>string</span> - <span>["normal", "popup"]</span> + <span>["normal", "popup", "panel"]</span> </span> </span> ) @@ -1150,7 +1150,7 @@ For other examples and for help in viewing the source code, see <dd class="todo" style="display: none; "> Undocumented. </dd> - <dd>Specifies what type of browser window to create.</dd> + <dd>Specifies what type of browser window to create. The 'panel' type requires the 'experimental' permission.</dd> <dd style="display: none; "> This parameter was added in version <b><span></span></b>. @@ -4190,7 +4190,7 @@ For other examples and for help in viewing the source code, see array of <span><span></span></span> </span> <span>string</span> - <span>["normal", "popup", "app"]</span> + <span>["normal", "popup", "panel", "app"]</span> </span> </span> ) @@ -4201,7 +4201,7 @@ For other examples and for help in viewing the source code, see <dd class="todo" style="display: none; "> Undocumented. </dd> - <dd>The type of browser window this is.</dd> + <dd>The type of browser window this is. The 'panel' type requires the 'experimental' permission.</dd> <dd style="display: none; "> This parameter was added in version <b><span></span></b>. diff --git a/chrome/common/extensions/extension_constants.cc b/chrome/common/extensions/extension_constants.cc index f526f1c..97243e5 100644 --- a/chrome/common/extensions/extension_constants.cc +++ b/chrome/common/extensions/extension_constants.cc @@ -124,6 +124,9 @@ const char* kExpectString = "Expect string value."; const char* kExperimentalFlagRequired = "Loading extensions with 'experimental' permission requires" " --enable-experimental-extension-apis command line flag."; +const char *kExperimentalFeature = + "This feature requires 'experimental' permissions and" + " --enable-experimental-extension-apis command line flag."; const char* kHostedAppsCannotIncludeExtensionFeatures = "Hosted apps cannot use extension features."; const char* kInvalidAllFrames = diff --git a/chrome/common/extensions/extension_constants.h b/chrome/common/extensions/extension_constants.h index 8f1f270..daa2156 100644 --- a/chrome/common/extensions/extension_constants.h +++ b/chrome/common/extensions/extension_constants.h @@ -113,6 +113,7 @@ namespace extension_manifest_errors { extern const char* kDevToolsExperimental; extern const char* kDisabledByPolicy; extern const char* kExperimentalFlagRequired; + extern const char* kExperimentalFeature; extern const char* kExpectString; extern const char* kHostedAppsCannotIncludeExtensionFeatures; extern const char* kInvalidAllFrames; diff --git a/chrome/test/data/extensions/api_test/window_open/panel/manifest.json b/chrome/test/data/extensions/api_test/window_open/panel/manifest.json new file mode 100644 index 0000000..3e5a830 --- /dev/null +++ b/chrome/test/data/extensions/api_test/window_open/panel/manifest.json @@ -0,0 +1,7 @@ +{ + "name": "window/create.panel", + "version": "0.1", + "description": "Tests window.create with panel type.", + "background_page": "test.html", + "permissions": ["experimental", "tabs"] +} diff --git a/chrome/test/data/extensions/api_test/window_open/panel/test.html b/chrome/test/data/extensions/api_test/window_open/panel/test.html new file mode 100644 index 0000000..81d03b2 --- /dev/null +++ b/chrome/test/data/extensions/api_test/window_open/panel/test.html @@ -0,0 +1,11 @@ +<script> +chrome.test.runTests([ + function openPanel() { + chrome.windows.create( + { 'url': 'about:blank', 'type': 'panel' }, + chrome.test.callbackPass(function(win) { + chrome.test.assertEq('panel', win.type); + })); + } +]); +</script> |