diff options
author | rafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-09 17:33:18 +0000 |
---|---|---|
committer | rafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-09 17:33:18 +0000 |
commit | dd9d627a45031a4fe8414e79253e82fdfac7132c (patch) | |
tree | a049ade38464deffdc606ee3dec8607122e2354b /chrome/browser/extensions/extension_apitest.cc | |
parent | 422a0b90cbcd884221d3fabac3507dd964e5a064 (diff) | |
download | chromium_src-dd9d627a45031a4fe8414e79253e82fdfac7132c.zip chromium_src-dd9d627a45031a4fe8414e79253e82fdfac7132c.tar.gz chromium_src-dd9d627a45031a4fe8414e79253e82fdfac7132c.tar.bz2 |
Implement gallery install API
This patch implements chrome.experimental.management.install() which is only available for use by the web store. Calling with an extensionId, causes the download url to be constructed internally and downloaded and then cause the installation to bypass the normal permissions dialog.
BUG=27431,54148
Review URL: http://codereview.chromium.org/3353015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58956 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_apitest.cc')
-rw-r--r-- | chrome/browser/extensions/extension_apitest.cc | 59 |
1 files changed, 40 insertions, 19 deletions
diff --git a/chrome/browser/extensions/extension_apitest.cc b/chrome/browser/extensions/extension_apitest.cc index 005bff0..bddce0f 100644 --- a/chrome/browser/extensions/extension_apitest.cc +++ b/chrome/browser/extensions/extension_apitest.cc @@ -81,32 +81,53 @@ bool ExtensionApiTest::RunExtensionTest(const char* extension_name) { } bool ExtensionApiTest::RunExtensionSubtest(const char* extension_name, - const std::string& subtest_page) { - DCHECK(!subtest_page.empty()) << "Argument subtest_page is required."; - return RunExtensionTestImpl(extension_name, subtest_page); + const std::string& page_url) { + DCHECK(!page_url.empty()) << "Argument page_url is required."; + return RunExtensionTestImpl(extension_name, page_url); } -// Load an extension and wait for it to notify of PASSED or FAILED. +bool ExtensionApiTest::RunPageTest(const std::string& page_url) { + return RunExtensionSubtest("", page_url); +} + +// Load |extension_name| extension and/or |page_url| and wait for +// PASSED or FAILED notification. bool ExtensionApiTest::RunExtensionTestImpl(const char* extension_name, - const std::string& subtest_page) { + const std::string& page_url) { ResultCatcher catcher; - LOG(INFO) << "Running ExtensionApiTest with: " << extension_name; - - if (!LoadExtension(test_data_dir_.AppendASCII(extension_name))) { - message_ = "Failed to load extension."; - return false; + DCHECK(!std::string(extension_name).empty() || !page_url.empty()) << + "extension_name and page_url cannot both be empty"; + LOG(INFO) << "Running ExtensionApiTest"; + + if (!std::string(extension_name).empty()) { + LOG(INFO) << "Loading Extension: " << extension_name; + if (!LoadExtension(test_data_dir_.AppendASCII(extension_name))) { + message_ = "Failed to load extension."; + return false; + } } - // If there is a subtest to load, navigate to the subtest page. - if (!subtest_page.empty()) { - ExtensionsService* service = browser()->profile()->GetExtensionsService(); - Extension* extension = - service->GetExtensionById(last_loaded_extension_id_, false); - if (!extension) - return false; + // If there is a page_url to load, navigate it. + if (!page_url.empty()) { + GURL url = GURL(page_url); + + // Note: We use is_valid() here in the expectation that the provided url + // may lack a scheme & host and thus be a relative url within the loaded + // extension. + if (!url.is_valid()) { + DCHECK(!std::string(extension_name).empty()) << + "Relative page_url given with no extension_name"; + + ExtensionsService* service = browser()->profile()->GetExtensionsService(); + Extension* extension = + service->GetExtensionById(last_loaded_extension_id_, false); + if (!extension) + return false; + + url = extension->GetResourceURL(page_url); + } - GURL url = extension->GetResourceURL(subtest_page); - LOG(ERROR) << "Loading subtest page url: " << url.spec(); + LOG(ERROR) << "Loading page url: " << url.spec(); ui_test_utils::NavigateToURL(browser(), url); } |