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

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

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