| 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 | 4 |
| 5 #include "chrome/browser/chromeos/extensions/file_browser_private_api.h" | 5 #include "chrome/browser/chromeos/extensions/file_browser_private_api.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 for (size_t i = 0; i < len; ++i) { | 702 for (size_t i = 0; i < len; ++i) { |
| 703 FilePath real_path; | 703 FilePath real_path; |
| 704 const GURL& file_url = file_urls[i]; | 704 const GURL& file_url = file_urls[i]; |
| 705 | 705 |
| 706 // If "localPath" parameter is set, use it as the real path. | 706 // If "localPath" parameter is set, use it as the real path. |
| 707 // TODO(satorux): Eventually, we should be able to get the real path | 707 // TODO(satorux): Eventually, we should be able to get the real path |
| 708 // from GDataFileSystem instead of passing through with filesystem | 708 // from GDataFileSystem instead of passing through with filesystem |
| 709 // URLs. crosbug.com/27510. | 709 // URLs. crosbug.com/27510. |
| 710 // | 710 // |
| 711 // TODO(satorux): GURL::query() is not yet supported for filesystem: | 711 // TODO(satorux): GURL::query() is not yet supported for filesystem: |
| 712 // URLs. For now, use GURL::spec() to get the query portion. Should | 712 // URLs. For now, use GURL::possibly_invalid_spec() to get the query |
| 713 // get rid of the hack once query() is supported: crbug.com/114484. | 713 // portion. Should get rid of the hack once query() is supported: |
| 714 const std::string::size_type query_start = file_url.spec().find('?'); | 714 // crbug.com/114484. |
| 715 const std::string::size_type query_start = |
| 716 file_url.possibly_invalid_spec().find('?'); |
| 715 if (query_start != std::string::npos) { | 717 if (query_start != std::string::npos) { |
| 716 const std::string query = file_url.spec().substr(query_start + 1); | 718 const std::string query = |
| 719 file_url.possibly_invalid_spec().substr(query_start + 1); |
| 717 std::vector<std::pair<std::string, std::string> > parameters; | 720 std::vector<std::pair<std::string, std::string> > parameters; |
| 718 if (base::SplitStringIntoKeyValuePairs( | 721 if (base::SplitStringIntoKeyValuePairs( |
| 719 query, '=', '&', ¶meters)) { | 722 query, '=', '&', ¶meters)) { |
| 720 for (size_t i = 0; i < parameters.size(); ++i) { | 723 for (size_t i = 0; i < parameters.size(); ++i) { |
| 721 if (parameters[i].first == "localPath") { | 724 if (parameters[i].first == "localPath") { |
| 722 const std::string unescaped_value = | 725 const std::string unescaped_value = |
| 723 net::UnescapeURLComponent(parameters[i].second, | 726 net::UnescapeURLComponent(parameters[i].second, |
| 724 kUnescapeRuleForQueryParameters); | 727 kUnescapeRuleForQueryParameters); |
| 725 real_path = FilePath::FromUTF8Unsafe(unescaped_value); | 728 real_path = FilePath::FromUTF8Unsafe(unescaped_value); |
| 726 break; | 729 break; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 751 false); | 754 false); |
| 752 if (!root.empty()) { | 755 if (!root.empty()) { |
| 753 // If we haven't got the real path from "localPath", use it as the | 756 // If we haven't got the real path from "localPath", use it as the |
| 754 // real path. Otherwise, use it as the display name. | 757 // real path. Otherwise, use it as the display name. |
| 755 if (real_path.empty()) | 758 if (real_path.empty()) |
| 756 real_path = root.Append(virtual_path); | 759 real_path = root.Append(virtual_path); |
| 757 else | 760 else |
| 758 display_name = virtual_path.BaseName().value(); | 761 display_name = virtual_path.BaseName().value(); |
| 759 } else { | 762 } else { |
| 760 LOG(WARNING) << "GetLocalPathsOnFileThread failed " | 763 LOG(WARNING) << "GetLocalPathsOnFileThread failed " |
| 761 << file_url.spec(); | 764 << file_url.possibly_invalid_spec(); |
| 762 } | 765 } |
| 763 | 766 |
| 764 if (!real_path.empty()) { | 767 if (!real_path.empty()) { |
| 765 DVLOG(1) << "Selected: real path: " << real_path.value() | 768 DVLOG(1) << "Selected: real path: " << real_path.value() |
| 766 << " display name: " << display_name; | 769 << " display name: " << display_name; |
| 767 selected_files.push_back( | 770 selected_files.push_back( |
| 768 content::SelectedFileInfo(real_path, display_name)); | 771 content::SelectedFileInfo(real_path, display_name)); |
| 769 } | 772 } |
| 770 } | 773 } |
| 771 | 774 |
| (...skipping 1448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2220 gdata::GDataSystemService* system_service = | 2223 gdata::GDataSystemService* system_service = |
| 2221 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 2224 gdata::GDataSystemServiceFactory::GetForProfile(profile_); |
| 2222 if (!system_service || !system_service->file_system()) | 2225 if (!system_service || !system_service->file_system()) |
| 2223 return false; | 2226 return false; |
| 2224 | 2227 |
| 2225 FilePath directory_path = GetVirtualPathFromURL(GURL(file_url_as_string)); | 2228 FilePath directory_path = GetVirtualPathFromURL(GURL(file_url_as_string)); |
| 2226 system_service->file_system()->RequestDirectoryRefresh(directory_path); | 2229 system_service->file_system()->RequestDirectoryRefresh(directory_path); |
| 2227 | 2230 |
| 2228 return true; | 2231 return true; |
| 2229 } | 2232 } |
| OLD | NEW |