Chromium Code Reviews| Index: chrome/browser/ui/webui/options/advanced_options_handler.cc |
| diff --git a/chrome/browser/ui/webui/options/advanced_options_handler.cc b/chrome/browser/ui/webui/options/advanced_options_handler.cc |
| index 071ff37fdf83fda820bc5b4ab7f0713ba201d81b..1d3f48a24dbbab3501d49a4eaa5af6c3c14fbfcf 100644 |
| --- a/chrome/browser/ui/webui/options/advanced_options_handler.cc |
| +++ b/chrome/browser/ui/webui/options/advanced_options_handler.cc |
| @@ -9,6 +9,8 @@ |
| #include "base/basictypes.h" |
| #include "base/callback.h" |
| #include "base/command_line.h" |
| +#include "base/file_util.h" |
| +#include "base/path_service.h" |
| #include "base/utf_string_conversions.h" |
| #include "base/values.h" |
| #include "chrome/browser/browser_process.h" |
| @@ -25,6 +27,7 @@ |
| #include "chrome/browser/service/service_process_control_manager.h" |
| #include "chrome/browser/ui/options/options_util.h" |
| #include "chrome/browser/ui/webui/options/options_managed_banner_handler.h" |
| +#include "chrome/common/chrome_paths.h" |
| #include "chrome/common/chrome_switches.h" |
| #include "chrome/common/pref_names.h" |
| #include "chrome/common/url_constants.h" |
| @@ -188,6 +191,9 @@ void AdvancedOptionsHandler::Initialize() { |
| SetupMetricsReportingSettingVisibility(); |
| SetupFontSizeLabel(); |
| SetupDownloadLocationPath(); |
| + download_path_checker_ = new DownloadPathChecker(this); |
| + download_path_checker_->CheckIfDownloadPathExists( |
| + default_download_location_.GetValue()); |
|
Paweł Hajdan Jr.
2011/05/13 09:16:22
nit: Is the indentation correct here? I think it s
haraken1
2011/05/17 04:29:05
Done.
|
| SetupPromptForDownload(); |
| SetupAutoOpenFileTypesDisabledAttribute(); |
| SetupProxySettingsSection(); |
| @@ -642,3 +648,38 @@ void AdvancedOptionsHandler::SetupSSLConfigSettings() { |
| "options.AdvancedOptions.SetUseTLS1CheckboxState", checked, disabled); |
| } |
| } |
| + |
| +AdvancedOptionsHandler::DownloadPathChecker::DownloadPathChecker( |
| + AdvancedOptionsHandler* handler) |
| + : handler_(handler) { |
| +} |
| + |
| +void AdvancedOptionsHandler::DownloadPathChecker:: |
| + CheckIfDownloadPathExists(const FilePath& path) { |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| + BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
| + NewRunnableMethod(this, |
| + &DownloadPathChecker::CheckIfDownloadPathExistsOnFileThread, path)); |
| +} |
| + |
| +void AdvancedOptionsHandler::DownloadPathChecker:: |
| + CheckIfDownloadPathExistsOnFileThread( |
| + const FilePath path) { |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| + if (!file_util::PathExists(path)) { |
| + FilePath new_path; |
| + PathService::Get(chrome::DIR_USER_DOCUMENTS, &new_path); |
|
Paweł Hajdan Jr.
2011/05/13 09:16:22
Check the return value.
haraken1
2011/05/17 04:29:05
Done.
|
| + BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| + NewRunnableMethod(this, |
| + &DownloadPathChecker::OnDownloadPathChanged, new_path)); |
| + } |
| +} |
| + |
| +void AdvancedOptionsHandler::DownloadPathChecker:: |
| + OnDownloadPathChanged(const FilePath path) { |
|
Paweł Hajdan Jr.
2011/05/13 09:16:22
nit: Why not "const FilePath&", here and above?
haraken1
2011/05/17 04:29:05
Done.
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| + if (handler_) { |
| + handler_->default_download_location_.SetValue(path); |
| + handler_->SetupDownloadLocationPath(); |
| + } |
| +} |