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

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 1911 matching lines...) Expand 10 before | Expand all | Expand 10 after
1922 *error = ExtensionErrorUtils::FormatErrorMessage( 1922 *error = ExtensionErrorUtils::FormatErrorMessage(
1923 errors::kInvalidPermission, base::IntToString(i)); 1923 errors::kInvalidPermission, base::IntToString(i));
1924 return false; 1924 return false;
1925 } 1925 }
1926 1926
1927 // Only COMPONENT extensions can use the webstorePrivate and 1927 // Only COMPONENT extensions can use the webstorePrivate and
1928 // fileBrowserPrivate APIs. 1928 // fileBrowserPrivate APIs.
1929 // TODO(asargent) - We want a more general purpose mechanism for this, 1929 // TODO(asargent) - We want a more general purpose mechanism for this,
1930 // and better error messages. (http://crbug.com/54013) 1930 // and better error messages. (http://crbug.com/54013)
1931 if ((permission_str == kWebstorePrivatePermission || 1931 if ((permission_str == kWebstorePrivatePermission ||
1932 permission_str == kChromeosInfoPrivatePermissions ||
1932 permission_str == kFileBrowserPrivatePermission) && 1933 permission_str == kFileBrowserPrivatePermission) &&
1933 location_ != Extension::COMPONENT) { 1934 (location_ != Extension::COMPONENT
1934 continue; 1935 #ifndef NDEBUG
1935 } 1936 && !CommandLine::ForCurrentProcess()->HasSwitch(
1936 1937 switches::kExposePrivateExtensionApi)
1937 if (permission_str == kChromeosInfoPrivatePermissions && 1938 #endif
1938 location_ != Extension::COMPONENT) { 1939 )) {
1939 continue; 1940 continue;
1940 } 1941 }
1941 1942
1942 // Remap the old unlimited storage permission name. 1943 // Remap the old unlimited storage permission name.
1943 if (permission_str == kOldUnlimitedStoragePermission) 1944 if (permission_str == kOldUnlimitedStoragePermission)
1944 permission_str = kUnlimitedStoragePermission; 1945 permission_str = kUnlimitedStoragePermission;
1945 1946
1946 if (web_extent().is_empty() || location() == Extension::COMPONENT) { 1947 if (web_extent().is_empty() || location() == Extension::COMPONENT) {
1947 // Check if it's a module permission. If so, enable that permission. 1948 // Check if it's a module permission. If so, enable that permission.
1948 if (IsAPIPermission(permission_str)) { 1949 if (IsAPIPermission(permission_str)) {
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
2512 bool Extension::IsAPIPermission(const std::string& str) const { 2513 bool Extension::IsAPIPermission(const std::string& str) const {
2513 for (size_t i = 0; i < Extension::kNumPermissions; ++i) { 2514 for (size_t i = 0; i < Extension::kNumPermissions; ++i) {
2514 if (str == Extension::kPermissions[i].name) { 2515 if (str == Extension::kPermissions[i].name) {
2515 return true; 2516 return true;
2516 } 2517 }
2517 } 2518 }
2518 return false; 2519 return false;
2519 } 2520 }
2520 2521
2521 bool Extension::CanExecuteScriptEverywhere() const { 2522 bool Extension::CanExecuteScriptEverywhere() const {
2522 if (location() == Extension::COMPONENT) 2523 if (location() == Extension::COMPONENT
2524 #ifndef NDEBUG
2525 || CommandLine::ForCurrentProcess()->HasSwitch(
2526 switches::kExposePrivateExtensionApi)
2527 #endif
2528 )
2523 return true; 2529 return true;
2524 2530
2525 ScriptingWhitelist* whitelist = 2531 ScriptingWhitelist* whitelist =
2526 ExtensionConfig::GetInstance()->whitelist(); 2532 ExtensionConfig::GetInstance()->whitelist();
2527 2533
2528 for (ScriptingWhitelist::const_iterator it = whitelist->begin(); 2534 for (ScriptingWhitelist::const_iterator it = whitelist->begin();
2529 it != whitelist->end(); ++it) { 2535 it != whitelist->end(); ++it) {
2530 if (id() == *it) { 2536 if (id() == *it) {
2531 return true; 2537 return true;
2532 } 2538 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2594 2600
2595 UninstalledExtensionInfo::~UninstalledExtensionInfo() {} 2601 UninstalledExtensionInfo::~UninstalledExtensionInfo() {}
2596 2602
2597 2603
2598 UnloadedExtensionInfo::UnloadedExtensionInfo( 2604 UnloadedExtensionInfo::UnloadedExtensionInfo(
2599 const Extension* extension, 2605 const Extension* extension,
2600 Reason reason) 2606 Reason reason)
2601 : reason(reason), 2607 : reason(reason),
2602 already_disabled(false), 2608 already_disabled(false),
2603 extension(extension) {} 2609 extension(extension) {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698