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

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

Issue 2361513003: MD History: Update sign in state in data source (Closed)
Patch Set: move 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
« no previous file with comments | « chrome/browser/ui/webui/history_login_handler.h ('k') | chrome/browser/ui/webui/history_ui.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..2d647084f82178c2575f4434be9b0ea0f591c35f 100644
--- a/chrome/browser/ui/webui/history_login_handler.cc
+++ b/chrome/browser/ui/webui/history_login_handler.cc
@@ -6,6 +6,7 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
+#include "base/callback.h"
#include "base/values.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
@@ -16,7 +17,9 @@
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
-HistoryLoginHandler::HistoryLoginHandler() {}
+HistoryLoginHandler::HistoryLoginHandler(const base::Closure& signin_callback)
+ : signin_callback_(signin_callback) {}
+
HistoryLoginHandler::~HistoryLoginHandler() {}
void HistoryLoginHandler::RegisterMessages() {
@@ -36,13 +39,20 @@ void HistoryLoginHandler::RegisterMessages() {
void HistoryLoginHandler::HandleOtherDevicesInitialized(
const base::ListValue* /*args*/) {
+ AllowJavascript();
ProfileInfoChanged();
}
void HistoryLoginHandler::ProfileInfoChanged() {
bool signed_in = !profile_info_watcher_->GetAuthenticatedUsername().empty();
- web_ui()->CallJavascriptFunctionUnsafe("updateSignInState",
- base::FundamentalValue(signed_in));
+ if (!signin_callback_.is_null())
+ signin_callback_.Run();
+
+ if (IsJavascriptAllowed()) {
+ CallJavascriptFunction("cr.webUIListenerCallback",
+ base::StringValue("sign-in-state-updated"),
+ base::FundamentalValue(signed_in));
+ }
}
void HistoryLoginHandler::HandleStartSignInFlow(
« no previous file with comments | « chrome/browser/ui/webui/history_login_handler.h ('k') | chrome/browser/ui/webui/history_ui.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698