Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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/history_login_handler.h" | 5 #include "chrome/browser/ui/webui/history_login_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/ui/webui/profile_info_watcher.h" | 11 #include "chrome/browser/ui/webui/profile_info_watcher.h" |
| 12 #include "content/public/browser/web_ui.h" | 12 #include "content/public/browser/web_ui.h" |
| 13 | 13 |
| 14 HistoryLoginHandler::HistoryLoginHandler() {} | 14 HistoryLoginHandler::HistoryLoginHandler() {} |
| 15 HistoryLoginHandler::~HistoryLoginHandler() {} | 15 HistoryLoginHandler::~HistoryLoginHandler() {} |
| 16 | 16 |
| 17 void HistoryLoginHandler::RegisterMessages() { | 17 void HistoryLoginHandler::RegisterMessages() { |
| 18 profile_info_watcher_.reset(new ProfileInfoWatcher( | 18 profile_info_watcher_.reset(new ProfileInfoWatcher( |
| 19 Profile::FromWebUI(web_ui()), | 19 Profile::FromWebUI(web_ui()), |
| 20 base::Bind(&HistoryLoginHandler::ProfileInfoChanged, | 20 base::Bind(&HistoryLoginHandler::ProfileInfoChanged, |
| 21 base::Unretained(this)))); | 21 base::Unretained(this)))); |
| 22 | 22 |
| 23 web_ui()->RegisterMessageCallback("otherDevicesInitialized", | 23 web_ui()->RegisterMessageCallback("otherDevicesInitialized", |
| 24 base::Bind(&HistoryLoginHandler::HandleOtherDevicesInitialized, | 24 base::Bind(&HistoryLoginHandler::HandleOtherDevicesInitialized, |
| 25 base::Unretained(this))); | 25 base::Unretained(this))); |
|
calamity
2016/07/29 05:14:59
Can we just reuse this message? It seems to be exa
lshang
2016/07/29 06:11:58
Done.
I thought it would be a little confusing to
| |
| 26 web_ui()->RegisterMessageCallback("getSignInState", | |
| 27 base::Bind(&HistoryLoginHandler::HandleGetSignInState, | |
| 28 base::Unretained(this))); | |
| 26 } | 29 } |
| 27 | 30 |
| 28 void HistoryLoginHandler::HandleOtherDevicesInitialized( | 31 void HistoryLoginHandler::HandleOtherDevicesInitialized( |
| 29 const base::ListValue* /*args*/) { | 32 const base::ListValue* /*args*/) { |
| 30 ProfileInfoChanged(); | 33 ProfileInfoChanged(); |
| 31 } | 34 } |
| 32 | 35 |
| 36 void HistoryLoginHandler::HandleGetSignInState( | |
| 37 const base::ListValue* /*args*/) { | |
| 38 ProfileInfoChanged(); | |
| 39 } | |
| 40 | |
| 33 void HistoryLoginHandler::ProfileInfoChanged() { | 41 void HistoryLoginHandler::ProfileInfoChanged() { |
| 34 bool signed_in = !profile_info_watcher_->GetAuthenticatedUsername().empty(); | 42 bool signed_in = !profile_info_watcher_->GetAuthenticatedUsername().empty(); |
| 35 web_ui()->CallJavascriptFunctionUnsafe("updateSignInState", | 43 web_ui()->CallJavascriptFunctionUnsafe("updateSignInState", |
| 36 base::FundamentalValue(signed_in)); | 44 base::FundamentalValue(signed_in)); |
| 37 } | 45 } |
| OLD | NEW |