Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(272)

Side by Side Diff: chrome/browser/chromeos/extensions/file_manager/private_api_dialog.cc

Issue 23715003: Files.app: Rename the FileBrowserPrivateAPI's functions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed the comments. Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/extensions/file_manager/private_api_dialog.h" 5 #include "chrome/browser/chromeos/extensions/file_manager/private_api_dialog.h"
6 6
7 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h" 7 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h"
8 #include "chrome/browser/ui/views/select_file_dialog_extension.h" 8 #include "chrome/browser/ui/views/select_file_dialog_extension.h"
9 #include "content/public/browser/browser_thread.h" 9 #include "content/public/browser/browser_thread.h"
10 #include "ui/shell_dialogs/selected_file_info.h" 10 #include "ui/shell_dialogs/selected_file_info.h"
11 11
12 using content::BrowserThread; 12 using content::BrowserThread;
13 13
14 namespace extensions { 14 namespace extensions {
15 15
16 CancelFileDialogFunction::CancelFileDialogFunction() { 16 FileBrowserPrivateCancelDialogFunction::
17 FileBrowserPrivateCancelDialogFunction() {
17 } 18 }
18 19
19 CancelFileDialogFunction::~CancelFileDialogFunction() { 20 FileBrowserPrivateCancelDialogFunction::
21 ~FileBrowserPrivateCancelDialogFunction() {
20 } 22 }
21 23
22 bool CancelFileDialogFunction::RunImpl() { 24 bool FileBrowserPrivateCancelDialogFunction::RunImpl() {
23 int32 tab_id = file_manager::util::GetTabId(dispatcher()); 25 int32 tab_id = file_manager::util::GetTabId(dispatcher());
24 SelectFileDialogExtension::OnFileSelectionCanceled(tab_id); 26 SelectFileDialogExtension::OnFileSelectionCanceled(tab_id);
25 SendResponse(true); 27 SendResponse(true);
26 return true; 28 return true;
27 } 29 }
28 30
29 SelectFileFunction::SelectFileFunction() { 31 FileBrowserPrivateSelectFileFunction::FileBrowserPrivateSelectFileFunction() {
30 } 32 }
31 33
32 SelectFileFunction::~SelectFileFunction() { 34 FileBrowserPrivateSelectFileFunction::~FileBrowserPrivateSelectFileFunction() {
33 } 35 }
34 36
35 bool SelectFileFunction::RunImpl() { 37 bool FileBrowserPrivateSelectFileFunction::RunImpl() {
36 if (args_->GetSize() != 4) { 38 if (args_->GetSize() != 4) {
37 return false; 39 return false;
38 } 40 }
39 std::string file_url; 41 std::string file_url;
40 args_->GetString(0, &file_url); 42 args_->GetString(0, &file_url);
41 std::vector<GURL> file_paths; 43 std::vector<GURL> file_paths;
42 file_paths.push_back(GURL(file_url)); 44 file_paths.push_back(GURL(file_url));
43 bool for_opening = false; 45 bool for_opening = false;
44 args_->GetBoolean(2, &for_opening); 46 args_->GetBoolean(2, &for_opening);
45 bool need_local_path = false; 47 bool need_local_path = false;
46 args_->GetBoolean(3, &need_local_path); 48 args_->GetBoolean(3, &need_local_path);
47 49
48 file_manager::util::GetSelectedFileInfoLocalPathOption option = 50 file_manager::util::GetSelectedFileInfoLocalPathOption option =
49 file_manager::util::NO_LOCAL_PATH_RESOLUTION; 51 file_manager::util::NO_LOCAL_PATH_RESOLUTION;
50 if (need_local_path) { 52 if (need_local_path) {
51 option = for_opening ? 53 option = for_opening ?
52 file_manager::util::NEED_LOCAL_PATH_FOR_OPENING : 54 file_manager::util::NEED_LOCAL_PATH_FOR_OPENING :
53 file_manager::util::NEED_LOCAL_PATH_FOR_SAVING; 55 file_manager::util::NEED_LOCAL_PATH_FOR_SAVING;
54 } 56 }
55 57
56 file_manager::util::GetSelectedFileInfo( 58 file_manager::util::GetSelectedFileInfo(
57 render_view_host(), 59 render_view_host(),
58 profile(), 60 profile(),
59 file_paths, 61 file_paths,
60 option, 62 option,
61 base::Bind(&SelectFileFunction::GetSelectedFileInfoResponse, this)); 63 base::Bind(&FileBrowserPrivateSelectFileFunction::
64 GetSelectedFileInfoResponse, this));
62 return true; 65 return true;
63 } 66 }
64 67
65 void SelectFileFunction::GetSelectedFileInfoResponse( 68 void FileBrowserPrivateSelectFileFunction::GetSelectedFileInfoResponse(
66 const std::vector<ui::SelectedFileInfo>& files) { 69 const std::vector<ui::SelectedFileInfo>& files) {
67 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 70 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
68 if (files.size() != 1) { 71 if (files.size() != 1) {
69 SendResponse(false); 72 SendResponse(false);
70 return; 73 return;
71 } 74 }
72 int index; 75 int index;
73 args_->GetInteger(1, &index); 76 args_->GetInteger(1, &index);
74 int32 tab_id = file_manager::util::GetTabId(dispatcher()); 77 int32 tab_id = file_manager::util::GetTabId(dispatcher());
75 SelectFileDialogExtension::OnFileSelected(tab_id, files[0], index); 78 SelectFileDialogExtension::OnFileSelected(tab_id, files[0], index);
76 SendResponse(true); 79 SendResponse(true);
77 } 80 }
78 81
79 SelectFilesFunction::SelectFilesFunction() { 82 FileBrowserPrivateSelectFilesFunction::FileBrowserPrivateSelectFilesFunction() {
80 } 83 }
81 84
82 SelectFilesFunction::~SelectFilesFunction() { 85 FileBrowserPrivateSelectFilesFunction::
86 ~FileBrowserPrivateSelectFilesFunction() {
83 } 87 }
84 88
85 bool SelectFilesFunction::RunImpl() { 89 bool FileBrowserPrivateSelectFilesFunction::RunImpl() {
86 if (args_->GetSize() != 2) { 90 if (args_->GetSize() != 2) {
87 return false; 91 return false;
88 } 92 }
89 93
90 ListValue* path_list = NULL; 94 ListValue* path_list = NULL;
91 args_->GetList(0, &path_list); 95 args_->GetList(0, &path_list);
92 DCHECK(path_list); 96 DCHECK(path_list);
93 97
94 std::string virtual_path; 98 std::string virtual_path;
95 size_t len = path_list->GetSize(); 99 size_t len = path_list->GetSize();
96 std::vector<GURL> file_urls; 100 std::vector<GURL> file_urls;
97 file_urls.reserve(len); 101 file_urls.reserve(len);
98 for (size_t i = 0; i < len; ++i) { 102 for (size_t i = 0; i < len; ++i) {
99 path_list->GetString(i, &virtual_path); 103 path_list->GetString(i, &virtual_path);
100 file_urls.push_back(GURL(virtual_path)); 104 file_urls.push_back(GURL(virtual_path));
101 } 105 }
102 106
103 bool need_local_path = false; 107 bool need_local_path = false;
104 args_->GetBoolean(1, &need_local_path); 108 args_->GetBoolean(1, &need_local_path);
105 109
106 file_manager::util::GetSelectedFileInfo( 110 file_manager::util::GetSelectedFileInfo(
107 render_view_host(), 111 render_view_host(),
108 profile(), 112 profile(),
109 file_urls, 113 file_urls,
110 need_local_path ? 114 need_local_path ?
111 file_manager::util::NEED_LOCAL_PATH_FOR_OPENING : 115 file_manager::util::NEED_LOCAL_PATH_FOR_OPENING :
112 file_manager::util::NO_LOCAL_PATH_RESOLUTION, 116 file_manager::util::NO_LOCAL_PATH_RESOLUTION,
113 base::Bind(&SelectFilesFunction::GetSelectedFileInfoResponse, this)); 117 base::Bind(&FileBrowserPrivateSelectFilesFunction::
118 GetSelectedFileInfoResponse, this));
114 return true; 119 return true;
115 } 120 }
116 121
117 void SelectFilesFunction::GetSelectedFileInfoResponse( 122 void FileBrowserPrivateSelectFilesFunction::GetSelectedFileInfoResponse(
118 const std::vector<ui::SelectedFileInfo>& files) { 123 const std::vector<ui::SelectedFileInfo>& files) {
119 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 124 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
120 int32 tab_id = file_manager::util::GetTabId(dispatcher()); 125 int32 tab_id = file_manager::util::GetTabId(dispatcher());
121 SelectFileDialogExtension::OnMultiFilesSelected(tab_id, files); 126 SelectFileDialogExtension::OnMultiFilesSelected(tab_id, files);
122 SendResponse(true); 127 SendResponse(true);
123 } 128 }
124 129
125 } // namespace extensions 130 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698