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

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

Issue 9232010: [uber page] Migrate all elements in the 'System' (cros) page to new locations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: compile fix Created 8 years, 11 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 "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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 #include "content/public/browser/notification_service.h" 53 #include "content/public/browser/notification_service.h"
54 #include "content/public/browser/notification_source.h" 54 #include "content/public/browser/notification_source.h"
55 #include "content/public/browser/user_metrics.h" 55 #include "content/public/browser/user_metrics.h"
56 #include "content/public/browser/web_contents.h" 56 #include "content/public/browser/web_contents.h"
57 #include "grit/chromium_strings.h" 57 #include "grit/chromium_strings.h"
58 #include "grit/generated_resources.h" 58 #include "grit/generated_resources.h"
59 #include "grit/locale_settings.h" 59 #include "grit/locale_settings.h"
60 #include "grit/theme_resources.h" 60 #include "grit/theme_resources.h"
61 #include "ui/base/l10n/l10n_util.h" 61 #include "ui/base/l10n/l10n_util.h"
62 62
63 #if defined(OS_CHROMEOS)
64 #include "chrome/browser/chromeos/cros_settings.h"
65 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h"
66 #include "chrome/browser/chromeos/dbus/power_manager_client.h"
67 #include "chrome/browser/chromeos/login/user_manager.h"
68 #include "chrome/browser/chromeos/options/take_photo_dialog.h"
69 #include "chrome/browser/chromeos/system/input_device_settings.h"
70 #include "chrome/browser/chromeos/xinput_hierarchy_changed_event_listener.h"
71 #include "chrome/browser/ui/browser_window.h"
72 #include "chrome/browser/ui/views/window.h"
73 #include "third_party/skia/include/core/SkBitmap.h"
74 #endif // defined(OS_CHROMEOS)
75
63 #if defined(OS_WIN) 76 #if defined(OS_WIN)
64 #include "chrome/installer/util/auto_launch_util.h" 77 #include "chrome/installer/util/auto_launch_util.h"
65 #endif // defined(OS_WIN) 78 #endif // defined(OS_WIN)
66 79
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) 80 #if defined(TOOLKIT_GTK)
76 #include "chrome/browser/ui/gtk/gtk_theme_service.h" 81 #include "chrome/browser/ui/gtk/gtk_theme_service.h"
77 #endif // defined(TOOLKIT_GTK) 82 #endif // defined(TOOLKIT_GTK)
78 83
79 using content::BrowserThread; 84 using content::BrowserThread;
80 using content::UserMetricsAction; 85 using content::UserMetricsAction;
81 86
87 namespace {
88
89 #if defined(OS_CHROMEOS)
90 void TouchpadExistsFileThread(bool* exists) {
91 *exists = chromeos::system::touchpad_settings::TouchpadExists();
92 }
93
94 void MouseExistsFileThread(bool* exists) {
95 *exists = chromeos::system::mouse_settings::MouseExists();
96 }
97 #endif // defined(OS_CHROMEOS)
98
99 } // namespace
100
82 namespace options2 { 101 namespace options2 {
83 102
84 BrowserOptionsHandler::BrowserOptionsHandler() 103 BrowserOptionsHandler::BrowserOptionsHandler()
85 : template_url_service_(NULL), 104 : template_url_service_(NULL),
86 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_for_file_(this)), 105 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_for_file_(this)),
87 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_for_ui_(this)) { 106 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_for_ui_(this)) {
88 multiprofile_ = ProfileManager::IsMultipleProfilesEnabled(); 107 multiprofile_ = ProfileManager::IsMultipleProfilesEnabled();
89 #if !defined(OS_MACOSX) 108 #if !defined(OS_MACOSX)
90 default_browser_worker_ = new ShellIntegration::DefaultBrowserWorker(this); 109 default_browser_worker_ = new ShellIntegration::DefaultBrowserWorker(this);
91 #endif 110 #endif
92 } 111 }
93 112
94 BrowserOptionsHandler::~BrowserOptionsHandler() { 113 BrowserOptionsHandler::~BrowserOptionsHandler() {
95 ProfileSyncService* sync_service = 114 ProfileSyncService* sync_service =
96 Profile::FromWebUI(web_ui())->GetProfileSyncService(); 115 Profile::FromWebUI(web_ui())->GetProfileSyncService();
97 if (sync_service) 116 if (sync_service)
98 sync_service->RemoveObserver(this); 117 sync_service->RemoveObserver(this);
99 118
100 if (default_browser_worker_.get()) 119 if (default_browser_worker_.get())
101 default_browser_worker_->ObserverDestroyed(); 120 default_browser_worker_->ObserverDestroyed();
102 if (template_url_service_) 121 if (template_url_service_)
103 template_url_service_->RemoveObserver(this); 122 template_url_service_->RemoveObserver(this);
123
124 #if defined(OS_CHROMEOS)
125 chromeos::XInputHierarchyChangedEventListener::GetInstance()
126 ->RemoveObserver(this);
127 #endif
104 } 128 }
105 129
106 void BrowserOptionsHandler::GetLocalizedValues( 130 void BrowserOptionsHandler::GetLocalizedValues(
107 DictionaryValue* localized_strings) { 131 DictionaryValue* localized_strings) {
108 DCHECK(localized_strings); 132 DCHECK(localized_strings);
109 133
110 static OptionsStringResource resources[] = { 134 static OptionsStringResource resources[] = {
111 { "appearance", IDS_APPEARANCE_GROUP_NAME }, 135 { "appearance", IDS_APPEARANCE_GROUP_NAME },
112 { "advancedGroupName", IDS_OPTIONS_ADVANCED_TAB_LABEL }, 136 { "advancedGroupName", IDS_OPTIONS_ADVANCED_TAB_LABEL },
113 { "advancedOptionsButtonTitle", IDS_OPTIONS_ADVANCED_BUTTON_TITLE }, 137 { "advancedOptionsButtonTitle", IDS_OPTIONS_ADVANCED_BUTTON_TITLE },
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 { "showWindowDecorations", IDS_SHOW_WINDOW_DECORATIONS }, 171 { "showWindowDecorations", IDS_SHOW_WINDOW_DECORATIONS },
148 { "themesGTKButton", IDS_THEMES_GTK_BUTTON }, 172 { "themesGTKButton", IDS_THEMES_GTK_BUTTON },
149 { "themesSetClassic", IDS_THEMES_SET_CLASSIC }, 173 { "themesSetClassic", IDS_THEMES_SET_CLASSIC },
150 #else 174 #else
151 { "themes", IDS_THEMES_GROUP_NAME }, 175 { "themes", IDS_THEMES_GROUP_NAME },
152 { "themesReset", IDS_THEMES_RESET_BUTTON }, 176 { "themesReset", IDS_THEMES_RESET_BUTTON },
153 #endif 177 #endif
154 #if defined(OS_CHROMEOS) 178 #if defined(OS_CHROMEOS)
155 { "changePicture", IDS_OPTIONS_CHANGE_PICTURE }, 179 { "changePicture", IDS_OPTIONS_CHANGE_PICTURE },
156 { "enableScreenlock", IDS_OPTIONS_ENABLE_SCREENLOCKER_CHECKBOX }, 180 { "enableScreenlock", IDS_OPTIONS_ENABLE_SCREENLOCKER_CHECKBOX },
181 { "deviceGroupName", IDS_OPTIONS_DEVICE_GROUP_NAME },
182 { "deviceGroupBrightness", IDS_OPTIONS_SETTINGS_BRIGHTNESS_DESCRIPTION },
183 { "brightnessDecrease", IDS_OPTIONS_SETTINGS_BRIGHTNESS_DECREASE },
184 { "brightnessIncrease", IDS_OPTIONS_SETTINGS_BRIGHTNESS_INCREASE },
185 { "deviceGroupKeyboard", IDS_OPTIONS_DEVICE_GROUP_KEYBOARD_SECTION },
186 { "keyboardSettingsButtonTitle",
187 IDS_OPTIONS_DEVICE_GROUP_KEYBOARD_SETTINGS_BUTTON_TITLE },
188 { "deviceGroupPointer", IDS_OPTIONS_DEVICE_GROUP_POINTER_SECTION },
189 { "pointerSettingsButtonTitle",
190 IDS_OPTIONS_DEVICE_GROUP_POINTER_SETTINGS_BUTTON_TITLE },
191 { "pointerSensitivityLess",
192 IDS_OPTIONS_SETTINGS_SENSITIVITY_LESS_DESCRIPTION },
193 { "pointerSensitivityMore",
194 IDS_OPTIONS_SETTINGS_SENSITIVITY_MORE_DESCRIPTION },
157 #endif 195 #endif
158 }; 196 };
159 197
160 RegisterStrings(localized_strings, resources, arraysize(resources)); 198 RegisterStrings(localized_strings, resources, arraysize(resources));
161 RegisterTitle(localized_strings, "browserPage", IDS_SETTINGS_TITLE); 199 RegisterTitle(localized_strings, "browserPage", IDS_SETTINGS_TITLE);
162 200
163 localized_strings->SetString( 201 localized_strings->SetString(
164 "syncOverview", 202 "syncOverview",
165 l10n_util::GetStringFUTF16(IDS_SYNC_OVERVIEW, 203 l10n_util::GetStringFUTF16(IDS_SYNC_OVERVIEW,
166 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); 204 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)));
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 web_ui()->RegisterMessageCallback( 280 web_ui()->RegisterMessageCallback(
243 "themesReset", 281 "themesReset",
244 base::Bind(&BrowserOptionsHandler::ThemesReset, 282 base::Bind(&BrowserOptionsHandler::ThemesReset,
245 base::Unretained(this))); 283 base::Unretained(this)));
246 #if defined(TOOLKIT_GTK) 284 #if defined(TOOLKIT_GTK)
247 web_ui()->RegisterMessageCallback( 285 web_ui()->RegisterMessageCallback(
248 "themesSetGTK", 286 "themesSetGTK",
249 base::Bind(&BrowserOptionsHandler::ThemesSetGTK, 287 base::Bind(&BrowserOptionsHandler::ThemesSetGTK,
250 base::Unretained(this))); 288 base::Unretained(this)));
251 #endif 289 #endif
290 #if defined(OS_CHROMEOS)
291 web_ui()->RegisterMessageCallback(
292 "decreaseScreenBrightness",
293 base::Bind(&BrowserOptionsHandler::DecreaseScreenBrightnessCallback,
294 base::Unretained(this)));
295 web_ui()->RegisterMessageCallback(
296 "increaseScreenBrightness",
297 base::Bind(&BrowserOptionsHandler::IncreaseScreenBrightnessCallback,
298 base::Unretained(this)));
299 #endif
252 } 300 }
253 301
254 void BrowserOptionsHandler::OnStateChanged() { 302 void BrowserOptionsHandler::OnStateChanged() {
255 string16 status_label; 303 string16 status_label;
256 string16 link_label; 304 string16 link_label;
257 ProfileSyncService* service = 305 ProfileSyncService* service =
258 Profile::FromWebUI(web_ui())->GetProfileSyncService(); 306 Profile::FromWebUI(web_ui())->GetProfileSyncService();
259 DCHECK(service); 307 DCHECK(service);
260 bool managed = service->IsManaged(); 308 bool managed = service->IsManaged();
261 bool sync_setup_completed = service->HasSyncSetupCompleted(); 309 bool sync_setup_completed = service->HasSyncSetupCompleted();
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 431
384 autocomplete_controller_.reset(new AutocompleteController(profile, this)); 432 autocomplete_controller_.reset(new AutocompleteController(profile, this));
385 433
386 #if defined(OS_WIN) 434 #if defined(OS_WIN)
387 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 435 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
388 base::Bind(&BrowserOptionsHandler::CheckAutoLaunch, 436 base::Bind(&BrowserOptionsHandler::CheckAutoLaunch,
389 weak_ptr_factory_for_ui_.GetWeakPtr(), 437 weak_ptr_factory_for_ui_.GetWeakPtr(),
390 weak_ptr_factory_for_file_.GetWeakPtr())); 438 weak_ptr_factory_for_file_.GetWeakPtr()));
391 weak_ptr_factory_for_ui_.DetachFromThread(); 439 weak_ptr_factory_for_ui_.DetachFromThread();
392 #endif 440 #endif
441
442 #if defined(OS_CHROMEOS)
443 chromeos::XInputHierarchyChangedEventListener::GetInstance()
444 ->AddObserver(this);
445 DeviceHierarchyChanged();
446 #endif
393 } 447 }
394 448
449 #if defined(OS_CHROMEOS)
450 void BrowserOptionsHandler::CheckTouchpadExists() {
451 bool* exists = new bool;
452 BrowserThread::PostTaskAndReply(BrowserThread::FILE, FROM_HERE,
453 base::Bind(&TouchpadExistsFileThread, exists),
454 base::Bind(&BrowserOptionsHandler::TouchpadExists, AsWeakPtr(), exists));
455 }
456
457 void BrowserOptionsHandler::CheckMouseExists() {
458 bool* exists = new bool;
459 BrowserThread::PostTaskAndReply(BrowserThread::FILE, FROM_HERE,
460 base::Bind(&MouseExistsFileThread, exists),
461 base::Bind(&BrowserOptionsHandler::MouseExists, AsWeakPtr(), exists));
462 }
463
464 void BrowserOptionsHandler::TouchpadExists(bool* exists) {
465 base::FundamentalValue val(*exists);
466 web_ui()->CallJavascriptFunction("BrowserOptions.showTouchpadControls", val);
467 delete exists;
468 }
469
470 void BrowserOptionsHandler::MouseExists(bool* exists) {
471 base::FundamentalValue val(*exists);
472 web_ui()->CallJavascriptFunction("BrowserOptions.showMouseControls", val);
473 delete exists;
474 }
475
476 void BrowserOptionsHandler::DeviceHierarchyChanged() {
477 CheckMouseExists();
478 CheckTouchpadExists();
479 }
480 #endif
481
395 void BrowserOptionsHandler::CheckAutoLaunch( 482 void BrowserOptionsHandler::CheckAutoLaunch(
396 base::WeakPtr<BrowserOptionsHandler> weak_this) { 483 base::WeakPtr<BrowserOptionsHandler> weak_this) {
397 #if defined(OS_WIN) 484 #if defined(OS_WIN)
398 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 485 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
399 486
400 // Pass in weak pointer to this to avoid race if BrowserOptionsHandler is 487 // Pass in weak pointer to this to avoid race if BrowserOptionsHandler is
401 // deleted. 488 // deleted.
402 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 489 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
403 base::Bind(&BrowserOptionsHandler::CheckAutoLaunchCallback, 490 base::Bind(&BrowserOptionsHandler::CheckAutoLaunchCallback,
404 weak_this, 491 weak_this,
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 #if defined(OS_CHROMEOS) 845 #if defined(OS_CHROMEOS)
759 void BrowserOptionsHandler::UpdateAccountPicture() { 846 void BrowserOptionsHandler::UpdateAccountPicture() {
760 std::string email = chromeos::UserManager::Get()->logged_in_user().email(); 847 std::string email = chromeos::UserManager::Get()->logged_in_user().email();
761 if (!email.empty()) { 848 if (!email.empty()) {
762 web_ui()->CallJavascriptFunction("BrowserOptions.updateAccountPicture"); 849 web_ui()->CallJavascriptFunction("BrowserOptions.updateAccountPicture");
763 base::StringValue email_value(email); 850 base::StringValue email_value(email);
764 web_ui()->CallJavascriptFunction("BrowserOptions.updateAccountPicture", 851 web_ui()->CallJavascriptFunction("BrowserOptions.updateAccountPicture",
765 email_value); 852 email_value);
766 } 853 }
767 } 854 }
855
856 void BrowserOptionsHandler::DecreaseScreenBrightnessCallback(
857 const ListValue* args) {
858 // Do not allow the options button to turn off the backlight, as that
859 // can make it very difficult to see the increase brightness button.
860 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
861 DecreaseScreenBrightness(false);
862 }
863
864 void BrowserOptionsHandler::IncreaseScreenBrightnessCallback(
865 const ListValue* args) {
866 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
867 IncreaseScreenBrightness();
868 }
768 #endif 869 #endif
769 870
770 } // namespace options2 871 } // namespace options2
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698