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

Side by Side Diff: chrome/browser/ui/views/select_file_dialog_extension.cc

Issue 132453007: Migrate fullPaths to URLs in appState. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 6 years, 10 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 (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/ui/views/select_file_dialog_extension.h" 5 #include "chrome/browser/ui/views/select_file_dialog_extension.h"
6 6
7 #include "apps/shell_window.h" 7 #include "apps/shell_window.h"
8 #include "apps/shell_window_registry.h" 8 #include "apps/shell_window_registry.h"
9 #include "apps/ui/native_app_window.h" 9 #include "apps/ui/native_app_window.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 326
327 base::FilePath download_default_path( 327 base::FilePath download_default_path(
328 pref_service->GetFilePath(prefs::kDownloadDefaultDirectory)); 328 pref_service->GetFilePath(prefs::kDownloadDefaultDirectory));
329 329
330 base::FilePath selection_path = default_path.IsAbsolute() ? 330 base::FilePath selection_path = default_path.IsAbsolute() ?
331 default_path : download_default_path.Append(default_path.BaseName()); 331 default_path : download_default_path.Append(default_path.BaseName());
332 332
333 base::FilePath fallback_path = profile_->last_selected_directory().empty() ? 333 base::FilePath fallback_path = profile_->last_selected_directory().empty() ?
334 download_default_path : profile_->last_selected_directory(); 334 download_default_path : profile_->last_selected_directory();
335 335
336 // Convert the above absolute paths to virtual paths. 336 // Convert the above absolute paths to file system URLs.
337 // TODO(mtomasz): Use URLs instead of paths. 337 GURL selection_url;
338 base::FilePath selection_virtual_path; 338 if (!file_manager::util::ConvertAbsoluteFilePathToFileSystemUrl(
339 if (!file_manager::util::ConvertAbsoluteFilePathToRelativeFileSystemPath(
340 profile_, 339 profile_,
340 selection_path,
341 file_manager::kFileManagerAppId, 341 file_manager::kFileManagerAppId,
342 selection_path, 342 &selection_url)) {
343 &selection_virtual_path)) {
344 // Due to the current design, an invalid temporal cache file path may passed 343 // Due to the current design, an invalid temporal cache file path may passed
345 // as |default_path| (crbug.com/178013 #9-#11). In such a case, we use the 344 // as |default_path| (crbug.com/178013 #9-#11). In such a case, we use the
346 // last selected directory as a workaround. Real fix is tracked at 345 // last selected directory as a workaround. Real fix is tracked at
347 // crbug.com/110119. 346 // crbug.com/110119.
348 if (!file_manager::util::ConvertAbsoluteFilePathToRelativeFileSystemPath( 347 if (!file_manager::util::ConvertAbsoluteFilePathToFileSystemUrl(
349 profile_, 348 profile_,
349 fallback_path.Append(default_path.BaseName()),
350 file_manager::kFileManagerAppId, 350 file_manager::kFileManagerAppId,
351 fallback_path.Append(default_path.BaseName()), 351 &selection_url)) {
352 &selection_virtual_path)) { 352 LOG(ERROR) << "Unable to resolve the selection URL.";
353 LOG(ERROR) << "Unable to resolve the selection path.";
354 return; 353 return;
355 } 354 }
356 } 355 }
357 // TODO(mtomasz): Adding a leading separator works, because this code is
358 // executed on Chrome OS only. This trick will be removed, once migration to
359 // URLs is finished.
360 selection_virtual_path = base::FilePath("/").Append(selection_virtual_path);
361 356
362 base::FilePath current_directory_virtual_path; 357 GURL current_directory_url;
363 base::FilePath current_directory_path = selection_path.DirName(); 358 base::FilePath current_directory_path = selection_path.DirName();
364 if (!file_manager::util::ConvertAbsoluteFilePathToRelativeFileSystemPath( 359 if (!file_manager::util::ConvertAbsoluteFilePathToFileSystemUrl(
365 profile_, 360 profile_,
361 current_directory_path,
366 file_manager::kFileManagerAppId, 362 file_manager::kFileManagerAppId,
367 current_directory_path, 363 &current_directory_url)) {
368 &current_directory_virtual_path)) {
369 // Fallback if necessary, see the comment above. 364 // Fallback if necessary, see the comment above.
370 if (!file_manager::util::ConvertAbsoluteFilePathToRelativeFileSystemPath( 365 if (!file_manager::util::ConvertAbsoluteFilePathToFileSystemUrl(
371 profile_, 366 profile_,
367 fallback_path,
372 file_manager::kFileManagerAppId, 368 file_manager::kFileManagerAppId,
373 fallback_path, 369 &current_directory_url)) {
374 &current_directory_virtual_path)) { 370 LOG(ERROR) << "Unable to resolve the current directory URL for: "
375 LOG(ERROR) << "Unable to resolve the current directory path: "
376 << fallback_path.value(); 371 << fallback_path.value();
377 return; 372 return;
378 } 373 }
379 } 374 }
380 current_directory_virtual_path = base::FilePath("/").Append(
381 current_directory_virtual_path);
382 375
383 has_multiple_file_type_choices_ = 376 has_multiple_file_type_choices_ =
384 !file_types || (file_types->extensions.size() > 1); 377 !file_types || (file_types->extensions.size() > 1);
385 378
386 GURL file_manager_url = 379 GURL file_manager_url =
387 file_manager::util::GetFileManagerMainPageUrlWithParams( 380 file_manager::util::GetFileManagerMainPageUrlWithParams(
388 type, 381 type,
389 title, 382 title,
390 current_directory_virtual_path, 383 current_directory_url,
391 selection_virtual_path, 384 selection_url,
385 default_path.BaseName().value(),
392 file_types, 386 file_types,
393 file_type_index, 387 file_type_index,
394 default_extension); 388 default_extension);
395 389
396 ExtensionDialog* dialog = ExtensionDialog::Show(file_manager_url, 390 ExtensionDialog* dialog = ExtensionDialog::Show(file_manager_url,
397 base_window, profile_, web_contents, 391 base_window, profile_, web_contents,
398 kFileManagerWidth, kFileManagerHeight, 392 kFileManagerWidth, kFileManagerHeight,
399 kFileManagerMinimumWidth, 393 kFileManagerMinimumWidth,
400 kFileManagerMinimumHeight, 394 kFileManagerMinimumHeight,
401 #if defined(USE_AURA) 395 #if defined(USE_AURA)
402 file_manager::util::GetSelectFileDialogTitle(type), 396 file_manager::util::GetSelectFileDialogTitle(type),
403 #else 397 #else
404 // HTML-based header used. 398 // HTML-based header used.
405 base::string16(), 399 base::string16(),
406 #endif 400 #endif
407 this /* ExtensionDialog::Observer */); 401 this /* ExtensionDialog::Observer */);
408 if (!dialog) { 402 if (!dialog) {
409 LOG(ERROR) << "Unable to create extension dialog"; 403 LOG(ERROR) << "Unable to create extension dialog";
410 return; 404 return;
411 } 405 }
412 406
413 // Connect our listener to FileDialogFunction's per-tab callbacks. 407 // Connect our listener to FileDialogFunction's per-tab callbacks.
414 AddPending(routing_id); 408 AddPending(routing_id);
415 409
416 extension_dialog_ = dialog; 410 extension_dialog_ = dialog;
417 params_ = params; 411 params_ = params;
418 routing_id_ = routing_id; 412 routing_id_ = routing_id;
419 owner_window_ = owner_window; 413 owner_window_ = owner_window;
420 } 414 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698