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/remoting/setup_flow.h" | 25 #include "chrome/browser/remoting/setup_flow.h" |
24 #include "chrome/browser/service/service_process_control.h" | 26 #include "chrome/browser/service/service_process_control.h" |
25 #include "chrome/browser/service/service_process_control_manager.h" | 27 #include "chrome/browser/service/service_process_control_manager.h" |
26 #include "chrome/browser/ui/options/options_util.h" | 28 #include "chrome/browser/ui/options/options_util.h" |
27 #include "chrome/browser/ui/webui/options/options_managed_banner_handler.h" | 29 #include "chrome/browser/ui/webui/options/options_managed_banner_handler.h" |
30 #include "chrome/common/chrome_paths.h" | |
28 #include "chrome/common/chrome_switches.h" | 31 #include "chrome/common/chrome_switches.h" |
29 #include "chrome/common/pref_names.h" | 32 #include "chrome/common/pref_names.h" |
30 #include "chrome/common/url_constants.h" | 33 #include "chrome/common/url_constants.h" |
31 #include "content/browser/tab_contents/tab_contents.h" | 34 #include "content/browser/tab_contents/tab_contents.h" |
32 #include "content/browser/tab_contents/tab_contents_view.h" | 35 #include "content/browser/tab_contents/tab_contents_view.h" |
33 #include "content/browser/user_metrics.h" | 36 #include "content/browser/user_metrics.h" |
34 #include "content/common/notification_details.h" | 37 #include "content/common/notification_details.h" |
35 #include "content/common/notification_type.h" | 38 #include "content/common/notification_type.h" |
36 #include "grit/chromium_strings.h" | 39 #include "grit/chromium_strings.h" |
37 #include "grit/generated_resources.h" | 40 #include "grit/generated_resources.h" |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
181 google_util::AppendGoogleLocaleParam( | 184 google_util::AppendGoogleLocaleParam( |
182 GURL(chrome::kPrivacyLearnMoreURL)).spec()); | 185 GURL(chrome::kPrivacyLearnMoreURL)).spec()); |
183 } | 186 } |
184 | 187 |
185 void AdvancedOptionsHandler::Initialize() { | 188 void AdvancedOptionsHandler::Initialize() { |
186 DCHECK(web_ui_); | 189 DCHECK(web_ui_); |
187 SetupMetricsReportingCheckbox(); | 190 SetupMetricsReportingCheckbox(); |
188 SetupMetricsReportingSettingVisibility(); | 191 SetupMetricsReportingSettingVisibility(); |
189 SetupFontSizeLabel(); | 192 SetupFontSizeLabel(); |
190 SetupDownloadLocationPath(); | 193 SetupDownloadLocationPath(); |
194 download_path_checker_ = new DownloadPathChecker(this); | |
195 download_path_checker_->CheckIfDownloadPathExists( | |
196 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.
| |
191 SetupPromptForDownload(); | 197 SetupPromptForDownload(); |
192 SetupAutoOpenFileTypesDisabledAttribute(); | 198 SetupAutoOpenFileTypesDisabledAttribute(); |
193 SetupProxySettingsSection(); | 199 SetupProxySettingsSection(); |
194 SetupSSLConfigSettings(); | 200 SetupSSLConfigSettings(); |
195 #if !defined(OS_CHROMEOS) | 201 #if !defined(OS_CHROMEOS) |
196 if (cloud_print_proxy_ui_enabled_) { | 202 if (cloud_print_proxy_ui_enabled_) { |
197 SetupCloudPrintProxySection(); | 203 SetupCloudPrintProxySection(); |
198 RefreshCloudPrintStatusFromService(); | 204 RefreshCloudPrintStatusFromService(); |
199 } else { | 205 } else { |
200 RemoveCloudPrintProxySection(); | 206 RemoveCloudPrintProxySection(); |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
635 web_ui_->CallJavascriptFunction( | 641 web_ui_->CallJavascriptFunction( |
636 "options.AdvancedOptions.SetUseSSL3CheckboxState", checked, disabled); | 642 "options.AdvancedOptions.SetUseSSL3CheckboxState", checked, disabled); |
637 } | 643 } |
638 { | 644 { |
639 FundamentalValue checked(tls1_enabled_.GetValue()); | 645 FundamentalValue checked(tls1_enabled_.GetValue()); |
640 FundamentalValue disabled(tls1_enabled_.IsManaged()); | 646 FundamentalValue disabled(tls1_enabled_.IsManaged()); |
641 web_ui_->CallJavascriptFunction( | 647 web_ui_->CallJavascriptFunction( |
642 "options.AdvancedOptions.SetUseTLS1CheckboxState", checked, disabled); | 648 "options.AdvancedOptions.SetUseTLS1CheckboxState", checked, disabled); |
643 } | 649 } |
644 } | 650 } |
651 | |
652 AdvancedOptionsHandler::DownloadPathChecker::DownloadPathChecker( | |
653 AdvancedOptionsHandler* handler) | |
654 : handler_(handler) { | |
655 } | |
656 | |
657 void AdvancedOptionsHandler::DownloadPathChecker:: | |
658 CheckIfDownloadPathExists(const FilePath& path) { | |
659 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
660 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | |
661 NewRunnableMethod(this, | |
662 &DownloadPathChecker::CheckIfDownloadPathExistsOnFileThread, path)); | |
663 } | |
664 | |
665 void AdvancedOptionsHandler::DownloadPathChecker:: | |
666 CheckIfDownloadPathExistsOnFileThread( | |
667 const FilePath path) { | |
668 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | |
669 if (!file_util::PathExists(path)) { | |
670 FilePath new_path; | |
671 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.
| |
672 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | |
673 NewRunnableMethod(this, | |
674 &DownloadPathChecker::OnDownloadPathChanged, new_path)); | |
675 } | |
676 } | |
677 | |
678 void AdvancedOptionsHandler::DownloadPathChecker:: | |
679 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.
| |
680 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
681 if (handler_) { | |
682 handler_->default_download_location_.SetValue(path); | |
683 handler_->SetupDownloadLocationPath(); | |
684 } | |
685 } | |
OLD | NEW |