Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Side by Side Diff: chrome/common/extensions/extension.cc

Issue 6749021: Added new fileBrowserPrivate and fileHandler extension APIs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 1919 matching lines...) Expand 10 before | Expand all | Expand 10 after
1930 std::string permission_str; 1930 std::string permission_str;
1931 if (!permissions->GetString(i, &permission_str)) { 1931 if (!permissions->GetString(i, &permission_str)) {
1932 *error = ExtensionErrorUtils::FormatErrorMessage( 1932 *error = ExtensionErrorUtils::FormatErrorMessage(
1933 errors::kInvalidPermission, base::IntToString(i)); 1933 errors::kInvalidPermission, base::IntToString(i));
1934 return false; 1934 return false;
1935 } 1935 }
1936 1936
1937 // Only COMPONENT extensions can use private APIs. 1937 // Only COMPONENT extensions can use private APIs.
1938 // TODO(asargent) - We want a more general purpose mechanism for this, 1938 // TODO(asargent) - We want a more general purpose mechanism for this,
1939 // and better error messages. (http://crbug.com/54013) 1939 // and better error messages. (http://crbug.com/54013)
1940 if (!IsComponentOnlyPermission(permission_str)) { 1940 if (!IsComponentOnlyPermission(permission_str)
1941 #ifndef NDEBUG
1942 && !CommandLine::ForCurrentProcess()->HasSwitch(
1943 switches::kExposePrivateExtensionApi)
1944 #endif
1945 ) {
1941 continue; 1946 continue;
1942 } 1947 }
1943 1948
1944 // Remap the old unlimited storage permission name. 1949 // Remap the old unlimited storage permission name.
1945 if (permission_str == kOldUnlimitedStoragePermission) 1950 if (permission_str == kOldUnlimitedStoragePermission)
1946 permission_str = kUnlimitedStoragePermission; 1951 permission_str = kUnlimitedStoragePermission;
1947 1952
1948 if (web_extent().is_empty() || location() == Extension::COMPONENT) { 1953 if (web_extent().is_empty() || location() == Extension::COMPONENT) {
1949 // Check if it's a module permission. If so, enable that permission. 1954 // Check if it's a module permission. If so, enable that permission.
1950 if (IsAPIPermission(permission_str)) { 1955 if (IsAPIPermission(permission_str)) {
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
2527 bool Extension::IsAPIPermission(const std::string& str) const { 2532 bool Extension::IsAPIPermission(const std::string& str) const {
2528 for (size_t i = 0; i < Extension::kNumPermissions; ++i) { 2533 for (size_t i = 0; i < Extension::kNumPermissions; ++i) {
2529 if (str == Extension::kPermissions[i].name) { 2534 if (str == Extension::kPermissions[i].name) {
2530 return true; 2535 return true;
2531 } 2536 }
2532 } 2537 }
2533 return false; 2538 return false;
2534 } 2539 }
2535 2540
2536 bool Extension::CanExecuteScriptEverywhere() const { 2541 bool Extension::CanExecuteScriptEverywhere() const {
2537 if (location() == Extension::COMPONENT) 2542 if (location() == Extension::COMPONENT
2543 #ifndef NDEBUG
2544 || CommandLine::ForCurrentProcess()->HasSwitch(
2545 switches::kExposePrivateExtensionApi)
2546 #endif
2547 )
2538 return true; 2548 return true;
2539 2549
2540 ScriptingWhitelist* whitelist = 2550 ScriptingWhitelist* whitelist =
2541 ExtensionConfig::GetInstance()->whitelist(); 2551 ExtensionConfig::GetInstance()->whitelist();
2542 2552
2543 for (ScriptingWhitelist::const_iterator it = whitelist->begin(); 2553 for (ScriptingWhitelist::const_iterator it = whitelist->begin();
2544 it != whitelist->end(); ++it) { 2554 it != whitelist->end(); ++it) {
2545 if (id() == *it) { 2555 if (id() == *it) {
2546 return true; 2556 return true;
2547 } 2557 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2609 2619
2610 UninstalledExtensionInfo::~UninstalledExtensionInfo() {} 2620 UninstalledExtensionInfo::~UninstalledExtensionInfo() {}
2611 2621
2612 2622
2613 UnloadedExtensionInfo::UnloadedExtensionInfo( 2623 UnloadedExtensionInfo::UnloadedExtensionInfo(
2614 const Extension* extension, 2624 const Extension* extension,
2615 Reason reason) 2625 Reason reason)
2616 : reason(reason), 2626 : reason(reason),
2617 already_disabled(false), 2627 already_disabled(false),
2618 extension(extension) {} 2628 extension(extension) {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698