| Index: chrome/browser/ui/views/file_manager_dialogs.cc
|
| ===================================================================
|
| --- chrome/browser/ui/views/file_manager_dialogs.cc (revision 81876)
|
| +++ chrome/browser/ui/views/file_manager_dialogs.cc (working copy)
|
| @@ -2,23 +2,19 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "base/json/json_writer.h"
|
| #include "base/logging.h"
|
| -#include "base/memory/scoped_ptr.h"
|
| -#include "base/utf_string_conversions.h"
|
| -#include "base/values.h"
|
| #include "chrome/browser/extensions/extension_file_browser_private_api.h"
|
| +#include "chrome/browser/extensions/file_manager_util.h"
|
| +#include "chrome/browser/metrics/user_metrics.h"
|
| #include "chrome/browser/profiles/profile_manager.h"
|
| #include "chrome/browser/ui/browser.h"
|
| #include "chrome/browser/ui/browser_dialogs.h"
|
| #include "chrome/browser/ui/browser_list.h"
|
| -#include "chrome/browser/ui/shell_dialogs.h"
|
| #include "chrome/browser/ui/views/html_dialog_view.h"
|
| #include "chrome/browser/ui/views/window.h"
|
| #include "chrome/browser/ui/webui/html_dialog_ui.h"
|
| #include "content/browser/browser_thread.h"
|
| #include "content/browser/tab_contents/tab_contents.h"
|
| -#include "third_party/libjingle/source/talk/base/urlencode.h"
|
| #include "views/window/window.h"
|
| #include "ui/gfx/rect.h"
|
| #include "ui/gfx/size.h"
|
| @@ -31,18 +27,6 @@
|
| public:
|
| explicit FileManagerDialog(Listener* listener);
|
|
|
| - // Helper to convert numeric dialog type to a string.
|
| - static std::string GetDialogTypeAsString(Type dialog_type);
|
| -
|
| - // Help to convert potential dialog arguments into json.
|
| - static std::string GetArgumentsJson(
|
| - Type type,
|
| - const string16& title,
|
| - const FilePath& default_path,
|
| - const FileTypeInfo* file_types,
|
| - int file_type_index,
|
| - const FilePath::StringType& default_extension);
|
| -
|
| void CreateHtmlDialogView(Profile* profile, void* params) {
|
| HtmlDialogView* html_view = new HtmlDialogView(profile, this);
|
| browser::CreateViewsWindow(owner_window_, gfx::Rect(), html_view);
|
| @@ -149,9 +133,6 @@
|
| // Base url plus query string.
|
| GURL dialog_url_;
|
|
|
| - // The base url for the file manager extension.
|
| - static std::string s_extension_base_url_;
|
| -
|
| DISALLOW_COPY_AND_ASSIGN(FileManagerDialog);
|
| };
|
|
|
| @@ -164,12 +145,6 @@
|
| return new FileManagerDialog(listener);
|
| }
|
|
|
| -// This is the "well known" url for the file manager extension from
|
| -// browser/resources/file_manager. In the future we may provide a way to swap
|
| -// out this file manager for an aftermarket part, but not yet.
|
| -std::string FileManagerDialog::s_extension_base_url_ =
|
| - "chrome-extension://hhaomjibdihmijegdhdafkllkbggdgoj/main.html";
|
| -
|
| FileManagerDialog::FileManagerDialog(Listener* listener)
|
| : SelectFileDialog(listener),
|
| tab_id_(0),
|
| @@ -195,10 +170,8 @@
|
| title_ = UTF16ToWide(title);
|
| owner_window_ = owner_window;
|
|
|
| - std::string json = GetArgumentsJson(type, title, default_path, file_types,
|
| - file_type_index, default_extension);
|
| - dialog_url_ = GURL(s_extension_base_url_ + "?" +
|
| - UrlEncodeStringWithoutEncodingSpaceAsPlus(json));
|
| + dialog_url_ = FileManagerUtil::GetFileBrowserUrlWithParams(type, title,
|
| + default_path, file_types, file_type_index, default_extension);
|
|
|
| if (browser_mode_) {
|
| Browser* browser = BrowserList::GetLastActive();
|
| @@ -217,78 +190,3 @@
|
| ProfileManager::GetDefaultProfile(), params));
|
| }
|
|
|
| -// static
|
| -std::string FileManagerDialog::GetDialogTypeAsString(Type dialog_type) {
|
| - std::string type_str;
|
| - switch (dialog_type) {
|
| - case SelectFileDialog::SELECT_NONE:
|
| - type_str = "none";
|
| - break;
|
| -
|
| - case SELECT_FOLDER:
|
| - type_str = "folder";
|
| - break;
|
| -
|
| - case SELECT_SAVEAS_FILE:
|
| - type_str = "saveas-file";
|
| - break;
|
| -
|
| - case SELECT_OPEN_FILE:
|
| - type_str = "open-file";
|
| - break;
|
| -
|
| - case SELECT_OPEN_MULTI_FILE:
|
| - type_str = "open-multi-file";
|
| - break;
|
| -
|
| - default:
|
| - NOTREACHED();
|
| - }
|
| -
|
| - return type_str;
|
| -}
|
| -
|
| -// static
|
| -std::string FileManagerDialog::GetArgumentsJson(
|
| - Type type,
|
| - const string16& title,
|
| - const FilePath& default_path,
|
| - const FileTypeInfo* file_types,
|
| - int file_type_index,
|
| - const FilePath::StringType& default_extension) {
|
| - DictionaryValue arg_value;
|
| - arg_value.SetString("type", GetDialogTypeAsString(type));
|
| - arg_value.SetString("title", title);
|
| - arg_value.SetString("defaultPath", default_path.value());
|
| - arg_value.SetString("defaultExtension", default_extension);
|
| -
|
| - ListValue* types_list = new ListValue();
|
| -
|
| - if (file_types) {
|
| - for (size_t i = 0; i < file_types->extensions.size(); ++i) {
|
| - ListValue* extensions_list = new ListValue();
|
| - for (size_t j = 0; j < file_types->extensions[i].size(); ++j) {
|
| - extensions_list->Set(
|
| - i, Value::CreateStringValue(file_types->extensions[i][j]));
|
| - }
|
| -
|
| - DictionaryValue* dict = new DictionaryValue();
|
| - dict->Set("extensions", extensions_list);
|
| -
|
| - if (i < file_types->extension_description_overrides.size()) {
|
| - string16 desc = file_types->extension_description_overrides[i];
|
| - dict->SetString("description", desc);
|
| - }
|
| -
|
| - dict->SetBoolean("selected",
|
| - (static_cast<size_t>(file_type_index) == i));
|
| -
|
| - types_list->Set(i, dict);
|
| - }
|
| - }
|
| -
|
| - std::string rv;
|
| - base::JSONWriter::Write(&arg_value, false, &rv);
|
| -
|
| - return rv;
|
| -}
|
|
|