| 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" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #include "chrome/browser/prefs/pref_service.h" | 28 #include "chrome/browser/prefs/pref_service.h" |
| 29 #include "chrome/browser/prefs/session_startup_pref.h" | 29 #include "chrome/browser/prefs/session_startup_pref.h" |
| 30 #include "chrome/browser/profiles/profile.h" | 30 #include "chrome/browser/profiles/profile.h" |
| 31 #include "chrome/browser/profiles/profile_info_cache.h" | 31 #include "chrome/browser/profiles/profile_info_cache.h" |
| 32 #include "chrome/browser/profiles/profile_info_util.h" | 32 #include "chrome/browser/profiles/profile_info_util.h" |
| 33 #include "chrome/browser/profiles/profile_manager.h" | 33 #include "chrome/browser/profiles/profile_manager.h" |
| 34 #include "chrome/browser/search_engines/template_url.h" | 34 #include "chrome/browser/search_engines/template_url.h" |
| 35 #include "chrome/browser/search_engines/template_url_service.h" | 35 #include "chrome/browser/search_engines/template_url_service.h" |
| 36 #include "chrome/browser/search_engines/template_url_service_factory.h" | 36 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 37 #include "chrome/browser/sync/profile_sync_service.h" | 37 #include "chrome/browser/sync/profile_sync_service.h" |
| 38 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 38 #include "chrome/browser/sync/sync_setup_flow.h" | 39 #include "chrome/browser/sync/sync_setup_flow.h" |
| 39 #include "chrome/browser/sync/sync_ui_util.h" | 40 #include "chrome/browser/sync/sync_ui_util.h" |
| 40 #include "chrome/browser/themes/theme_service.h" | 41 #include "chrome/browser/themes/theme_service.h" |
| 41 #include "chrome/browser/themes/theme_service_factory.h" | 42 #include "chrome/browser/themes/theme_service_factory.h" |
| 42 #include "chrome/browser/ui/webui/favicon_source.h" | 43 #include "chrome/browser/ui/webui/favicon_source.h" |
| 43 #include "chrome/browser/ui/webui/web_ui_util.h" | 44 #include "chrome/browser/ui/webui/web_ui_util.h" |
| 44 #include "chrome/common/chrome_notification_types.h" | 45 #include "chrome/common/chrome_notification_types.h" |
| 45 #include "chrome/common/chrome_paths.h" | 46 #include "chrome/common/chrome_paths.h" |
| 46 #include "chrome/common/chrome_switches.h" | 47 #include "chrome/common/chrome_switches.h" |
| 47 #include "chrome/common/net/gaia/google_service_auth_error.h" | 48 #include "chrome/common/net/gaia/google_service_auth_error.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 : template_url_service_(NULL), | 89 : template_url_service_(NULL), |
| 89 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_for_file_(this)), | 90 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_for_file_(this)), |
| 90 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_for_ui_(this)) { | 91 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_for_ui_(this)) { |
| 91 multiprofile_ = ProfileManager::IsMultipleProfilesEnabled(); | 92 multiprofile_ = ProfileManager::IsMultipleProfilesEnabled(); |
| 92 #if !defined(OS_MACOSX) | 93 #if !defined(OS_MACOSX) |
| 93 default_browser_worker_ = new ShellIntegration::DefaultBrowserWorker(this); | 94 default_browser_worker_ = new ShellIntegration::DefaultBrowserWorker(this); |
| 94 #endif | 95 #endif |
| 95 } | 96 } |
| 96 | 97 |
| 97 BrowserOptionsHandler::~BrowserOptionsHandler() { | 98 BrowserOptionsHandler::~BrowserOptionsHandler() { |
| 98 ProfileSyncService* sync_service = | 99 ProfileSyncService* sync_service(ProfileSyncServiceFactory:: |
| 99 Profile::FromWebUI(web_ui())->GetProfileSyncService(); | 100 GetInstance()->GetForProfile(Profile::FromWebUI(web_ui()))); |
| 100 if (sync_service) | 101 if (sync_service) |
| 101 sync_service->RemoveObserver(this); | 102 sync_service->RemoveObserver(this); |
| 102 | 103 |
| 103 if (default_browser_worker_.get()) | 104 if (default_browser_worker_.get()) |
| 104 default_browser_worker_->ObserverDestroyed(); | 105 default_browser_worker_->ObserverDestroyed(); |
| 105 if (template_url_service_) | 106 if (template_url_service_) |
| 106 template_url_service_->RemoveObserver(this); | 107 template_url_service_->RemoveObserver(this); |
| 107 } | 108 } |
| 108 | 109 |
| 109 void BrowserOptionsHandler::GetLocalizedValues( | 110 void BrowserOptionsHandler::GetLocalizedValues( |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 web_ui()->RegisterMessageCallback( | 274 web_ui()->RegisterMessageCallback( |
| 274 "increaseScreenBrightness", | 275 "increaseScreenBrightness", |
| 275 base::Bind(&BrowserOptionsHandler::IncreaseScreenBrightnessCallback, | 276 base::Bind(&BrowserOptionsHandler::IncreaseScreenBrightnessCallback, |
| 276 base::Unretained(this))); | 277 base::Unretained(this))); |
| 277 #endif | 278 #endif |
| 278 } | 279 } |
| 279 | 280 |
| 280 void BrowserOptionsHandler::OnStateChanged() { | 281 void BrowserOptionsHandler::OnStateChanged() { |
| 281 string16 status_label; | 282 string16 status_label; |
| 282 string16 link_label; | 283 string16 link_label; |
| 283 ProfileSyncService* service = | 284 ProfileSyncService* service(ProfileSyncServiceFactory:: |
| 284 Profile::FromWebUI(web_ui())->GetProfileSyncService(); | 285 GetInstance()->GetForProfile(Profile::FromWebUI(web_ui()))); |
| 285 DCHECK(service); | 286 DCHECK(service); |
| 286 bool managed = service->IsManaged(); | 287 bool managed = service->IsManaged(); |
| 287 bool sync_setup_completed = service->HasSyncSetupCompleted(); | 288 bool sync_setup_completed = service->HasSyncSetupCompleted(); |
| 288 bool status_has_error = sync_ui_util::GetStatusLabels( | 289 bool status_has_error = sync_ui_util::GetStatusLabels( |
| 289 service, sync_ui_util::WITH_HTML, &status_label, &link_label) == | 290 service, sync_ui_util::WITH_HTML, &status_label, &link_label) == |
| 290 sync_ui_util::SYNC_ERROR; | 291 sync_ui_util::SYNC_ERROR; |
| 291 | 292 |
| 292 string16 start_stop_button_label; | 293 string16 start_stop_button_label; |
| 293 bool is_start_stop_button_visible = false; | 294 bool is_start_stop_button_visible = false; |
| 294 bool is_start_stop_button_enabled = false; | 295 bool is_start_stop_button_enabled = false; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 visible.reset(Value::CreateBooleanValue(multiprofile_)); | 365 visible.reset(Value::CreateBooleanValue(multiprofile_)); |
| 365 web_ui()->CallJavascriptFunction("BrowserOptions.setProfilesSectionVisible", | 366 web_ui()->CallJavascriptFunction("BrowserOptions.setProfilesSectionVisible", |
| 366 *visible); | 367 *visible); |
| 367 if (multiprofile_) | 368 if (multiprofile_) |
| 368 SendProfilesInfo(); | 369 SendProfilesInfo(); |
| 369 } | 370 } |
| 370 | 371 |
| 371 void BrowserOptionsHandler::Initialize() { | 372 void BrowserOptionsHandler::Initialize() { |
| 372 Profile* profile = Profile::FromWebUI(web_ui()); | 373 Profile* profile = Profile::FromWebUI(web_ui()); |
| 373 | 374 |
| 374 ProfileSyncService* sync_service = profile->GetProfileSyncService(); | 375 ProfileSyncService* sync_service(ProfileSyncServiceFactory:: |
| 376 GetInstance()->GetForProfile(Profile::FromWebUI(web_ui()))); |
| 375 if (sync_service) { | 377 if (sync_service) { |
| 376 sync_service->AddObserver(this); | 378 sync_service->AddObserver(this); |
| 377 OnStateChanged(); | 379 OnStateChanged(); |
| 378 } else { | 380 } else { |
| 379 web_ui()->CallJavascriptFunction("options.BrowserOptions.hideSyncSection"); | 381 web_ui()->CallJavascriptFunction("options.BrowserOptions.hideSyncSection"); |
| 380 } | 382 } |
| 381 | 383 |
| 382 // Create our favicon data source. | 384 // Create our favicon data source. |
| 383 profile->GetChromeURLDataManager()->AddDataSource( | 385 profile->GetChromeURLDataManager()->AddDataSource( |
| 384 new FaviconSource(profile, FaviconSource::FAVICON)); | 386 new FaviconSource(profile, FaviconSource::FAVICON)); |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 801 } | 803 } |
| 802 | 804 |
| 803 void BrowserOptionsHandler::IncreaseScreenBrightnessCallback( | 805 void BrowserOptionsHandler::IncreaseScreenBrightnessCallback( |
| 804 const ListValue* args) { | 806 const ListValue* args) { |
| 805 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> | 807 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> |
| 806 IncreaseScreenBrightness(); | 808 IncreaseScreenBrightness(); |
| 807 } | 809 } |
| 808 #endif | 810 #endif |
| 809 | 811 |
| 810 } // namespace options2 | 812 } // namespace options2 |
| OLD | NEW |