OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/ui/webui/history_login_handler.h" |
| 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" |
| 9 #include "base/values.h" |
| 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/ui/webui/profile_info_watcher.h" |
| 12 #include "content/public/browser/web_ui.h" |
| 13 |
| 14 HistoryLoginHandler::HistoryLoginHandler() {} |
| 15 HistoryLoginHandler::~HistoryLoginHandler() {} |
| 16 |
| 17 void HistoryLoginHandler::RegisterMessages() { |
| 18 profile_info_watcher_.reset(new ProfileInfoWatcher( |
| 19 Profile::FromWebUI(web_ui()), |
| 20 base::Bind(&HistoryLoginHandler::ProfileInfoChanged, |
| 21 base::Unretained(this)))); |
| 22 |
| 23 web_ui()->RegisterMessageCallback("otherDevicesInitialized", |
| 24 base::Bind(&HistoryLoginHandler::HandleOtherDevicesInitialized, |
| 25 base::Unretained(this))); |
| 26 } |
| 27 |
| 28 void HistoryLoginHandler::HandleOtherDevicesInitialized( |
| 29 const base::ListValue* /*args*/) { |
| 30 ProfileInfoChanged(); |
| 31 } |
| 32 |
| 33 void HistoryLoginHandler::ProfileInfoChanged() { |
| 34 bool signed_in = !profile_info_watcher_->GetAuthenticatedUsername().empty(); |
| 35 web_ui()->CallJavascriptFunction( |
| 36 "updateSignInState", base::FundamentalValue(signed_in)); |
| 37 } |
OLD | NEW |