| 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" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
| 13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/md5.h" | 15 #include "base/md5.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 17 #include "base/value_conversions.h" | 17 #include "base/value_conversions.h" |
| 18 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
| 19 #include "chrome/browser/devtools/devtools_file_watcher.h" | 19 #include "chrome/browser/devtools/devtools_file_watcher.h" |
| 20 #include "chrome/browser/download/download_prefs.h" | 20 #include "chrome/browser/download/download_prefs.h" |
| 21 #include "chrome/browser/platform_util.h" | |
| 22 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
| 23 #include "chrome/browser/ui/chrome_select_file_policy.h" | 22 #include "chrome/browser/ui/chrome_select_file_policy.h" |
| 24 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
| 25 #include "chrome/grit/generated_resources.h" | 24 #include "chrome/grit/generated_resources.h" |
| 26 #include "components/prefs/pref_service.h" | 25 #include "components/prefs/pref_service.h" |
| 27 #include "components/prefs/scoped_user_pref_update.h" | 26 #include "components/prefs/scoped_user_pref_update.h" |
| 28 #include "content/public/browser/browser_context.h" | 27 #include "content/public/browser/browser_context.h" |
| 29 #include "content/public/browser/browser_thread.h" | 28 #include "content/public/browser/browser_thread.h" |
| 30 #include "content/public/browser/child_process_security_policy.h" | 29 #include "content/public/browser/child_process_security_policy.h" |
| 31 #include "content/public/browser/download_manager.h" | 30 #include "content/public/browser/download_manager.h" |
| 32 #include "content/public/browser/render_process_host.h" | 31 #include "content/public/browser/render_process_host.h" |
| 33 #include "content/public/browser/render_view_host.h" | 32 #include "content/public/browser/render_view_host.h" |
| 34 #include "content/public/browser/web_contents.h" | 33 #include "content/public/browser/web_contents.h" |
| 35 #include "content/public/common/content_client.h" | 34 #include "content/public/common/content_client.h" |
| 36 #include "content/public/common/url_constants.h" | 35 #include "content/public/common/url_constants.h" |
| 37 #include "storage/browser/fileapi/file_system_url.h" | 36 #include "storage/browser/fileapi/file_system_url.h" |
| 38 #include "storage/browser/fileapi/isolated_context.h" | 37 #include "storage/browser/fileapi/isolated_context.h" |
| 39 #include "storage/common/fileapi/file_system_util.h" | 38 #include "storage/common/fileapi/file_system_util.h" |
| 40 #include "ui/base/l10n/l10n_util.h" | 39 #include "ui/base/l10n/l10n_util.h" |
| 40 #include "ui/gfx/view_util.h" |
| 41 #include "ui/shell_dialogs/select_file_dialog.h" | 41 #include "ui/shell_dialogs/select_file_dialog.h" |
| 42 | 42 |
| 43 using base::Bind; | 43 using base::Bind; |
| 44 using base::Callback; | 44 using base::Callback; |
| 45 using content::BrowserContext; | 45 using content::BrowserContext; |
| 46 using content::BrowserThread; | 46 using content::BrowserThread; |
| 47 using content::DownloadManager; | 47 using content::DownloadManager; |
| 48 using content::RenderViewHost; | 48 using content::RenderViewHost; |
| 49 using content::WebContents; | 49 using content::WebContents; |
| 50 using std::set; | 50 using std::set; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 69 canceled_callback_(canceled_callback), | 69 canceled_callback_(canceled_callback), |
| 70 web_contents_(web_contents) { | 70 web_contents_(web_contents) { |
| 71 select_file_dialog_ = ui::SelectFileDialog::Create( | 71 select_file_dialog_ = ui::SelectFileDialog::Create( |
| 72 this, new ChromeSelectFilePolicy(web_contents)); | 72 this, new ChromeSelectFilePolicy(web_contents)); |
| 73 } | 73 } |
| 74 | 74 |
| 75 void Show(ui::SelectFileDialog::Type type, | 75 void Show(ui::SelectFileDialog::Type type, |
| 76 const base::FilePath& default_path) { | 76 const base::FilePath& default_path) { |
| 77 AddRef(); // Balanced in the three listener outcomes. | 77 AddRef(); // Balanced in the three listener outcomes. |
| 78 select_file_dialog_->SelectFile( | 78 select_file_dialog_->SelectFile( |
| 79 type, | 79 type, base::string16(), default_path, NULL, 0, |
| 80 base::string16(), | 80 base::FilePath::StringType(), |
| 81 default_path, | 81 gfx::GetTopLevel(web_contents_->GetNativeView()), NULL); |
| 82 NULL, | |
| 83 0, | |
| 84 base::FilePath::StringType(), | |
| 85 platform_util::GetTopLevel(web_contents_->GetNativeView()), | |
| 86 NULL); | |
| 87 } | 82 } |
| 88 | 83 |
| 89 // ui::SelectFileDialog::Listener implementation. | 84 // ui::SelectFileDialog::Listener implementation. |
| 90 void FileSelected(const base::FilePath& path, | 85 void FileSelected(const base::FilePath& path, |
| 91 int index, | 86 int index, |
| 92 void* params) override { | 87 void* params) override { |
| 93 selected_callback_.Run(path); | 88 selected_callback_.Run(path); |
| 94 Release(); // Balanced in ::Show. | 89 Release(); // Balanced in ::Show. |
| 95 } | 90 } |
| 96 | 91 |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 base::Unretained(file_watcher_.get()), path)); | 449 base::Unretained(file_watcher_.get()), path)); |
| 455 } | 450 } |
| 456 } | 451 } |
| 457 | 452 |
| 458 void DevToolsFileHelper::FilePathsChanged( | 453 void DevToolsFileHelper::FilePathsChanged( |
| 459 const std::vector<std::string>& changed_paths, | 454 const std::vector<std::string>& changed_paths, |
| 460 const std::vector<std::string>& added_paths, | 455 const std::vector<std::string>& added_paths, |
| 461 const std::vector<std::string>& removed_paths) { | 456 const std::vector<std::string>& removed_paths) { |
| 462 delegate_->FilePathsChanged(changed_paths, added_paths, removed_paths); | 457 delegate_->FilePathsChanged(changed_paths, added_paths, removed_paths); |
| 463 } | 458 } |
| OLD | NEW |