Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #include "chrome/browser/chromeos/extensions/file_manager_util.h" | 4 #include "chrome/browser/chromeos/extensions/file_manager_util.h" |
| 5 | 5 |
| 6 #include "ash/shell.h" | 6 #include "ash/shell.h" |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 398 ExecuteHandler(profile, kFileBrowserDomain, action_id, url); | 398 ExecuteHandler(profile, kFileBrowserDomain, action_id, url); |
| 399 return; | 399 return; |
| 400 } | 400 } |
| 401 | 401 |
| 402 std::string url = chrome::kChromeUIFileManagerURL; | 402 std::string url = chrome::kChromeUIFileManagerURL; |
| 403 if (action_id.size()) { | 403 if (action_id.size()) { |
| 404 DictionaryValue arg_value; | 404 DictionaryValue arg_value; |
| 405 arg_value.SetString("action", action_id); | 405 arg_value.SetString("action", action_id); |
| 406 std::string query; | 406 std::string query; |
| 407 base::JSONWriter::Write(&arg_value, &query); | 407 base::JSONWriter::Write(&arg_value, &query); |
| 408 url += "?" + net::EscapeUrlEncodedData(query, false); | 408 url += "?" + |
| 409 net::EscapeUrlEncodedData(query, | |
| 410 false); // Space to %20 instead of +. | |
| 409 } | 411 } |
| 410 if (!path.empty()) { | 412 if (!path.empty()) { |
| 411 base::FilePath virtual_path; | 413 base::FilePath virtual_path; |
| 412 if (!ConvertFileToRelativeFileSystemPath(profile, kFileBrowserDomain, path, | 414 if (!ConvertFileToRelativeFileSystemPath(profile, kFileBrowserDomain, path, |
| 413 &virtual_path)) | 415 &virtual_path)) |
| 414 return; | 416 return; |
| 415 url += "#/" + net::EscapeUrlEncodedData(virtual_path.value(), false); | 417 url += "#/" + |
|
yoshiki
2013/03/26 11:44:50
Should we use "#%2F" instead of "#/", because the
| |
| 418 net::EscapeUrlEncodedData(virtual_path.value(), | |
| 419 false); // Space to %20 instead of +. | |
| 416 } | 420 } |
| 417 | 421 |
| 418 ExtensionService* service = | 422 ExtensionService* service = |
| 419 extensions::ExtensionSystem::Get(profile)->extension_service(); | 423 extensions::ExtensionSystem::Get(profile)->extension_service(); |
| 420 if (!service) | 424 if (!service) |
| 421 return; | 425 return; |
| 422 | 426 |
| 423 const extensions::Extension* extension = | 427 const extensions::Extension* extension = |
| 424 service->GetExtensionById(kFileBrowserDomain, false); | 428 service->GetExtensionById(kFileBrowserDomain, false); |
| 425 if (!extension) | 429 if (!extension) |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 610 GURL* url) { | 614 GURL* url) { |
| 611 GURL origin_url = Extension::GetBaseURLFromExtensionId(extension_id); | 615 GURL origin_url = Extension::GetBaseURLFromExtensionId(extension_id); |
| 612 base::FilePath virtual_path; | 616 base::FilePath virtual_path; |
| 613 if (!ConvertFileToRelativeFileSystemPath(profile, extension_id, | 617 if (!ConvertFileToRelativeFileSystemPath(profile, extension_id, |
| 614 full_file_path, &virtual_path)) { | 618 full_file_path, &virtual_path)) { |
| 615 return false; | 619 return false; |
| 616 } | 620 } |
| 617 | 621 |
| 618 GURL base_url = fileapi::GetFileSystemRootURI(origin_url, | 622 GURL base_url = fileapi::GetFileSystemRootURI(origin_url, |
| 619 fileapi::kFileSystemTypeExternal); | 623 fileapi::kFileSystemTypeExternal); |
| 620 *url = GURL(base_url.spec() + virtual_path.value()); | 624 *url = GURL(base_url.spec() + |
| 625 net::EscapeUrlEncodedData(virtual_path.value(), | |
| 626 false)); // Space to %20 instead of +. | |
| 621 return true; | 627 return true; |
| 622 } | 628 } |
| 623 | 629 |
| 624 bool ConvertFileToRelativeFileSystemPath( | 630 bool ConvertFileToRelativeFileSystemPath( |
| 625 Profile* profile, | 631 Profile* profile, |
| 626 const std::string& extension_id, | 632 const std::string& extension_id, |
| 627 const base::FilePath& full_file_path, | 633 const base::FilePath& full_file_path, |
| 628 base::FilePath* virtual_path) { | 634 base::FilePath* virtual_path) { |
| 629 ExtensionService* service = | 635 ExtensionService* service = |
| 630 extensions::ExtensionSystem::Get(profile)->extension_service(); | 636 extensions::ExtensionSystem::Get(profile)->extension_service(); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 692 | 698 |
| 693 // Disable showing Drive unless it's specifically supported. | 699 // Disable showing Drive unless it's specifically supported. |
| 694 arg_value.SetBoolean("disableDrive", | 700 arg_value.SetBoolean("disableDrive", |
| 695 !file_types || !file_types->support_drive); | 701 !file_types || !file_types->support_drive); |
| 696 | 702 |
| 697 std::string json_args; | 703 std::string json_args; |
| 698 base::JSONWriter::Write(&arg_value, &json_args); | 704 base::JSONWriter::Write(&arg_value, &json_args); |
| 699 | 705 |
| 700 // kChromeUIFileManagerURL could not be used since query parameters are not | 706 // kChromeUIFileManagerURL could not be used since query parameters are not |
| 701 // supported for it. | 707 // supported for it. |
| 702 std::string url = GetFileBrowserUrl().spec() + | 708 std::string url = GetFileBrowserUrl().spec() + '?' + |
| 703 '?' + net::EscapeUrlEncodedData(json_args, false); | 709 net::EscapeUrlEncodedData(json_args, |
| 710 false); // Space to %20 instead of +. | |
| 704 return GURL(url); | 711 return GURL(url); |
| 705 } | 712 } |
| 706 | 713 |
| 707 string16 GetTitleFromType(ui::SelectFileDialog::Type dialog_type) { | 714 string16 GetTitleFromType(ui::SelectFileDialog::Type dialog_type) { |
| 708 string16 title; | 715 string16 title; |
| 709 switch (dialog_type) { | 716 switch (dialog_type) { |
| 710 case ui::SelectFileDialog::SELECT_NONE: | 717 case ui::SelectFileDialog::SELECT_NONE: |
| 711 // Full page file manager doesn't need a title. | 718 // Full page file manager doesn't need a title. |
| 712 break; | 719 break; |
| 713 | 720 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 767 // will have no title. | 774 // will have no title. |
| 768 const int kDialogHeight = 316 + 50; | 775 const int kDialogHeight = 316 + 50; |
| 769 | 776 |
| 770 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); | 777 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); |
| 771 | 778 |
| 772 base::FilePath virtual_path; | 779 base::FilePath virtual_path; |
| 773 if (!ConvertFileToRelativeFileSystemPath(profile, kFileBrowserDomain, path, | 780 if (!ConvertFileToRelativeFileSystemPath(profile, kFileBrowserDomain, path, |
| 774 &virtual_path)) | 781 &virtual_path)) |
| 775 return; | 782 return; |
| 776 std::string url = kActionChoiceUrl; | 783 std::string url = kActionChoiceUrl; |
| 777 url += "#/" + net::EscapeUrlEncodedData(virtual_path.value(), false); | 784 url += "#/" + net::EscapeUrlEncodedData(virtual_path.value(), |
|
yoshiki
2013/03/26 11:44:50
ditto
| |
| 785 false); // Space to %20 instead of +. | |
| 778 GURL dialog_url(url); | 786 GURL dialog_url(url); |
| 779 | 787 |
| 780 const gfx::Size screen = ash::Shell::GetScreen()->GetPrimaryDisplay().size(); | 788 const gfx::Size screen = ash::Shell::GetScreen()->GetPrimaryDisplay().size(); |
| 781 const gfx::Rect bounds((screen.width() - kDialogWidth) / 2, | 789 const gfx::Rect bounds((screen.width() - kDialogWidth) / 2, |
| 782 (screen.height() - kDialogHeight) / 2, | 790 (screen.height() - kDialogHeight) / 2, |
| 783 kDialogWidth, | 791 kDialogWidth, |
| 784 kDialogHeight); | 792 kDialogHeight); |
| 785 | 793 |
| 786 Browser* browser = GetBrowserForUrl(dialog_url); | 794 Browser* browser = GetBrowserForUrl(dialog_url); |
| 787 | 795 |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 967 for (google_apis::OperationProgressStatusList::const_iterator iter = | 975 for (google_apis::OperationProgressStatusList::const_iterator iter = |
| 968 list.begin(); | 976 list.begin(); |
| 969 iter != list.end(); ++iter) { | 977 iter != list.end(); ++iter) { |
| 970 result_list->Append( | 978 result_list->Append( |
| 971 ProgessStatusToDictionaryValue(profile, extension_id, *iter)); | 979 ProgessStatusToDictionaryValue(profile, extension_id, *iter)); |
| 972 } | 980 } |
| 973 return result_list.release(); | 981 return result_list.release(); |
| 974 } | 982 } |
| 975 | 983 |
| 976 } // namespace file_manager_util | 984 } // namespace file_manager_util |
| OLD | NEW |