Chromium Code Reviews| 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 |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a98f590c81e3b179124115df962a6add51914cca |
| --- /dev/null |
| +++ b/chrome/browser/ui/webui/history_login_handler.cc |
| @@ -0,0 +1,42 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/ui/webui/history_login_handler.h" |
| + |
| +#include "base/bind.h" |
| +#include "base/bind_helpers.h" |
| +#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.
|
| +#include "base/values.h" |
| +#include "chrome/browser/profiles/profile.h" |
| +#include "chrome/browser/signin/signin_manager_factory.h" |
| +#include "chrome/browser/sync/profile_sync_service.h" |
| +#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.
|
| +#include "chrome/common/pref_names.h" |
| +#include "chrome/browser/ui/webui/profile_info_watcher.h" |
| +#include "content/public/browser/web_ui.h" |
| + |
| +HistoryLoginHandler::HistoryLoginHandler() {} |
| +HistoryLoginHandler::~HistoryLoginHandler() {} |
| + |
| +void HistoryLoginHandler::RegisterMessages() { |
| + profile_info_watcher_.reset(new ProfileInfoWatcher( |
| + Profile::FromWebUI(web_ui()), |
| + base::Bind(&HistoryLoginHandler::ProfileInfoChanged, |
| + base::Unretained(this)))); |
| + |
| + web_ui()->RegisterMessageCallback("otherDevicesInitialized", |
| + base::Bind(&HistoryLoginHandler::HandleOtherDevicesInitialized, |
| + base::Unretained(this))); |
| +} |
| + |
| +void HistoryLoginHandler::HandleOtherDevicesInitialized( |
| + const base::ListValue* /*args*/) { |
| + ProfileInfoChanged(); |
| +} |
| + |
| +void HistoryLoginHandler::ProfileInfoChanged() { |
| + bool signed_in = !profile_info_watcher_->GetAuthenticatedUsername().empty(); |
| + web_ui()->CallJavascriptFunction( |
| + "updateSignInState", base::FundamentalValue(signed_in)); |
| +} |