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

Side by Side Diff: chrome/browser/chromeos/file_manager/open_util.cc

Issue 216053002: Files.app multi-profile: add back migration to old path format. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fix Created 6 years, 9 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/file_manager/path_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/open_util.h" 5 #include "chrome/browser/chromeos/file_manager/open_util.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "chrome/browser/chromeos/drive/file_system_util.h" 11 #include "chrome/browser/chromeos/drive/file_system_util.h"
12 #include "chrome/browser/chromeos/file_manager/app_id.h" 12 #include "chrome/browser/chromeos/file_manager/app_id.h"
13 #include "chrome/browser/chromeos/file_manager/file_browser_handlers.h" 13 #include "chrome/browser/chromeos/file_manager/file_browser_handlers.h"
14 #include "chrome/browser/chromeos/file_manager/file_tasks.h" 14 #include "chrome/browser/chromeos/file_manager/file_tasks.h"
15 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" 15 #include "chrome/browser/chromeos/file_manager/fileapi_util.h"
16 #include "chrome/browser/chromeos/file_manager/mime_util.h" 16 #include "chrome/browser/chromeos/file_manager/mime_util.h"
17 #include "chrome/browser/chromeos/file_manager/path_util.h"
17 #include "chrome/browser/chromeos/file_manager/url_util.h" 18 #include "chrome/browser/chromeos/file_manager/url_util.h"
18 #include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h" 19 #include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h"
19 #include "chrome/browser/extensions/extension_service.h" 20 #include "chrome/browser/extensions/extension_service.h"
20 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/ui/browser.h" 22 #include "chrome/browser/ui/browser.h"
22 #include "chrome/browser/ui/browser_finder.h" 23 #include "chrome/browser/ui/browser_finder.h"
23 #include "chrome/browser/ui/browser_tabstrip.h" 24 #include "chrome/browser/ui/browser_tabstrip.h"
24 #include "chrome/browser/ui/browser_window.h" 25 #include "chrome/browser/ui/browser_window.h"
25 #include "chrome/browser/ui/extensions/application_launch.h" 26 #include "chrome/browser/ui/extensions/application_launch.h"
26 #include "chrome/browser/ui/simple_message_box.h" 27 #include "chrome/browser/ui/simple_message_box.h"
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 201
201 } // namespace 202 } // namespace
202 203
203 void OpenRemovableDrive(Profile* profile, const base::FilePath& file_path) { 204 void OpenRemovableDrive(Profile* profile, const base::FilePath& file_path) {
204 OpenFileManagerWithInternalActionId(profile, file_path, "auto-open"); 205 OpenFileManagerWithInternalActionId(profile, file_path, "auto-open");
205 } 206 }
206 207
207 void OpenItem(Profile* profile, const base::FilePath& file_path) { 208 void OpenItem(Profile* profile, const base::FilePath& file_path) {
208 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 209 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
209 210
211 // The path may have been stored in preferences in old versions.
212 // We need migration here.
213 // TODO(kinaba): crbug.com/313539 remove it in the future.
214 base::FilePath path;
215 if (!util::MigratePathFromOldFormat(profile, file_path, &path))
216 path = file_path;
217
210 GURL url; 218 GURL url;
211 if (!ConvertAbsoluteFilePathToFileSystemUrl( 219 if (!ConvertAbsoluteFilePathToFileSystemUrl(
212 profile, file_path, kFileManagerAppId, &url) || 220 profile, path, kFileManagerAppId, &url) ||
213 !GrantFileSystemAccessToFileBrowser(profile)) { 221 !GrantFileSystemAccessToFileBrowser(profile)) {
214 ShowWarningMessageBox(profile, file_path); 222 ShowWarningMessageBox(profile, path);
215 return; 223 return;
216 } 224 }
217 225
218 scoped_refptr<fileapi::FileSystemContext> file_system_context = 226 scoped_refptr<fileapi::FileSystemContext> file_system_context =
219 GetFileSystemContextForExtensionId( 227 GetFileSystemContextForExtensionId(
220 profile, kFileManagerAppId); 228 profile, kFileManagerAppId);
221 229
222 CheckIfDirectoryExists(file_system_context, url, 230 CheckIfDirectoryExists(file_system_context, url,
223 base::Bind(&ContinueOpenItem, profile, file_path)); 231 base::Bind(&ContinueOpenItem, profile, path));
224 } 232 }
225 233
226 void ShowItemInFolder(Profile* profile, const base::FilePath& file_path) { 234 void ShowItemInFolder(Profile* profile, const base::FilePath& file_path) {
235 // The path may have been stored in preferences in old versions.
236 // We need migration here.
237 // TODO(kinaba): crbug.com/313539 remove it in the future.
238 base::FilePath path;
239 if (!util::MigratePathFromOldFormat(profile, file_path, &path))
240 path = file_path;
241
227 // This action changes the selection so we do not reuse existing tabs. 242 // This action changes the selection so we do not reuse existing tabs.
228 OpenFileManagerWithInternalActionId(profile, file_path, "select"); 243 OpenFileManagerWithInternalActionId(profile, path, "select");
229 } 244 }
230 245
231 } // namespace util 246 } // namespace util
232 } // namespace file_manager 247 } // namespace file_manager
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/file_manager/path_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698