Index: chrome/common/extensions/extension.cc |
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc |
index ecd638d0f0953f99d1194b6ddf25bdd45d0912fd..87a046fab354acedb54699fe79ba2f2f63726a94 100644 |
--- a/chrome/common/extensions/extension.cc |
+++ b/chrome/common/extensions/extension.cc |
@@ -272,6 +272,7 @@ const char Extension::kClipboardWritePermission[] = "clipboardWrite"; |
const char Extension::kContextMenusPermission[] = "contextMenus"; |
const char Extension::kContentSettingsPermission[] = "contentSettings"; |
const char Extension::kCookiePermission[] = "cookies"; |
+const char Extension::kChromeAuthPrivatePermission[] = "chromeAuthPrivate"; |
const char Extension::kChromePrivatePermission[] = "chromePrivate"; |
const char Extension::kChromeosInfoPrivatePermission[] = "chromeosInfoPrivate"; |
const char Extension::kDebuggerPermission[] = "debugger"; |
@@ -297,6 +298,7 @@ const char Extension::kWebSocketProxyPrivatePermission[] = |
const Extension::Permission Extension::kPermissions[] = { |
{ kBackgroundPermission, PermissionMessage::ID_NONE }, |
{ kBookmarkPermission, PermissionMessage::ID_BOOKMARKS }, |
+ { kChromeAuthPrivatePermission, PermissionMessage::ID_NONE }, |
{ kChromePrivatePermission, PermissionMessage::ID_NONE }, |
{ kChromeosInfoPrivatePermission, PermissionMessage::ID_NONE }, |
{ kClipboardReadPermission, PermissionMessage::ID_CLIPBOARD }, |
@@ -324,6 +326,7 @@ const size_t Extension::kNumPermissions = arraysize(Extension::kPermissions); |
const char* const Extension::kHostedAppPermissionNames[] = { |
Extension::kBackgroundPermission, |
+ Extension::kChromeAuthPrivatePermission, |
Extension::kChromePrivatePermission, |
Extension::kClipboardReadPermission, |
Extension::kClipboardWritePermission, |
@@ -337,6 +340,7 @@ const size_t Extension::kNumHostedAppPermissions = |
arraysize(Extension::kHostedAppPermissionNames); |
const char* const Extension::kComponentPrivatePermissionNames[] = { |
+ Extension::kChromeAuthPrivatePermission, |
Extension::kFileBrowserPrivatePermission, |
Extension::kWebstorePrivatePermission, |
Extension::kMediaPlayerPrivatePermission, |
@@ -537,6 +541,29 @@ std::set<Extension::PermissionMessage> |
return messages; |
} |
+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::PARSE_STRICT); |
+ pattern.SetPath(pattern.path() + '*'); |
+ extent_.AddPattern(pattern); |
+ } |
+} |
+ |
// static |
std::vector<std::string> Extension::GetDistinctHostsForDisplay( |
const URLPatternList& list) { |
@@ -1377,29 +1404,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::PARSE_STRICT); |
- 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; |
} |