Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(205)

Side by Side Diff: chrome/browser/ui/webui/options2/browser_options_handler2.cc

Issue 9693032: [uber page] Split up initialization of handlers from initialization of webui pages (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: code shuffling Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/ui/webui/options2/browser_options_handler2.h" 5 #include "chrome/browser/ui/webui/options2/browser_options_handler2.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 #endif 528 #endif
529 } 529 }
530 530
531 void BrowserOptionsHandler::OnStateChanged() { 531 void BrowserOptionsHandler::OnStateChanged() {
532 scoped_ptr<DictionaryValue> value(GetSyncStateDictionary()); 532 scoped_ptr<DictionaryValue> value(GetSyncStateDictionary());
533 web_ui()->CallJavascriptFunction("BrowserOptions.updateSyncState", *value); 533 web_ui()->CallJavascriptFunction("BrowserOptions.updateSyncState", *value);
534 534
535 SendProfilesInfo(); 535 SendProfilesInfo();
536 } 536 }
537 537
538 void BrowserOptionsHandler::Initialize() { 538 void BrowserOptionsHandler::InitializeHandler() {
539 Profile* profile = Profile::FromWebUI(web_ui()); 539 Profile* profile = Profile::FromWebUI(web_ui());
540 PrefService* prefs = profile->GetPrefs(); 540 PrefService* prefs = profile->GetPrefs();
541 541
542 ProfileSyncService* sync_service( 542 ProfileSyncService* sync_service(
543 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile)); 543 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile));
544 if (sync_service) 544 if (sync_service)
545 sync_service->AddObserver(this); 545 sync_service->AddObserver(this);
546 OnStateChanged(); 546 OnStateChanged();
547 547
548 // Create our favicon data source. 548 // Create our favicon data source.
549 profile->GetChromeURLDataManager()->AddDataSource( 549 profile->GetChromeURLDataManager()->AddDataSource(
550 new FaviconSource(profile, FaviconSource::FAVICON)); 550 new FaviconSource(profile, FaviconSource::FAVICON));
551 551
552 default_browser_policy_.Init(prefs::kDefaultBrowserSettingEnabled, 552 default_browser_policy_.Init(prefs::kDefaultBrowserSettingEnabled,
553 g_browser_process->local_state(), 553 g_browser_process->local_state(),
554 this); 554 this);
555 UpdateDefaultBrowserState(); 555 UpdateDefaultBrowserState();
556 556
557 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, 557 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED,
558 content::NotificationService::AllSources()); 558 content::NotificationService::AllSources());
559 #if defined(OS_CHROMEOS) 559 #if defined(OS_CHROMEOS)
560 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, 560 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED,
561 content::NotificationService::AllSources()); 561 content::NotificationService::AllSources());
562 #endif 562 #endif
563 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, 563 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED,
564 content::Source<ThemeService>( 564 content::Source<ThemeService>(
565 ThemeServiceFactory::GetForProfile(profile))); 565 ThemeServiceFactory::GetForProfile(profile)));
566 566
567 UpdateSearchEngines(); 567 AddTemplateUrlServiceObserver();
568 ObserveThemeChanged();
569 568
570 #if defined(OS_WIN) 569 #if defined(OS_WIN)
571 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 570 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
572 if (!command_line.HasSwitch(switches::kChromeFrame) && 571 if (!command_line.HasSwitch(switches::kChromeFrame) &&
573 !command_line.HasSwitch(switches::kUserDataDir)) { 572 !command_line.HasSwitch(switches::kUserDataDir)) {
574 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 573 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
575 base::Bind(&BrowserOptionsHandler::CheckAutoLaunch, 574 base::Bind(&BrowserOptionsHandler::CheckAutoLaunch,
576 weak_ptr_factory_for_ui_.GetWeakPtr(), 575 weak_ptr_factory_for_ui_.GetWeakPtr(),
577 weak_ptr_factory_for_file_.GetWeakPtr(), 576 weak_ptr_factory_for_file_.GetWeakPtr(),
578 profile->GetPath())); 577 profile->GetPath()));
(...skipping 17 matching lines...) Expand all
596 g_browser_process->local_state(), this); 595 g_browser_process->local_state(), this);
597 #endif 596 #endif
598 597
599 auto_open_files_.Init(prefs::kDownloadExtensionsToOpen, prefs, this); 598 auto_open_files_.Init(prefs::kDownloadExtensionsToOpen, prefs, this);
600 default_font_size_.Init(prefs::kWebKitGlobalDefaultFontSize, prefs, this); 599 default_font_size_.Init(prefs::kWebKitGlobalDefaultFontSize, prefs, this);
601 default_zoom_level_.Init(prefs::kDefaultZoomLevel, prefs, this); 600 default_zoom_level_.Init(prefs::kDefaultZoomLevel, prefs, this);
602 #if !defined(OS_CHROMEOS) 601 #if !defined(OS_CHROMEOS)
603 proxy_prefs_.reset( 602 proxy_prefs_.reset(
604 PrefSetObserver::CreateProxyPrefSetObserver(prefs, this)); 603 PrefSetObserver::CreateProxyPrefSetObserver(prefs, this));
605 #endif // !defined(OS_CHROMEOS) 604 #endif // !defined(OS_CHROMEOS)
605 }
606
607 void BrowserOptionsHandler::InitializePage() {
608 OnTemplateURLServiceChanged();
609 ObserveThemeChanged();
610
611 if (multiprofile_)
612 SendProfilesInfo();
606 613
607 SetupMetricsReportingCheckbox(); 614 SetupMetricsReportingCheckbox();
608 SetupMetricsReportingSettingVisibility(); 615 SetupMetricsReportingSettingVisibility();
609 SetupFontSizeSelector(); 616 SetupFontSizeSelector();
610 SetupPageZoomSelector(); 617 SetupPageZoomSelector();
611 SetupAutoOpenFileTypesDisabledAttribute(); 618 SetupAutoOpenFileTypesDisabledAttribute();
612 SetupProxySettingsSection(); 619 SetupProxySettingsSection();
613 SetupSSLConfigSettings(); 620 SetupSSLConfigSettings();
614 #if !defined(OS_CHROMEOS) 621 #if !defined(OS_CHROMEOS)
615 if (cloud_print_connector_ui_enabled_) { 622 if (cloud_print_connector_ui_enabled_) {
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 802
796 std::vector<const TemplateURL*> model_urls = 803 std::vector<const TemplateURL*> model_urls =
797 template_url_service_->GetTemplateURLs(); 804 template_url_service_->GetTemplateURLs();
798 if (selected_index >= 0 && 805 if (selected_index >= 0 &&
799 selected_index < static_cast<int>(model_urls.size())) 806 selected_index < static_cast<int>(model_urls.size()))
800 template_url_service_->SetDefaultSearchProvider(model_urls[selected_index]); 807 template_url_service_->SetDefaultSearchProvider(model_urls[selected_index]);
801 808
802 content::RecordAction(UserMetricsAction("Options_SearchEngineChanged")); 809 content::RecordAction(UserMetricsAction("Options_SearchEngineChanged"));
803 } 810 }
804 811
805 void BrowserOptionsHandler::UpdateSearchEngines() { 812 void BrowserOptionsHandler::AddTemplateUrlServiceObserver() {
806 template_url_service_ = 813 template_url_service_ =
807 TemplateURLServiceFactory::GetForProfile(Profile::FromWebUI(web_ui())); 814 TemplateURLServiceFactory::GetForProfile(Profile::FromWebUI(web_ui()));
808 if (template_url_service_) { 815 if (template_url_service_) {
809 template_url_service_->Load(); 816 template_url_service_->Load();
810 template_url_service_->AddObserver(this); 817 template_url_service_->AddObserver(this);
811 OnTemplateURLServiceChanged();
812 } 818 }
813 } 819 }
814 820
815 void BrowserOptionsHandler::Observe( 821 void BrowserOptionsHandler::Observe(
816 int type, 822 int type,
817 const content::NotificationSource& source, 823 const content::NotificationSource& source,
818 const content::NotificationDetails& details) { 824 const content::NotificationDetails& details) {
819 if (type == chrome::NOTIFICATION_BROWSER_THEME_CHANGED) { 825 if (type == chrome::NOTIFICATION_BROWSER_THEME_CHANGED) {
820 ObserveThemeChanged(); 826 ObserveThemeChanged();
821 #if defined(OS_CHROMEOS) 827 #if defined(OS_CHROMEOS)
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
1370 } 1376 }
1371 1377
1372 void BrowserOptionsHandler::SetupSSLConfigSettings() { 1378 void BrowserOptionsHandler::SetupSSLConfigSettings() {
1373 base::FundamentalValue checked(rev_checking_enabled_.GetValue()); 1379 base::FundamentalValue checked(rev_checking_enabled_.GetValue());
1374 base::FundamentalValue disabled(rev_checking_enabled_.IsManaged()); 1380 base::FundamentalValue disabled(rev_checking_enabled_.IsManaged());
1375 web_ui()->CallJavascriptFunction( 1381 web_ui()->CallJavascriptFunction(
1376 "BrowserOptions.setCheckRevocationCheckboxState", checked, disabled); 1382 "BrowserOptions.setCheckRevocationCheckboxState", checked, disabled);
1377 } 1383 }
1378 1384
1379 } // namespace options2 1385 } // namespace options2
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698