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

Side by Side Diff: chrome/browser/ui/webui/options/browser_options_handler.cc

Issue 17494005: linux_aura: Three fixes for switching themes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 7 years, 6 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/options/browser_options_handler.h" 5 #include "chrome/browser/ui/webui/options/browser_options_handler.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 #include "chromeos/chromeos_switches.h" 107 #include "chromeos/chromeos_switches.h"
108 #include "chromeos/dbus/dbus_thread_manager.h" 108 #include "chromeos/dbus/dbus_thread_manager.h"
109 #include "chromeos/dbus/power_manager_client.h" 109 #include "chromeos/dbus/power_manager_client.h"
110 #include "ui/gfx/image/image_skia.h" 110 #include "ui/gfx/image/image_skia.h"
111 #endif // defined(OS_CHROMEOS) 111 #endif // defined(OS_CHROMEOS)
112 112
113 #if defined(OS_WIN) 113 #if defined(OS_WIN)
114 #include "chrome/installer/util/auto_launch_util.h" 114 #include "chrome/installer/util/auto_launch_util.h"
115 #endif // defined(OS_WIN) 115 #endif // defined(OS_WIN)
116 116
117 #if defined(TOOLKIT_GTK)
118 #include "chrome/browser/ui/gtk/gtk_theme_service.h"
119 #endif // defined(TOOLKIT_GTK)
120
121 using content::BrowserContext; 117 using content::BrowserContext;
122 using content::BrowserThread; 118 using content::BrowserThread;
123 using content::DownloadManager; 119 using content::DownloadManager;
124 using content::OpenURLParams; 120 using content::OpenURLParams;
125 using content::Referrer; 121 using content::Referrer;
126 using content::UserMetricsAction; 122 using content::UserMetricsAction;
127 123
128 namespace options { 124 namespace options {
129 125
130 namespace { 126 namespace {
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 { "suggestPref", IDS_OPTIONS_SUGGEST_PREF }, 325 { "suggestPref", IDS_OPTIONS_SUGGEST_PREF },
330 { "syncButtonTextInProgress", IDS_SYNC_NTP_SETUP_IN_PROGRESS }, 326 { "syncButtonTextInProgress", IDS_SYNC_NTP_SETUP_IN_PROGRESS },
331 { "syncButtonTextStop", IDS_SYNC_STOP_SYNCING_BUTTON_LABEL }, 327 { "syncButtonTextStop", IDS_SYNC_STOP_SYNCING_BUTTON_LABEL },
332 { "themesGallery", IDS_THEMES_GALLERY_BUTTON }, 328 { "themesGallery", IDS_THEMES_GALLERY_BUTTON },
333 { "themesGalleryURL", IDS_THEMES_GALLERY_URL }, 329 { "themesGalleryURL", IDS_THEMES_GALLERY_URL },
334 { "tabsToLinksPref", IDS_OPTIONS_TABS_TO_LINKS_PREF }, 330 { "tabsToLinksPref", IDS_OPTIONS_TABS_TO_LINKS_PREF },
335 { "toolbarShowBookmarksBar", IDS_OPTIONS_TOOLBAR_SHOW_BOOKMARKS_BAR }, 331 { "toolbarShowBookmarksBar", IDS_OPTIONS_TOOLBAR_SHOW_BOOKMARKS_BAR },
336 { "toolbarShowHomeButton", IDS_OPTIONS_TOOLBAR_SHOW_HOME_BUTTON }, 332 { "toolbarShowHomeButton", IDS_OPTIONS_TOOLBAR_SHOW_HOME_BUTTON },
337 { "translateEnableTranslate", 333 { "translateEnableTranslate",
338 IDS_OPTIONS_TRANSLATE_ENABLE_TRANSLATE }, 334 IDS_OPTIONS_TRANSLATE_ENABLE_TRANSLATE },
339 #if defined(TOOLKIT_GTK) 335 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
340 { "showWindowDecorations", IDS_SHOW_WINDOW_DECORATIONS }, 336 { "showWindowDecorations", IDS_SHOW_WINDOW_DECORATIONS },
341 { "themesGTKButton", IDS_THEMES_GTK_BUTTON }, 337 { "themesNativeButton", IDS_THEMES_GTK_BUTTON },
342 { "themesSetClassic", IDS_THEMES_SET_CLASSIC }, 338 { "themesSetClassic", IDS_THEMES_SET_CLASSIC },
343 #else 339 #else
344 { "themes", IDS_THEMES_GROUP_NAME }, 340 { "themes", IDS_THEMES_GROUP_NAME },
345 { "themesReset", IDS_THEMES_RESET_BUTTON }, 341 { "themesReset", IDS_THEMES_RESET_BUTTON },
346 #endif 342 #endif
347 #if defined(OS_CHROMEOS) 343 #if defined(OS_CHROMEOS)
348 { "accessibilityExplanation", 344 { "accessibilityExplanation",
349 IDS_OPTIONS_SETTINGS_ACCESSIBILITY_EXPLANATION }, 345 IDS_OPTIONS_SETTINGS_ACCESSIBILITY_EXPLANATION },
350 { "accessibilityHighContrast", 346 { "accessibilityHighContrast",
351 IDS_OPTIONS_SETTINGS_ACCESSIBILITY_HIGH_CONTRAST_DESCRIPTION }, 347 IDS_OPTIONS_SETTINGS_ACCESSIBILITY_HIGH_CONTRAST_DESCRIPTION },
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 base::Bind(&BrowserOptionsHandler::DeleteProfile, 567 base::Bind(&BrowserOptionsHandler::DeleteProfile,
572 base::Unretained(this))); 568 base::Unretained(this)));
573 web_ui()->RegisterMessageCallback( 569 web_ui()->RegisterMessageCallback(
574 "cancelCreateProfile", 570 "cancelCreateProfile",
575 base::Bind(&BrowserOptionsHandler::HandleCancelProfileCreation, 571 base::Bind(&BrowserOptionsHandler::HandleCancelProfileCreation,
576 base::Unretained(this))); 572 base::Unretained(this)));
577 web_ui()->RegisterMessageCallback( 573 web_ui()->RegisterMessageCallback(
578 "themesReset", 574 "themesReset",
579 base::Bind(&BrowserOptionsHandler::ThemesReset, 575 base::Bind(&BrowserOptionsHandler::ThemesReset,
580 base::Unretained(this))); 576 base::Unretained(this)));
581 #if defined(TOOLKIT_GTK) 577 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
582 web_ui()->RegisterMessageCallback( 578 web_ui()->RegisterMessageCallback(
583 "themesSetGTK", 579 "themesSetNative",
584 base::Bind(&BrowserOptionsHandler::ThemesSetGTK, 580 base::Bind(&BrowserOptionsHandler::ThemesSetNative,
585 base::Unretained(this))); 581 base::Unretained(this)));
586 #endif 582 #endif
587 web_ui()->RegisterMessageCallback( 583 web_ui()->RegisterMessageCallback(
588 "selectDownloadLocation", 584 "selectDownloadLocation",
589 base::Bind(&BrowserOptionsHandler::HandleSelectDownloadLocation, 585 base::Bind(&BrowserOptionsHandler::HandleSelectDownloadLocation,
590 base::Unretained(this))); 586 base::Unretained(this)));
591 web_ui()->RegisterMessageCallback( 587 web_ui()->RegisterMessageCallback(
592 "autoOpenFileTypesAction", 588 "autoOpenFileTypesAction",
593 base::Bind(&BrowserOptionsHandler::HandleAutoOpenButton, 589 base::Bind(&BrowserOptionsHandler::HandleAutoOpenButton,
594 base::Unretained(this))); 590 base::Unretained(this)));
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after
1312 1308
1313 // Cancelling registration means the callback passed into 1309 // Cancelling registration means the callback passed into
1314 // RegisterAndInitSync() won't be called, so the cleanup must be done here. 1310 // RegisterAndInitSync() won't be called, so the cleanup must be done here.
1315 profile_path_being_created_.clear(); 1311 profile_path_being_created_.clear();
1316 DeleteProfileAtPath(new_profile->GetPath()); 1312 DeleteProfileAtPath(new_profile->GetPath());
1317 } 1313 }
1318 1314
1319 void BrowserOptionsHandler::ObserveThemeChanged() { 1315 void BrowserOptionsHandler::ObserveThemeChanged() {
1320 Profile* profile = Profile::FromWebUI(web_ui()); 1316 Profile* profile = Profile::FromWebUI(web_ui());
1321 bool profile_is_managed = ManagedUserService::ProfileIsManaged(profile); 1317 bool profile_is_managed = ManagedUserService::ProfileIsManaged(profile);
1322 #if defined(TOOLKIT_GTK)
1323 GtkThemeService* theme_service = GtkThemeService::GetFrom(profile);
1324 bool is_gtk_theme = theme_service->UsingNativeTheme();
1325 base::FundamentalValue gtk_enabled(!is_gtk_theme && !profile_is_managed);
1326 web_ui()->CallJavascriptFunction("BrowserOptions.setGtkThemeButtonEnabled",
1327 gtk_enabled);
1328 #else
1329 ThemeService* theme_service = ThemeServiceFactory::GetForProfile(profile); 1318 ThemeService* theme_service = ThemeServiceFactory::GetForProfile(profile);
1330 bool is_gtk_theme = false; 1319 bool is_native_theme = false;
1320
1321 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
1322 is_native_theme = theme_service->UsingNativeTheme();
1323 base::FundamentalValue native_theme_enabled(!is_native_theme &&
1324 !profile_is_managed);
1325 web_ui()->CallJavascriptFunction("BrowserOptions.setNativeThemeButtonEnabled",
1326 native_theme_enabled);
1331 #endif 1327 #endif
1332 1328
1333 bool is_classic_theme = !is_gtk_theme && theme_service->UsingDefaultTheme(); 1329 bool is_classic_theme = !is_native_theme &&
1330 theme_service->UsingDefaultTheme();
1334 base::FundamentalValue enabled(!is_classic_theme && !profile_is_managed); 1331 base::FundamentalValue enabled(!is_classic_theme && !profile_is_managed);
1335 web_ui()->CallJavascriptFunction("BrowserOptions.setThemesResetButtonEnabled", 1332 web_ui()->CallJavascriptFunction("BrowserOptions.setThemesResetButtonEnabled",
1336 enabled); 1333 enabled);
1337 } 1334 }
1338 1335
1339 void BrowserOptionsHandler::ThemesReset(const ListValue* args) { 1336 void BrowserOptionsHandler::ThemesReset(const ListValue* args) {
1340 Profile* profile = Profile::FromWebUI(web_ui()); 1337 Profile* profile = Profile::FromWebUI(web_ui());
1341 if (ManagedUserService::ProfileIsManaged(profile)) 1338 if (ManagedUserService::ProfileIsManaged(profile))
1342 return; 1339 return;
1343 content::RecordAction(UserMetricsAction("Options_ThemesReset")); 1340 content::RecordAction(UserMetricsAction("Options_ThemesReset"));
1344 ThemeServiceFactory::GetForProfile(profile)->UseDefaultTheme(); 1341 ThemeServiceFactory::GetForProfile(profile)->UseDefaultTheme();
1345 } 1342 }
1346 1343
1347 #if defined(TOOLKIT_GTK) 1344 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
1348 void BrowserOptionsHandler::ThemesSetGTK(const ListValue* args) { 1345 void BrowserOptionsHandler::ThemesSetNative(const ListValue* args) {
1349 content::RecordAction(UserMetricsAction("Options_GtkThemeSet")); 1346 content::RecordAction(UserMetricsAction("Options_GtkThemeSet"));
1350 Profile* profile = Profile::FromWebUI(web_ui()); 1347 Profile* profile = Profile::FromWebUI(web_ui());
1351 ThemeServiceFactory::GetForProfile(profile)->SetNativeTheme(); 1348 ThemeServiceFactory::GetForProfile(profile)->SetNativeTheme();
1352 } 1349 }
1353 #endif 1350 #endif
1354 1351
1355 #if defined(OS_CHROMEOS) 1352 #if defined(OS_CHROMEOS)
1356 void BrowserOptionsHandler::UpdateAccountPicture() { 1353 void BrowserOptionsHandler::UpdateAccountPicture() {
1357 std::string email = chromeos::UserManager::Get()->GetLoggedInUser()->email(); 1354 std::string email = chromeos::UserManager::Get()->GetLoggedInUser()->email();
1358 if (!email.empty()) { 1355 if (!email.empty()) {
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
1734 base::FundamentalValue disabled(profile_pref_registrar_.IsManaged() || 1731 base::FundamentalValue disabled(profile_pref_registrar_.IsManaged() ||
1735 is_extension_controlled); 1732 is_extension_controlled);
1736 base::FundamentalValue extension_controlled(is_extension_controlled); 1733 base::FundamentalValue extension_controlled(is_extension_controlled);
1737 web_ui()->CallJavascriptFunction("BrowserOptions.setupProxySettingsSection", 1734 web_ui()->CallJavascriptFunction("BrowserOptions.setupProxySettingsSection",
1738 disabled, extension_controlled); 1735 disabled, extension_controlled);
1739 1736
1740 #endif // !defined(OS_CHROMEOS) 1737 #endif // !defined(OS_CHROMEOS)
1741 } 1738 }
1742 1739
1743 } // namespace options 1740 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698