OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 // extension with options. All other menu items like uninstall have | 417 // extension with options. All other menu items like uninstall have |
418 // no sense for component extensions. | 418 // no sense for component extensions. |
419 return location() != Manifest::COMPONENT; | 419 return location() != Manifest::COMPONENT; |
420 } | 420 } |
421 | 421 |
422 GURL Extension::GetFullLaunchURL() const { | 422 GURL Extension::GetFullLaunchURL() const { |
423 return launch_local_path().empty() ? GURL(launch_web_url()) : | 423 return launch_local_path().empty() ? GURL(launch_web_url()) : |
424 url().Resolve(launch_local_path()); | 424 url().Resolve(launch_local_path()); |
425 } | 425 } |
426 | 426 |
427 bool Extension::UpdatesFromGallery() const { | |
428 return extension_urls::IsWebstoreUpdateUrl(ManifestURL::GetUpdateURL(this)); | |
429 } | |
430 | |
431 bool Extension::OverlapsWithOrigin(const GURL& origin) const { | 427 bool Extension::OverlapsWithOrigin(const GURL& origin) const { |
432 if (url() == origin) | 428 if (url() == origin) |
433 return true; | 429 return true; |
434 | 430 |
435 if (web_extent().is_empty()) | 431 if (web_extent().is_empty()) |
436 return false; | 432 return false; |
437 | 433 |
438 // Note: patterns and extents ignore port numbers. | 434 // Note: patterns and extents ignore port numbers. |
439 URLPattern origin_only_pattern(kValidWebExtentSchemes); | 435 URLPattern origin_only_pattern(kValidWebExtentSchemes); |
440 if (!origin_only_pattern.SetScheme(origin.scheme())) | 436 if (!origin_only_pattern.SetScheme(origin.scheme())) |
(...skipping 10 matching lines...) Expand all Loading... |
451 Extension::SyncType Extension::GetSyncType() const { | 447 Extension::SyncType Extension::GetSyncType() const { |
452 if (!IsSyncable()) { | 448 if (!IsSyncable()) { |
453 // We have a non-standard location. | 449 // We have a non-standard location. |
454 return SYNC_TYPE_NONE; | 450 return SYNC_TYPE_NONE; |
455 } | 451 } |
456 | 452 |
457 // Disallow extensions with non-gallery auto-update URLs for now. | 453 // Disallow extensions with non-gallery auto-update URLs for now. |
458 // | 454 // |
459 // TODO(akalin): Relax this restriction once we've put in UI to | 455 // TODO(akalin): Relax this restriction once we've put in UI to |
460 // approve synced extensions. | 456 // approve synced extensions. |
461 if (!ManifestURL::GetUpdateURL(this).is_empty() && !UpdatesFromGallery()) | 457 if (!ManifestURL::GetUpdateURL(this).is_empty() && |
| 458 !ManifestURL::UpdatesFromGallery(this)) |
462 return SYNC_TYPE_NONE; | 459 return SYNC_TYPE_NONE; |
463 | 460 |
464 // Disallow extensions with native code plugins. | 461 // Disallow extensions with native code plugins. |
465 // | 462 // |
466 // TODO(akalin): Relax this restriction once we've put in UI to | 463 // TODO(akalin): Relax this restriction once we've put in UI to |
467 // approve synced extensions. | 464 // approve synced extensions. |
468 if (PluginInfo::HasPlugins(this)) | 465 if (PluginInfo::HasPlugins(this)) |
469 return SYNC_TYPE_NONE; | 466 return SYNC_TYPE_NONE; |
470 | 467 |
471 switch (GetType()) { | 468 switch (GetType()) { |
472 case Manifest::TYPE_EXTENSION: | 469 case Manifest::TYPE_EXTENSION: |
473 return SYNC_TYPE_EXTENSION; | 470 return SYNC_TYPE_EXTENSION; |
474 | 471 |
475 case Manifest::TYPE_USER_SCRIPT: | 472 case Manifest::TYPE_USER_SCRIPT: |
476 // We only want to sync user scripts with gallery update URLs. | 473 // We only want to sync user scripts with gallery update URLs. |
477 if (UpdatesFromGallery()) | 474 if (ManifestURL::UpdatesFromGallery(this)) |
478 return SYNC_TYPE_EXTENSION; | 475 return SYNC_TYPE_EXTENSION; |
479 else | 476 else |
480 return SYNC_TYPE_NONE; | 477 return SYNC_TYPE_NONE; |
481 | 478 |
482 case Manifest::TYPE_HOSTED_APP: | 479 case Manifest::TYPE_HOSTED_APP: |
483 case Manifest::TYPE_LEGACY_PACKAGED_APP: | 480 case Manifest::TYPE_LEGACY_PACKAGED_APP: |
484 case Manifest::TYPE_PLATFORM_APP: | 481 case Manifest::TYPE_PLATFORM_APP: |
485 return SYNC_TYPE_APP; | 482 return SYNC_TYPE_APP; |
486 | 483 |
487 default: | 484 default: |
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1179 | 1176 |
1180 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( | 1177 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( |
1181 const Extension* extension, | 1178 const Extension* extension, |
1182 const PermissionSet* permissions, | 1179 const PermissionSet* permissions, |
1183 Reason reason) | 1180 Reason reason) |
1184 : reason(reason), | 1181 : reason(reason), |
1185 extension(extension), | 1182 extension(extension), |
1186 permissions(permissions) {} | 1183 permissions(permissions) {} |
1187 | 1184 |
1188 } // namespace extensions | 1185 } // namespace extensions |
OLD | NEW |