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 1901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1912 *error = ExtensionErrorUtils::FormatErrorMessage( | 1912 *error = ExtensionErrorUtils::FormatErrorMessage( |
1913 errors::kInvalidPermission, base::IntToString(i)); | 1913 errors::kInvalidPermission, base::IntToString(i)); |
1914 return false; | 1914 return false; |
1915 } | 1915 } |
1916 | 1916 |
1917 // Only COMPONENT extensions can use the webstorePrivate and | 1917 // Only COMPONENT extensions can use the webstorePrivate and |
1918 // fileBrowserPrivate APIs. | 1918 // fileBrowserPrivate APIs. |
1919 // TODO(asargent) - We want a more general purpose mechanism for this, | 1919 // TODO(asargent) - We want a more general purpose mechanism for this, |
1920 // and better error messages. (http://crbug.com/54013) | 1920 // and better error messages. (http://crbug.com/54013) |
1921 if ((permission_str == kWebstorePrivatePermission || | 1921 if ((permission_str == kWebstorePrivatePermission || |
| 1922 permission_str == kChromeosInfoPrivatePermissions || |
1922 permission_str == kFileBrowserPrivatePermission) && | 1923 permission_str == kFileBrowserPrivatePermission) && |
1923 location_ != Extension::COMPONENT) { | 1924 (location_ != Extension::COMPONENT |
1924 continue; | 1925 #ifndef NDEBUG |
1925 } | 1926 && !CommandLine::ForCurrentProcess()->HasSwitch( |
1926 | 1927 switches::kExposePrivateExtensionApi) |
1927 if (permission_str == kChromeosInfoPrivatePermissions && | 1928 #endif |
1928 location_ != Extension::COMPONENT) { | 1929 )) { |
1929 continue; | 1930 continue; |
1930 } | 1931 } |
1931 | 1932 |
1932 // Remap the old unlimited storage permission name. | 1933 // Remap the old unlimited storage permission name. |
1933 if (permission_str == kOldUnlimitedStoragePermission) | 1934 if (permission_str == kOldUnlimitedStoragePermission) |
1934 permission_str = kUnlimitedStoragePermission; | 1935 permission_str = kUnlimitedStoragePermission; |
1935 | 1936 |
1936 if (web_extent().is_empty() || location() == Extension::COMPONENT) { | 1937 if (web_extent().is_empty() || location() == Extension::COMPONENT) { |
1937 // Check if it's a module permission. If so, enable that permission. | 1938 // Check if it's a module permission. If so, enable that permission. |
1938 if (IsAPIPermission(permission_str)) { | 1939 if (IsAPIPermission(permission_str)) { |
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2502 bool Extension::IsAPIPermission(const std::string& str) const { | 2503 bool Extension::IsAPIPermission(const std::string& str) const { |
2503 for (size_t i = 0; i < Extension::kNumPermissions; ++i) { | 2504 for (size_t i = 0; i < Extension::kNumPermissions; ++i) { |
2504 if (str == Extension::kPermissions[i].name) { | 2505 if (str == Extension::kPermissions[i].name) { |
2505 return true; | 2506 return true; |
2506 } | 2507 } |
2507 } | 2508 } |
2508 return false; | 2509 return false; |
2509 } | 2510 } |
2510 | 2511 |
2511 bool Extension::CanExecuteScriptEverywhere() const { | 2512 bool Extension::CanExecuteScriptEverywhere() const { |
2512 if (location() == Extension::COMPONENT) | 2513 if (location() == Extension::COMPONENT |
| 2514 #ifndef NDEBUG |
| 2515 || CommandLine::ForCurrentProcess()->HasSwitch( |
| 2516 switches::kExposePrivateExtensionApi) |
| 2517 #endif |
| 2518 ) |
2513 return true; | 2519 return true; |
2514 | 2520 |
2515 ScriptingWhitelist* whitelist = | 2521 ScriptingWhitelist* whitelist = |
2516 ExtensionConfig::GetInstance()->whitelist(); | 2522 ExtensionConfig::GetInstance()->whitelist(); |
2517 | 2523 |
2518 for (ScriptingWhitelist::const_iterator it = whitelist->begin(); | 2524 for (ScriptingWhitelist::const_iterator it = whitelist->begin(); |
2519 it != whitelist->end(); ++it) { | 2525 it != whitelist->end(); ++it) { |
2520 if (id() == *it) { | 2526 if (id() == *it) { |
2521 return true; | 2527 return true; |
2522 } | 2528 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2584 | 2590 |
2585 UninstalledExtensionInfo::~UninstalledExtensionInfo() {} | 2591 UninstalledExtensionInfo::~UninstalledExtensionInfo() {} |
2586 | 2592 |
2587 | 2593 |
2588 UnloadedExtensionInfo::UnloadedExtensionInfo( | 2594 UnloadedExtensionInfo::UnloadedExtensionInfo( |
2589 const Extension* extension, | 2595 const Extension* extension, |
2590 Reason reason) | 2596 Reason reason) |
2591 : reason(reason), | 2597 : reason(reason), |
2592 already_disabled(false), | 2598 already_disabled(false), |
2593 extension(extension) {} | 2599 extension(extension) {} |
OLD | NEW |