Chromium Code Reviews| 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/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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 cloud_print_connector_ui_enabled_ = true; | 136 cloud_print_connector_ui_enabled_ = true; |
| 137 #endif | 137 #endif |
| 138 } | 138 } |
| 139 | 139 |
| 140 BrowserOptionsHandler::~BrowserOptionsHandler() { | 140 BrowserOptionsHandler::~BrowserOptionsHandler() { |
| 141 ProfileSyncService* sync_service(ProfileSyncServiceFactory:: | 141 ProfileSyncService* sync_service(ProfileSyncServiceFactory:: |
| 142 GetInstance()->GetForProfile(Profile::FromWebUI(web_ui()))); | 142 GetInstance()->GetForProfile(Profile::FromWebUI(web_ui()))); |
| 143 if (sync_service) | 143 if (sync_service) |
| 144 sync_service->RemoveObserver(this); | 144 sync_service->RemoveObserver(this); |
| 145 | 145 |
| 146 SigninManager* signin = | |
| 147 SigninManagerFactory::GetInstance()->GetForProfile( | |
| 148 Profile::FromWebUI(web_ui())); | |
| 149 if (signin) | |
| 150 signin->RemoveSigninPrefObserver(this); | |
| 151 | |
| 146 if (default_browser_worker_.get()) | 152 if (default_browser_worker_.get()) |
| 147 default_browser_worker_->ObserverDestroyed(); | 153 default_browser_worker_->ObserverDestroyed(); |
| 148 if (template_url_service_) | 154 if (template_url_service_) |
| 149 template_url_service_->RemoveObserver(this); | 155 template_url_service_->RemoveObserver(this); |
| 150 // There may be pending file dialogs, we need to tell them that we've gone | 156 // There may be pending file dialogs, we need to tell them that we've gone |
| 151 // away so they don't try and call back to us. | 157 // away so they don't try and call back to us. |
| 152 if (select_folder_dialog_.get()) | 158 if (select_folder_dialog_.get()) |
| 153 select_folder_dialog_->ListenerDestroyed(); | 159 select_folder_dialog_->ListenerDestroyed(); |
| 154 } | 160 } |
| 155 | 161 |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 569 #endif | 575 #endif |
| 570 } | 576 } |
| 571 | 577 |
| 572 void BrowserOptionsHandler::OnStateChanged() { | 578 void BrowserOptionsHandler::OnStateChanged() { |
| 573 web_ui()->CallJavascriptFunction("BrowserOptions.updateSyncState", | 579 web_ui()->CallJavascriptFunction("BrowserOptions.updateSyncState", |
| 574 *GetSyncStateDictionary()); | 580 *GetSyncStateDictionary()); |
| 575 | 581 |
| 576 SendProfilesInfo(); | 582 SendProfilesInfo(); |
| 577 } | 583 } |
| 578 | 584 |
| 585 void BrowserOptionsHandler::OnSigninAllowedPrefChange(bool signin_allowed) { | |
| 586 web_ui()->CallJavascriptFunction("BrowserOptions.updateSyncState", | |
| 587 *GetSyncStateDictionary()); | |
| 588 | |
| 589 SendProfilesInfo(); | |
| 590 } | |
| 591 | |
| 579 void BrowserOptionsHandler::PageLoadStarted() { | 592 void BrowserOptionsHandler::PageLoadStarted() { |
| 580 page_initialized_ = false; | 593 page_initialized_ = false; |
| 581 } | 594 } |
| 582 | 595 |
| 583 void BrowserOptionsHandler::InitializeHandler() { | 596 void BrowserOptionsHandler::InitializeHandler() { |
| 584 Profile* profile = Profile::FromWebUI(web_ui()); | 597 Profile* profile = Profile::FromWebUI(web_ui()); |
| 585 PrefService* prefs = profile->GetPrefs(); | 598 PrefService* prefs = profile->GetPrefs(); |
| 586 | 599 |
| 587 ProfileSyncService* sync_service( | 600 ProfileSyncService* sync_service( |
| 588 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile)); | 601 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile)); |
| 589 if (sync_service) | 602 if (sync_service) |
| 590 sync_service->AddObserver(this); | 603 sync_service->AddObserver(this); |
| 591 | 604 |
| 605 SigninManager* signin = | |
| 606 SigninManagerFactory::GetInstance()->GetForProfile(profile); | |
| 607 if (signin) | |
| 608 signin->AddSigninPrefObserver(this); | |
| 609 | |
| 592 // Create our favicon data source. | 610 // Create our favicon data source. |
| 593 content::URLDataSource::Add( | 611 content::URLDataSource::Add( |
| 594 profile, new FaviconSource(profile, FaviconSource::FAVICON)); | 612 profile, new FaviconSource(profile, FaviconSource::FAVICON)); |
| 595 | 613 |
| 596 default_browser_policy_.Init( | 614 default_browser_policy_.Init( |
| 597 prefs::kDefaultBrowserSettingEnabled, | 615 prefs::kDefaultBrowserSettingEnabled, |
| 598 g_browser_process->local_state(), | 616 g_browser_process->local_state(), |
| 599 base::Bind(&BrowserOptionsHandler::UpdateDefaultBrowserState, | 617 base::Bind(&BrowserOptionsHandler::UpdateDefaultBrowserState, |
| 600 base::Unretained(this))); | 618 base::Unretained(this))); |
| 601 | 619 |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1050 web_ui()->CallJavascriptFunction("BrowserOptions.updateAccountPicture", | 1068 web_ui()->CallJavascriptFunction("BrowserOptions.updateAccountPicture", |
| 1051 email_value); | 1069 email_value); |
| 1052 } | 1070 } |
| 1053 } | 1071 } |
| 1054 #endif | 1072 #endif |
| 1055 | 1073 |
| 1056 scoped_ptr<DictionaryValue> BrowserOptionsHandler::GetSyncStateDictionary() { | 1074 scoped_ptr<DictionaryValue> BrowserOptionsHandler::GetSyncStateDictionary() { |
| 1057 scoped_ptr<DictionaryValue> sync_status(new DictionaryValue); | 1075 scoped_ptr<DictionaryValue> sync_status(new DictionaryValue); |
| 1058 ProfileSyncService* service(ProfileSyncServiceFactory:: | 1076 ProfileSyncService* service(ProfileSyncServiceFactory:: |
| 1059 GetInstance()->GetForProfile(Profile::FromWebUI(web_ui()))); | 1077 GetInstance()->GetForProfile(Profile::FromWebUI(web_ui()))); |
| 1060 sync_status->SetBoolean("syncSystemEnabled", !!service); | 1078 SigninManager* signin = SigninManagerFactory::GetForProfile( |
| 1079 Profile::FromWebUI(web_ui())); | |
| 1080 sync_status->SetBoolean("syncSystemEnabled", | |
| 1081 !!service && (!signin || signin->IsSigninAllowed())); | |
|
Andrew T Wilson (Slow)
2013/02/04 15:41:48
I don't think that signin can be null here so no n
Andrew T Wilson (Slow)
2013/02/05 08:58:53
Also, I'm changing the JS code to not hide the sig
Adrian Kuegel
2013/02/05 10:55:15
Done.
| |
| 1061 if (!service) | 1082 if (!service) |
| 1062 return sync_status.Pass(); | 1083 return sync_status.Pass(); |
| 1063 | 1084 |
| 1064 sync_status->SetBoolean("setupCompleted", | 1085 sync_status->SetBoolean("setupCompleted", |
| 1065 service->HasSyncSetupCompleted()); | 1086 service->HasSyncSetupCompleted()); |
| 1066 sync_status->SetBoolean("setupInProgress", service->FirstSetupInProgress()); | 1087 sync_status->SetBoolean("setupInProgress", service->FirstSetupInProgress()); |
| 1067 | 1088 |
| 1068 string16 status_label; | 1089 string16 status_label; |
| 1069 string16 link_label; | 1090 string16 link_label; |
| 1070 SigninManager* signin = SigninManagerFactory::GetForProfile( | |
| 1071 Profile::FromWebUI(web_ui())); | |
| 1072 | 1091 |
| 1073 bool status_has_error = sync_ui_util::GetStatusLabels( | 1092 bool status_has_error = sync_ui_util::GetStatusLabels( |
| 1074 service, *signin, sync_ui_util::WITH_HTML, &status_label, &link_label) == | 1093 service, *signin, sync_ui_util::WITH_HTML, &status_label, &link_label) == |
| 1075 sync_ui_util::SYNC_ERROR; | 1094 sync_ui_util::SYNC_ERROR; |
| 1076 sync_status->SetString("statusText", status_label); | 1095 sync_status->SetString("statusText", status_label); |
| 1077 sync_status->SetString("actionLinkText", link_label); | 1096 sync_status->SetString("actionLinkText", link_label); |
| 1078 sync_status->SetBoolean("hasError", status_has_error); | 1097 sync_status->SetBoolean("hasError", status_has_error); |
| 1079 | 1098 |
| 1080 sync_status->SetBoolean("managed", service->IsManaged()); | 1099 sync_status->SetBoolean("managed", service->IsManaged()); |
| 1081 sync_status->SetBoolean("signedIn", | 1100 sync_status->SetBoolean("signedIn", |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1414 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); | 1433 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); |
| 1415 } | 1434 } |
| 1416 StringValue label(label_str); | 1435 StringValue label(label_str); |
| 1417 | 1436 |
| 1418 web_ui()->CallJavascriptFunction( | 1437 web_ui()->CallJavascriptFunction( |
| 1419 "BrowserOptions.setupProxySettingsSection", disabled, label); | 1438 "BrowserOptions.setupProxySettingsSection", disabled, label); |
| 1420 #endif // !defined(OS_CHROMEOS) | 1439 #endif // !defined(OS_CHROMEOS) |
| 1421 } | 1440 } |
| 1422 | 1441 |
| 1423 } // namespace options | 1442 } // namespace options |
| OLD | NEW |