| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/file_manager/url_util.h" | 5 #include "chrome/browser/chromeos/file_manager/url_util.h" |
| 6 | 6 |
| 7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/chromeos/file_manager/app_id.h" | 9 #include "chrome/browser/chromeos/file_manager/app_id.h" |
| 10 #include "net/base/escape.h" | 10 #include "net/base/escape.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 return GetFileManagerUrl("/"); | 60 return GetFileManagerUrl("/"); |
| 61 } | 61 } |
| 62 | 62 |
| 63 GURL GetFileManagerMainPageUrl() { | 63 GURL GetFileManagerMainPageUrl() { |
| 64 return GetFileManagerUrl("/main.html"); | 64 return GetFileManagerUrl("/main.html"); |
| 65 } | 65 } |
| 66 | 66 |
| 67 GURL GetFileManagerMainPageUrlWithParams( | 67 GURL GetFileManagerMainPageUrlWithParams( |
| 68 ui::SelectFileDialog::Type type, | 68 ui::SelectFileDialog::Type type, |
| 69 const base::string16& title, | 69 const base::string16& title, |
| 70 const base::FilePath& current_directory_virtual_path, | 70 const GURL& current_directory_url, |
| 71 const base::FilePath& selection_virtual_path, | 71 const GURL& selection_url, |
| 72 const std::string& target_name, |
| 72 const ui::SelectFileDialog::FileTypeInfo* file_types, | 73 const ui::SelectFileDialog::FileTypeInfo* file_types, |
| 73 int file_type_index, | 74 int file_type_index, |
| 74 const base::FilePath::StringType& default_extension) { | 75 const base::FilePath::StringType& default_extension) { |
| 75 base::DictionaryValue arg_value; | 76 base::DictionaryValue arg_value; |
| 76 arg_value.SetString("type", GetDialogTypeAsString(type)); | 77 arg_value.SetString("type", GetDialogTypeAsString(type)); |
| 77 arg_value.SetString("title", title); | 78 arg_value.SetString("title", title); |
| 78 arg_value.SetString( | 79 arg_value.SetString("currentDirectoryURL", current_directory_url.spec()); |
| 79 "currentDirectoryPath", current_directory_virtual_path.value()); | 80 arg_value.SetString("selectionURL", selection_url.spec()); |
| 80 arg_value.SetString("selectionPath", selection_virtual_path.value()); | 81 arg_value.SetString("targetName", target_name); |
| 81 arg_value.SetString("targetName", selection_virtual_path.BaseName().value()); | |
| 82 arg_value.SetString("defaultExtension", default_extension); | 82 arg_value.SetString("defaultExtension", default_extension); |
| 83 | 83 |
| 84 if (file_types) { | 84 if (file_types) { |
| 85 base::ListValue* types_list = new base::ListValue(); | 85 base::ListValue* types_list = new base::ListValue(); |
| 86 for (size_t i = 0; i < file_types->extensions.size(); ++i) { | 86 for (size_t i = 0; i < file_types->extensions.size(); ++i) { |
| 87 base::ListValue* extensions_list = new base::ListValue(); | 87 base::ListValue* extensions_list = new base::ListValue(); |
| 88 for (size_t j = 0; j < file_types->extensions[i].size(); ++j) { | 88 for (size_t j = 0; j < file_types->extensions[i].size(); ++j) { |
| 89 extensions_list->Append( | 89 extensions_list->Append( |
| 90 new base::StringValue(file_types->extensions[i][j])); | 90 new base::StringValue(file_types->extensions[i][j])); |
| 91 } | 91 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 118 base::JSONWriter::Write(&arg_value, &json_args); | 118 base::JSONWriter::Write(&arg_value, &json_args); |
| 119 | 119 |
| 120 std::string url = GetFileManagerMainPageUrl().spec() + '?' + | 120 std::string url = GetFileManagerMainPageUrl().spec() + '?' + |
| 121 net::EscapeUrlEncodedData(json_args, | 121 net::EscapeUrlEncodedData(json_args, |
| 122 false); // Space to %20 instead of +. | 122 false); // Space to %20 instead of +. |
| 123 return GURL(url); | 123 return GURL(url); |
| 124 } | 124 } |
| 125 | 125 |
| 126 } // namespace util | 126 } // namespace util |
| 127 } // namespace file_manager | 127 } // namespace file_manager |
| OLD | NEW |