summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-21 20:26:19 +0000
committerjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-21 20:26:19 +0000
commitf6e68091282a63e3d201cd13affc54f96b5f04d3 (patch)
treee3e31c04a067d877631370fd1425044ed52929bc /chrome/browser
parente6a4d78c70426f6bce0558fca79b0a38ea12070f (diff)
downloadchromium_src-f6e68091282a63e3d201cd13affc54f96b5f04d3.zip
chromium_src-f6e68091282a63e3d201cd13affc54f96b5f04d3.tar.gz
chromium_src-f6e68091282a63e3d201cd13affc54f96b5f04d3.tar.bz2
Aura: Use extension-based file picker from CrOS for pure-views builds.
Removes the dependency on chromeos-specific code in the extension-based file picker. Compiles, links, and runs, but the dialog doesn't function yet - there's still some work to do to wire up the private JavaScript API calls. See crbug.com/97424 BUG=chromium-os:20583 TEST=On plain ChromeOS, can still open a file with control-O file picker. Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=102113 Review URL: http://codereview.chromium.org/7941014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102156 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/browser_resources.grd4
-rw-r--r--chrome/browser/chromeos/preferences.cc4
-rw-r--r--chrome/browser/extensions/extension_file_browser_private_api.cc18
-rw-r--r--chrome/browser/extensions/extension_file_browser_private_api.h4
-rw-r--r--chrome/browser/extensions/file_manager_util.cc7
-rw-r--r--chrome/browser/profiles/profile_impl.cc42
-rw-r--r--chrome/browser/ui/browser.cc3
-rw-r--r--chrome/browser/ui/views/file_manager_dialog.cc18
-rw-r--r--chrome/browser/ui/views/shell_dialogs_aura.cc6
9 files changed, 69 insertions, 37 deletions
diff --git a/chrome/browser/browser_resources.grd b/chrome/browser/browser_resources.grd
index 5ef0cc2..20d86f4 100644
--- a/chrome/browser/browser_resources.grd
+++ b/chrome/browser/browser_resources.grd
@@ -149,10 +149,12 @@
<include name="IDR_CHROMEVOX_MANIFEST" file="resources\access_chromevox\manifest.json" type="BINDATA" />
<!-- Enterprise enrollment dialog -->
<include name="IDR_ENTERPRISE_ENROLLMENT_HTML" file="policy\resources\enrollment.html" flattenhtml="true" type="BINDATA" />
- <include name="IDR_FILEMANAGER_MANIFEST" file="resources\file_manager\manifest.json" type="BINDATA" />
<include name="IDR_GAIA_AUTH_MANIFEST" file="resources\gaia_auth\manifest.json" type="BINDATA" />
<include name="IDR_GAIA_TEST_AUTH_MANIFEST" file="resources\gaia_auth\manifest_test.json" type="BINDATA" />
</if>
+ <if expr="pp_ifdef('file_manager_extension')">
+ <include name="IDR_FILEMANAGER_MANIFEST" file="resources\file_manager\manifest.json" type="BINDATA" />
+ </if>
<if expr="pp_ifdef('chromeos') and pp_ifdef('_google_chrome')">
<include name="IDR_HELP_MANIFEST" file="resources\help_app\manifest.json" type="BINDATA" />
</if>
diff --git a/chrome/browser/chromeos/preferences.cc b/chrome/browser/chromeos/preferences.cc
index 02d454c..da52e95 100644
--- a/chrome/browser/chromeos/preferences.cc
+++ b/chrome/browser/chromeos/preferences.cc
@@ -195,10 +195,6 @@ void Preferences::RegisterUserPrefs(PrefService* prefs) {
true,
PrefService::UNSYNCABLE_PREF);
- // The map of timestamps of the last used file browser handlers.
- prefs->RegisterDictionaryPref(prefs::kLastUsedFileBrowserHandlers,
- PrefService::UNSYNCABLE_PREF);
-
// Use shared proxies default to off.
prefs->RegisterBooleanPref(prefs::kUseSharedProxies,
false,
diff --git a/chrome/browser/extensions/extension_file_browser_private_api.cc b/chrome/browser/extensions/extension_file_browser_private_api.cc
index 76c21a6..fc884e0 100644
--- a/chrome/browser/extensions/extension_file_browser_private_api.cc
+++ b/chrome/browser/extensions/extension_file_browser_private_api.cc
@@ -56,9 +56,7 @@
// Error messages.
const char kFileError[] = "File error %d";
const char kInvalidFileUrl[] = "Invalid file URL";
-#ifdef OS_CHROMEOS
const char kVolumeDevicePathNotFound[] = "Device path not found";
-#endif
#ifdef OS_CHROMEOS
// Volume type strings.
@@ -543,15 +541,21 @@ void FileWatchBrowserFunctionBase::RunFileWatchOperationOnFileThread(
bool AddFileWatchBrowserFunction::PerformFileWatchOperation(
const FilePath& local_path, const FilePath& virtual_path,
const std::string& extension_id) {
+#if defined(OS_CHROMEOS)
return profile_->GetExtensionService()->file_browser_event_router()->
AddFileWatch(local_path, virtual_path, extension_id);
+#else
+ return true;
+#endif // OS_CHROMEOS
}
bool RemoveFileWatchBrowserFunction::PerformFileWatchOperation(
const FilePath& local_path, const FilePath& unused,
const std::string& extension_id) {
+#if defined(OS_CHROMEOS)
profile_->GetExtensionService()->file_browser_event_router()->
RemoveFileWatch(local_path, extension_id);
+#endif
return true;
}
@@ -1177,6 +1181,7 @@ bool AddMountFunction::RunImpl() {
UrlList file_paths;
file_paths.push_back(GURL(file_url));
+#if defined(OS_CHROMEOS)
chromeos::MountPathOptions options;
if (args_->GetSize() == 3) {
DictionaryValue *dict;
@@ -1203,6 +1208,7 @@ bool AddMountFunction::RunImpl() {
NewRunnableMethod(this,
&AddMountFunction::GetLocalPathsOnFileThread,
file_paths, reinterpret_cast<void*>(params)));
+#endif // OS_CHROMEOS
return true;
}
@@ -1211,19 +1217,19 @@ void AddMountFunction::GetLocalPathsResponseOnUIThread(
const FilePathList& files, void* context) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(context);
- scoped_ptr<MountParamaters> params(
- reinterpret_cast<MountParamaters*>(context));
if (!files.size()) {
SendResponse(false);
return;
}
+#ifdef OS_CHROMEOS
+ scoped_ptr<MountParamaters> params(
+ reinterpret_cast<MountParamaters*>(context));
const std::string& mount_type_str = params->mount_type;
const chromeos::MountPathOptions& options = params->mount_options;
FilePath::StringType source_file = files[0].value();
-#ifdef OS_CHROMEOS
chromeos::MountLibrary *mount_lib =
chromeos::CrosLibrary::Get()->GetMountLibrary();
@@ -1649,8 +1655,10 @@ bool FileDialogStringsFunction::RunImpl() {
l10n_util::GetStringUTF16(IDS_CERT_MANAGER_VIEW_CERT_BUTTON));
dict->SetString("PLAY_MEDIA",
l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLAY));
+#if defined(OS_CHROMEOS)
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableArchives))
dict->SetString("ENABLE_ARCHIVES", "true");
+#endif
return true;
}
diff --git a/chrome/browser/extensions/extension_file_browser_private_api.h b/chrome/browser/extensions/extension_file_browser_private_api.h
index 69b6827..28e96f4 100644
--- a/chrome/browser/extensions/extension_file_browser_private_api.h
+++ b/chrome/browser/extensions/extension_file_browser_private_api.h
@@ -233,6 +233,7 @@ class AddMountFunction
void* context) OVERRIDE;
private:
+#if defined(OS_CHROMEOS)
struct MountParamaters {
MountParamaters(const std::string& type,
const chromeos::MountPathOptions& options)
@@ -241,6 +242,7 @@ class AddMountFunction
std::string mount_type;
chromeos::MountPathOptions mount_options;
};
+#endif
DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.addMount");
};
@@ -330,7 +332,7 @@ class GetVolumeMetadataFunction
virtual bool RunImpl() OVERRIDE;
private:
-#ifdef OS_CHROMEOS
+#if defined(OS_CHROMEOS)
const std::string& DeviceTypeToString(chromeos::DeviceType type);
#endif
diff --git a/chrome/browser/extensions/file_manager_util.cc b/chrome/browser/extensions/file_manager_util.cc
index 25f91ce..5739d22 100644
--- a/chrome/browser/extensions/file_manager_util.cc
+++ b/chrome/browser/extensions/file_manager_util.cc
@@ -9,7 +9,6 @@
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
#include "base/values.h"
-#include "chrome/browser/chromeos/media/media_player.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/simple_message_box.h"
#include "chrome/browser/ui/browser.h"
@@ -24,6 +23,10 @@
#include "webkit/fileapi/file_system_mount_point_provider.h"
#include "webkit/fileapi/file_system_util.h"
+#if defined(OS_CHROMEOS)
+#include "chrome/browser/chromeos/media/media_player.h"
+#endif
+
#define FILEBROWSER_DOMAIN "hhaomjibdihmijegdhdafkllkbggdgoj"
const char kFileBrowserDomain[] = FILEBROWSER_DOMAIN;
#define FILEBROWSER_URL(PATH) \
@@ -238,6 +241,7 @@ void FileManagerUtil::ViewItem(const FilePath& full_path, bool enqueue) {
browser->AddSelectedTabWithURL(GURL(path), PageTransition::LINK);
return;
}
+#if defined(OS_CHROMEOS)
if (IsSupportedAVExtension(ext.data())) {
Browser* browser = BrowserList::GetLastActive();
if (!browser)
@@ -249,6 +253,7 @@ void FileManagerUtil::ViewItem(const FilePath& full_path, bool enqueue) {
mediaplayer->ForcePlayMediaFile(browser->profile(), full_path, NULL);
return;
}
+#endif // OS_CHROMEOS
// Unknown file type. Record UMA and show an error message.
size_t extension_index = UMAExtensionIndex(ext.data(),
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc
index 77deefb..be393ae 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -156,6 +156,28 @@ enum ContextType {
kMediaContext
};
+typedef std::list<std::pair<FilePath::StringType, int> >
+ ComponentExtensionList;
+
+#if defined(FILE_MANAGER_EXTENSION)
+void AddFileManagerExtension(ComponentExtensionList* component_extensions) {
+#ifndef NDEBUG
+ const CommandLine* command_line = CommandLine::ForCurrentProcess();
+ if (command_line->HasSwitch(switches::kFileManagerExtensionPath)) {
+ FilePath filemgr_extension_path =
+ command_line->GetSwitchValuePath(switches::kFileManagerExtensionPath);
+ component_extensions->push_back(std::make_pair(
+ filemgr_extension_path.value(),
+ IDR_FILEMANAGER_MANIFEST));
+ return;
+ }
+#endif // NDEBUG
+ component_extensions->push_back(std::make_pair(
+ FILE_PATH_LITERAL("file_manager"),
+ IDR_FILEMANAGER_MANIFEST));
+}
+#endif // defined(FILE_MANAGER_EXTENSION)
+
// Gets the cache parameters from the command line. |type| is the type of
// request context that we need, |cache_path| will be set to the user provided
// path, or will not be touched if there is not an argument. |max_size| will
@@ -610,24 +632,7 @@ void ProfileImpl::RegisterComponentExtensions() {
IDR_BOOKMARKS_MANIFEST));
#if defined(FILE_MANAGER_EXTENSION)
- const CommandLine* command_line = CommandLine::ForCurrentProcess();
-#ifndef NDEBUG
- if (command_line->HasSwitch(switches::kFileManagerExtensionPath)) {
- FilePath filemgr_extension_path =
- command_line->GetSwitchValuePath(switches::kFileManagerExtensionPath);
- component_extensions.push_back(std::make_pair(
- filemgr_extension_path.value(),
- IDR_FILEMANAGER_MANIFEST));
- } else {
- component_extensions.push_back(std::make_pair(
- FILE_PATH_LITERAL("file_manager"),
- IDR_FILEMANAGER_MANIFEST));
- }
-#else
- component_extensions.push_back(std::make_pair(
- FILE_PATH_LITERAL("file_manager"),
- IDR_FILEMANAGER_MANIFEST));
-#endif
+ AddFileManagerExtension(&component_extensions);
#endif
#if defined(TOUCH_UI)
@@ -641,6 +646,7 @@ void ProfileImpl::RegisterComponentExtensions() {
FILE_PATH_LITERAL("/usr/share/chromeos-assets/mobile"),
IDR_MOBILE_MANIFEST));
+ const CommandLine* command_line = CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(switches::kAuthExtensionPath)) {
FilePath auth_extension_path =
command_line->GetSwitchValuePath(switches::kAuthExtensionPath);
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index 86969cd..9a24b1b 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -2330,6 +2330,9 @@ void Browser::RegisterUserPrefs(PrefService* prefs) {
prefs->RegisterBooleanPref(prefs::kImportSavedPasswords,
true,
PrefService::UNSYNCABLE_PREF);
+ // The map of timestamps of the last used file browser handlers.
+ prefs->RegisterDictionaryPref(prefs::kLastUsedFileBrowserHandlers,
+ PrefService::UNSYNCABLE_PREF);
// We need to register the type of these preferences in order to query
// them even though they're only typically controlled via policy.
diff --git a/chrome/browser/ui/views/file_manager_dialog.cc b/chrome/browser/ui/views/file_manager_dialog.cc
index e7f1564..cc2dc01 100644
--- a/chrome/browser/ui/views/file_manager_dialog.cc
+++ b/chrome/browser/ui/views/file_manager_dialog.cc
@@ -73,6 +73,7 @@ FileManagerDialog* PendingDialog::Find(int32 tab_id) {
// Linking this implementation of SelectFileDialog::Create into the target
// selects FileManagerDialog as the dialog of choice.
+// TODO(jamescook): Move this into a new file shell_dialogs_chromeos.cc
// static
SelectFileDialog* SelectFileDialog::Create(Listener* listener) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -182,19 +183,24 @@ void FileManagerDialog::SelectFileImpl(
virtual_path = FilePath();
}
- // Connect our listener to FileDialogFunction's per-tab callbacks.
- TabContentsWrapper* tab = owner_browser->GetSelectedTabContentsWrapper();
- int32 tab_id = (tab ? tab->restore_tab_helper()->session_id().id() : 0);
- PendingDialog::Add(tab_id, this);
-
GURL file_browser_url = FileManagerUtil::GetFileBrowserUrlWithParams(
type, title, virtual_path, file_types, file_type_index,
default_extension);
- extension_dialog_ = ExtensionDialog::Show(file_browser_url,
+ TabContentsWrapper* tab = owner_browser->GetSelectedTabContentsWrapper();
+ ExtensionDialog* dialog = ExtensionDialog::Show(file_browser_url,
owner_browser, tab->tab_contents(),
kFileManagerWidth, kFileManagerHeight,
this /* ExtensionDialog::Observer */);
+ if (!dialog) {
+ LOG(ERROR) << "Unable to create extension dialog";
+ return;
+ }
+
+ // Connect our listener to FileDialogFunction's per-tab callbacks.
+ int32 tab_id = (tab ? tab->restore_tab_helper()->session_id().id() : 0);
+ PendingDialog::Add(tab_id, this);
+ extension_dialog_ = dialog;
params_ = params;
tab_id_ = tab_id;
owner_window_ = owner_window;
diff --git a/chrome/browser/ui/views/shell_dialogs_aura.cc b/chrome/browser/ui/views/shell_dialogs_aura.cc
index b3f10d0..2548b9a 100644
--- a/chrome/browser/ui/views/shell_dialogs_aura.cc
+++ b/chrome/browser/ui/views/shell_dialogs_aura.cc
@@ -4,7 +4,11 @@
#include "chrome/browser/ui/shell_dialogs.h"
+#include "chrome/browser/ui/views/file_manager_dialog.h"
+#include "content/browser/browser_thread.h"
+
// static
SelectFileDialog* SelectFileDialog::Create(Listener* listener) {
- return NULL;
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ return new FileManagerDialog(listener);
}