summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions
diff options
context:
space:
mode:
authorzelidrag@chromium.org <zelidrag@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-16 08:49:30 +0000
committerzelidrag@chromium.org <zelidrag@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-16 08:49:30 +0000
commit99b370004f7d287d9904275255967d8e6edf1e7d (patch)
treed0a69d77ff9df70e6e587fb704bb7b40339090c4 /chrome/common/extensions
parent76066e5180a794b39d8f9550937b37b05f7793e8 (diff)
downloadchromium_src-99b370004f7d287d9904275255967d8e6edf1e7d.zip
chromium_src-99b370004f7d287d9904275255967d8e6edf1e7d.tar.gz
chromium_src-99b370004f7d287d9904275255967d8e6edf1e7d.tar.bz2
Revert 81865 - New fileBrowserPrivate and fileHandler APIs added + plus magic needed to safely hand over access to local file system elements from content extension to 3rd party extension.As agreed with aa@ and asargent@, this new API defines following event:chrome.fileHandler.onExecute.addListener(function(id, file_entries) {}This event is invoked when user selects files in ChromeOS file browser. The extension needs to register itself as file content hanlder with following manifest changes: ... "file_browser_actions": [ { "id" : "ActionIdentifier", "default_title" : "Action title", "default_icon" : "icon.png", "file_filters" : [ "filesystem:*.jpeg", ... ] } ... ], ...BUG=chromium-os:11996TEST=ExtensionApiTest.FileBrowserTest, ExtensionManifestTest.FileBrowserActionsReview URL: http://codereview.chromium.org/6749021
TBR=zelidrag@chromium.org Review URL: http://codereview.chromium.org/6873031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81866 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions')
-rw-r--r--chrome/common/extensions/api/extension_api.json95
-rw-r--r--chrome/common/extensions/extension.cc117
-rw-r--r--chrome/common/extensions/extension.h18
-rw-r--r--chrome/common/extensions/extension_constants.cc10
-rw-r--r--chrome/common/extensions/extension_constants.h6
-rw-r--r--chrome/common/extensions/extension_manifests_unittest.cc37
-rw-r--r--chrome/common/extensions/extension_unittest.cc4
-rw-r--r--chrome/common/extensions/file_browser_handler.cc32
-rw-r--r--chrome/common/extensions/file_browser_handler.h64
-rw-r--r--chrome/common/extensions/url_pattern.cc2
-rw-r--r--chrome/common/extensions/url_pattern.h15
11 files changed, 17 insertions, 383 deletions
diff --git a/chrome/common/extensions/api/extension_api.json b/chrome/common/extensions/api/extension_api.json
index 9264e86..8a098be 100644
--- a/chrome/common/extensions/api/extension_api.json
+++ b/chrome/common/extensions/api/extension_api.json
@@ -4529,44 +4529,8 @@
]
},
{
- "namespace":"fileBrowserHandler",
- "nodoc": "true",
- "events": [
- {
- "name": "onExecute",
- "type": "function",
- "description": "Fired when file system action is executed from ChromeOS file browser.",
- "parameters": [
- {
- "name": "id",
- "type": "string",
- "description": "File browser action id as specified in the listener component's manifest."
- },
- {
- "name": "entries",
- "type": "any",
- "optional": true,
- "description": "Array of Entry instances representing files that are targets of this action (selected in ChromeOS file browser)."
- }
- ]
- }
- ]
- },
- {
"namespace":"fileBrowserPrivate",
"nodoc": "true",
- "types": [
- {
- "id": "FileBrowserTask",
- "type": "object",
- "description": "Represents information about available browser tasks. A task is an abstraction of an operation that the file browser can perform over a selected file set.",
- "properties": {
- "taskId": {"type": "string", "description": "The unique identifier of the task."},
- "title": {"type": "string", "description": "Task title."},
- "iconUrl": {"type": "string", "description": "Task icon url (from chrome://extension-icon/...)"}
- }
- }
- ],
"functions": [
{
"name": "requestLocalFileSystem",
@@ -4578,65 +4542,8 @@
"optional": "false",
"parameters": [
{
- "name" : "fileSystem",
"type": "object",
- "optional": "true",
- "description": "A DOMFileSystem instance for local file system access. null if the caller has no appropriate permissions."
- }
- ]
- }
- ]
- },
- {
- "name": "getFileTasks",
- "description": "Gets the of tasks that can be performed over selected files.",
- "parameters": [
- {
- "name": "fileURLs",
- "type": "array",
- "description": "Array of selected file URLs",
- "items": { "type": "string" }
- },
- {
- "name": "callback",
- "type": "function",
- "optional": "false",
- "parameters": [
- {
- "name": "tasks",
- "type": "array",
- "items": {"$ref": "FileBrowserTask"},
- "description": "The list of available tasks that can be performed on all of the passed file paths."
- }
- ]
- }
- ]
- },
- {
- "name": "executeTask",
- "description": "Executes file browser task over selected files",
- "parameters": [
- {
- "name": "taskId",
- "type": "string",
- "description": "The unique identifier of task to execute."
- },
- {
- "name": "fileURLs",
- "type": "array",
- "description": "Array of file URLs",
- "items": { "type": "string" }
- },
- {
- "name": "callback",
- "type": "function",
- "optional": "false",
- "parameters": [
- {
- "name": "success",
- "type": "boolean",
- "optional": "true",
- "description": "True of task execution was successfully initiated."
+ "isInstanceOf": "DOMFileSystem"
}
]
}
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
index 18dbd03..5f4f7d47 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -32,7 +32,6 @@
#include "chrome/common/extensions/extension_resource.h"
#include "chrome/common/extensions/extension_sidebar_defaults.h"
#include "chrome/common/extensions/extension_sidebar_utils.h"
-#include "chrome/common/extensions/file_browser_handler.h"
#include "chrome/common/extensions/user_script.h"
#include "chrome/common/url_constants.h"
#include "googleurl/src/url_util.h"
@@ -266,6 +265,7 @@ 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";
const char Extension::kHistoryPermission[] = "history";
@@ -290,6 +290,7 @@ const Extension::Permission Extension::kPermissions[] = {
{ kDebuggerPermission, IDS_EXTENSION_PROMPT_WARNING_DEBUGGER },
{ kExperimentalPermission, 0 },
{ kFileBrowserHandlerPermission, 0 },
+ { kFileSystemPermission, 0 },
{ kFileBrowserPrivatePermission, 0 },
{ kGeolocationPermission, IDS_EXTENSION_PROMPT_WARNING_GEOLOCATION },
{ kIdlePermission, 0 },
@@ -951,91 +952,6 @@ ExtensionAction* Extension::LoadExtensionActionHelper(
return result.release();
}
-Extension::FileBrowserHandlerList* Extension::LoadFileBrowserHandlers(
- const ListValue* extension_actions, std::string* error) {
- scoped_ptr<FileBrowserHandlerList> result(
- new FileBrowserHandlerList());
- for (ListValue::const_iterator iter = extension_actions->begin();
- iter != extension_actions->end();
- ++iter) {
- if (!(*iter)->IsType(Value::TYPE_DICTIONARY)) {
- *error = errors::kInvalidFileBrowserHandler;
- return false;
- }
- scoped_ptr<FileBrowserHandler> action(
- LoadFileBrowserHandler(
- reinterpret_cast<DictionaryValue*>(*iter), error));
- if (!action.get())
- return NULL; // Failed to parse file browser action definition.
- result->push_back(linked_ptr<FileBrowserHandler>(action.release()));
- }
- return result.release();
-}
-
-FileBrowserHandler* Extension::LoadFileBrowserHandler(
- const DictionaryValue* file_browser_handler, std::string* error) {
- scoped_ptr<FileBrowserHandler> result(
- new FileBrowserHandler());
- result->set_extension_id(id());
-
- std::string id;
- // Read the file action |id| (mandatory).
- if (!file_browser_handler->HasKey(keys::kPageActionId) ||
- !file_browser_handler->GetString(keys::kPageActionId, &id)) {
- *error = errors::kInvalidPageActionId;
- return NULL;
- }
- result->set_id(id);
-
- // Read the page action title from |default_title| (mandatory).
- std::string title;
- if (!file_browser_handler->HasKey(keys::kPageActionDefaultTitle) ||
- !file_browser_handler->GetString(keys::kPageActionDefaultTitle, &title)) {
- *error = errors::kInvalidPageActionDefaultTitle;
- return NULL;
- }
- result->set_title(title);
-
- // Initialize file filters (mandatory).
- ListValue* list_value = NULL;
- if (!file_browser_handler->HasKey(keys::kFileFilters) ||
- !file_browser_handler->GetList(keys::kFileFilters, &list_value) ||
- list_value->empty()) {
- *error = errors::kInvalidFileFiltersList;
- return false;
- }
- for (size_t i = 0; i < list_value->GetSize(); ++i) {
- std::string filter;
- if (!list_value->GetString(i, &filter)) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
- errors::kInvalidFileFilterValue, base::IntToString(i));
- return false;
- }
- URLPattern pattern(URLPattern::SCHEME_FILESYSTEM);
- if (URLPattern::PARSE_SUCCESS != pattern.Parse(filter,
- URLPattern::PARSE_STRICT)) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
- errors::kInvalidURLPatternError, filter);
- return false;
- }
- result->AddPattern(pattern);
- }
-
- std::string default_icon;
- // Read the file browser action |default_icon| (optional).
- if (file_browser_handler->HasKey(keys::kPageActionDefaultIcon)) {
- if (!file_browser_handler->GetString(
- keys::kPageActionDefaultIcon,&default_icon) ||
- default_icon.empty()) {
- *error = errors::kInvalidPageActionIconPath;
- return NULL;
- }
- result->set_icon_path(default_icon);
- }
-
- return result.release();
-}
-
ExtensionSidebarDefaults* Extension::LoadExtensionSidebarDefaults(
const DictionaryValue* extension_sidebar, std::string* error) {
scoped_ptr<ExtensionSidebarDefaults> result(new ExtensionSidebarDefaults());
@@ -2059,21 +1975,6 @@ bool Extension::InitFromValue(const DictionaryValue& source, int flags,
return false; // Failed to parse browser action definition.
}
- // Initialize file browser actions (optional).
- if (source.HasKey(keys::kFileBrowserHandlers)) {
- ListValue* file_browser_handlers_value = NULL;
- if (!source.GetList(keys::kFileBrowserHandlers,
- &file_browser_handlers_value)) {
- *error = errors::kInvalidFileBrowserHandler;
- return false;
- }
-
- file_browser_handlers_.reset(
- LoadFileBrowserHandlers(file_browser_handlers_value, error));
- if (!file_browser_handlers_.get())
- return false; // Failed to parse file browser actions definition.
- }
-
// Load App settings.
if (!LoadIsApp(manifest_value_.get(), error) ||
!LoadExtent(manifest_value_.get(), keys::kWebURLs,
@@ -2139,12 +2040,7 @@ bool Extension::InitFromValue(const DictionaryValue& source, int flags,
// Only COMPONENT extensions can use private APIs.
// TODO(asargent) - We want a more general purpose mechanism for this,
// and better error messages. (http://crbug.com/54013)
- if (!IsComponentOnlyPermission(permission_str)
-#ifndef NDEBUG
- && !CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kExposePrivateExtensionApi)
-#endif
- ) {
+ if (!IsComponentOnlyPermission(permission_str)) {
continue;
}
@@ -2776,12 +2672,7 @@ bool Extension::IsAPIPermission(const std::string& str) const {
}
bool Extension::CanExecuteScriptEverywhere() const {
- if (location() == Extension::COMPONENT
-#ifndef NDEBUG
- || CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kExposePrivateExtensionApi)
-#endif
- )
+ if (location() == Extension::COMPONENT)
return true;
ScriptingWhitelist* whitelist =
diff --git a/chrome/common/extensions/extension.h b/chrome/common/extensions/extension.h
index a164317..8a8cfc9 100644
--- a/chrome/common/extensions/extension.h
+++ b/chrome/common/extensions/extension.h
@@ -13,7 +13,6 @@
#include "base/file_path.h"
#include "base/gtest_prod_util.h"
-#include "base/memory/linked_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/common/extensions/extension_constants.h"
@@ -28,8 +27,6 @@ class DictionaryValue;
class ExtensionAction;
class ExtensionResource;
class ExtensionSidebarDefaults;
-class FileBrowserHandler;
-class ListValue;
class SkBitmap;
class Version;
@@ -38,7 +35,6 @@ class Extension : public base::RefCountedThreadSafe<Extension> {
public:
typedef std::map<const std::string, GURL> URLOverrideMap;
typedef std::vector<std::string> ScriptingWhitelist;
- typedef std::vector<linked_ptr<FileBrowserHandler> > FileBrowserHandlerList;
// What an extension was loaded from.
// NOTE: These values are stored as integers in the preferences and used
@@ -211,6 +207,7 @@ class Extension : public base::RefCountedThreadSafe<Extension> {
static const char kDebuggerPermission[];
static const char kExperimentalPermission[];
static const char kFileBrowserHandlerPermission[];
+ static const char kFileSystemPermission[];
static const char kFileBrowserPrivatePermission[];
static const char kGeolocationPermission[];
static const char kHistoryPermission[];
@@ -513,9 +510,6 @@ class Extension : public base::RefCountedThreadSafe<Extension> {
ExtensionSidebarDefaults* sidebar_defaults() const {
return sidebar_defaults_.get();
}
- const FileBrowserHandlerList* file_browser_handlers() const {
- return file_browser_handlers_.get();
- }
const std::vector<PluginInfo>& plugins() const { return plugins_; }
const std::vector<NaClModuleInfo>& nacl_modules() const {
return nacl_modules_;
@@ -644,13 +638,6 @@ class Extension : public base::RefCountedThreadSafe<Extension> {
ExtensionAction* LoadExtensionActionHelper(
const DictionaryValue* extension_action, std::string* error);
- // Helper method to load an FileBrowserHandlerList from the manifest.
- FileBrowserHandlerList* LoadFileBrowserHandlers(
- const ListValue* extension_actions, std::string* error);
- // Helper method to load an FileBrowserHandler from manifest.
- FileBrowserHandler* LoadFileBrowserHandler(
- const DictionaryValue* file_browser_handlers, std::string* error);
-
// Helper method to load an ExtensionSidebarDefaults from the sidebar manifest
// entry.
ExtensionSidebarDefaults* LoadExtensionSidebarDefaults(
@@ -753,9 +740,6 @@ class Extension : public base::RefCountedThreadSafe<Extension> {
// The extension's browser action, if any.
scoped_ptr<ExtensionAction> browser_action_;
- // The extension's file browser actions, if any.
- scoped_ptr<FileBrowserHandlerList> file_browser_handlers_;
-
// The extension's sidebar, if any.
scoped_ptr<ExtensionSidebarDefaults> sidebar_defaults_;
diff --git a/chrome/common/extensions/extension_constants.cc b/chrome/common/extensions/extension_constants.cc
index fc5f4ef..27324ef 100644
--- a/chrome/common/extensions/extension_constants.cc
+++ b/chrome/common/extensions/extension_constants.cc
@@ -19,8 +19,6 @@ const char* kDefaultLocale = "default_locale";
const char* kDescription = "description";
const char* kDevToolsPage = "devtools_page";
const char* kExcludeGlobs = "exclude_globs";
-const char* kFileFilters = "file_filters";
-const char* kFileBrowserHandlers = "file_browser_handlers";
const char* kHomepageURL = "homepage_url";
const char* kIcons = "icons";
const char* kIncognito = "incognito";
@@ -159,12 +157,6 @@ const char* kInvalidDescription =
"Invalid value for 'description'.";
const char* kInvalidDevToolsPage =
"Invalid value for 'devtools_page'.";
-const char* kInvalidFileBrowserHandler =
- "Invalid value for 'file_browser_handers'.";
-const char* kInvalidFileFiltersList =
- "Invalid value for 'file_filters'.";
-const char* kInvalidFileFilterValue =
- "Invalid value for 'file_filters[*]'.";
const char* kInvalidGlob =
"Invalid value for 'content_scripts[*].*[*]'.";
const char* kInvalidGlobList =
@@ -304,8 +296,6 @@ const char* kInvalidTtsVoicesVoiceName =
"Invalid value for 'tts.voices[*].voiceName'.";
const char* kInvalidUpdateURL =
"Invalid value for update url: '[*]'.";
-const char* kInvalidURLPatternError =
- "Invalid url pattern '*'";
const char* kInvalidVersion =
"Required value 'version' is missing or invalid. It must be between 1-4 "
"dot-separated integers each between 0 and 65536.";
diff --git a/chrome/common/extensions/extension_constants.h b/chrome/common/extensions/extension_constants.h
index 6b703f3..28514da 100644
--- a/chrome/common/extensions/extension_constants.h
+++ b/chrome/common/extensions/extension_constants.h
@@ -24,8 +24,6 @@ namespace extension_manifest_keys {
extern const char* kDescription;
extern const char* kDevToolsPage;
extern const char* kExcludeGlobs;
- extern const char* kFileFilters;
- extern const char* kFileBrowserHandlers;
extern const char* kHomepageURL;
extern const char* kIcons;
extern const char* kIncognito;
@@ -133,9 +131,6 @@ namespace extension_manifest_errors {
extern const char* kInvalidDefaultLocale;
extern const char* kInvalidDescription;
extern const char* kInvalidDevToolsPage;
- extern const char* kInvalidFileBrowserHandler;
- extern const char* kInvalidFileFiltersList;
- extern const char* kInvalidFileFilterValue;
extern const char* kInvalidGlob;
extern const char* kInvalidGlobList;
extern const char* kInvalidHomepageURL;
@@ -204,7 +199,6 @@ namespace extension_manifest_errors {
extern const char* kInvalidTtsVoicesLocale;
extern const char* kInvalidTtsVoicesVoiceName;
extern const char* kInvalidUpdateURL;
- extern const char* kInvalidURLPatternError;
extern const char* kInvalidVersion;
extern const char* kInvalidWebURL;
extern const char* kInvalidWebURLs;
diff --git a/chrome/common/extensions/extension_manifests_unittest.cc b/chrome/common/extensions/extension_manifests_unittest.cc
index f304619..092e9e1 100644
--- a/chrome/common/extensions/extension_manifests_unittest.cc
+++ b/chrome/common/extensions/extension_manifests_unittest.cc
@@ -16,8 +16,6 @@
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/extensions/extension_error_utils.h"
#include "chrome/common/extensions/extension_sidebar_defaults.h"
-#include "chrome/common/extensions/file_browser_handler.h"
-#include "chrome/common/extensions/url_pattern.h"
#include "content/common/json_value_serializer.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -570,38 +568,3 @@ TEST_F(ExtensionManifestTest, IsolatedApps) {
EXPECT_TRUE(extension2->is_storage_isolated());
*CommandLine::ForCurrentProcess() = old_command_line;
}
-
-
-TEST_F(ExtensionManifestTest, FileBrowserHandlers) {
- LoadAndExpectError("filebrowser_invalid_actions_1.json",
- errors::kInvalidFileBrowserHandler);
- LoadAndExpectError("filebrowser_invalid_actions_2.json",
- errors::kInvalidFileBrowserHandler);
- LoadAndExpectError("filebrowser_invalid_action_id.json",
- errors::kInvalidPageActionId);
- LoadAndExpectError("filebrowser_invalid_action_title.json",
- errors::kInvalidPageActionDefaultTitle);
- LoadAndExpectError("filebrowser_invalid_action_id.json",
- errors::kInvalidPageActionId);
- LoadAndExpectError("filebrowser_invalid_file_filters_1.json",
- errors::kInvalidFileFiltersList);
- LoadAndExpectError("filebrowser_invalid_file_filters_2.json",
- ExtensionErrorUtils::FormatErrorMessage(
- errors::kInvalidFileFilterValue, base::IntToString(0)));
- LoadAndExpectError("filebrowser_invalid_file_filters_url.json",
- ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidURLPatternError,
- "http:*.html"));
-
- scoped_refptr<Extension> extension(
- LoadAndExpectSuccess("filebrowser_valid.json"));
- ASSERT_TRUE(extension->file_browser_handlers() != NULL);
- ASSERT_EQ(extension->file_browser_handlers()->size(), 1U);
- const FileBrowserHandler* action =
- extension->file_browser_handlers()->at(0).get();
- EXPECT_EQ(action->title(), "Default title");
- EXPECT_EQ(action->icon_path(), "icon.png");
- const FileBrowserHandler::PatternList& patterns = action->file_url_patterns();
- ASSERT_EQ(patterns.size(), 1U);
- ASSERT_TRUE(action->MatchesURL(
- GURL("filesystem:chrome-extension://foo/local/test.txt")));
-}
diff --git a/chrome/common/extensions/extension_unittest.cc b/chrome/common/extensions/extension_unittest.cc
index 131f144..905fd5c 100644
--- a/chrome/common/extensions/extension_unittest.cc
+++ b/chrome/common/extensions/extension_unittest.cc
@@ -1025,6 +1025,10 @@ TEST(ExtensionTest, PermissionMessages) {
// 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
// to warn you further.
skip.insert(Extension::kExperimentalPermission);
diff --git a/chrome/common/extensions/file_browser_handler.cc b/chrome/common/extensions/file_browser_handler.cc
deleted file mode 100644
index ea270b4..0000000
--- a/chrome/common/extensions/file_browser_handler.cc
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/common/extensions/file_browser_handler.h"
-
-#include "chrome/common/extensions/url_pattern.h"
-#include "googleurl/src/gurl.h"
-
-FileBrowserHandler::FileBrowserHandler() {
-}
-
-FileBrowserHandler::~FileBrowserHandler() {
-}
-
-void FileBrowserHandler::AddPattern(const URLPattern& pattern) {
- patterns_.push_back(pattern);
-}
-
-void FileBrowserHandler::ClearPatterns() {
- patterns_.clear();
-}
-
-bool FileBrowserHandler::MatchesURL(const GURL& url) const {
- for (PatternList::const_iterator pattern = patterns_.begin();
- pattern != patterns_.end(); ++pattern) {
- if (pattern->MatchesUrl(url))
- return true;
- }
- return false;
-}
-
diff --git a/chrome/common/extensions/file_browser_handler.h b/chrome/common/extensions/file_browser_handler.h
deleted file mode 100644
index 420be17..0000000
--- a/chrome/common/extensions/file_browser_handler.h
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_COMMON_EXTENSIONS_FILE_BROWSER_HANDLER_H_
-#define CHROME_COMMON_EXTENSIONS_FILE_BROWSER_HANDLER_H_
-#pragma once
-
-#include <string>
-#include <vector>
-
-#include "base/basictypes.h"
-#include "chrome/common/extensions/url_pattern.h"
-#include "googleurl/src/gurl.h"
-
-class URLPattern;
-
-// FileBrowserHandler encapsulates the state of a file browser action.
-class FileBrowserHandler {
- public:
- typedef std::vector<URLPattern> PatternList;
-
- FileBrowserHandler();
- ~FileBrowserHandler();
-
- // extension id
- std::string extension_id() const { return extension_id_; }
- void set_extension_id(const std::string& extension_id) {
- extension_id_ = extension_id;
- }
-
- // action id
- const std::string& id() const { return id_; }
- void set_id(const std::string& id) { id_ = id; }
-
- // default title
- const std::string& title() const { return title_; }
- void set_title(const std::string& title) { title_ = title; }
-
- // File schema URL patterns.
- const PatternList& file_url_patterns() const { return patterns_; }
- void AddPattern(const URLPattern& pattern);
- bool MatchesURL(const GURL& url) const;
- void ClearPatterns();
-
- // Action icon path.
- const std::string icon_path() const { return default_icon_path_; }
- void set_icon_path(const std::string& path) {
- default_icon_path_ = path;
- }
-
- private:
- // The id for the extension this action belongs to (as defined in the
- // extension manifest).
- std::string extension_id_;
- std::string title_;
- std::string default_icon_path_;
- // The id for the FileBrowserHandler, for example: "PdfFileAction".
- std::string id_;
- // A list of file filters.
- PatternList patterns_;
-};
-
-#endif // CHROME_COMMON_EXTENSIONS_FILE_BROWSER_HANDLER_H_
diff --git a/chrome/common/extensions/url_pattern.cc b/chrome/common/extensions/url_pattern.cc
index 986487a..ac5a8eb 100644
--- a/chrome/common/extensions/url_pattern.cc
+++ b/chrome/common/extensions/url_pattern.cc
@@ -24,7 +24,6 @@ const char* kValidSchemes[] = {
chrome::kFileScheme,
chrome::kFtpScheme,
chrome::kChromeUIScheme,
- chrome::kFileSystemScheme,
};
const int kValidSchemeMasks[] = {
@@ -33,7 +32,6 @@ const int kValidSchemeMasks[] = {
URLPattern::SCHEME_FILE,
URLPattern::SCHEME_FTP,
URLPattern::SCHEME_CHROMEUI,
- URLPattern::SCHEME_FILESYSTEM,
};
COMPILE_ASSERT(arraysize(kValidSchemes) == arraysize(kValidSchemeMasks),
diff --git a/chrome/common/extensions/url_pattern.h b/chrome/common/extensions/url_pattern.h
index cf89382..edd92d4 100644
--- a/chrome/common/extensions/url_pattern.h
+++ b/chrome/common/extensions/url_pattern.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_COMMON_EXTENSIONS_URL_PATTERN_H_
@@ -77,13 +77,12 @@ class URLPattern {
public:
// A collection of scheme bitmasks for use with valid_schemes.
enum SchemeMasks {
- SCHEME_NONE = 0,
- SCHEME_HTTP = 1 << 0,
- SCHEME_HTTPS = 1 << 1,
- SCHEME_FILE = 1 << 2,
- SCHEME_FTP = 1 << 3,
- SCHEME_CHROMEUI = 1 << 4,
- SCHEME_FILESYSTEM = 1 << 5,
+ SCHEME_NONE = 0,
+ SCHEME_HTTP = 1 << 0,
+ SCHEME_HTTPS = 1 << 1,
+ SCHEME_FILE = 1 << 2,
+ SCHEME_FTP = 1 << 3,
+ SCHEME_CHROMEUI = 1 << 4,
// SCHEME_ALL will match every scheme, including chrome://, chrome-
// extension://, about:, etc. Because this has lots of security
// implications, third-party extensions should never be able to get access