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