OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
26 #include "chrome/common/extensions/extension_action.h" | 26 #include "chrome/common/extensions/extension_action.h" |
27 #include "chrome/common/extensions/extension_constants.h" | 27 #include "chrome/common/extensions/extension_constants.h" |
28 #include "chrome/common/extensions/extension_error_utils.h" | 28 #include "chrome/common/extensions/extension_error_utils.h" |
29 #include "chrome/common/extensions/extension_l10n_util.h" | 29 #include "chrome/common/extensions/extension_l10n_util.h" |
30 #include "chrome/common/extensions/extension_resource.h" | 30 #include "chrome/common/extensions/extension_resource.h" |
31 #include "chrome/common/extensions/user_script.h" | 31 #include "chrome/common/extensions/user_script.h" |
32 #include "chrome/common/notification_service.h" | 32 #include "chrome/common/notification_service.h" |
33 #include "chrome/common/url_constants.h" | 33 #include "chrome/common/url_constants.h" |
34 #include "grit/chromium_strings.h" | 34 #include "grit/chromium_strings.h" |
| 35 #include "grit/generated_resources.h" |
35 #include "webkit/glue/image_decoder.h" | 36 #include "webkit/glue/image_decoder.h" |
36 | 37 |
37 #if defined(OS_WIN) | 38 #if defined(OS_WIN) |
38 #include "base/registry.h" | 39 #include "base/registry.h" |
39 #endif | 40 #endif |
40 | 41 |
41 namespace keys = extension_manifest_keys; | 42 namespace keys = extension_manifest_keys; |
42 namespace values = extension_manifest_values; | 43 namespace values = extension_manifest_values; |
43 namespace errors = extension_manifest_errors; | 44 namespace errors = extension_manifest_errors; |
44 | 45 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 Extension::kExperimentalPermission, | 140 Extension::kExperimentalPermission, |
140 Extension::kGeolocationPermission, | 141 Extension::kGeolocationPermission, |
141 Extension::kHistoryPermission, | 142 Extension::kHistoryPermission, |
142 Extension::kNotificationPermission, | 143 Extension::kNotificationPermission, |
143 Extension::kTabPermission, | 144 Extension::kTabPermission, |
144 Extension::kUnlimitedStoragePermission, | 145 Extension::kUnlimitedStoragePermission, |
145 }; | 146 }; |
146 const size_t Extension::kNumPermissions = | 147 const size_t Extension::kNumPermissions = |
147 arraysize(Extension::kPermissionNames); | 148 arraysize(Extension::kPermissionNames); |
148 | 149 |
| 150 const Extension::SimplePermissions& Extension::GetSimplePermissions() { |
| 151 static SimplePermissions permissions; |
| 152 if (permissions.empty()) { |
| 153 permissions[Extension::kBookmarkPermission] = |
| 154 l10n_util::GetStringUTF16( |
| 155 IDS_EXTENSION_PROMPT2_WARNING_BOOKMARKS); |
| 156 permissions[Extension::kGeolocationPermission] = |
| 157 l10n_util::GetStringUTF16( |
| 158 IDS_EXTENSION_PROMPT2_WARNING_GEOLOCATION); |
| 159 } |
| 160 return permissions; |
| 161 } |
| 162 |
149 Extension::~Extension() { | 163 Extension::~Extension() { |
150 } | 164 } |
151 | 165 |
152 const std::string Extension::VersionString() const { | 166 const std::string Extension::VersionString() const { |
153 return version_->GetString(); | 167 return version_->GetString(); |
154 } | 168 } |
155 | 169 |
156 // static | 170 // static |
157 bool Extension::IsExtension(const FilePath& file_name) { | 171 bool Extension::IsExtension(const FilePath& file_name) { |
158 return file_name.MatchesExtension( | 172 return file_name.MatchesExtension( |
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 | 881 |
868 std::set<std::string> difference; | 882 std::set<std::string> difference; |
869 std::set_difference(new_hosts.begin(), new_hosts.end(), | 883 std::set_difference(new_hosts.begin(), new_hosts.end(), |
870 old_hosts.begin(), old_hosts.end(), | 884 old_hosts.begin(), old_hosts.end(), |
871 std::insert_iterator<std::set<std::string> >( | 885 std::insert_iterator<std::set<std::string> >( |
872 difference, difference.end())); | 886 difference, difference.end())); |
873 if (difference.size() > 0) | 887 if (difference.size() > 0) |
874 return true; | 888 return true; |
875 } | 889 } |
876 | 890 |
877 // If we're going from not having history to not having it, it's an increase. | |
878 if (!old_extension->HasEffectiveBrowsingHistoryPermission() && | 891 if (!old_extension->HasEffectiveBrowsingHistoryPermission() && |
879 new_extension->HasEffectiveBrowsingHistoryPermission()) { | 892 new_extension->HasEffectiveBrowsingHistoryPermission()) { |
880 return true; | 893 return true; |
881 } | 894 } |
882 | 895 |
| 896 const SimplePermissions& simple_permissions = GetSimplePermissions(); |
| 897 for (SimplePermissions::const_iterator iter = simple_permissions.begin(); |
| 898 iter != simple_permissions.end(); ++iter) { |
| 899 if (!old_extension->HasApiPermission(iter->first) && |
| 900 new_extension->HasApiPermission(iter->first)) { |
| 901 return true; |
| 902 } |
| 903 } |
| 904 |
883 // Nothing much has changed. | 905 // Nothing much has changed. |
884 return false; | 906 return false; |
885 } | 907 } |
886 | 908 |
887 // static | 909 // static |
888 bool Extension::HasEffectiveBrowsingHistoryPermission() const { | 910 bool Extension::HasEffectiveBrowsingHistoryPermission() const { |
889 return HasApiPermission(kTabPermission) || | 911 return HasApiPermission(kTabPermission) || |
890 HasApiPermission(kBookmarkPermission); | 912 HasApiPermission(kBookmarkPermission); |
891 } | 913 } |
892 | 914 |
(...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1741 } else { | 1763 } else { |
1742 return false; | 1764 return false; |
1743 } | 1765 } |
1744 } else { | 1766 } else { |
1745 return true; | 1767 return true; |
1746 } | 1768 } |
1747 } | 1769 } |
1748 } | 1770 } |
1749 return false; | 1771 return false; |
1750 } | 1772 } |
OLD | NEW |