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

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

Powered by Google App Engine
This is Rietveld 408576698