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

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

Issue 257333002: Drive extension functions from ExtensionFunction::Run. The (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix comment Created 6 years, 7 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 "chrome/common/extensions/api/file_browser_private.h" 9 #include "chrome/common/extensions/api/file_browser_private.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
11 #include "ui/shell_dialogs/selected_file_info.h" 11 #include "ui/shell_dialogs/selected_file_info.h"
12 12
13 using content::BrowserThread; 13 using content::BrowserThread;
14 14
15 namespace extensions { 15 namespace extensions {
16 16
17 namespace { 17 namespace {
18 18
19 // Computes the routing ID for SelectFileDialogExtension from the |function|. 19 // Computes the routing ID for SelectFileDialogExtension from the |function|.
20 SelectFileDialogExtension::RoutingID GetFileDialogRoutingID( 20 SelectFileDialogExtension::RoutingID GetFileDialogRoutingID(
21 ChromeAsyncExtensionFunction* function) { 21 ChromeAsyncExtensionFunction* function) {
22 return SelectFileDialogExtension::GetRoutingIDFromWebContents( 22 return SelectFileDialogExtension::GetRoutingIDFromWebContents(
23 function->GetAssociatedWebContents()); 23 function->GetAssociatedWebContents());
24 } 24 }
25 25
26 } // namespace 26 } // namespace
27 27
28 bool FileBrowserPrivateCancelDialogFunction::RunImpl() { 28 bool FileBrowserPrivateCancelDialogFunction::RunAsync() {
29 SelectFileDialogExtension::OnFileSelectionCanceled( 29 SelectFileDialogExtension::OnFileSelectionCanceled(
30 GetFileDialogRoutingID(this)); 30 GetFileDialogRoutingID(this));
31 SendResponse(true); 31 SendResponse(true);
32 return true; 32 return true;
33 } 33 }
34 34
35 bool FileBrowserPrivateSelectFileFunction::RunImpl() { 35 bool FileBrowserPrivateSelectFileFunction::RunAsync() {
36 using extensions::api::file_browser_private::SelectFile::Params; 36 using extensions::api::file_browser_private::SelectFile::Params;
37 const scoped_ptr<Params> params(Params::Create(*args_)); 37 const scoped_ptr<Params> params(Params::Create(*args_));
38 EXTENSION_FUNCTION_VALIDATE(params); 38 EXTENSION_FUNCTION_VALIDATE(params);
39 39
40 std::vector<GURL> file_paths; 40 std::vector<GURL> file_paths;
41 file_paths.push_back(GURL(params->selected_path)); 41 file_paths.push_back(GURL(params->selected_path));
42 42
43 file_manager::util::GetSelectedFileInfoLocalPathOption option = 43 file_manager::util::GetSelectedFileInfoLocalPathOption option =
44 file_manager::util::NO_LOCAL_PATH_RESOLUTION; 44 file_manager::util::NO_LOCAL_PATH_RESOLUTION;
45 if (params->should_return_local_path) { 45 if (params->should_return_local_path) {
(...skipping 20 matching lines...) Expand all
66 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 66 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
67 if (files.size() != 1) { 67 if (files.size() != 1) {
68 SendResponse(false); 68 SendResponse(false);
69 return; 69 return;
70 } 70 }
71 SelectFileDialogExtension::OnFileSelected(GetFileDialogRoutingID(this), 71 SelectFileDialogExtension::OnFileSelected(GetFileDialogRoutingID(this),
72 files[0], index); 72 files[0], index);
73 SendResponse(true); 73 SendResponse(true);
74 } 74 }
75 75
76 bool FileBrowserPrivateSelectFilesFunction::RunImpl() { 76 bool FileBrowserPrivateSelectFilesFunction::RunAsync() {
77 using extensions::api::file_browser_private::SelectFiles::Params; 77 using extensions::api::file_browser_private::SelectFiles::Params;
78 const scoped_ptr<Params> params(Params::Create(*args_)); 78 const scoped_ptr<Params> params(Params::Create(*args_));
79 EXTENSION_FUNCTION_VALIDATE(params); 79 EXTENSION_FUNCTION_VALIDATE(params);
80 80
81 std::vector<GURL> file_urls; 81 std::vector<GURL> file_urls;
82 for (size_t i = 0; i < params->selected_paths.size(); ++i) 82 for (size_t i = 0; i < params->selected_paths.size(); ++i)
83 file_urls.push_back(GURL(params->selected_paths[i])); 83 file_urls.push_back(GURL(params->selected_paths[i]));
84 84
85 file_manager::util::GetSelectedFileInfo( 85 file_manager::util::GetSelectedFileInfo(
86 render_view_host(), 86 render_view_host(),
(...skipping 10 matching lines...) Expand all
97 97
98 void FileBrowserPrivateSelectFilesFunction::GetSelectedFileInfoResponse( 98 void FileBrowserPrivateSelectFilesFunction::GetSelectedFileInfoResponse(
99 const std::vector<ui::SelectedFileInfo>& files) { 99 const std::vector<ui::SelectedFileInfo>& files) {
100 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 100 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
101 SelectFileDialogExtension::OnMultiFilesSelected(GetFileDialogRoutingID(this), 101 SelectFileDialogExtension::OnMultiFilesSelected(GetFileDialogRoutingID(this),
102 files); 102 files);
103 SendResponse(true); 103 SendResponse(true);
104 } 104 }
105 105
106 } // namespace extensions 106 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698