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

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

Issue 9296038: [uber] Redoing the homepage selection UI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 10 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
« no previous file with comments | « chrome/browser/ui/webui/options2/browser_options_handler2.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 DictionaryValue* localized_strings) { 110 DictionaryValue* localized_strings) {
111 DCHECK(localized_strings); 111 DCHECK(localized_strings);
112 112
113 static OptionsStringResource resources[] = { 113 static OptionsStringResource resources[] = {
114 { "advancedOptionsButtonTitle", IDS_OPTIONS_ADVANCED_BUTTON_TITLE }, 114 { "advancedOptionsButtonTitle", IDS_OPTIONS_ADVANCED_BUTTON_TITLE },
115 { "autologinEnabled", IDS_OPTIONS_PASSWORDS_AUTOLOGIN }, 115 { "autologinEnabled", IDS_OPTIONS_PASSWORDS_AUTOLOGIN },
116 { "browsingData", IDS_OPTIONS_BROWSING_DATA_GROUP_NAME }, // needed? 116 { "browsingData", IDS_OPTIONS_BROWSING_DATA_GROUP_NAME }, // needed?
117 { "changeHomePage", IDS_OPTIONS_CHANGE_HOME_PAGE }, 117 { "changeHomePage", IDS_OPTIONS_CHANGE_HOME_PAGE },
118 { "customizeSync", IDS_OPTIONS2_CUSTOMIZE_SYNC_BUTTON_LABEL }, 118 { "customizeSync", IDS_OPTIONS2_CUSTOMIZE_SYNC_BUTTON_LABEL },
119 { "defaultSearchManageEngines", IDS_OPTIONS_DEFAULTSEARCH_MANAGE_ENGINES }, 119 { "defaultSearchManageEngines", IDS_OPTIONS_DEFAULTSEARCH_MANAGE_ENGINES },
120 { "homePage", IDS_OPTIONS2_HOMEPAGE },
121 { "homePageChoose", IDS_OPTIONS2_HOMEPAGE_CHOOSE },
122 { "homePageDialogLabel", IDS_OPTIONS2_HOMEPAGE_DIALOG_LABEL },
120 { "homePageTitle", IDS_OPTIONS2_HOMEPAGE_TITLE }, 123 { "homePageTitle", IDS_OPTIONS2_HOMEPAGE_TITLE },
121 { "homepageUseNewTab", IDS_OPTIONS_HOMEPAGE_USE_NEWTAB }, 124 { "homePageNone", IDS_OPTIONS2_HOMEPAGE_NONE },
122 { "homepageUseURL", IDS_OPTIONS_HOMEPAGE_USE_URL }, 125 { "homePageNtp", IDS_OPTIONS2_HOMEPAGE_NTP },
126 { "homePageUseNewTab", IDS_OPTIONS_HOMEPAGE_USE_NEWTAB },
127 { "homePageUseURL", IDS_OPTIONS_HOMEPAGE_USE_URL },
123 { "instantConfirmMessage", IDS_INSTANT_OPT_IN_MESSAGE }, 128 { "instantConfirmMessage", IDS_INSTANT_OPT_IN_MESSAGE },
124 { "instantConfirmTitle", IDS_INSTANT_OPT_IN_TITLE }, 129 { "instantConfirmTitle", IDS_INSTANT_OPT_IN_TITLE },
125 { "importData", IDS_OPTIONS_IMPORT_DATA_BUTTON }, 130 { "importData", IDS_OPTIONS_IMPORT_DATA_BUTTON },
126 { "manageDataDescription", IDS_OPTIONS_MANAGE_DATA_DESCRIPTION }, 131 { "manageDataDescription", IDS_OPTIONS_MANAGE_DATA_DESCRIPTION },
127 { "profilesCreate", IDS_PROFILES_CREATE_BUTTON_LABEL }, 132 { "profilesCreate", IDS_PROFILES_CREATE_BUTTON_LABEL },
128 { "profilesDelete", IDS_PROFILES_DELETE_BUTTON_LABEL }, 133 { "profilesDelete", IDS_PROFILES_DELETE_BUTTON_LABEL },
129 { "profilesDeleteSingle", IDS_PROFILES_DELETE_SINGLE_BUTTON_LABEL }, 134 { "profilesDeleteSingle", IDS_PROFILES_DELETE_SINGLE_BUTTON_LABEL },
130 { "profilesListItemCurrent", IDS_PROFILES_LIST_ITEM_CURRENT }, 135 { "profilesListItemCurrent", IDS_PROFILES_LIST_ITEM_CURRENT },
131 { "profilesManage", IDS_PROFILES_MANAGE_BUTTON_LABEL }, 136 { "profilesManage", IDS_PROFILES_MANAGE_BUTTON_LABEL },
132 { "sectionTitleAdvanced", IDS_OPTIONS_ADVANCED_TAB_LABEL }, 137 { "sectionTitleAdvanced", IDS_OPTIONS_ADVANCED_TAB_LABEL },
133 { "sectionTitleAppearance", IDS_APPEARANCE_GROUP_NAME }, 138 { "sectionTitleAppearance", IDS_APPEARANCE_GROUP_NAME },
134 { "sectionTitleDefaultBrowser", IDS_OPTIONS_DEFAULTBROWSER_GROUP_NAME }, 139 { "sectionTitleDefaultBrowser", IDS_OPTIONS_DEFAULTBROWSER_GROUP_NAME },
135 { "sectionTitleUsers", IDS_PROFILES_OPTIONS_GROUP_NAME }, 140 { "sectionTitleUsers", IDS_PROFILES_OPTIONS_GROUP_NAME },
136 { "sectionTitleSearch", IDS_OPTIONS_DEFAULTSEARCH_GROUP_NAME }, 141 { "sectionTitleSearch", IDS_OPTIONS_DEFAULTSEARCH_GROUP_NAME },
137 { "sectionTitleStartup", IDS_OPTIONS_STARTUP_GROUP_NAME }, 142 { "sectionTitleStartup", IDS_OPTIONS_STARTUP_GROUP_NAME },
138 { "sectionTitleSync", IDS_SYNC_OPTIONS_GROUP_NAME }, 143 { "sectionTitleSync", IDS_SYNC_OPTIONS_GROUP_NAME },
139 { "sessionRestoreOverlayMessage", IDS_SESSION_RESTORE_OVERLAY_MESSAGE }, 144 { "sessionRestoreOverlayMessage", IDS_SESSION_RESTORE_OVERLAY_MESSAGE },
140 { "sessionRestoreOverlayTitle", IDS_SESSION_RESTORE_OVERLAY_TITLE }, 145 { "sessionRestoreOverlayTitle", IDS_SESSION_RESTORE_OVERLAY_TITLE },
141 { "startupRestoreLastSession", IDS_OPTIONS_STARTUP_RESTORE_LAST_SESSION }, 146 { "startupRestoreLastSession", IDS_OPTIONS_STARTUP_RESTORE_LAST_SESSION },
142 { "startupSetPages", IDS_OPTIONS2_STARTUP_SET_PAGES }, 147 { "startupSetPages", IDS_OPTIONS2_STARTUP_SET_PAGES },
143 { "startupShowDefaultAndNewTab", 148 { "startupShowDefaultAndNewTab",
144 IDS_OPTIONS_STARTUP_SHOW_DEFAULT_AND_NEWTAB}, 149 IDS_OPTIONS2_STARTUP_SHOW_DEFAULT_AND_NEWTAB},
145 { "startupShowLastSession", IDS_OPTIONS_STARTUP_SHOW_LAST_SESSION }, 150 { "startupShowLastSession", IDS_OPTIONS_STARTUP_SHOW_LAST_SESSION },
146 { "startupShowPages", IDS_OPTIONS2_STARTUP_SHOW_PAGES }, 151 { "startupShowPages", IDS_OPTIONS2_STARTUP_SHOW_PAGES },
147 { "themesGallery", IDS_THEMES_GALLERY_BUTTON }, 152 { "themesGallery", IDS_THEMES_GALLERY_BUTTON },
148 { "themesGalleryURL", IDS_THEMES_GALLERY_URL }, 153 { "themesGalleryURL", IDS_THEMES_GALLERY_URL },
149 { "toolbarGroupName", IDS_OPTIONS2_TOOLBAR_GROUP_NAME }, 154 { "toolbarGroupName", IDS_OPTIONS2_TOOLBAR_GROUP_NAME },
150 { "toolbarShowBookmarksBar", IDS_OPTIONS_TOOLBAR_SHOW_BOOKMARKS_BAR }, 155 { "toolbarShowBookmarksBar", IDS_OPTIONS_TOOLBAR_SHOW_BOOKMARKS_BAR },
151 { "toolbarShowHomeButton", IDS_OPTIONS_TOOLBAR_SHOW_HOME_BUTTON }, 156 { "toolbarShowHomeButton", IDS_OPTIONS_TOOLBAR_SHOW_HOME_BUTTON },
152 #if defined(TOOLKIT_GTK) 157 #if defined(TOOLKIT_GTK)
153 { "showWindowDecorations", IDS_SHOW_WINDOW_DECORATIONS }, 158 { "showWindowDecorations", IDS_SHOW_WINDOW_DECORATIONS },
154 { "themesGTKButton", IDS_THEMES_GTK_BUTTON }, 159 { "themesGTKButton", IDS_THEMES_GTK_BUTTON },
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 // Create our favicon data source. 387 // Create our favicon data source.
383 profile->GetChromeURLDataManager()->AddDataSource( 388 profile->GetChromeURLDataManager()->AddDataSource(
384 new FaviconSource(profile, FaviconSource::FAVICON)); 389 new FaviconSource(profile, FaviconSource::FAVICON));
385 390
386 homepage_.Init(prefs::kHomePage, profile->GetPrefs(), NULL); 391 homepage_.Init(prefs::kHomePage, profile->GetPrefs(), NULL);
387 default_browser_policy_.Init(prefs::kDefaultBrowserSettingEnabled, 392 default_browser_policy_.Init(prefs::kDefaultBrowserSettingEnabled,
388 g_browser_process->local_state(), 393 g_browser_process->local_state(),
389 this); 394 this);
390 UpdateDefaultBrowserState(); 395 UpdateDefaultBrowserState();
391 396
392 pref_change_registrar_.Init(profile->GetPrefs());
393 pref_change_registrar_.Add(prefs::kHomePageIsNewTabPage, this);
394 pref_change_registrar_.Add(prefs::kHomePage, this);
395
396 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, 397 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED,
397 content::NotificationService::AllSources()); 398 content::NotificationService::AllSources());
398 #if defined(OS_CHROMEOS) 399 #if defined(OS_CHROMEOS)
399 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, 400 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED,
400 content::NotificationService::AllSources()); 401 content::NotificationService::AllSources());
401 #endif 402 #endif
402 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, 403 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED,
403 content::Source<ThemeService>( 404 content::Source<ThemeService>(
404 ThemeServiceFactory::GetForProfile(profile))); 405 ThemeServiceFactory::GetForProfile(profile)));
405 406
406 UpdateSearchEngines(); 407 UpdateSearchEngines();
407 UpdateHomePageLabel();
408 ObserveThemeChanged(); 408 ObserveThemeChanged();
409 409
410 autocomplete_controller_.reset(new AutocompleteController(profile, this)); 410 autocomplete_controller_.reset(new AutocompleteController(profile, this));
411 411
412 #if defined(OS_WIN) 412 #if defined(OS_WIN)
413 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 413 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
414 base::Bind(&BrowserOptionsHandler::CheckAutoLaunch, 414 base::Bind(&BrowserOptionsHandler::CheckAutoLaunch,
415 weak_ptr_factory_for_ui_.GetWeakPtr(), 415 weak_ptr_factory_for_ui_.GetWeakPtr(),
416 weak_ptr_factory_for_file_.GetWeakPtr())); 416 weak_ptr_factory_for_file_.GetWeakPtr()));
417 weak_ptr_factory_for_ui_.DetachFromThread(); 417 weak_ptr_factory_for_ui_.DetachFromThread();
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 void BrowserOptionsHandler::UpdateSearchEngines() { 589 void BrowserOptionsHandler::UpdateSearchEngines() {
590 template_url_service_ = 590 template_url_service_ =
591 TemplateURLServiceFactory::GetForProfile(Profile::FromWebUI(web_ui())); 591 TemplateURLServiceFactory::GetForProfile(Profile::FromWebUI(web_ui()));
592 if (template_url_service_) { 592 if (template_url_service_) {
593 template_url_service_->Load(); 593 template_url_service_->Load();
594 template_url_service_->AddObserver(this); 594 template_url_service_->AddObserver(this);
595 OnTemplateURLServiceChanged(); 595 OnTemplateURLServiceChanged();
596 } 596 }
597 } 597 }
598 598
599 void BrowserOptionsHandler::UpdateHomePageLabel() const {
600 Profile* profile = Profile::FromWebUI(web_ui());
601 PrefService* prefs = profile->GetPrefs();
602 scoped_ptr<Value> label;
603 string16 str;
604
605 if (prefs->GetBoolean(prefs::kHomePageIsNewTabPage)) {
606 str = l10n_util::GetStringUTF16(IDS_OPTIONS_SHOW_HOME_BUTTON_FOR_NTP);
607 } else {
608 str = l10n_util::GetStringFUTF16(
609 IDS_OPTIONS_SHOW_HOME_BUTTON_FOR_URL,
610 UTF8ToUTF16(prefs->GetString(prefs::kHomePage)));
611 }
612
613 label.reset(Value::CreateStringValue(str));
614 web_ui()->CallJavascriptFunction("BrowserOptions.updateHomePageLabel",
615 *label);
616 }
617
618 void BrowserOptionsHandler::Observe( 599 void BrowserOptionsHandler::Observe(
619 int type, 600 int type,
620 const content::NotificationSource& source, 601 const content::NotificationSource& source,
621 const content::NotificationDetails& details) { 602 const content::NotificationDetails& details) {
622 if (type == chrome::NOTIFICATION_BROWSER_THEME_CHANGED) { 603 if (type == chrome::NOTIFICATION_BROWSER_THEME_CHANGED) {
623 ObserveThemeChanged(); 604 ObserveThemeChanged();
624 #if defined(OS_CHROMEOS) 605 #if defined(OS_CHROMEOS)
625 } else if (type == chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED) { 606 } else if (type == chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED) {
626 UpdateAccountPicture(); 607 UpdateAccountPicture();
627 #endif 608 #endif
628 } else if (type == chrome::NOTIFICATION_PREF_CHANGED) { 609 } else if (type == chrome::NOTIFICATION_PREF_CHANGED) {
629 std::string* pref = content::Details<std::string>(details).ptr(); 610 std::string* pref = content::Details<std::string>(details).ptr();
630 if (*pref == prefs::kDefaultBrowserSettingEnabled) { 611 if (*pref == prefs::kDefaultBrowserSettingEnabled) {
631 UpdateDefaultBrowserState(); 612 UpdateDefaultBrowserState();
632 } else if (*pref == prefs::kHomePageIsNewTabPage ||
633 *pref == prefs::kHomePage) {
634 UpdateHomePageLabel();
635 } else { 613 } else {
636 NOTREACHED(); 614 NOTREACHED();
637 } 615 }
638 } else if (multiprofile_ && 616 } else if (multiprofile_ &&
639 type == chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED) { 617 type == chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED) {
640 SendProfilesInfo(); 618 SendProfilesInfo();
641 } else { 619 } else {
642 NOTREACHED(); 620 NOTREACHED();
643 } 621 }
644 } 622 }
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 } 779 }
802 780
803 void BrowserOptionsHandler::IncreaseScreenBrightnessCallback( 781 void BrowserOptionsHandler::IncreaseScreenBrightnessCallback(
804 const ListValue* args) { 782 const ListValue* args) {
805 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> 783 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
806 IncreaseScreenBrightness(); 784 IncreaseScreenBrightness();
807 } 785 }
808 #endif 786 #endif
809 787
810 } // namespace options2 788 } // namespace options2
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options2/browser_options_handler2.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698