OLD | NEW |
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_util.h" | 5 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 for (size_t i = params->selected_files.size(); | 112 for (size_t i = params->selected_files.size(); |
113 i < params->file_paths.size(); ++i) { | 113 i < params->file_paths.size(); ++i) { |
114 const base::FilePath& file_path = params->file_paths[i]; | 114 const base::FilePath& file_path = params->file_paths[i]; |
115 | 115 |
116 if (file_manager::util::IsUnderNonNativeLocalPath(profile, file_path)) { | 116 if (file_manager::util::IsUnderNonNativeLocalPath(profile, file_path)) { |
117 // When the caller of the select file dialog wants local file paths, and | 117 // When the caller of the select file dialog wants local file paths, and |
118 // the selected path does not point to a native local path (e.g., Drive, | 118 // the selected path does not point to a native local path (e.g., Drive, |
119 // MTP, or provided file system), we should resolve the path. | 119 // MTP, or provided file system), we should resolve the path. |
120 switch (params->local_path_option) { | 120 switch (params->local_path_option) { |
121 case NO_LOCAL_PATH_RESOLUTION: | 121 case NO_LOCAL_PATH_RESOLUTION: |
122 break; // No special handling needed. | 122 // Pass empty local path. |
| 123 params->selected_files.push_back( |
| 124 ui::SelectedFileInfo(file_path, base::FilePath())); |
| 125 break; |
123 case NEED_LOCAL_PATH_FOR_OPENING: | 126 case NEED_LOCAL_PATH_FOR_OPENING: |
124 GetFileNativeLocalPathForOpening( | 127 GetFileNativeLocalPathForOpening( |
125 profile, | 128 profile, |
126 file_path, | 129 file_path, |
127 base::Bind(&ContinueGetSelectedFileInfo, | 130 base::Bind(&ContinueGetSelectedFileInfo, |
128 profile, | 131 profile, |
129 base::Passed(¶ms))); | 132 base::Passed(¶ms))); |
130 return; // Remaining work is done in ContinueGetSelectedFileInfo. | 133 return; // Remaining work is done in ContinueGetSelectedFileInfo. |
131 case NEED_LOCAL_PATH_FOR_SAVING: | 134 case NEED_LOCAL_PATH_FOR_SAVING: |
132 GetFileNativeLocalPathForSaving( | 135 GetFileNativeLocalPathForSaving( |
133 profile, | 136 profile, |
134 file_path, | 137 file_path, |
135 base::Bind(&ContinueGetSelectedFileInfo, | 138 base::Bind(&ContinueGetSelectedFileInfo, |
136 profile, | 139 profile, |
137 base::Passed(¶ms))); | 140 base::Passed(¶ms))); |
138 return; // Remaining work is done in ContinueGetSelectedFileInfo. | 141 return; // Remaining work is done in ContinueGetSelectedFileInfo. |
139 } | 142 } |
| 143 } else { |
| 144 params->selected_files.push_back( |
| 145 ui::SelectedFileInfo(file_path, file_path)); |
140 } | 146 } |
141 params->selected_files.push_back( | |
142 ui::SelectedFileInfo(file_path, base::FilePath())); | |
143 } | 147 } |
144 params->callback.Run(params->selected_files); | 148 params->callback.Run(params->selected_files); |
145 } | 149 } |
146 | 150 |
147 // Part of GetSelectedFileInfo(). | 151 // Part of GetSelectedFileInfo(). |
148 void ContinueGetSelectedFileInfo(Profile* profile, | 152 void ContinueGetSelectedFileInfo(Profile* profile, |
149 scoped_ptr<GetSelectedFileInfoParams> params, | 153 scoped_ptr<GetSelectedFileInfoParams> params, |
150 const base::FilePath& local_path) { | 154 const base::FilePath& local_path) { |
151 if (local_path.empty()) { | 155 if (local_path.empty()) { |
152 params->callback.Run(std::vector<ui::SelectedFileInfo>()); | 156 params->callback.Run(std::vector<ui::SelectedFileInfo>()); |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 } | 334 } |
331 | 335 |
332 drive::EventLogger* GetLogger(Profile* profile) { | 336 drive::EventLogger* GetLogger(Profile* profile) { |
333 drive::DriveIntegrationService* service = | 337 drive::DriveIntegrationService* service = |
334 drive::DriveIntegrationServiceFactory::FindForProfile(profile); | 338 drive::DriveIntegrationServiceFactory::FindForProfile(profile); |
335 return service ? service->event_logger() : NULL; | 339 return service ? service->event_logger() : NULL; |
336 } | 340 } |
337 | 341 |
338 } // namespace util | 342 } // namespace util |
339 } // namespace file_manager | 343 } // namespace file_manager |
OLD | NEW |