summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
authorsanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-13 04:17:31 +0000
committersanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-13 04:17:31 +0000
commitbe9d9c8af20532001eff248886578d4ab844707d (patch)
tree5440af7f7193ccaae9e0dcfb8bdb2676debb045a /chrome/common
parenteeb3a533308c6a9ebe2206a57137c095bfbb2e01 (diff)
downloadchromium_src-be9d9c8af20532001eff248886578d4ab844707d.zip
chromium_src-be9d9c8af20532001eff248886578d4ab844707d.tar.gz
chromium_src-be9d9c8af20532001eff248886578d4ab844707d.tar.bz2
Re-land change 7253001.
This change was reverted in r90547 due to unrelated test failures. BUG=None TEST=Unit-tests. Review URL: http://codereview.chromium.org/7348001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@92317 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r--chrome/common/extensions/api/extension_api.json42
-rw-r--r--chrome/common/extensions/extension.cc62
-rw-r--r--chrome/common/extensions/extension.h4
-rw-r--r--chrome/common/extensions/extension_constants.cc1
-rw-r--r--chrome/common/extensions/extension_constants.h3
-rw-r--r--chrome/common/extensions/extension_permission_set.cc4
-rw-r--r--chrome/common/extensions/extension_permission_set.h1
-rw-r--r--chrome/common/extensions/extension_permission_set_unittest.cc9
8 files changed, 102 insertions, 24 deletions
diff --git a/chrome/common/extensions/api/extension_api.json b/chrome/common/extensions/api/extension_api.json
index 6458211..bac8e0b 100644
--- a/chrome/common/extensions/api/extension_api.json
+++ b/chrome/common/extensions/api/extension_api.json
@@ -6414,5 +6414,47 @@
]
}
]
+ },
+ {
+ "namespace": "chromeAuthPrivate",
+ "nodoc": "true",
+ "functions": [
+ {
+ "name": "setCloudPrintCredentials",
+ "description": "Sets the login credentials for Cloud Print.",
+ "type": "function",
+ "parameters": [
+ {
+ "name": "userEmail",
+ "type": "string",
+ "description": "The email address of the user."
+ },
+ {
+ "name": "robotEmail",
+ "type": "string",
+ "description": "The email address of the robot account."
+ },
+ {
+ "name": "credentials",
+ "type": "string",
+ "description": "The login credentials(OAuth2 Auth code)."
+ },
+ {
+ "name": "callback",
+ "type": "function",
+ "description": "Called when a failure happens. Called upon success only in tests.",
+ "optional": "true",
+ "parameters": [
+ {
+ "name": "result",
+ "type": "string",
+ "description": "A string result code. The value is non-empty on success only in tests.",
+ "optional": "true"
+ }
+ ]
+ }
+ ]
+ }
+ ]
}
]
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
index f61f789..c0ba929 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -300,6 +300,29 @@ std::vector<string16> Extension::GetPermissionMessageStrings() const {
return permission_set_->GetWarningMessages();
}
+void Extension::OverrideLaunchUrl(const GURL& override_url) {
+ GURL new_url(override_url);
+ if (!new_url.is_valid()) {
+ LOG(WARNING) << "Invalid override url given for " << name();
+ } else {
+ if (new_url.has_port()) {
+ LOG(WARNING) << "Override URL passed for " << name()
+ << " should not contain a port. Removing it.";
+
+ GURL::Replacements remove_port;
+ remove_port.ClearPort();
+ new_url = new_url.ReplaceComponents(remove_port);
+ }
+
+ launch_web_url_ = new_url.spec();
+
+ URLPattern pattern(kValidWebExtentSchemes);
+ pattern.Parse(new_url.spec(), URLPattern::ERROR_ON_PORTS);
+ pattern.SetPath(pattern.path() + '*');
+ extent_.AddPattern(pattern);
+ }
+}
+
FilePath Extension::MaybeNormalizePath(const FilePath& path) {
#if defined(OS_WIN)
// Normalize any drive letter to upper-case. We do this for consistency with
@@ -1041,29 +1064,26 @@ bool Extension::LoadLaunchURL(const DictionaryValue* manifest,
// Empty string means option was not used.
if (!gallery_url_str.empty()) {
GURL gallery_url(gallery_url_str);
- if (!gallery_url.is_valid()) {
- LOG(WARNING) << "Invalid url given in switch "
- << switches::kAppsGalleryURL;
- } else {
- if (gallery_url.has_port()) {
- LOG(WARNING) << "URLs passed to switch " << switches::kAppsGalleryURL
- << " should not contain a port. Removing it.";
-
- GURL::Replacements remove_port;
- remove_port.ClearPort();
- gallery_url = gallery_url.ReplaceComponents(remove_port);
- }
-
- launch_web_url_ = gallery_url.spec();
-
- URLPattern pattern(kValidWebExtentSchemes);
- pattern.Parse(gallery_url.spec(), URLPattern::ERROR_ON_PORTS);
- pattern.SetPath(pattern.path() + '*');
- extent_.AddPattern(pattern);
- }
+ OverrideLaunchUrl(gallery_url);
+ }
+ } else if (id() == extension_misc::kCloudPrintAppId) {
+ // In order for the --cloud-print-service switch to work, we must update
+ // the launch URL and web extent.
+ // TODO(sanjeevr): Ideally we want to use CloudPrintURL here but that is
+ // currently under chrome/browser.
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
+ GURL cloud_print_service_url = GURL(command_line.GetSwitchValueASCII(
+ switches::kCloudPrintServiceURL));
+ if (!cloud_print_service_url.is_empty()) {
+ std::string path(
+ cloud_print_service_url.path() + "/enable_chrome_connector");
+ GURL::Replacements replacements;
+ replacements.SetPathStr(path);
+ GURL cloud_print_enable_connector_url =
+ cloud_print_service_url.ReplaceComponents(replacements);
+ OverrideLaunchUrl(cloud_print_enable_connector_url);
}
}
-
return true;
}
diff --git a/chrome/common/extensions/extension.h b/chrome/common/extensions/extension.h
index c1543da..517ebdb 100644
--- a/chrome/common/extensions/extension.h
+++ b/chrome/common/extensions/extension.h
@@ -645,6 +645,10 @@ class Extension : public base::RefCountedThreadSafe<Extension> {
// component-private permission.
bool IsComponentOnlyPermission(const ExtensionAPIPermission* api) const;
+ // Updates the launch URL and extents for the extension using the given
+ // |override_url|.
+ void OverrideLaunchUrl(const GURL& override_url);
+
// Cached images for this extension. This should only be touched on the UI
// thread.
mutable ImageCache image_cache_;
diff --git a/chrome/common/extensions/extension_constants.cc b/chrome/common/extensions/extension_constants.cc
index 0218761..827c384 100644
--- a/chrome/common/extensions/extension_constants.cc
+++ b/chrome/common/extensions/extension_constants.cc
@@ -416,6 +416,7 @@ const char* kDecodedMessageCatalogsFilename = "DECODED_MESSAGE_CATALOGS";
namespace extension_misc {
const char* kBookmarkManagerId = "eemcgdkfndhakfknompkggombfjjjeno";
const char* kWebStoreAppId = "ahfgeienlihckogmohjhadlkjgocpleb";
+const char* kCloudPrintAppId = "mfehgcgbbipciphmccgaenjidiccnmng";
const char* kAppsPromoHistogram = "Extensions.AppsPromo";
const char* kAppLaunchHistogram = "Extensions.AppLaunch";
#if defined(OS_CHROMEOS)
diff --git a/chrome/common/extensions/extension_constants.h b/chrome/common/extensions/extension_constants.h
index b9fd273..57742d8 100644
--- a/chrome/common/extensions/extension_constants.h
+++ b/chrome/common/extensions/extension_constants.h
@@ -294,6 +294,9 @@ namespace extension_misc {
// The extension id of the Web Store component application.
extern const char* kWebStoreAppId;
+ // The extension id of the Cloud Print component application.
+ extern const char* kCloudPrintAppId;
+
// Note: this structure is an ASN.1 which encodes the algorithm used
// with its parameters. This is defined in PKCS #1 v2.1 (RFC 3447).
// It is encoding: { OID sha1WithRSAEncryption PARAMETERS NULL }
diff --git a/chrome/common/extensions/extension_permission_set.cc b/chrome/common/extensions/extension_permission_set.cc
index d87e9e3..c829c10 100644
--- a/chrome/common/extensions/extension_permission_set.cc
+++ b/chrome/common/extensions/extension_permission_set.cc
@@ -249,6 +249,10 @@ ExtensionPermissionsInfo::ExtensionPermissionsInfo()
// Hosted app and private permissions.
RegisterPermission(
+ ExtensionAPIPermission::kChromeAuthPrivate, "chromeAuthPrivate", 0,
+ ExtensionPermissionMessage::kNone,
+ true, true, false, false);
+ RegisterPermission(
ExtensionAPIPermission::kWebstorePrivate, "webstorePrivate", 0,
ExtensionPermissionMessage::kNone,
true, true, false, false);
diff --git a/chrome/common/extensions/extension_permission_set.h b/chrome/common/extensions/extension_permission_set.h
index 5cd331a..3ed0451 100644
--- a/chrome/common/extensions/extension_permission_set.h
+++ b/chrome/common/extensions/extension_permission_set.h
@@ -97,6 +97,7 @@ class ExtensionAPIPermission {
kContentSettings,
kContextMenus,
kCookie,
+ kChromeAuthPrivate,
kChromePrivate,
kChromeosInfoPrivate,
kDebugger,
diff --git a/chrome/common/extensions/extension_permission_set_unittest.cc b/chrome/common/extensions/extension_permission_set_unittest.cc
index 9cfa698..75e12fa 100644
--- a/chrome/common/extensions/extension_permission_set_unittest.cc
+++ b/chrome/common/extensions/extension_permission_set_unittest.cc
@@ -162,6 +162,7 @@ TEST(ExtensionAPIPermissionTest, HostedAppPermissions) {
hosted_perms.insert(ExtensionAPIPermission::kBackground);
hosted_perms.insert(ExtensionAPIPermission::kClipboardRead);
hosted_perms.insert(ExtensionAPIPermission::kClipboardWrite);
+ hosted_perms.insert(ExtensionAPIPermission::kChromeAuthPrivate);
hosted_perms.insert(ExtensionAPIPermission::kChromePrivate);
hosted_perms.insert(ExtensionAPIPermission::kExperimental);
hosted_perms.insert(ExtensionAPIPermission::kGeolocation);
@@ -177,13 +178,14 @@ TEST(ExtensionAPIPermissionTest, HostedAppPermissions) {
EXPECT_EQ(hosted_perms.count(*i) > 0, info->GetByID(*i)->is_hosted_app());
}
- EXPECT_EQ(9u, count);
- EXPECT_EQ(9u, info->get_hosted_app_permission_count());
+ EXPECT_EQ(10u, count);
+ EXPECT_EQ(10u, info->get_hosted_app_permission_count());
}
TEST(ExtensionAPIPermissionTest, ComponentOnlyPermissions) {
ExtensionPermissionsInfo* info = ExtensionPermissionsInfo::GetInstance();
ExtensionAPIPermissionSet private_perms;
+ private_perms.insert(ExtensionAPIPermission::kChromeAuthPrivate);
private_perms.insert(ExtensionAPIPermission::kChromeosInfoPrivate);
private_perms.insert(ExtensionAPIPermission::kFileBrowserPrivate);
private_perms.insert(ExtensionAPIPermission::kMediaPlayerPrivate);
@@ -198,7 +200,7 @@ TEST(ExtensionAPIPermissionTest, ComponentOnlyPermissions) {
info->GetByID(*i)->is_component_only());
}
- EXPECT_EQ(4, count);
+ EXPECT_EQ(5, count);
}
TEST(ExtensionPermissionSetTest, EffectiveHostPermissions) {
@@ -497,6 +499,7 @@ TEST(ExtensionPermissionSetTest, PermissionMessages) {
skip.insert(ExtensionAPIPermission::kWebstorePrivate);
skip.insert(ExtensionAPIPermission::kFileBrowserPrivate);
skip.insert(ExtensionAPIPermission::kMediaPlayerPrivate);
+ skip.insert(ExtensionAPIPermission::kChromeAuthPrivate);
skip.insert(ExtensionAPIPermission::kChromePrivate);
skip.insert(ExtensionAPIPermission::kChromeosInfoPrivate);
skip.insert(ExtensionAPIPermission::kWebSocketProxyPrivate);