OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extensions/file_manager_util.h" | 4 #include "chrome/browser/extensions/file_manager_util.h" |
5 | 5 |
6 #include "base/json/json_writer.h" | 6 #include "base/json/json_writer.h" |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
74 path_manager->external_provider(); | 74 path_manager->external_provider(); |
75 if (!provider) | 75 if (!provider) |
76 return false; | 76 return false; |
77 | 77 |
78 // Find if this file path is managed by the external provider. | 78 // Find if this file path is managed by the external provider. |
79 std::vector<FilePath> root_dirs = provider->GetRootDirectories(); | 79 std::vector<FilePath> root_dirs = provider->GetRootDirectories(); |
80 for (std::vector<FilePath>::iterator iter = root_dirs.begin(); | 80 for (std::vector<FilePath>::iterator iter = root_dirs.begin(); |
81 iter != root_dirs.end(); | 81 iter != root_dirs.end(); |
82 ++iter) { | 82 ++iter) { |
83 FilePath path; | 83 FilePath path; |
84 std::vector<FilePath::StringType> components; | |
84 const FilePath& root_path = *iter; | 85 const FilePath& root_path = *iter; |
86 root_path.GetComponents(&components); | |
87 if (!components.size()) { | |
88 NOTREACHED(); | |
89 continue; | |
90 } | |
85 if (root_path.AppendRelativePath(full_file_path, &path)) { | 91 if (root_path.AppendRelativePath(full_file_path, &path)) { |
86 GURL base_url = fileapi::GetFileSystemRootURI(origin_url, | 92 GURL base_url = fileapi::GetFileSystemRootURI(origin_url, |
87 fileapi::kFileSystemTypeExternal); | 93 fileapi::kFileSystemTypeExternal); |
88 *url = GURL(base_url.spec() + root_path.Append(path).value().substr(1)); | 94 std::string final_url = base_url.spec(); |
achuithb
2011/05/20 22:01:04
final_url unused.
| |
95 FilePath relative_path(components[components.size() - 1]); | |
96 *url = GURL(base_url.spec() + relative_path.Append(path).value()); | |
achuithb
2011/05/20 22:01:04
Hmm, I don't understand this. Do you think a comme
| |
89 return true; | 97 return true; |
90 } | 98 } |
91 } | 99 } |
92 return false; | 100 return false; |
93 } | 101 } |
94 | 102 |
95 // static | 103 // static |
96 GURL FileManagerUtil::GetFileBrowserUrlWithParams( | 104 GURL FileManagerUtil::GetFileBrowserUrlWithParams( |
97 SelectFileDialog::Type type, | 105 SelectFileDialog::Type type, |
98 const string16& title, | 106 const string16& title, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
147 if (!browser) | 155 if (!browser) |
148 return; | 156 return; |
149 MediaPlayer* mediaplayer = MediaPlayer::GetInstance(); | 157 MediaPlayer* mediaplayer = MediaPlayer::GetInstance(); |
150 if (enqueue) | 158 if (enqueue) |
151 mediaplayer->EnqueueMediaFile(browser->profile(), full_path, NULL); | 159 mediaplayer->EnqueueMediaFile(browser->profile(), full_path, NULL); |
152 else | 160 else |
153 mediaplayer->ForcePlayMediaFile(browser->profile(), full_path, NULL); | 161 mediaplayer->ForcePlayMediaFile(browser->profile(), full_path, NULL); |
154 return; | 162 return; |
155 } | 163 } |
156 | 164 |
157 // Unknwon file type. Show an error message. | 165 // Unknown file type. Show an error message. |
158 BrowserThread::PostTask( | 166 BrowserThread::PostTask( |
159 BrowserThread::UI, FROM_HERE, | 167 BrowserThread::UI, FROM_HERE, |
160 NewRunnableFunction( | 168 NewRunnableFunction( |
161 &platform_util::SimpleErrorBox, | 169 &platform_util::SimpleErrorBox, |
162 static_cast<gfx::NativeWindow>(NULL), | 170 static_cast<gfx::NativeWindow>(NULL), |
163 l10n_util::GetStringUTF16(IDS_FILEBROWSER_ERROR_TITLE), | 171 l10n_util::GetStringUTF16(IDS_FILEBROWSER_ERROR_TITLE), |
164 l10n_util::GetStringFUTF16(IDS_FILEBROWSER_ERROR_UNKNOWN_FILE_TYPE, | 172 l10n_util::GetStringFUTF16(IDS_FILEBROWSER_ERROR_UNKNOWN_FILE_TYPE, |
165 UTF8ToUTF16(full_path.BaseName().value())) | 173 UTF8ToUTF16(full_path.BaseName().value())) |
166 )); | 174 )); |
167 } | 175 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
236 case SelectFileDialog::SELECT_OPEN_MULTI_FILE: | 244 case SelectFileDialog::SELECT_OPEN_MULTI_FILE: |
237 type_str = "open-multi-file"; | 245 type_str = "open-multi-file"; |
238 break; | 246 break; |
239 | 247 |
240 default: | 248 default: |
241 NOTREACHED(); | 249 NOTREACHED(); |
242 } | 250 } |
243 | 251 |
244 return type_str; | 252 return type_str; |
245 } | 253 } |
OLD | NEW |