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

Unified Diff: chrome/browser/ui/webui/history_login_handler.cc

Issue 2361513003: MD History: Update sign in state in data source (Closed)
Patch Set: try another approach Created 4 years, 3 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
Index: chrome/browser/ui/webui/history_login_handler.cc
diff --git a/chrome/browser/ui/webui/history_login_handler.cc b/chrome/browser/ui/webui/history_login_handler.cc
index 1e4e89d8dd03d399d5f16ce404fc957fc120fec0..50d799fdc7e45d51356492241e3a7afd9c12f642 100644
--- a/chrome/browser/ui/webui/history_login_handler.cc
+++ b/chrome/browser/ui/webui/history_login_handler.cc
@@ -15,8 +15,11 @@
#include "components/signin/core/browser/signin_metrics.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
+#include "content/public/browser/web_ui_data_source.h"
+
+HistoryLoginHandler::HistoryLoginHandler(content::WebUIDataSource* data_source)
Dan Beam 2016/09/28 03:56:49 could we just pass a base::Callback instead of a W
lshang 2016/09/29 08:06:47 Done.
+ : data_source_(data_source) {}
-HistoryLoginHandler::HistoryLoginHandler() {}
HistoryLoginHandler::~HistoryLoginHandler() {}
void HistoryLoginHandler::RegisterMessages() {
@@ -41,8 +44,11 @@ void HistoryLoginHandler::HandleOtherDevicesInitialized(
void HistoryLoginHandler::ProfileInfoChanged() {
bool signed_in = !profile_info_watcher_->GetAuthenticatedUsername().empty();
- web_ui()->CallJavascriptFunctionUnsafe("updateSignInState",
- base::FundamentalValue(signed_in));
+ data_source_->AddBoolean("isUserSignedIn", signed_in);
Dan Beam 2016/09/28 03:56:49 this also duplicates the name of this key (not so
lshang 2016/09/29 08:06:47 NaN after we re-create the data source here and th
+ AllowJavascript();
Dan Beam 2016/09/27 23:16:23 you only want to call AllowJavascript() when the p
calamity 2016/09/28 02:54:23 Hmm, the other handlers in history don't have init
+ CallJavascriptFunction("cr.webUIListenerCallback",
+ base::StringValue("sign-in-state-updated"),
+ base::FundamentalValue(signed_in));
}
void HistoryLoginHandler::HandleStartSignInFlow(

Powered by Google App Engine
This is Rietveld 408576698