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 "base/base64.h" | 10 #include "base/base64.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 const char* kNonPermissionFunctionNames[] = { | 126 const char* kNonPermissionFunctionNames[] = { |
127 "tabs.create", | 127 "tabs.create", |
128 "tabs.update" | 128 "tabs.update" |
129 }; | 129 }; |
130 const size_t kNumNonPermissionFunctionNames = | 130 const size_t kNumNonPermissionFunctionNames = |
131 arraysize(kNonPermissionFunctionNames); | 131 arraysize(kNonPermissionFunctionNames); |
132 | 132 |
133 // A singleton object containing global data needed by the extension objects. | 133 // A singleton object containing global data needed by the extension objects. |
134 class ExtensionConfig { | 134 class ExtensionConfig { |
135 public: | 135 public: |
136 static ExtensionConfig* GetSingleton() { | 136 static ExtensionConfig* GetInstance() { |
137 return Singleton<ExtensionConfig>::get(); | 137 return Singleton<ExtensionConfig>::get(); |
138 } | 138 } |
139 | 139 |
140 int GetPermissionMessageId(const std::string& permission) { | 140 int GetPermissionMessageId(const std::string& permission) { |
141 return Extension::kPermissions[permission_map_[permission]].message_id; | 141 return Extension::kPermissions[permission_map_[permission]].message_id; |
142 } | 142 } |
143 | 143 |
144 Extension::ScriptingWhitelist* whitelist() { return &scripting_whitelist_; } | 144 Extension::ScriptingWhitelist* whitelist() { return &scripting_whitelist_; } |
145 | 145 |
146 private: | 146 private: |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 GURL Extension::GalleryUpdateUrl(bool secure) { | 281 GURL Extension::GalleryUpdateUrl(bool secure) { |
282 CommandLine* cmdline = CommandLine::ForCurrentProcess(); | 282 CommandLine* cmdline = CommandLine::ForCurrentProcess(); |
283 if (cmdline->HasSwitch(switches::kAppsGalleryUpdateURL)) | 283 if (cmdline->HasSwitch(switches::kAppsGalleryUpdateURL)) |
284 return GURL(cmdline->GetSwitchValueASCII(switches::kAppsGalleryUpdateURL)); | 284 return GURL(cmdline->GetSwitchValueASCII(switches::kAppsGalleryUpdateURL)); |
285 else | 285 else |
286 return GURL(secure ? kGalleryUpdateHttpsUrl : kGalleryUpdateHttpUrl); | 286 return GURL(secure ? kGalleryUpdateHttpsUrl : kGalleryUpdateHttpUrl); |
287 } | 287 } |
288 | 288 |
289 // static | 289 // static |
290 int Extension::GetPermissionMessageId(const std::string& permission) { | 290 int Extension::GetPermissionMessageId(const std::string& permission) { |
291 return ExtensionConfig::GetSingleton()->GetPermissionMessageId(permission); | 291 return ExtensionConfig::GetInstance()->GetPermissionMessageId(permission); |
292 } | 292 } |
293 | 293 |
294 std::vector<string16> Extension::GetPermissionMessages() const { | 294 std::vector<string16> Extension::GetPermissionMessages() const { |
295 std::vector<string16> messages; | 295 std::vector<string16> messages; |
296 if (!plugins().empty()) { | 296 if (!plugins().empty()) { |
297 messages.push_back( | 297 messages.push_back( |
298 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_FULL_ACCESS)); | 298 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_FULL_ACCESS)); |
299 return messages; | 299 return messages; |
300 } | 300 } |
301 | 301 |
(...skipping 1666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1968 | 1968 |
1969 static std::string SizeToString(const gfx::Size& max_size) { | 1969 static std::string SizeToString(const gfx::Size& max_size) { |
1970 return base::IntToString(max_size.width()) + "x" + | 1970 return base::IntToString(max_size.width()) + "x" + |
1971 base::IntToString(max_size.height()); | 1971 base::IntToString(max_size.height()); |
1972 } | 1972 } |
1973 | 1973 |
1974 // static | 1974 // static |
1975 void Extension::SetScriptingWhitelist( | 1975 void Extension::SetScriptingWhitelist( |
1976 const std::vector<std::string>& whitelist) { | 1976 const std::vector<std::string>& whitelist) { |
1977 ScriptingWhitelist* current_whitelist = | 1977 ScriptingWhitelist* current_whitelist = |
1978 ExtensionConfig::GetSingleton()->whitelist(); | 1978 ExtensionConfig::GetInstance()->whitelist(); |
1979 current_whitelist->clear(); | 1979 current_whitelist->clear(); |
1980 for (ScriptingWhitelist::const_iterator it = whitelist.begin(); | 1980 for (ScriptingWhitelist::const_iterator it = whitelist.begin(); |
1981 it != whitelist.end(); ++it) { | 1981 it != whitelist.end(); ++it) { |
1982 current_whitelist->push_back(*it); | 1982 current_whitelist->push_back(*it); |
1983 } | 1983 } |
1984 } | 1984 } |
1985 | 1985 |
1986 void Extension::SetCachedImage(const ExtensionResource& source, | 1986 void Extension::SetCachedImage(const ExtensionResource& source, |
1987 const SkBitmap& image, | 1987 const SkBitmap& image, |
1988 const gfx::Size& original_size) const { | 1988 const gfx::Size& original_size) const { |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2214 } | 2214 } |
2215 } | 2215 } |
2216 return false; | 2216 return false; |
2217 } | 2217 } |
2218 | 2218 |
2219 bool Extension::CanExecuteScriptEverywhere() const { | 2219 bool Extension::CanExecuteScriptEverywhere() const { |
2220 if (location() == Extension::COMPONENT) | 2220 if (location() == Extension::COMPONENT) |
2221 return true; | 2221 return true; |
2222 | 2222 |
2223 ScriptingWhitelist* whitelist = | 2223 ScriptingWhitelist* whitelist = |
2224 ExtensionConfig::GetSingleton()->whitelist(); | 2224 ExtensionConfig::GetInstance()->whitelist(); |
2225 | 2225 |
2226 for (ScriptingWhitelist::const_iterator it = whitelist->begin(); | 2226 for (ScriptingWhitelist::const_iterator it = whitelist->begin(); |
2227 it != whitelist->end(); ++it) { | 2227 it != whitelist->end(); ++it) { |
2228 if (id() == *it) { | 2228 if (id() == *it) { |
2229 return true; | 2229 return true; |
2230 } | 2230 } |
2231 } | 2231 } |
2232 | 2232 |
2233 return false; | 2233 return false; |
2234 } | 2234 } |
(...skipping 20 matching lines...) Expand all Loading... |
2255 UninstalledExtensionInfo::UninstalledExtensionInfo( | 2255 UninstalledExtensionInfo::UninstalledExtensionInfo( |
2256 const Extension& extension) | 2256 const Extension& extension) |
2257 : extension_id(extension.id()), | 2257 : extension_id(extension.id()), |
2258 extension_api_permissions(extension.api_permissions()), | 2258 extension_api_permissions(extension.api_permissions()), |
2259 is_theme(extension.is_theme()), | 2259 is_theme(extension.is_theme()), |
2260 is_app(extension.is_app()), | 2260 is_app(extension.is_app()), |
2261 converted_from_user_script(extension.converted_from_user_script()), | 2261 converted_from_user_script(extension.converted_from_user_script()), |
2262 update_url(extension.update_url()) {} | 2262 update_url(extension.update_url()) {} |
2263 | 2263 |
2264 UninstalledExtensionInfo::~UninstalledExtensionInfo() {} | 2264 UninstalledExtensionInfo::~UninstalledExtensionInfo() {} |
OLD | NEW |