summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/extensions/extension_file_browser_private_api.cc4
-rw-r--r--chrome/browser/extensions/extension_local_filesystem_apitest.cc3
-rw-r--r--chrome/browser/extensions/extension_service.cc8
-rw-r--r--chrome/browser/extensions/extension_special_storage_policy.cc39
-rw-r--r--chrome/browser/extensions/extension_special_storage_policy.h7
-rw-r--r--chrome/browser/extensions/extension_special_storage_policy_unittest.cc53
-rw-r--r--chrome/common/chrome_switches.cc4
-rw-r--r--chrome/common/chrome_switches.h1
-rw-r--r--chrome/common/extensions/extension.cc2
-rw-r--r--chrome/common/extensions/extension.h1
-rw-r--r--chrome/common/extensions/extension_unittest.cc4
-rw-r--r--chrome/renderer/extensions/extension_process_bindings.cc2
12 files changed, 104 insertions, 24 deletions
diff --git a/chrome/browser/extensions/extension_file_browser_private_api.cc b/chrome/browser/extensions/extension_file_browser_private_api.cc
index 62a488b..448b8e2 100644
--- a/chrome/browser/extensions/extension_file_browser_private_api.cc
+++ b/chrome/browser/extensions/extension_file_browser_private_api.cc
@@ -79,7 +79,7 @@ bool RequestLocalFileSystemFunction::RunImpl() {
profile()->GetFileSystemContext(),
NULL);
GURL origin_url = source_url().GetOrigin();
- operation->OpenFileSystem(origin_url, fileapi::kFileSystemTypeLocal,
+ operation->OpenFileSystem(origin_url, fileapi::kFileSystemTypeExternal,
false); // create
// Will finish asynchronously.
return true;
@@ -171,7 +171,7 @@ void FileDialogFunction::GetLocalPathsOnFileThread() {
std::string virtual_path = virtual_paths_[i];
FilePath root = path_manager->GetFileSystemRootPathOnFileThread(
origin_url,
- fileapi::kFileSystemTypeLocal,
+ fileapi::kFileSystemTypeExternal,
FilePath(virtual_path),
false);
if (!root.empty()) {
diff --git a/chrome/browser/extensions/extension_local_filesystem_apitest.cc b/chrome/browser/extensions/extension_local_filesystem_apitest.cc
index 003e56a..5a8ba72 100644
--- a/chrome/browser/extensions/extension_local_filesystem_apitest.cc
+++ b/chrome/browser/extensions/extension_local_filesystem_apitest.cc
@@ -6,7 +6,8 @@
#if defined(OS_CHROMEOS)
-IN_PROC_BROWSER_TEST_F(ExtensionApiTest, LocalFileSystem) {
+// TODO(zelidrag): Remove disable prefix on this test once API changes land.
+IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_LocalFileSystem) {
ASSERT_TRUE(RunComponentExtensionTest("local_filesystem")) << message_;
}
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index 1c68cf0..7dcba6e 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -76,6 +76,9 @@
#if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/extensions/file_browser_event_router.h"
+#include "webkit/fileapi/file_system_context.h"
+#include "webkit/fileapi/file_system_mount_point_provider.h"
+#include "webkit/fileapi/file_system_path_manager.h"
#endif
using base::Time;
@@ -1081,6 +1084,11 @@ void ExtensionService::NotifyExtensionUnloaded(
profile_->UnregisterExtensionWithRequestContexts(extension);
profile_->GetExtensionSpecialStoragePolicy()->
RevokeRightsForExtension(extension);
+#if defined(OS_CHROMEOS)
+ // Revoke external file access to
+ profile_->GetFileSystemContext()->path_manager()->external_provider()->
+ RevokeAccessForExtension(extension->id());
+#endif
}
bool plugins_changed = false;
diff --git a/chrome/browser/extensions/extension_special_storage_policy.cc b/chrome/browser/extensions/extension_special_storage_policy.cc
index 90f32fa..fd3ccc4 100644
--- a/chrome/browser/extensions/extension_special_storage_policy.cc
+++ b/chrome/browser/extensions/extension_special_storage_policy.cc
@@ -24,10 +24,10 @@ bool ExtensionSpecialStoragePolicy::IsStorageUnlimited(const GURL& origin) {
return unlimited_extensions_.Contains(origin);
}
-bool ExtensionSpecialStoragePolicy::IsLocalFileSystemAccessAllowed(
- const GURL& origin) {
+bool ExtensionSpecialStoragePolicy::IsFileHandler(
+ const std::string& extension_id) {
base::AutoLock locker(lock_);
- return local_filesystem_extensions_.Contains(origin);
+ return file_handler_extensions_.ContainsExtension(extension_id);
}
void ExtensionSpecialStoragePolicy::GrantRightsForExtension(
@@ -35,7 +35,7 @@ void ExtensionSpecialStoragePolicy::GrantRightsForExtension(
DCHECK(extension);
if (!extension->is_hosted_app() &&
!extension->HasApiPermission(Extension::kUnlimitedStoragePermission) &&
- !extension->HasApiPermission(Extension::kFileSystemPermission)) {
+ !extension->HasApiPermission(Extension::kFileBrowserHandlerPermission)) {
return;
}
base::AutoLock locker(lock_);
@@ -43,8 +43,8 @@ void ExtensionSpecialStoragePolicy::GrantRightsForExtension(
protected_apps_.Add(extension);
if (extension->HasApiPermission(Extension::kUnlimitedStoragePermission))
unlimited_extensions_.Add(extension);
- if (extension->HasApiPermission(Extension::kFileSystemPermission))
- local_filesystem_extensions_.Add(extension);
+ if (extension->HasApiPermission(Extension::kFileBrowserHandlerPermission))
+ file_handler_extensions_.Add(extension);
}
void ExtensionSpecialStoragePolicy::RevokeRightsForExtension(
@@ -52,7 +52,7 @@ void ExtensionSpecialStoragePolicy::RevokeRightsForExtension(
DCHECK(extension);
if (!extension->is_hosted_app() &&
!extension->HasApiPermission(Extension::kUnlimitedStoragePermission) &&
- !extension->HasApiPermission(Extension::kFileSystemPermission)) {
+ !extension->HasApiPermission(Extension::kFileBrowserHandlerPermission)) {
return;
}
base::AutoLock locker(lock_);
@@ -60,15 +60,15 @@ void ExtensionSpecialStoragePolicy::RevokeRightsForExtension(
protected_apps_.Remove(extension);
if (extension->HasApiPermission(Extension::kUnlimitedStoragePermission))
unlimited_extensions_.Remove(extension);
- if (extension->HasApiPermission(Extension::kFileSystemPermission))
- local_filesystem_extensions_.Remove(extension);
+ if (extension->HasApiPermission(Extension::kFileBrowserHandlerPermission))
+ file_handler_extensions_.Remove(extension);
}
void ExtensionSpecialStoragePolicy::RevokeRightsForAllExtensions() {
base::AutoLock locker(lock_);
protected_apps_.Clear();
unlimited_extensions_.Clear();
- local_filesystem_extensions_.Clear();
+ file_handler_extensions_.Clear();
}
//-----------------------------------------------------------------------------
@@ -81,34 +81,39 @@ ExtensionSpecialStoragePolicy::SpecialCollection::~SpecialCollection() {}
bool ExtensionSpecialStoragePolicy::SpecialCollection::Contains(
const GURL& origin) {
- CachedResults::const_iterator found = cached_resuts_.find(origin);
- if (found != cached_resuts_.end())
+ CachedResults::const_iterator found = cached_results_.find(origin);
+ if (found != cached_results_.end())
return found->second;
for (Extensions::const_iterator iter = extensions_.begin();
iter != extensions_.end(); ++iter) {
if (iter->second->OverlapsWithOrigin(origin)) {
- cached_resuts_[origin] = true;
+ cached_results_[origin] = true;
return true;
}
}
- cached_resuts_[origin] = false;
+ cached_results_[origin] = false;
return false;
}
+bool ExtensionSpecialStoragePolicy::SpecialCollection::ContainsExtension(
+ const std::string& extension_id) {
+ return extensions_.find(extension_id) != extensions_.end();
+}
+
void ExtensionSpecialStoragePolicy::SpecialCollection::Add(
const Extension* extension) {
- cached_resuts_.clear();
+ cached_results_.clear();
extensions_[extension->id()] = extension;
}
void ExtensionSpecialStoragePolicy::SpecialCollection::Remove(
const Extension* extension) {
- cached_resuts_.clear();
+ cached_results_.clear();
extensions_.erase(extension->id());
}
void ExtensionSpecialStoragePolicy::SpecialCollection::Clear() {
- cached_resuts_.clear();
+ cached_results_.clear();
extensions_.clear();
}
diff --git a/chrome/browser/extensions/extension_special_storage_policy.h b/chrome/browser/extensions/extension_special_storage_policy.h
index 3a01a2e..478e271 100644
--- a/chrome/browser/extensions/extension_special_storage_policy.h
+++ b/chrome/browser/extensions/extension_special_storage_policy.h
@@ -26,7 +26,7 @@ class ExtensionSpecialStoragePolicy : public quota::SpecialStoragePolicy {
// data remover. These methods are safe to call on any thread.
virtual bool IsStorageProtected(const GURL& origin);
virtual bool IsStorageUnlimited(const GURL& origin);
- virtual bool IsLocalFileSystemAccessAllowed(const GURL& origin);
+ virtual bool IsFileHandler(const std::string& extension_id);
// Methods used by the ExtensionService to populate this class.
void GrantRightsForExtension(const Extension* extension);
@@ -40,6 +40,7 @@ class ExtensionSpecialStoragePolicy : public quota::SpecialStoragePolicy {
~SpecialCollection();
bool Contains(const GURL& origin);
+ bool ContainsExtension(const std::string& extension_id);
void Add(const Extension* extension);
void Remove(const Extension* extension);
void Clear();
@@ -48,7 +49,7 @@ class ExtensionSpecialStoragePolicy : public quota::SpecialStoragePolicy {
typedef std::map<GURL, bool> CachedResults;
typedef std::map<std::string, scoped_refptr<const Extension> > Extensions;
Extensions extensions_;
- CachedResults cached_resuts_;
+ CachedResults cached_results_;
};
virtual ~ExtensionSpecialStoragePolicy();
@@ -56,7 +57,7 @@ class ExtensionSpecialStoragePolicy : public quota::SpecialStoragePolicy {
base::Lock lock_; // Synchronize all access to the collections.
SpecialCollection protected_apps_;
SpecialCollection unlimited_extensions_;
- SpecialCollection local_filesystem_extensions_;
+ SpecialCollection file_handler_extensions_;
};
#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SPECIAL_STORAGE_POLICY_H_
diff --git a/chrome/browser/extensions/extension_special_storage_policy_unittest.cc b/chrome/browser/extensions/extension_special_storage_policy_unittest.cc
index 3f34ccf..cbaf6ed 100644
--- a/chrome/browser/extensions/extension_special_storage_policy_unittest.cc
+++ b/chrome/browser/extensions/extension_special_storage_policy_unittest.cc
@@ -58,6 +58,59 @@ class ExtensionSpecialStoragePolicyTest : public testing::Test {
EXPECT_TRUE(unlimited_app.get()) << error;
return unlimited_app;
}
+
+ scoped_refptr<Extension> CreateComponentApp() {
+#if defined(OS_WIN)
+ FilePath path(FILE_PATH_LITERAL("c:\\component"));
+#elif defined(OS_POSIX)
+ FilePath path(FILE_PATH_LITERAL("/component"));
+#endif
+ DictionaryValue manifest;
+ manifest.SetString(keys::kName, "Component");
+ manifest.SetString(keys::kVersion, "1");
+ manifest.SetString(keys::kPublicKey,
+ "MIGdMA0GCSqGSIb3DQEBAQUAA4GLADCBhwKBgQDOuXEIuoK1kAkBe0SKiJn/N9oNn3oU" \
+ "xGa4dwj40MnJqPn+w0aR2vuyocm0R4Drp67aYwtLjOVPF4CICRq6ICP6eU07gGwQxGdZ" \
+ "7HJASXV8hm0tab5I70oJmRLfFJyVAMCeWlFaOGq05v2i6EbifZM0qO5xALKNGQt+yjXi" \
+ "5INM5wIBIw==");
+ ListValue* list = new ListValue();
+ list->Append(Value::CreateStringValue("unlimitedStorage"));
+ list->Append(Value::CreateStringValue("fileSystem"));
+ list->Append(Value::CreateStringValue("fileBrowserPrivate"));
+ manifest.Set(keys::kPermissions, list);
+ std::string error;
+ scoped_refptr<Extension> component_app = Extension::Create(
+ path, Extension::COMPONENT, manifest, Extension::STRICT_ERROR_CHECKS,
+ &error);
+ EXPECT_TRUE(component_app.get()) << error;
+ return component_app;
+ }
+
+ scoped_refptr<Extension> CreateHandlerApp() {
+#if defined(OS_WIN)
+ FilePath path(FILE_PATH_LITERAL("c:\\handler"));
+#elif defined(OS_POSIX)
+ FilePath path(FILE_PATH_LITERAL("/handler"));
+#endif
+ DictionaryValue manifest;
+ manifest.SetString(keys::kName, "Handler");
+ manifest.SetString(keys::kVersion, "1");
+ manifest.SetString(keys::kPublicKey,
+ "MIGdMA0GCSqGSIb3DQEBAQUAA4GLADCBhwKBgQChptAQ0n4R56N03nWQ1ogR7DVRBjGo" \
+ "80Vw6G9KLjzZv44D8rq5Q5IkeQrtKgWyZfXevlsCe3LaLo18rcz8iZx6lK2xhLdUR+OR" \
+ "jsjuBfdEL5a5cWeRTSxf75AcqndQsmpwMBdrMTCZ8jQNusUI+XlrihLNNJuI5TM4vNIN" \
+ "I5bYFQIBIw==");
+ ListValue* list = new ListValue();
+ list->Append(Value::CreateStringValue("unlimitedStorage"));
+ list->Append(Value::CreateStringValue("fileSystem"));
+ manifest.Set(keys::kPermissions, list);
+ std::string error;
+ scoped_refptr<Extension> handler_app = Extension::Create(
+ path, Extension::INVALID, manifest, Extension::STRICT_ERROR_CHECKS,
+ &error);
+ EXPECT_TRUE(handler_app.get()) << error;
+ return handler_app;
+ }
};
TEST_F(ExtensionSpecialStoragePolicyTest, EmptyPolicy) {
diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc
index fc381a1..58410fb 100644
--- a/chrome/common/chrome_switches.cc
+++ b/chrome/common/chrome_switches.cc
@@ -1154,6 +1154,10 @@ const char kSetToken[] = "set-token";
// If host is specified, it also makes initial delay shorter (5 min to 5 sec)
// to make it faster to test websocket live experiment code.
const char kWebSocketLiveExperimentHost[] = "websocket-live-experiment-host";
+
+// Debug only switch to give access to all private extension APIs to
+// any non-component extension that is requesting it.
+const char kExposePrivateExtensionApi[] = "expose-private-extension-api";
#endif
#if defined(HAVE_XINPUT2)
diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h
index 1a377d0..e624157 100644
--- a/chrome/common/chrome_switches.h
+++ b/chrome/common/chrome_switches.h
@@ -344,6 +344,7 @@ extern const char kKeepMouseCursor[];
extern const char kClearTokenService[];
extern const char kSetToken[];
extern const char kWebSocketLiveExperimentHost[];
+extern const char kExposePrivateExtensionApi[];
#endif
#if !defined(OFFICIAL_BUILD)
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
index c5c88e3..5f4f7d47 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -264,6 +264,7 @@ const char Extension::kCookiePermission[] = "cookies";
const char Extension::kChromeosInfoPrivatePermissions[] = "chromeosInfoPrivate";
const char Extension::kDebuggerPermission[] = "debugger";
const char Extension::kExperimentalPermission[] = "experimental";
+const char Extension::kFileBrowserHandlerPermission[] = "fileBrowserHandler";
const char Extension::kFileSystemPermission[] = "fileSystem";
const char Extension::kFileBrowserPrivatePermission[] = "fileBrowserPrivate";
const char Extension::kGeolocationPermission[] = "geolocation";
@@ -288,6 +289,7 @@ const Extension::Permission Extension::kPermissions[] = {
{ kCookiePermission, 0 },
{ kDebuggerPermission, IDS_EXTENSION_PROMPT_WARNING_DEBUGGER },
{ kExperimentalPermission, 0 },
+ { kFileBrowserHandlerPermission, 0 },
{ kFileSystemPermission, 0 },
{ kFileBrowserPrivatePermission, 0 },
{ kGeolocationPermission, IDS_EXTENSION_PROMPT_WARNING_GEOLOCATION },
diff --git a/chrome/common/extensions/extension.h b/chrome/common/extensions/extension.h
index 9ccb745..8a8cfc9 100644
--- a/chrome/common/extensions/extension.h
+++ b/chrome/common/extensions/extension.h
@@ -206,6 +206,7 @@ class Extension : public base::RefCountedThreadSafe<Extension> {
static const char kChromeosInfoPrivatePermissions[];
static const char kDebuggerPermission[];
static const char kExperimentalPermission[];
+ static const char kFileBrowserHandlerPermission[];
static const char kFileSystemPermission[];
static const char kFileBrowserPrivatePermission[];
static const char kGeolocationPermission[];
diff --git a/chrome/common/extensions/extension_unittest.cc b/chrome/common/extensions/extension_unittest.cc
index 18751b3..905fd5c 100644
--- a/chrome/common/extensions/extension_unittest.cc
+++ b/chrome/common/extensions/extension_unittest.cc
@@ -1023,6 +1023,10 @@ TEST(ExtensionTest, PermissionMessages) {
// This permission requires explicit user action (context menu handler)
// so we won't prompt for it for now.
+ skip.insert(Extension::kFileBrowserHandlerPermission);
+
+ // This permission requires explicit user action (context menu handler)
+ // so we won't prompt for it for now.
skip.insert(Extension::kFileSystemPermission);
// If you've turned on the experimental command-line flag, we don't need
diff --git a/chrome/renderer/extensions/extension_process_bindings.cc b/chrome/renderer/extensions/extension_process_bindings.cc
index 2e2bd78..36b92b1 100644
--- a/chrome/renderer/extensions/extension_process_bindings.cc
+++ b/chrome/renderer/extensions/extension_process_bindings.cc
@@ -328,7 +328,7 @@ class ExtensionImpl : public ExtensionBase {
WebKit::WebString::fromUTF8(name.c_str()),
WebKit::WebString::fromUTF8(path.c_str()));
#else
- return webframe->createFileSystem(fileapi::kFileSystemTypeLocal,
+ return webframe->createFileSystem(fileapi::kFileSystemTypeExternal,
WebKit::WebString::fromUTF8(name.c_str()),
WebKit::WebString::fromUTF8(path.c_str()));
#endif