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

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

Issue 23581006: Reland 220012: Move the functions of filebrowserPrivateApi from the file_manager namespace to the e… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased 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 file_manager { 14 namespace extensions {
15 15
16 CancelFileDialogFunction::CancelFileDialogFunction() { 16 CancelFileDialogFunction::CancelFileDialogFunction() {
17 } 17 }
18 18
19 CancelFileDialogFunction::~CancelFileDialogFunction() { 19 CancelFileDialogFunction::~CancelFileDialogFunction() {
20 } 20 }
21 21
22 bool CancelFileDialogFunction::RunImpl() { 22 bool CancelFileDialogFunction::RunImpl() {
23 int32 tab_id = util::GetTabId(dispatcher()); 23 int32 tab_id = file_manager::util::GetTabId(dispatcher());
24 SelectFileDialogExtension::OnFileSelectionCanceled(tab_id); 24 SelectFileDialogExtension::OnFileSelectionCanceled(tab_id);
25 SendResponse(true); 25 SendResponse(true);
26 return true; 26 return true;
27 } 27 }
28 28
29 SelectFileFunction::SelectFileFunction() { 29 SelectFileFunction::SelectFileFunction() {
30 } 30 }
31 31
32 SelectFileFunction::~SelectFileFunction() { 32 SelectFileFunction::~SelectFileFunction() {
33 } 33 }
34 34
35 bool SelectFileFunction::RunImpl() { 35 bool SelectFileFunction::RunImpl() {
36 if (args_->GetSize() != 4) { 36 if (args_->GetSize() != 4) {
37 return false; 37 return false;
38 } 38 }
39 std::string file_url; 39 std::string file_url;
40 args_->GetString(0, &file_url); 40 args_->GetString(0, &file_url);
41 std::vector<GURL> file_paths; 41 std::vector<GURL> file_paths;
42 file_paths.push_back(GURL(file_url)); 42 file_paths.push_back(GURL(file_url));
43 bool for_opening = false; 43 bool for_opening = false;
44 args_->GetBoolean(2, &for_opening); 44 args_->GetBoolean(2, &for_opening);
45 bool need_local_path = false; 45 bool need_local_path = false;
46 args_->GetBoolean(3, &need_local_path); 46 args_->GetBoolean(3, &need_local_path);
47 47
48 util::GetSelectedFileInfoLocalPathOption option = 48 file_manager::util::GetSelectedFileInfoLocalPathOption option =
49 util::NO_LOCAL_PATH_RESOLUTION; 49 file_manager::util::NO_LOCAL_PATH_RESOLUTION;
50 if (need_local_path) { 50 if (need_local_path) {
51 option = for_opening ? 51 option = for_opening ?
52 util::NEED_LOCAL_PATH_FOR_OPENING : util::NEED_LOCAL_PATH_FOR_SAVING; 52 file_manager::util::NEED_LOCAL_PATH_FOR_OPENING :
53 file_manager::util::NEED_LOCAL_PATH_FOR_SAVING;
53 } 54 }
54 55
55 util::GetSelectedFileInfo( 56 file_manager::util::GetSelectedFileInfo(
56 render_view_host(), 57 render_view_host(),
57 profile(), 58 profile(),
58 file_paths, 59 file_paths,
59 option, 60 option,
60 base::Bind(&SelectFileFunction::GetSelectedFileInfoResponse, this)); 61 base::Bind(&SelectFileFunction::GetSelectedFileInfoResponse, this));
61 return true; 62 return true;
62 } 63 }
63 64
64 void SelectFileFunction::GetSelectedFileInfoResponse( 65 void SelectFileFunction::GetSelectedFileInfoResponse(
65 const std::vector<ui::SelectedFileInfo>& files) { 66 const std::vector<ui::SelectedFileInfo>& files) {
66 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 67 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
67 if (files.size() != 1) { 68 if (files.size() != 1) {
68 SendResponse(false); 69 SendResponse(false);
69 return; 70 return;
70 } 71 }
71 int index; 72 int index;
72 args_->GetInteger(1, &index); 73 args_->GetInteger(1, &index);
73 int32 tab_id = util::GetTabId(dispatcher()); 74 int32 tab_id = file_manager::util::GetTabId(dispatcher());
74 SelectFileDialogExtension::OnFileSelected(tab_id, files[0], index); 75 SelectFileDialogExtension::OnFileSelected(tab_id, files[0], index);
75 SendResponse(true); 76 SendResponse(true);
76 } 77 }
77 78
78 SelectFilesFunction::SelectFilesFunction() { 79 SelectFilesFunction::SelectFilesFunction() {
79 } 80 }
80 81
81 SelectFilesFunction::~SelectFilesFunction() { 82 SelectFilesFunction::~SelectFilesFunction() {
82 } 83 }
83 84
(...skipping 11 matching lines...) Expand all
95 std::vector<GURL> file_urls; 96 std::vector<GURL> file_urls;
96 file_urls.reserve(len); 97 file_urls.reserve(len);
97 for (size_t i = 0; i < len; ++i) { 98 for (size_t i = 0; i < len; ++i) {
98 path_list->GetString(i, &virtual_path); 99 path_list->GetString(i, &virtual_path);
99 file_urls.push_back(GURL(virtual_path)); 100 file_urls.push_back(GURL(virtual_path));
100 } 101 }
101 102
102 bool need_local_path = false; 103 bool need_local_path = false;
103 args_->GetBoolean(1, &need_local_path); 104 args_->GetBoolean(1, &need_local_path);
104 105
105 util::GetSelectedFileInfo( 106 file_manager::util::GetSelectedFileInfo(
106 render_view_host(), 107 render_view_host(),
107 profile(), 108 profile(),
108 file_urls, 109 file_urls,
109 need_local_path ? 110 need_local_path ?
110 util::NEED_LOCAL_PATH_FOR_OPENING : util::NO_LOCAL_PATH_RESOLUTION, 111 file_manager::util::NEED_LOCAL_PATH_FOR_OPENING :
112 file_manager::util::NO_LOCAL_PATH_RESOLUTION,
111 base::Bind(&SelectFilesFunction::GetSelectedFileInfoResponse, this)); 113 base::Bind(&SelectFilesFunction::GetSelectedFileInfoResponse, this));
112 return true; 114 return true;
113 } 115 }
114 116
115 void SelectFilesFunction::GetSelectedFileInfoResponse( 117 void SelectFilesFunction::GetSelectedFileInfoResponse(
116 const std::vector<ui::SelectedFileInfo>& files) { 118 const std::vector<ui::SelectedFileInfo>& files) {
117 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 119 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
118 int32 tab_id = util::GetTabId(dispatcher()); 120 int32 tab_id = file_manager::util::GetTabId(dispatcher());
119 SelectFileDialogExtension::OnMultiFilesSelected(tab_id, files); 121 SelectFileDialogExtension::OnMultiFilesSelected(tab_id, files);
120 SendResponse(true); 122 SendResponse(true);
121 } 123 }
122 124
123 } // namespace file_manager 125 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698