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 2691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2702 return true; | 2702 return true; |
2703 } | 2703 } |
2704 } | 2704 } |
2705 | 2705 |
2706 return false; | 2706 return false; |
2707 } | 2707 } |
2708 | 2708 |
2709 bool Extension::HasHostPermission(const GURL& url) const { | 2709 bool Extension::HasHostPermission(const GURL& url) const { |
2710 for (URLPatternList::const_iterator host = host_permissions().begin(); | 2710 for (URLPatternList::const_iterator host = host_permissions().begin(); |
2711 host != host_permissions().end(); ++host) { | 2711 host != host_permissions().end(); ++host) { |
| 2712 // Non-component extensions can only access chrome://favicon and no other |
| 2713 // chrome:// scheme urls. |
| 2714 if (url.SchemeIs(chrome::kChromeUIScheme) && |
| 2715 url.host() != chrome::kChromeUIFaviconHost && |
| 2716 location() != Extension::COMPONENT) |
| 2717 return false; |
| 2718 |
2712 if (host->MatchesUrl(url)) | 2719 if (host->MatchesUrl(url)) |
2713 return true; | 2720 return true; |
2714 } | 2721 } |
2715 return false; | 2722 return false; |
2716 } | 2723 } |
2717 | 2724 |
2718 void Extension::InitEffectiveHostPermissions() { | 2725 void Extension::InitEffectiveHostPermissions() { |
2719 // Some APIs effectively grant access to every site. New ones should be | 2726 // Some APIs effectively grant access to every site. New ones should be |
2720 // added here. (I'm looking at you, network API) | 2727 // added here. (I'm looking at you, network API) |
2721 if (HasApiPermission(api_permissions_, kProxyPermission) || | 2728 if (HasApiPermission(api_permissions_, kProxyPermission) || |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2778 // against the store app extent? | 2785 // against the store app extent? |
2779 if ((page_url.host() == GURL(Extension::ChromeStoreLaunchURL()).host()) && | 2786 if ((page_url.host() == GURL(Extension::ChromeStoreLaunchURL()).host()) && |
2780 !CanExecuteScriptEverywhere() && | 2787 !CanExecuteScriptEverywhere() && |
2781 !CommandLine::ForCurrentProcess()->HasSwitch( | 2788 !CommandLine::ForCurrentProcess()->HasSwitch( |
2782 switches::kAllowScriptingGallery)) { | 2789 switches::kAllowScriptingGallery)) { |
2783 if (error) | 2790 if (error) |
2784 *error = errors::kCannotScriptGallery; | 2791 *error = errors::kCannotScriptGallery; |
2785 return false; | 2792 return false; |
2786 } | 2793 } |
2787 | 2794 |
| 2795 if (page_url.SchemeIs(chrome::kChromeUIScheme) && |
| 2796 !CanExecuteScriptEverywhere()) |
| 2797 return false; |
| 2798 |
2788 // If a script is specified, use its matches. | 2799 // If a script is specified, use its matches. |
2789 if (script) | 2800 if (script) |
2790 return script->MatchesUrl(page_url); | 2801 return script->MatchesUrl(page_url); |
2791 | 2802 |
2792 // Otherwise, see if this extension has permission to execute script | 2803 // Otherwise, see if this extension has permission to execute script |
2793 // programmatically on pages. | 2804 // programmatically on pages. |
2794 for (size_t i = 0; i < host_permissions_.size(); ++i) { | 2805 for (size_t i = 0; i < host_permissions_.size(); ++i) { |
2795 if (host_permissions_[i].MatchesUrl(page_url)) | 2806 if (host_permissions_[i].MatchesUrl(page_url)) |
2796 return true; | 2807 return true; |
2797 } | 2808 } |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2926 | 2937 |
2927 UninstalledExtensionInfo::~UninstalledExtensionInfo() {} | 2938 UninstalledExtensionInfo::~UninstalledExtensionInfo() {} |
2928 | 2939 |
2929 | 2940 |
2930 UnloadedExtensionInfo::UnloadedExtensionInfo( | 2941 UnloadedExtensionInfo::UnloadedExtensionInfo( |
2931 const Extension* extension, | 2942 const Extension* extension, |
2932 Reason reason) | 2943 Reason reason) |
2933 : reason(reason), | 2944 : reason(reason), |
2934 already_disabled(false), | 2945 already_disabled(false), |
2935 extension(extension) {} | 2946 extension(extension) {} |
OLD | NEW |