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

Unified Diff: chrome/browser/ui/webui/options/autofill_options_handler.cc

Issue 1014913003: Hide Wallet checkbox when user signs out of sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: handle null service Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/options/autofill_options_handler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/options/autofill_options_handler.cc
diff --git a/chrome/browser/ui/webui/options/autofill_options_handler.cc b/chrome/browser/ui/webui/options/autofill_options_handler.cc
index 681ccdf4026fa09a87e4096de7bb75e3b067cd4b..0b38cdd77b83b0a329c684556b9bcf455ca844fb 100644
--- a/chrome/browser/ui/webui/options/autofill_options_handler.cc
+++ b/chrome/browser/ui/webui/options/autofill_options_handler.cc
@@ -19,7 +19,6 @@
#include "chrome/browser/autofill/personal_data_manager_factory.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/ui/autofill/country_combobox_model.h"
#include "chrome/common/url_constants.h"
@@ -316,7 +315,8 @@ scoped_ptr<base::ListValue> ValidatePhoneArguments(
namespace options {
AutofillOptionsHandler::AutofillOptionsHandler()
- : personal_data_(NULL) {}
+ : personal_data_(NULL), observer_(this) {
+}
AutofillOptionsHandler::~AutofillOptionsHandler() {
if (personal_data_)
@@ -361,19 +361,24 @@ void AutofillOptionsHandler::GetLocalizedValues(
SetAddressOverlayStrings(localized_strings);
SetCreditCardOverlayStrings(localized_strings);
- ProfileSyncService* service =
- ProfileSyncServiceFactory::GetInstance()->GetForProfile(
- Profile::FromWebUI(web_ui()));
- localized_strings->SetBoolean(
- "enableAutofillWalletIntegration",
- service && service->IsSyncEnabledAndLoggedIn() &&
- personal_data_->IsExperimentalWalletIntegrationEnabled());
localized_strings->SetString(
"manageWalletAddressesUrl",
autofill::wallet::GetManageAddressesUrl(0).spec());
localized_strings->SetString(
"manageWalletPaymentMethodsUrl",
autofill::wallet::GetManageInstrumentsUrl(0).spec());
+
+ // This is set in loadTimeData to minimize the chance of a load-time flash of
+ // content.
+ ProfileSyncService* service =
+ ProfileSyncServiceFactory::GetInstance()->GetForProfile(
+ Profile::FromWebUI(web_ui()));
+ if (service)
+ observer_.Add(service);
+ localized_strings->SetBoolean(
+ "autofillWalletIntegrationAvailable",
+ service && service->IsSyncEnabledAndLoggedIn() &&
+ personal_data_->IsExperimentalWalletIntegrationEnabled());
}
void AutofillOptionsHandler::InitializeHandler() {
@@ -385,6 +390,10 @@ void AutofillOptionsHandler::InitializeHandler() {
void AutofillOptionsHandler::InitializePage() {
if (personal_data_)
LoadAutofillData();
+
+ // Also update the visibility of the Wallet checkbox (which may have
+ // changed since the localized string dictionary was built).
+ OnStateChanged();
}
void AutofillOptionsHandler::RegisterMessages() {
@@ -433,6 +442,15 @@ void AutofillOptionsHandler::OnPersonalDataChanged() {
LoadAutofillData();
}
+void AutofillOptionsHandler::OnStateChanged() {
+ ProfileSyncService* service =
+ ProfileSyncServiceFactory::GetInstance()->GetForProfile(
+ Profile::FromWebUI(web_ui()));
+ web_ui()->CallJavascriptFunction(
+ "AutofillOptions.walletIntegrationAvailableStateChanged",
+ base::FundamentalValue(service && service->IsSyncEnabledAndLoggedIn()));
+}
+
void AutofillOptionsHandler::SetAddressOverlayStrings(
base::DictionaryValue* localized_strings) {
localized_strings->SetString("autofillEditAddressTitle",
« no previous file with comments | « chrome/browser/ui/webui/options/autofill_options_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698