OLD | NEW |
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" |
11 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 13 #include "base/stl_util.h" |
13 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
14 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
15 #include "base/values.h" | 16 #include "base/values.h" |
16 #include "base/value_conversions.h" | 17 #include "base/value_conversions.h" |
17 #include "chrome/browser/auto_launch_trial.h" | 18 #include "chrome/browser/auto_launch_trial.h" |
18 #include "chrome/browser/autocomplete/autocomplete.h" | 19 #include "chrome/browser/autocomplete/autocomplete.h" |
19 #include "chrome/browser/autocomplete/autocomplete_match.h" | 20 #include "chrome/browser/autocomplete/autocomplete_match.h" |
20 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
21 #include "chrome/browser/custom_home_pages_table_model.h" | 22 #include "chrome/browser/custom_home_pages_table_model.h" |
22 #include "chrome/browser/google/google_util.h" | 23 #include "chrome/browser/google/google_util.h" |
23 #include "chrome/browser/instant/instant_confirm_dialog.h" | 24 #include "chrome/browser/instant/instant_confirm_dialog.h" |
24 #include "chrome/browser/instant/instant_controller.h" | 25 #include "chrome/browser/instant/instant_controller.h" |
25 #include "chrome/browser/instant/instant_field_trial.h" | 26 #include "chrome/browser/instant/instant_field_trial.h" |
26 #include "chrome/browser/net/url_fixer_upper.h" | 27 #include "chrome/browser/net/url_fixer_upper.h" |
27 #include "chrome/browser/prefs/pref_service.h" | 28 #include "chrome/browser/prefs/pref_service.h" |
28 #include "chrome/browser/prefs/session_startup_pref.h" | 29 #include "chrome/browser/prefs/session_startup_pref.h" |
29 #include "chrome/browser/profiles/profile.h" | 30 #include "chrome/browser/profiles/profile.h" |
30 #include "chrome/browser/profiles/profile_info_cache.h" | 31 #include "chrome/browser/profiles/profile_info_cache.h" |
31 #include "chrome/browser/profiles/profile_info_util.h" | 32 #include "chrome/browser/profiles/profile_info_util.h" |
32 #include "chrome/browser/profiles/profile_manager.h" | 33 #include "chrome/browser/profiles/profile_manager.h" |
33 #include "chrome/browser/search_engines/template_url.h" | 34 #include "chrome/browser/search_engines/template_url.h" |
34 #include "chrome/browser/search_engines/template_url_service.h" | 35 #include "chrome/browser/search_engines/template_url_service.h" |
35 #include "chrome/browser/search_engines/template_url_service_factory.h" | 36 #include "chrome/browser/search_engines/template_url_service_factory.h" |
36 #include "chrome/browser/sync/profile_sync_service.h" | 37 #include "chrome/browser/sync/profile_sync_service.h" |
37 #include "chrome/browser/sync/sync_setup_flow.h" | 38 #include "chrome/browser/sync/sync_setup_flow.h" |
38 #include "chrome/browser/sync/sync_ui_util.h" | 39 #include "chrome/browser/sync/sync_ui_util.h" |
| 40 #include "chrome/browser/themes/theme_service.h" |
| 41 #include "chrome/browser/themes/theme_service_factory.h" |
39 #include "chrome/browser/ui/webui/favicon_source.h" | 42 #include "chrome/browser/ui/webui/favicon_source.h" |
40 #include "chrome/browser/ui/webui/web_ui_util.h" | 43 #include "chrome/browser/ui/webui/web_ui_util.h" |
41 #include "chrome/common/chrome_notification_types.h" | 44 #include "chrome/common/chrome_notification_types.h" |
| 45 #include "chrome/common/chrome_paths.h" |
42 #include "chrome/common/chrome_switches.h" | 46 #include "chrome/common/chrome_switches.h" |
| 47 #include "chrome/common/net/gaia/google_service_auth_error.h" |
43 #include "chrome/common/pref_names.h" | 48 #include "chrome/common/pref_names.h" |
44 #include "chrome/common/url_constants.h" | 49 #include "chrome/common/url_constants.h" |
45 #include "content/public/browser/browser_thread.h" | 50 #include "content/public/browser/browser_thread.h" |
| 51 #include "content/public/browser/navigation_controller.h" |
46 #include "content/public/browser/notification_details.h" | 52 #include "content/public/browser/notification_details.h" |
47 #include "content/public/browser/notification_service.h" | 53 #include "content/public/browser/notification_service.h" |
48 #include "content/public/browser/notification_source.h" | 54 #include "content/public/browser/notification_source.h" |
49 #include "content/public/browser/user_metrics.h" | 55 #include "content/public/browser/user_metrics.h" |
50 #include "content/public/browser/web_contents.h" | 56 #include "content/public/browser/web_contents.h" |
51 #include "grit/chromium_strings.h" | 57 #include "grit/chromium_strings.h" |
52 #include "grit/generated_resources.h" | 58 #include "grit/generated_resources.h" |
| 59 #include "grit/locale_settings.h" |
| 60 #include "grit/theme_resources.h" |
53 #include "ui/base/l10n/l10n_util.h" | 61 #include "ui/base/l10n/l10n_util.h" |
54 | 62 |
55 #if defined(OS_WIN) | 63 #if defined(OS_WIN) |
56 #include "chrome/installer/util/auto_launch_util.h" | 64 #include "chrome/installer/util/auto_launch_util.h" |
57 #endif | 65 #endif // defined(OS_WIN) |
| 66 |
| 67 #if defined(OS_CHROMEOS) |
| 68 #include "chrome/browser/chromeos/login/user_manager.h" |
| 69 #include "chrome/browser/chromeos/options/take_photo_dialog.h" |
| 70 #include "chrome/browser/ui/browser_window.h" |
| 71 #include "chrome/browser/ui/views/window.h" |
| 72 #include "third_party/skia/include/core/SkBitmap.h" |
| 73 #endif // defined(OS_CHROMEOS) |
| 74 |
| 75 #if defined(TOOLKIT_GTK) |
| 76 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
| 77 #endif // defined(TOOLKIT_GTK) |
58 | 78 |
59 using content::BrowserThread; | 79 using content::BrowserThread; |
60 using content::UserMetricsAction; | 80 using content::UserMetricsAction; |
61 | 81 |
62 namespace options2 { | 82 namespace options2 { |
63 | 83 |
64 BrowserOptionsHandler::BrowserOptionsHandler() | 84 BrowserOptionsHandler::BrowserOptionsHandler() |
65 : template_url_service_(NULL), | 85 : template_url_service_(NULL), |
66 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_for_file_(this)), | 86 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_for_file_(this)), |
67 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_for_ui_(this)) { | 87 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_for_ui_(this)) { |
(...skipping 13 matching lines...) Expand all Loading... |
81 default_browser_worker_->ObserverDestroyed(); | 101 default_browser_worker_->ObserverDestroyed(); |
82 if (template_url_service_) | 102 if (template_url_service_) |
83 template_url_service_->RemoveObserver(this); | 103 template_url_service_->RemoveObserver(this); |
84 } | 104 } |
85 | 105 |
86 void BrowserOptionsHandler::GetLocalizedValues( | 106 void BrowserOptionsHandler::GetLocalizedValues( |
87 DictionaryValue* localized_strings) { | 107 DictionaryValue* localized_strings) { |
88 DCHECK(localized_strings); | 108 DCHECK(localized_strings); |
89 | 109 |
90 static OptionsStringResource resources[] = { | 110 static OptionsStringResource resources[] = { |
91 { "syncSection", IDS_SYNC_OPTIONS_GROUP_NAME }, | 111 { "appearance", IDS_APPEARANCE_GROUP_NAME }, |
| 112 { "advancedGroupName", IDS_OPTIONS_ADVANCED_TAB_LABEL }, |
| 113 { "advancedOptionsButtonTitle", IDS_OPTIONS_ADVANCED_BUTTON_TITLE }, |
| 114 { "autologinEnabled", IDS_OPTIONS_PASSWORDS_AUTOLOGIN }, |
| 115 { "browsingData", IDS_OPTIONS_BROWSING_DATA_GROUP_NAME }, // needed? |
| 116 { "changeHomePage", IDS_OPTIONS_CHANGE_HOME_PAGE }, |
92 { "customizeSync", IDS_SYNC_CUSTOMIZE_BUTTON_LABEL }, | 117 { "customizeSync", IDS_SYNC_CUSTOMIZE_BUTTON_LABEL }, |
| 118 { "defaultBrowserGroupName", IDS_OPTIONS_DEFAULTBROWSER_GROUP_NAME }, |
| 119 { "defaultSearchGroupName", IDS_OPTIONS_DEFAULTSEARCH_GROUP_NAME }, |
| 120 { "defaultSearchManageEngines", IDS_OPTIONS_DEFAULTSEARCH_MANAGE_ENGINES }, |
| 121 { "instantConfirmMessage", IDS_INSTANT_OPT_IN_MESSAGE }, |
| 122 { "instantConfirmTitle", IDS_INSTANT_OPT_IN_TITLE }, |
| 123 { "importData", IDS_OPTIONS_IMPORT_DATA_BUTTON }, |
| 124 { "manageDataDescription", IDS_OPTIONS_MANAGE_DATA_DESCRIPTION }, |
93 { "profiles", IDS_PROFILES_OPTIONS_GROUP_NAME }, | 125 { "profiles", IDS_PROFILES_OPTIONS_GROUP_NAME }, |
94 { "profilesCreate", IDS_PROFILES_CREATE_BUTTON_LABEL }, | 126 { "profilesCreate", IDS_PROFILES_CREATE_BUTTON_LABEL }, |
95 { "profilesManage", IDS_PROFILES_MANAGE_BUTTON_LABEL }, | |
96 { "profilesDelete", IDS_PROFILES_DELETE_BUTTON_LABEL }, | 127 { "profilesDelete", IDS_PROFILES_DELETE_BUTTON_LABEL }, |
97 { "profilesDeleteSingle", IDS_PROFILES_DELETE_SINGLE_BUTTON_LABEL }, | 128 { "profilesDeleteSingle", IDS_PROFILES_DELETE_SINGLE_BUTTON_LABEL }, |
98 { "profilesListItemCurrent", IDS_PROFILES_LIST_ITEM_CURRENT }, | 129 { "profilesListItemCurrent", IDS_PROFILES_LIST_ITEM_CURRENT }, |
| 130 { "profilesManage", IDS_PROFILES_MANAGE_BUTTON_LABEL }, |
99 { "startupGroupName", IDS_OPTIONS_STARTUP_GROUP_NAME }, | 131 { "startupGroupName", IDS_OPTIONS_STARTUP_GROUP_NAME }, |
| 132 { "startupSetPages", IDS_OPTIONS2_STARTUP_SET_PAGES }, |
100 { "startupShowDefaultAndNewTab", | 133 { "startupShowDefaultAndNewTab", |
101 IDS_OPTIONS_STARTUP_SHOW_DEFAULT_AND_NEWTAB}, | 134 IDS_OPTIONS_STARTUP_SHOW_DEFAULT_AND_NEWTAB}, |
102 { "startupShowLastSession", IDS_OPTIONS_STARTUP_SHOW_LAST_SESSION }, | 135 { "startupShowLastSession", IDS_OPTIONS_STARTUP_SHOW_LAST_SESSION }, |
103 { "startupShowPages", IDS_OPTIONS2_STARTUP_SHOW_PAGES }, | 136 { "startupShowPages", IDS_OPTIONS2_STARTUP_SHOW_PAGES }, |
104 { "startupSetPages", IDS_OPTIONS2_STARTUP_SET_PAGES }, | 137 { "syncSection", IDS_SYNC_OPTIONS_GROUP_NAME }, |
| 138 { "themesGallery", IDS_THEMES_GALLERY_BUTTON }, |
| 139 { "themesGalleryURL", IDS_THEMES_GALLERY_URL }, |
105 { "toolbarGroupName", IDS_OPTIONS2_TOOLBAR_GROUP_NAME }, | 140 { "toolbarGroupName", IDS_OPTIONS2_TOOLBAR_GROUP_NAME }, |
| 141 { "toolbarShowBookmarksBar", IDS_OPTIONS_TOOLBAR_SHOW_BOOKMARKS_BAR }, |
106 { "toolbarShowHomeButton", IDS_OPTIONS_TOOLBAR_SHOW_HOME_BUTTON }, | 142 { "toolbarShowHomeButton", IDS_OPTIONS_TOOLBAR_SHOW_HOME_BUTTON }, |
107 { "changeHomePage", IDS_OPTIONS_CHANGE_HOME_PAGE }, | 143 #if defined(TOOLKIT_GTK) |
108 { "toolbarShowBookmarksBar", IDS_OPTIONS_TOOLBAR_SHOW_BOOKMARKS_BAR }, | 144 { "showWindowDecorations", IDS_SHOW_WINDOW_DECORATIONS_RADIO }, |
109 { "defaultSearchGroupName", IDS_OPTIONS_DEFAULTSEARCH_GROUP_NAME }, | 145 { "hideWindowDecorations", IDS_HIDE_WINDOW_DECORATIONS_RADIO }, |
110 { "defaultSearchManageEngines", IDS_OPTIONS_DEFAULTSEARCH_MANAGE_ENGINES }, | 146 { "themesGTKButton", IDS_THEMES_GTK_BUTTON }, |
111 { "instantConfirmTitle", IDS_INSTANT_OPT_IN_TITLE }, | 147 { "themesSetClassic", IDS_THEMES_SET_CLASSIC }, |
112 { "instantConfirmMessage", IDS_INSTANT_OPT_IN_MESSAGE }, | 148 #else |
113 { "defaultBrowserGroupName", IDS_OPTIONS_DEFAULTBROWSER_GROUP_NAME }, | 149 { "themes", IDS_THEMES_GROUP_NAME }, |
114 { "advancedGroupName", IDS_OPTIONS_ADVANCED_TAB_LABEL }, | 150 { "themesReset", IDS_THEMES_RESET_BUTTON }, |
115 { "advancedOptionsButtonTitle", IDS_OPTIONS_ADVANCED_BUTTON_TITLE }, | 151 #endif |
| 152 #if defined(OS_CHROMEOS) |
| 153 { "changePicture", IDS_OPTIONS_CHANGE_PICTURE }, |
| 154 { "enableScreenlock", IDS_OPTIONS_ENABLE_SCREENLOCKER_CHECKBOX }, |
| 155 #endif |
116 }; | 156 }; |
117 | 157 |
118 RegisterStrings(localized_strings, resources, arraysize(resources)); | 158 RegisterStrings(localized_strings, resources, arraysize(resources)); |
119 RegisterTitle(localized_strings, "settingsTitle", IDS_SETTINGS_TITLE); | 159 RegisterTitle(localized_strings, "settingsTitle", IDS_SETTINGS_TITLE); |
120 | 160 |
121 localized_strings->SetString( | 161 localized_strings->SetString( |
122 "syncOverview", | 162 "syncOverview", |
123 l10n_util::GetStringFUTF16(IDS_SYNC_OVERVIEW, | 163 l10n_util::GetStringFUTF16(IDS_SYNC_OVERVIEW, |
124 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); | 164 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); |
125 localized_strings->SetString("syncLearnMoreURL", | 165 |
| 166 localized_strings->SetString( |
| 167 "syncLearnMoreURL", |
126 google_util::StringAppendGoogleLocaleParam(chrome::kSyncLearnMoreURL)); | 168 google_util::StringAppendGoogleLocaleParam(chrome::kSyncLearnMoreURL)); |
127 | 169 localized_strings->SetString( |
128 localized_strings->SetString("profilesSingleUser", | 170 "profilesSingleUser", |
129 l10n_util::GetStringFUTF16(IDS_PROFILES_SINGLE_USER_MESSAGE, | 171 l10n_util::GetStringFUTF16(IDS_PROFILES_SINGLE_USER_MESSAGE, |
130 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); | 172 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); |
131 | 173 |
132 localized_strings->SetString("defaultSearchGroupLabel", | 174 localized_strings->SetString( |
| 175 "defaultSearchGroupLabel", |
133 l10n_util::GetStringFUTF16(IDS_SEARCH_PREF_EXPLANATION, | 176 l10n_util::GetStringFUTF16(IDS_SEARCH_PREF_EXPLANATION, |
134 l10n_util::GetStringUTF16(IDS_OMNIBOX_LEARN_MORE_URL))); | 177 l10n_util::GetStringUTF16(IDS_OMNIBOX_LEARN_MORE_URL))); |
135 localized_strings->SetString("instantPrefAndWarning", | 178 localized_strings->SetString( |
| 179 "instantPrefAndWarning", |
136 l10n_util::GetStringFUTF16(IDS_INSTANT_PREF_WITH_WARNING, | 180 l10n_util::GetStringFUTF16(IDS_INSTANT_PREF_WITH_WARNING, |
137 l10n_util::GetStringUTF16(IDS_INSTANT_LEARN_MORE_URL))); | 181 l10n_util::GetStringUTF16(IDS_INSTANT_LEARN_MORE_URL))); |
138 localized_strings->SetString("instantLearnMoreLink", | 182 localized_strings->SetString( |
| 183 "instantLearnMoreLink", |
139 ASCIIToUTF16(browser::InstantLearnMoreURL().spec())); | 184 ASCIIToUTF16(browser::InstantLearnMoreURL().spec())); |
140 localized_strings->SetString("defaultBrowserUnknown", | 185 |
| 186 localized_strings->SetString( |
| 187 "defaultBrowserUnknown", |
141 l10n_util::GetStringFUTF16(IDS_OPTIONS_DEFAULTBROWSER_UNKNOWN, | 188 l10n_util::GetStringFUTF16(IDS_OPTIONS_DEFAULTBROWSER_UNKNOWN, |
142 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); | 189 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); |
143 localized_strings->SetString("defaultBrowserUseAsDefault", | 190 localized_strings->SetString( |
| 191 "defaultBrowserUseAsDefault", |
144 l10n_util::GetStringFUTF16(IDS_OPTIONS_DEFAULTBROWSER_USEASDEFAULT, | 192 l10n_util::GetStringFUTF16(IDS_OPTIONS_DEFAULTBROWSER_USEASDEFAULT, |
145 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); | 193 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); |
146 localized_strings->SetString("autoLaunchText", | 194 localized_strings->SetString( |
| 195 "autoLaunchText", |
147 l10n_util::GetStringFUTF16(IDS_AUTOLAUNCH_TEXT, | 196 l10n_util::GetStringFUTF16(IDS_AUTOLAUNCH_TEXT, |
148 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); | 197 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); |
149 localized_strings->SetString("advancedGroupDescription", | 198 localized_strings->SetString( |
| 199 "advancedGroupDescription", |
150 l10n_util::GetStringFUTF16(IDS_OPTIONS_ADVANCED_GROUP_DESCRIPTION, | 200 l10n_util::GetStringFUTF16(IDS_OPTIONS_ADVANCED_GROUP_DESCRIPTION, |
151 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); | 201 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); |
| 202 |
| 203 #if defined(OS_CHROMEOS) |
| 204 if (chromeos::UserManager::Get()->user_is_logged_in()) { |
| 205 localized_strings->SetString("username", |
| 206 chromeos::UserManager::Get()->logged_in_user().email()); |
| 207 } |
| 208 #endif |
152 } | 209 } |
153 | 210 |
154 void BrowserOptionsHandler::RegisterMessages() { | 211 void BrowserOptionsHandler::RegisterMessages() { |
155 web_ui()->RegisterMessageCallback("becomeDefaultBrowser", | 212 web_ui()->RegisterMessageCallback( |
| 213 "becomeDefaultBrowser", |
156 base::Bind(&BrowserOptionsHandler::BecomeDefaultBrowser, | 214 base::Bind(&BrowserOptionsHandler::BecomeDefaultBrowser, |
157 base::Unretained(this))); | 215 base::Unretained(this))); |
158 web_ui()->RegisterMessageCallback("setDefaultSearchEngine", | 216 web_ui()->RegisterMessageCallback( |
| 217 "setDefaultSearchEngine", |
159 base::Bind(&BrowserOptionsHandler::SetDefaultSearchEngine, | 218 base::Bind(&BrowserOptionsHandler::SetDefaultSearchEngine, |
160 base::Unretained(this))); | 219 base::Unretained(this))); |
161 web_ui()->RegisterMessageCallback("requestAutocompleteSuggestions", | 220 web_ui()->RegisterMessageCallback( |
| 221 "requestAutocompleteSuggestions", |
162 base::Bind(&BrowserOptionsHandler::RequestAutocompleteSuggestions, | 222 base::Bind(&BrowserOptionsHandler::RequestAutocompleteSuggestions, |
163 base::Unretained(this))); | 223 base::Unretained(this))); |
164 web_ui()->RegisterMessageCallback("enableInstant", | 224 web_ui()->RegisterMessageCallback( |
| 225 "enableInstant", |
165 base::Bind(&BrowserOptionsHandler::EnableInstant, | 226 base::Bind(&BrowserOptionsHandler::EnableInstant, |
166 base::Unretained(this))); | 227 base::Unretained(this))); |
167 web_ui()->RegisterMessageCallback("disableInstant", | 228 web_ui()->RegisterMessageCallback( |
| 229 "disableInstant", |
168 base::Bind(&BrowserOptionsHandler::DisableInstant, | 230 base::Bind(&BrowserOptionsHandler::DisableInstant, |
169 base::Unretained(this))); | 231 base::Unretained(this))); |
170 web_ui()->RegisterMessageCallback("getInstantFieldTrialStatus", | 232 web_ui()->RegisterMessageCallback( |
| 233 "getInstantFieldTrialStatus", |
171 base::Bind(&BrowserOptionsHandler::GetInstantFieldTrialStatus, | 234 base::Bind(&BrowserOptionsHandler::GetInstantFieldTrialStatus, |
172 base::Unretained(this))); | 235 base::Unretained(this))); |
173 web_ui()->RegisterMessageCallback( | 236 web_ui()->RegisterMessageCallback( |
174 "createProfile", | 237 "createProfile", |
175 base::Bind(&BrowserOptionsHandler::CreateProfile, | 238 base::Bind(&BrowserOptionsHandler::CreateProfile, |
176 base::Unretained(this))); | 239 base::Unretained(this))); |
| 240 web_ui()->RegisterMessageCallback( |
| 241 "themesReset", |
| 242 base::Bind(&BrowserOptionsHandler::ThemesReset, |
| 243 base::Unretained(this))); |
| 244 #if defined(TOOLKIT_GTK) |
| 245 web_ui()->RegisterMessageCallback( |
| 246 "themesSetGTK", |
| 247 base::Bind(&BrowserOptionsHandler::ThemesSetGTK, |
| 248 base::Unretained(this))); |
| 249 #endif |
177 } | 250 } |
178 | 251 |
179 void BrowserOptionsHandler::OnStateChanged() { | 252 void BrowserOptionsHandler::OnStateChanged() { |
180 string16 status_label; | 253 string16 status_label; |
181 string16 link_label; | 254 string16 link_label; |
182 ProfileSyncService* service = | 255 ProfileSyncService* service = |
183 Profile::FromWebUI(web_ui())->GetProfileSyncService(); | 256 Profile::FromWebUI(web_ui())->GetProfileSyncService(); |
184 DCHECK(service); | 257 DCHECK(service); |
185 bool managed = service->IsManaged(); | 258 bool managed = service->IsManaged(); |
186 bool sync_setup_completed = service->HasSyncSetupCompleted(); | 259 bool sync_setup_completed = service->HasSyncSetupCompleted(); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 default_browser_policy_.Init(prefs::kDefaultBrowserSettingEnabled, | 359 default_browser_policy_.Init(prefs::kDefaultBrowserSettingEnabled, |
287 g_browser_process->local_state(), | 360 g_browser_process->local_state(), |
288 this); | 361 this); |
289 UpdateDefaultBrowserState(); | 362 UpdateDefaultBrowserState(); |
290 | 363 |
291 pref_change_registrar_.Init(profile->GetPrefs()); | 364 pref_change_registrar_.Init(profile->GetPrefs()); |
292 pref_change_registrar_.Add(prefs::kHomePage, this); | 365 pref_change_registrar_.Add(prefs::kHomePage, this); |
293 | 366 |
294 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, | 367 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, |
295 content::NotificationService::AllSources()); | 368 content::NotificationService::AllSources()); |
| 369 #if defined(OS_CHROMEOS) |
| 370 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, |
| 371 content::NotificationService::AllSources()); |
| 372 #endif |
| 373 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
| 374 content::Source<ThemeService>( |
| 375 ThemeServiceFactory::GetForProfile(profile))); |
296 | 376 |
297 UpdateSearchEngines(); | 377 UpdateSearchEngines(); |
298 UpdateHomePageLabel(); | 378 UpdateHomePageLabel(); |
| 379 ObserveThemeChanged(); |
299 | 380 |
300 autocomplete_controller_.reset(new AutocompleteController(profile, this)); | 381 autocomplete_controller_.reset(new AutocompleteController(profile, this)); |
301 | 382 |
302 #if defined(OS_WIN) | 383 #if defined(OS_WIN) |
303 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 384 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
304 base::Bind(&BrowserOptionsHandler::CheckAutoLaunch, | 385 base::Bind(&BrowserOptionsHandler::CheckAutoLaunch, |
305 weak_ptr_factory_for_ui_.GetWeakPtr(), | 386 weak_ptr_factory_for_ui_.GetWeakPtr(), |
306 weak_ptr_factory_for_file_.GetWeakPtr())); | 387 weak_ptr_factory_for_file_.GetWeakPtr())); |
307 weak_ptr_factory_for_ui_.DetachFromThread(); | 388 weak_ptr_factory_for_ui_.DetachFromThread(); |
308 #endif | 389 #endif |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 | 583 |
503 label.reset(Value::CreateStringValue(str)); | 584 label.reset(Value::CreateStringValue(str)); |
504 web_ui()->CallJavascriptFunction("BrowserOptions.updateHomePageLabel", | 585 web_ui()->CallJavascriptFunction("BrowserOptions.updateHomePageLabel", |
505 *label); | 586 *label); |
506 } | 587 } |
507 | 588 |
508 void BrowserOptionsHandler::Observe( | 589 void BrowserOptionsHandler::Observe( |
509 int type, | 590 int type, |
510 const content::NotificationSource& source, | 591 const content::NotificationSource& source, |
511 const content::NotificationDetails& details) { | 592 const content::NotificationDetails& details) { |
512 if (type == chrome::NOTIFICATION_PREF_CHANGED) { | 593 if (type == chrome::NOTIFICATION_BROWSER_THEME_CHANGED) { |
| 594 ObserveThemeChanged(); |
| 595 #if defined(OS_CHROMEOS) |
| 596 } else if (type == chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED) { |
| 597 UpdateAccountPicture(); |
| 598 #endif |
| 599 } else if (type == chrome::NOTIFICATION_PREF_CHANGED) { |
513 std::string* pref = content::Details<std::string>(details).ptr(); | 600 std::string* pref = content::Details<std::string>(details).ptr(); |
514 if (*pref == prefs::kDefaultBrowserSettingEnabled) { | 601 if (*pref == prefs::kDefaultBrowserSettingEnabled) { |
515 UpdateDefaultBrowserState(); | 602 UpdateDefaultBrowserState(); |
516 } else if (*pref == prefs::kHomePage) { | 603 } else if (*pref == prefs::kHomePage) { |
517 UpdateHomePageLabel(); | 604 UpdateHomePageLabel(); |
518 } else { | 605 } else { |
519 NOTREACHED(); | 606 NOTREACHED(); |
520 } | 607 } |
521 } else if (multiprofile_ && | 608 } else if (multiprofile_ && |
522 type == chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED) { | 609 type == chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED) { |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 profile_value->SetString("iconURL", web_ui_util::GetImageDataUrl(icon)); | 703 profile_value->SetString("iconURL", web_ui_util::GetImageDataUrl(icon)); |
617 } else { | 704 } else { |
618 size_t icon_index = cache.GetAvatarIconIndexOfProfileAtIndex(i); | 705 size_t icon_index = cache.GetAvatarIconIndexOfProfileAtIndex(i); |
619 profile_value->SetString("iconURL", | 706 profile_value->SetString("iconURL", |
620 cache.GetDefaultAvatarIconUrl(icon_index)); | 707 cache.GetDefaultAvatarIconUrl(icon_index)); |
621 } | 708 } |
622 | 709 |
623 profile_info_list.Append(profile_value); | 710 profile_info_list.Append(profile_value); |
624 } | 711 } |
625 | 712 |
626 web_ui()->CallJavascriptFunction("PersonalOptions.setProfilesInfo", | 713 web_ui()->CallJavascriptFunction("BrowserOptions.setProfilesInfo", |
627 profile_info_list); | 714 profile_info_list); |
628 } | 715 } |
629 | 716 |
630 void BrowserOptionsHandler::CreateProfile(const ListValue* args) { | 717 void BrowserOptionsHandler::CreateProfile(const ListValue* args) { |
631 ProfileManager::CreateMultiProfileAsync(); | 718 ProfileManager::CreateMultiProfileAsync(); |
632 } | 719 } |
633 | 720 |
| 721 void BrowserOptionsHandler::ObserveThemeChanged() { |
| 722 Profile* profile = Profile::FromWebUI(web_ui()); |
| 723 #if defined(TOOLKIT_GTK) |
| 724 GtkThemeService* theme_service = GtkThemeService::GetFrom(profile); |
| 725 bool is_gtk_theme = theme_service->UsingNativeTheme(); |
| 726 base::FundamentalValue gtk_enabled(!is_gtk_theme); |
| 727 web_ui()->CallJavascriptFunction("BrowserOptions.setGtkThemeButtonEnabled", |
| 728 gtk_enabled); |
| 729 #else |
| 730 ThemeService* theme_service = ThemeServiceFactory::GetForProfile(profile); |
| 731 bool is_gtk_theme = false; |
| 732 #endif |
| 733 |
| 734 bool is_classic_theme = !is_gtk_theme && theme_service->UsingDefaultTheme(); |
| 735 base::FundamentalValue enabled(!is_classic_theme); |
| 736 web_ui()->CallJavascriptFunction("BrowserOptions.setThemesResetButtonEnabled", |
| 737 enabled); |
| 738 } |
| 739 |
| 740 void BrowserOptionsHandler::ThemesReset(const ListValue* args) { |
| 741 content::RecordAction(UserMetricsAction("Options_ThemesReset")); |
| 742 Profile* profile = Profile::FromWebUI(web_ui()); |
| 743 ThemeServiceFactory::GetForProfile(profile)->UseDefaultTheme(); |
| 744 } |
| 745 |
| 746 #if defined(TOOLKIT_GTK) |
| 747 void BrowserOptionsHandler::ThemesSetGTK(const ListValue* args) { |
| 748 content::RecordAction(UserMetricsAction("Options_GtkThemeSet")); |
| 749 Profile* profile = Profile::FromWebUI(web_ui()); |
| 750 ThemeServiceFactory::GetForProfile(profile)->SetNativeTheme(); |
| 751 } |
| 752 #endif |
| 753 |
| 754 #if defined(OS_CHROMEOS) |
| 755 void BrowserOptionsHandler::UpdateAccountPicture() { |
| 756 std::string email = chromeos::UserManager::Get()->logged_in_user().email(); |
| 757 if (!email.empty()) { |
| 758 web_ui()->CallJavascriptFunction("BrowserOptions.updateAccountPicture"); |
| 759 base::StringValue email_value(email); |
| 760 web_ui()->CallJavascriptFunction("BrowserOptions.updateAccountPicture", |
| 761 email_value); |
| 762 } |
| 763 } |
| 764 #endif |
| 765 |
634 } // namespace options2 | 766 } // namespace options2 |
OLD | NEW |