Chromium Code Reviews| 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/prefs/pref_service.h" | |
|
MAD
2015/05/20 19:33:02
I don't think we need this, and neither pref_names
Dan Beam
2015/05/20 21:53:23
Done.
| |
| 10 #include "base/values.h" | |
| 11 #include "chrome/browser/profiles/profile.h" | |
| 12 #include "chrome/browser/signin/signin_manager_factory.h" | |
| 13 #include "chrome/browser/sync/profile_sync_service.h" | |
| 14 #include "chrome/browser/sync/profile_sync_service_factory.h" | |
|
MAD
2015/05/20 19:33:02
No need for signin_* and profile_sync_* either, ri
Dan Beam
2015/05/20 21:53:23
Done.
| |
| 15 #include "chrome/common/pref_names.h" | |
| 16 #include "chrome/browser/ui/webui/profile_info_watcher.h" | |
| 17 #include "content/public/browser/web_ui.h" | |
| 18 | |
| 19 HistoryLoginHandler::HistoryLoginHandler() {} | |
| 20 HistoryLoginHandler::~HistoryLoginHandler() {} | |
| 21 | |
| 22 void HistoryLoginHandler::RegisterMessages() { | |
| 23 profile_info_watcher_.reset(new ProfileInfoWatcher( | |
| 24 Profile::FromWebUI(web_ui()), | |
| 25 base::Bind(&HistoryLoginHandler::ProfileInfoChanged, | |
| 26 base::Unretained(this)))); | |
| 27 | |
| 28 web_ui()->RegisterMessageCallback("otherDevicesInitialized", | |
| 29 base::Bind(&HistoryLoginHandler::HandleOtherDevicesInitialized, | |
| 30 base::Unretained(this))); | |
| 31 } | |
| 32 | |
| 33 void HistoryLoginHandler::HandleOtherDevicesInitialized( | |
| 34 const base::ListValue* /*args*/) { | |
| 35 ProfileInfoChanged(); | |
| 36 } | |
| 37 | |
| 38 void HistoryLoginHandler::ProfileInfoChanged() { | |
| 39 bool signed_in = !profile_info_watcher_->GetAuthenticatedUsername().empty(); | |
| 40 web_ui()->CallJavascriptFunction( | |
| 41 "updateSignInState", base::FundamentalValue(signed_in)); | |
| 42 } | |
| OLD | NEW |