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 | 4 |
5 #include "chrome/browser/ui/webui/options/advanced_options_handler.h" | 5 #include "chrome/browser/ui/webui/options/advanced_options_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/file_util.h" | |
13 #include "base/path_service.h" | |
12 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
13 #include "base/values.h" | 15 #include "base/values.h" |
14 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
15 #include "chrome/browser/download/download_manager.h" | 17 #include "chrome/browser/download/download_manager.h" |
16 #include "chrome/browser/download/download_prefs.h" | 18 #include "chrome/browser/download/download_prefs.h" |
17 #include "chrome/browser/google/google_util.h" | 19 #include "chrome/browser/google/google_util.h" |
18 #include "chrome/browser/prefs/pref_service.h" | 20 #include "chrome/browser/prefs/pref_service.h" |
19 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" | 21 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" |
20 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" | 22 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" |
21 #include "chrome/browser/printing/cloud_print/cloud_print_url.h" | 23 #include "chrome/browser/printing/cloud_print/cloud_print_url.h" |
22 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
23 #include "chrome/browser/service/service_process_control.h" | 25 #include "chrome/browser/service/service_process_control.h" |
24 #include "chrome/browser/service/service_process_control_manager.h" | 26 #include "chrome/browser/service/service_process_control_manager.h" |
25 #include "chrome/browser/ui/options/options_util.h" | 27 #include "chrome/browser/ui/options/options_util.h" |
26 #include "chrome/browser/ui/webui/options/options_managed_banner_handler.h" | 28 #include "chrome/browser/ui/webui/options/options_managed_banner_handler.h" |
29 #include "chrome/common/chrome_paths.h" | |
27 #include "chrome/common/chrome_switches.h" | 30 #include "chrome/common/chrome_switches.h" |
28 #include "chrome/common/pref_names.h" | 31 #include "chrome/common/pref_names.h" |
29 #include "chrome/common/url_constants.h" | 32 #include "chrome/common/url_constants.h" |
30 #include "content/browser/tab_contents/tab_contents.h" | 33 #include "content/browser/tab_contents/tab_contents.h" |
31 #include "content/browser/tab_contents/tab_contents_view.h" | 34 #include "content/browser/tab_contents/tab_contents_view.h" |
32 #include "content/browser/user_metrics.h" | 35 #include "content/browser/user_metrics.h" |
33 #include "content/common/notification_details.h" | 36 #include "content/common/notification_details.h" |
34 #include "content/common/notification_type.h" | 37 #include "content/common/notification_type.h" |
35 #include "grit/chromium_strings.h" | 38 #include "grit/chromium_strings.h" |
36 #include "grit/generated_resources.h" | 39 #include "grit/generated_resources.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
178 google_util::AppendGoogleLocaleParam( | 181 google_util::AppendGoogleLocaleParam( |
179 GURL(chrome::kPrivacyLearnMoreURL)).spec()); | 182 GURL(chrome::kPrivacyLearnMoreURL)).spec()); |
180 } | 183 } |
181 | 184 |
182 void AdvancedOptionsHandler::Initialize() { | 185 void AdvancedOptionsHandler::Initialize() { |
183 DCHECK(web_ui_); | 186 DCHECK(web_ui_); |
184 SetupMetricsReportingCheckbox(); | 187 SetupMetricsReportingCheckbox(); |
185 SetupMetricsReportingSettingVisibility(); | 188 SetupMetricsReportingSettingVisibility(); |
186 SetupFontSizeLabel(); | 189 SetupFontSizeLabel(); |
187 SetupDownloadLocationPath(); | 190 SetupDownloadLocationPath(); |
191 download_path_checker_ = new DownloadPathChecker(this); | |
192 download_path_checker_->CheckIfDownloadPathExists( | |
193 default_download_location_.GetValue()); | |
188 SetupPromptForDownload(); | 194 SetupPromptForDownload(); |
189 SetupAutoOpenFileTypesDisabledAttribute(); | 195 SetupAutoOpenFileTypesDisabledAttribute(); |
190 SetupProxySettingsSection(); | 196 SetupProxySettingsSection(); |
191 SetupSSLConfigSettings(); | 197 SetupSSLConfigSettings(); |
192 #if !defined(OS_CHROMEOS) | 198 #if !defined(OS_CHROMEOS) |
193 if (cloud_print_proxy_ui_enabled_) { | 199 if (cloud_print_proxy_ui_enabled_) { |
194 SetupCloudPrintProxySection(); | 200 SetupCloudPrintProxySection(); |
195 RefreshCloudPrintStatusFromService(); | 201 RefreshCloudPrintStatusFromService(); |
196 } else { | 202 } else { |
197 RemoveCloudPrintProxySection(); | 203 RemoveCloudPrintProxySection(); |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
633 web_ui_->CallJavascriptFunction( | 639 web_ui_->CallJavascriptFunction( |
634 "options.AdvancedOptions.SetUseSSL3CheckboxState", checked, disabled); | 640 "options.AdvancedOptions.SetUseSSL3CheckboxState", checked, disabled); |
635 } | 641 } |
636 { | 642 { |
637 FundamentalValue checked(tls1_enabled_.GetValue()); | 643 FundamentalValue checked(tls1_enabled_.GetValue()); |
638 FundamentalValue disabled(tls1_enabled_.IsManaged()); | 644 FundamentalValue disabled(tls1_enabled_.IsManaged()); |
639 web_ui_->CallJavascriptFunction( | 645 web_ui_->CallJavascriptFunction( |
640 "options.AdvancedOptions.SetUseTLS1CheckboxState", checked, disabled); | 646 "options.AdvancedOptions.SetUseTLS1CheckboxState", checked, disabled); |
641 } | 647 } |
642 } | 648 } |
649 | |
650 AdvancedOptionsHandler::DownloadPathChecker::DownloadPathChecker( | |
651 AdvancedOptionsHandler* handler) | |
652 : handler_(handler) { | |
653 } | |
654 | |
655 AdvancedOptionsHandler::DownloadPathChecker::~DownloadPathChecker() { | |
656 } | |
657 | |
658 void AdvancedOptionsHandler::DownloadPathChecker:: | |
659 CheckIfDownloadPathExists(const FilePath& path) { | |
660 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
661 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | |
662 NewRunnableMethod(this, | |
663 &DownloadPathChecker::CheckIfDownloadPathExistsOnFileThread, path)); | |
664 } | |
665 | |
666 void AdvancedOptionsHandler::DownloadPathChecker:: | |
667 CheckIfDownloadPathExistsOnFileThread( | |
668 const FilePath& path) { | |
669 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | |
670 if (!file_util::PathExists(path)) { | |
671 FilePath new_path; | |
672 if (!PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS, &new_path)) { | |
673 // Create the |path| folder if we cannot get DIR_DEFAULT_DOWNLOADS | |
674 // (This will be a rare case). | |
675 new_path = path; | |
676 } | |
677 // Make sure that the folder does exist. | |
678 file_util::CreateDirectory(new_path); | |
Paweł Hajdan Jr.
2011/05/30 14:15:49
What if this fails?
haraken1
2011/05/31 12:41:31
For the reason that I wrote above, I just added an
| |
679 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | |
680 NewRunnableMethod(this, | |
681 &DownloadPathChecker::OnDownloadPathChanged, new_path)); | |
682 } | |
683 } | |
684 | |
685 void AdvancedOptionsHandler::DownloadPathChecker:: | |
686 OnDownloadPathChanged(const FilePath path) { | |
687 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
688 if (handler_) { | |
689 handler_->default_download_location_.SetValue(path); | |
690 handler_->SetupDownloadLocationPath(); | |
691 } | |
692 } | |
OLD | NEW |