OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/common/extensions/extension.h" | 5 #include "chrome/common/extensions/extension.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 CHECK(loc1_rank != loc2_rank); | 267 CHECK(loc1_rank != loc2_rank); |
268 | 268 |
269 // Lowest rank has highest priority. | 269 // Lowest rank has highest priority. |
270 return (loc1_rank > loc2_rank ? loc1 : loc2 ); | 270 return (loc1_rank > loc2_rank ? loc1 : loc2 ); |
271 } | 271 } |
272 | 272 |
273 ExtensionPermissionMessages Extension::GetPermissionMessages() const { | 273 ExtensionPermissionMessages Extension::GetPermissionMessages() const { |
274 return permission_set_->GetPermissionMessages(); | 274 return permission_set_->GetPermissionMessages(); |
275 } | 275 } |
276 | 276 |
| 277 void Extension::OverrideLaunchUrl(const GURL& override_url) { |
| 278 GURL new_url(override_url); |
| 279 if (!new_url.is_valid()) { |
| 280 LOG(WARNING) << "Invalid override url given for " << name(); |
| 281 } else { |
| 282 if (new_url.has_port()) { |
| 283 LOG(WARNING) << "Override URL passed for " << name() |
| 284 << " should not contain a port. Removing it."; |
| 285 |
| 286 GURL::Replacements remove_port; |
| 287 remove_port.ClearPort(); |
| 288 new_url = new_url.ReplaceComponents(remove_port); |
| 289 } |
| 290 |
| 291 launch_web_url_ = new_url.spec(); |
| 292 |
| 293 URLPattern pattern(kValidWebExtentSchemes); |
| 294 pattern.Parse(new_url.spec(), URLPattern::PARSE_STRICT); |
| 295 pattern.SetPath(pattern.path() + '*'); |
| 296 extent_.AddPattern(pattern); |
| 297 } |
| 298 } |
| 299 |
277 std::vector<string16> Extension::GetPermissionMessageStrings() const { | 300 std::vector<string16> Extension::GetPermissionMessageStrings() const { |
278 return permission_set_->GetWarningMessages(); | 301 return permission_set_->GetWarningMessages(); |
279 } | 302 } |
280 | 303 |
281 FilePath Extension::MaybeNormalizePath(const FilePath& path) { | 304 FilePath Extension::MaybeNormalizePath(const FilePath& path) { |
282 #if defined(OS_WIN) | 305 #if defined(OS_WIN) |
283 // Normalize any drive letter to upper-case. We do this for consistency with | 306 // Normalize any drive letter to upper-case. We do this for consistency with |
284 // net_utils::FilePathToFileURL(), which does the same thing, to make string | 307 // net_utils::FilePathToFileURL(), which does the same thing, to make string |
285 // comparisons simpler. | 308 // comparisons simpler. |
286 std::wstring path_str = path.value(); | 309 std::wstring path_str = path.value(); |
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1012 // In order for the --apps-gallery-url switch to work with the gallery | 1035 // In order for the --apps-gallery-url switch to work with the gallery |
1013 // process isolation, we must insert any provided value into the component | 1036 // process isolation, we must insert any provided value into the component |
1014 // app's launch url and web extent. | 1037 // app's launch url and web extent. |
1015 if (id() == extension_misc::kWebStoreAppId) { | 1038 if (id() == extension_misc::kWebStoreAppId) { |
1016 std::string gallery_url_str = CommandLine::ForCurrentProcess()-> | 1039 std::string gallery_url_str = CommandLine::ForCurrentProcess()-> |
1017 GetSwitchValueASCII(switches::kAppsGalleryURL); | 1040 GetSwitchValueASCII(switches::kAppsGalleryURL); |
1018 | 1041 |
1019 // Empty string means option was not used. | 1042 // Empty string means option was not used. |
1020 if (!gallery_url_str.empty()) { | 1043 if (!gallery_url_str.empty()) { |
1021 GURL gallery_url(gallery_url_str); | 1044 GURL gallery_url(gallery_url_str); |
1022 if (!gallery_url.is_valid()) { | 1045 OverrideLaunchUrl(gallery_url); |
1023 LOG(WARNING) << "Invalid url given in switch " | 1046 } |
1024 << switches::kAppsGalleryURL; | 1047 } else if (id() == extension_misc::kCloudPrintAppId) { |
1025 } else { | 1048 // In order for the --cloud-print-service switch to work, we must update |
1026 if (gallery_url.has_port()) { | 1049 // the launch URL and web extent. |
1027 LOG(WARNING) << "URLs passed to switch " << switches::kAppsGalleryURL | 1050 // TODO(sanjeevr): Ideally we want to use CloudPrintURL here but that is |
1028 << " should not contain a port. Removing it."; | 1051 // currently under chrome/browser. |
1029 | 1052 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
1030 GURL::Replacements remove_port; | 1053 GURL cloud_print_service_url = GURL(command_line.GetSwitchValueASCII( |
1031 remove_port.ClearPort(); | 1054 switches::kCloudPrintServiceURL)); |
1032 gallery_url = gallery_url.ReplaceComponents(remove_port); | 1055 if (!cloud_print_service_url.is_empty()) { |
1033 } | 1056 std::string path( |
1034 | 1057 cloud_print_service_url.path() + "/enable_chrome_connector"); |
1035 launch_web_url_ = gallery_url.spec(); | 1058 GURL::Replacements replacements; |
1036 | 1059 replacements.SetPathStr(path); |
1037 URLPattern pattern(kValidWebExtentSchemes); | 1060 GURL cloud_print_enable_connector_url = |
1038 pattern.Parse(gallery_url.spec(), URLPattern::PARSE_STRICT); | 1061 cloud_print_service_url.ReplaceComponents(replacements); |
1039 pattern.SetPath(pattern.path() + '*'); | 1062 OverrideLaunchUrl(cloud_print_enable_connector_url); |
1040 extent_.AddPattern(pattern); | |
1041 } | |
1042 } | 1063 } |
1043 } | 1064 } |
1044 | |
1045 return true; | 1065 return true; |
1046 } | 1066 } |
1047 | 1067 |
1048 bool Extension::LoadLaunchContainer(const DictionaryValue* manifest, | 1068 bool Extension::LoadLaunchContainer(const DictionaryValue* manifest, |
1049 std::string* error) { | 1069 std::string* error) { |
1050 Value* temp = NULL; | 1070 Value* temp = NULL; |
1051 if (!manifest->Get(keys::kLaunchContainer, &temp)) | 1071 if (!manifest->Get(keys::kLaunchContainer, &temp)) |
1052 return true; | 1072 return true; |
1053 | 1073 |
1054 std::string launch_container_string; | 1074 std::string launch_container_string; |
(...skipping 1624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2679 | 2699 |
2680 UninstalledExtensionInfo::~UninstalledExtensionInfo() {} | 2700 UninstalledExtensionInfo::~UninstalledExtensionInfo() {} |
2681 | 2701 |
2682 | 2702 |
2683 UnloadedExtensionInfo::UnloadedExtensionInfo( | 2703 UnloadedExtensionInfo::UnloadedExtensionInfo( |
2684 const Extension* extension, | 2704 const Extension* extension, |
2685 Reason reason) | 2705 Reason reason) |
2686 : reason(reason), | 2706 : reason(reason), |
2687 already_disabled(false), | 2707 already_disabled(false), |
2688 extension(extension) {} | 2708 extension(extension) {} |
OLD | NEW |