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/devtools/devtools_file_helper.h" | 5 #include "chrome/browser/devtools/devtools_file_helper.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 17 matching lines...) Expand all Loading... | |
28 #include "content/public/browser/download_manager.h" | 28 #include "content/public/browser/download_manager.h" |
29 #include "content/public/browser/render_process_host.h" | 29 #include "content/public/browser/render_process_host.h" |
30 #include "content/public/browser/render_view_host.h" | 30 #include "content/public/browser/render_view_host.h" |
31 #include "content/public/browser/web_contents.h" | 31 #include "content/public/browser/web_contents.h" |
32 #include "content/public/browser/web_contents_view.h" | 32 #include "content/public/browser/web_contents_view.h" |
33 #include "content/public/common/content_client.h" | 33 #include "content/public/common/content_client.h" |
34 #include "content/public/common/url_constants.h" | 34 #include "content/public/common/url_constants.h" |
35 #include "grit/generated_resources.h" | 35 #include "grit/generated_resources.h" |
36 #include "ui/base/l10n/l10n_util.h" | 36 #include "ui/base/l10n/l10n_util.h" |
37 #include "ui/shell_dialogs/select_file_dialog.h" | 37 #include "ui/shell_dialogs/select_file_dialog.h" |
38 #include "webkit/browser/fileapi/file_system_url.h" | |
38 #include "webkit/browser/fileapi/isolated_context.h" | 39 #include "webkit/browser/fileapi/isolated_context.h" |
39 #include "webkit/common/fileapi/file_system_util.h" | 40 #include "webkit/common/fileapi/file_system_util.h" |
40 | 41 |
41 using base::Bind; | 42 using base::Bind; |
42 using base::Callback; | 43 using base::Callback; |
43 using content::BrowserContext; | 44 using content::BrowserContext; |
44 using content::BrowserThread; | 45 using content::BrowserThread; |
45 using content::DownloadManager; | 46 using content::DownloadManager; |
46 using content::RenderViewHost; | 47 using content::RenderViewHost; |
47 using content::WebContents; | 48 using content::WebContents; |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
302 Bind(&DevToolsFileHelper::InnerAddFileSystem, | 303 Bind(&DevToolsFileHelper::InnerAddFileSystem, |
303 weak_factory_.GetWeakPtr(), | 304 weak_factory_.GetWeakPtr(), |
304 callback, | 305 callback, |
305 show_info_bar_callback), | 306 show_info_bar_callback), |
306 Bind(callback, FileSystem()), | 307 Bind(callback, FileSystem()), |
307 web_contents_); | 308 web_contents_); |
308 select_file_dialog->Show(ui::SelectFileDialog::SELECT_FOLDER, | 309 select_file_dialog->Show(ui::SelectFileDialog::SELECT_FOLDER, |
309 base::FilePath()); | 310 base::FilePath()); |
310 } | 311 } |
311 | 312 |
313 void DevToolsFileHelper::UpgradeDraggedFileSystemPermissions( | |
314 const std::string& file_system_url, | |
315 const AddFileSystemCallback& callback, | |
316 const ShowInfoBarCallback& show_info_bar_callback) { | |
317 fileapi::FileSystemURL root_url = | |
318 isolated_context()->CrackURL(GURL(file_system_url)); | |
319 if (!root_url.is_valid() || !root_url.path().empty()) { | |
320 callback.Run(FileSystem()); | |
321 return; | |
322 } | |
323 | |
324 std::vector<fileapi::MountPoints::MountPointInfo> mount_points; | |
325 isolated_context()->GetDraggedFileInfo(root_url.filesystem_id(), | |
326 &mount_points); | |
327 | |
328 std::vector<fileapi::MountPoints::MountPointInfo>::const_iterator it = | |
329 mount_points.begin(); | |
330 for (; it != mount_points.end(); ++it) { | |
331 InnerAddFileSystem(callback, show_info_bar_callback, it->path); | |
pfeldman
2013/11/05 06:10:54
drop {}
| |
332 } | |
333 } | |
334 | |
312 void DevToolsFileHelper::InnerAddFileSystem( | 335 void DevToolsFileHelper::InnerAddFileSystem( |
313 const AddFileSystemCallback& callback, | 336 const AddFileSystemCallback& callback, |
314 const ShowInfoBarCallback& show_info_bar_callback, | 337 const ShowInfoBarCallback& show_info_bar_callback, |
315 const base::FilePath& path) { | 338 const base::FilePath& path) { |
316 std::string file_system_path = path.AsUTF8Unsafe(); | 339 std::string file_system_path = path.AsUTF8Unsafe(); |
317 | 340 |
318 const DictionaryValue* file_systems_paths_value = | 341 const DictionaryValue* file_systems_paths_value = |
319 profile_->GetPrefs()->GetDictionary(prefs::kDevToolsFileSystemPaths); | 342 profile_->GetPrefs()->GetDictionary(prefs::kDevToolsFileSystemPaths); |
320 if (file_systems_paths_value->HasKey(file_system_path)) { | 343 if (file_systems_paths_value->HasKey(file_system_path)) { |
321 callback.Run(FileSystem()); | 344 callback.Run(FileSystem()); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
392 DictionaryValue* file_systems_paths_value = update.Get(); | 415 DictionaryValue* file_systems_paths_value = update.Get(); |
393 file_systems_paths_value->RemoveWithoutPathExpansion(file_system_path, NULL); | 416 file_systems_paths_value->RemoveWithoutPathExpansion(file_system_path, NULL); |
394 } | 417 } |
395 | 418 |
396 bool DevToolsFileHelper::IsFileSystemAdded( | 419 bool DevToolsFileHelper::IsFileSystemAdded( |
397 const std::string& file_system_path) { | 420 const std::string& file_system_path) { |
398 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 421 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
399 set<std::string> file_system_paths = GetAddedFileSystemPaths(profile_); | 422 set<std::string> file_system_paths = GetAddedFileSystemPaths(profile_); |
400 return file_system_paths.find(file_system_path) != file_system_paths.end(); | 423 return file_system_paths.find(file_system_path) != file_system_paths.end(); |
401 } | 424 } |
OLD | NEW |