summaryrefslogtreecommitdiffstats
path: root/extensions/browser
diff options
context:
space:
mode:
authorcmihail <cmihail@chromium.org>2016-02-24 18:15:21 -0800
committerCommit bot <commit-bot@chromium.org>2016-02-25 02:16:28 +0000
commit20232c23c12a81d98b69d10c9e18c0b4292606cb (patch)
tree669678e9e8b9e74461c8d963710f64018f04b277 /extensions/browser
parent3d3507bd86994743e974e04ecfc97db4f640a007 (diff)
downloadchromium_src-20232c23c12a81d98b69d10c9e18c0b4292606cb.zip
chromium_src-20232c23c12a81d98b69d10c9e18c0b4292606cb.tar.gz
chromium_src-20232c23c12a81d98b69d10c9e18c0b4292606cb.tar.bz2
Add directories handling support for apps/extensions.
The change introduces a "include_directories" entry in the manifest file for file_handlers. In case the value is true, the file handler becomes a generic handler and adds the given extension to the right click menu. BUG=415897 R=mtomasz@chromium.org Review URL: https://codereview.chromium.org/1407473003 Cr-Commit-Position: refs/heads/master@{#377467}
Diffstat (limited to 'extensions/browser')
-rw-r--r--extensions/browser/api/app_runtime/app_runtime_api.cc8
-rw-r--r--extensions/browser/api/app_runtime/app_runtime_api.h3
-rw-r--r--extensions/browser/entry_info.h28
3 files changed, 35 insertions, 4 deletions
diff --git a/extensions/browser/api/app_runtime/app_runtime_api.cc b/extensions/browser/api/app_runtime/app_runtime_api.cc
index 67f3ead..fca709b 100644
--- a/extensions/browser/api/app_runtime/app_runtime_api.cc
+++ b/extensions/browser/api/app_runtime/app_runtime_api.cc
@@ -11,6 +11,7 @@
#include "base/metrics/histogram.h"
#include "base/time/time.h"
#include "base/values.h"
+#include "extensions/browser/entry_info.h"
#include "extensions/browser/event_router.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extensions_browser_client.h"
@@ -162,7 +163,7 @@ void AppRuntimeEventRouter::DispatchOnLaunchedEventWithFileEntries(
BrowserContext* context,
const Extension* extension,
const std::string& handler_id,
- const std::vector<std::string>& mime_types,
+ const std::vector<EntryInfo>& entries,
const std::vector<GrantedFileEntry>& file_entries) {
// TODO(sergeygs): Use the same way of creating an event (using the generated
// boilerplate) as below in DispatchOnLaunchedEventWithUrl.
@@ -176,14 +177,15 @@ void AppRuntimeEventRouter::DispatchOnLaunchedEventWithFileEntries(
}
scoped_ptr<base::ListValue> items(new base::ListValue);
- DCHECK(file_entries.size() == mime_types.size());
+ DCHECK(file_entries.size() == entries.size());
for (size_t i = 0; i < file_entries.size(); ++i) {
scoped_ptr<base::DictionaryValue> launch_item(new base::DictionaryValue);
launch_item->SetString("fileSystemId", file_entries[i].filesystem_id);
launch_item->SetString("baseName", file_entries[i].registered_name);
- launch_item->SetString("mimeType", mime_types[i]);
+ launch_item->SetString("mimeType", entries[i].mime_type);
launch_item->SetString("entryId", file_entries[i].id);
+ launch_item->SetBoolean("isDirectory", entries[i].is_directory);
items->Append(launch_item.release());
}
launch_data->Set("items", items.release());
diff --git a/extensions/browser/api/app_runtime/app_runtime_api.h b/extensions/browser/api/app_runtime/app_runtime_api.h
index 38f6fd6..35a28d2 100644
--- a/extensions/browser/api/app_runtime/app_runtime_api.h
+++ b/extensions/browser/api/app_runtime/app_runtime_api.h
@@ -25,6 +25,7 @@ class WebContents;
namespace extensions {
class Extension;
+struct EntryInfo;
struct GrantedFileEntry;
class AppRuntimeEventRouter {
@@ -64,7 +65,7 @@ class AppRuntimeEventRouter {
content::BrowserContext* context,
const Extension* extension,
const std::string& handler_id,
- const std::vector<std::string>& mime_types,
+ const std::vector<EntryInfo>& entries,
const std::vector<GrantedFileEntry>& file_entries);
// |handler_id| corresponds to the id of the url_handlers item
diff --git a/extensions/browser/entry_info.h b/extensions/browser/entry_info.h
new file mode 100644
index 0000000..eb5f5d5
--- /dev/null
+++ b/extensions/browser/entry_info.h
@@ -0,0 +1,28 @@
+// Copyright 2016 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 EXTENSIONS_BROWSER_ENTRY_INFO_H_
+#define EXTENSIONS_BROWSER_ENTRY_INFO_H_
+
+#include <string>
+
+#include "base/files/file_path.h"
+
+namespace extensions {
+
+// Contains information about files and directories.
+struct EntryInfo {
+ EntryInfo(const base::FilePath& path,
+ const std::string& mime_type,
+ bool is_directory)
+ : path(path), mime_type(mime_type), is_directory(is_directory) {}
+
+ base::FilePath path;
+ std::string mime_type; // Useful only if is_directory = false.
+ bool is_directory;
+};
+
+} // namespace extensions
+
+#endif // EXTENSIONS_BROWSER_ENTRY_INFO_H_