Commit 309b54c3 authored by Kushagra Sinha's avatar Kushagra Sinha Committed by Commit Bot

Lacros: Add AccountManagerFacade

Add a bare bones AccountManagerFacade interface definition and 2 stub
implementations - AccountManagerFacadeAsh and
AccountManagerFacadeLacros.
Additionally, add a factory function - GetAccountManagerFacade, to
return the correct implementation.

Bug: 1117472
Change-Id: Ied4b50e08ecee78f72412b64c86341fb097bdc0c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2424229Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Commit-Queue: Kush Sinha <sinhak@chromium.org>
Cr-Commit-Position: refs/heads/master@{#813759}
parent 2b9f5809
......@@ -109,6 +109,7 @@ static_library("browser") {
"accessibility/accessibility_ui.h",
"accessibility/caption_util.cc",
"accessibility/caption_util.h",
"account_manager_facade_factory.h",
"after_startup_task_utils.cc",
"after_startup_task_utils.h",
"app_mode/app_mode_utils.cc",
......@@ -4377,6 +4378,9 @@ static_library("browser") {
sources += [
"feedback/show_feedback_page_lacros.cc",
"first_run/first_run_internal_lacros.cc",
"lacros/account_manager_facade_factory_lacros.cc",
"lacros/account_manager_facade_lacros.cc",
"lacros/account_manager_facade_lacros.h",
"lacros/lacros_chrome_service_delegate_impl.cc",
"lacros/lacros_chrome_service_delegate_impl.h",
"metrics/lacros_metrics_provider.cc",
......
// Copyright 2020 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.
#ifndef CHROME_BROWSER_ACCOUNT_MANAGER_FACADE_FACTORY_H_
#define CHROME_BROWSER_ACCOUNT_MANAGER_FACADE_FACTORY_H_
#include <string>
class AccountManagerFacade;
// A factory function for getting platform specific implementations of
// |AccountManagerFacade|.
// Returns the |AccountManagerFacade| for the given |profile_path|.
// Note that |AccountManagerFacade| is independent of a |Profile|, and this is
// needed only because of Multi-Login on Chrome OS, and will be removed soon.
AccountManagerFacade* GetAccountManagerFacade(const std::string& profile_path);
#endif // CHROME_BROWSER_ACCOUNT_MANAGER_FACADE_FACTORY_H_
......@@ -416,6 +416,7 @@ source_set("chromeos") {
"accessibility/magnifier_type.h",
"accessibility/select_to_speak_event_handler_delegate.cc",
"accessibility/select_to_speak_event_handler_delegate.h",
"account_manager/account_manager_facade_factory_ash.cc",
"account_manager/account_manager_migrator.cc",
"account_manager/account_manager_migrator.h",
"account_manager/account_manager_policy_controller.cc",
......
// Copyright 2020 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/account_manager_facade_factory.h"
#include <map>
#include <memory>
#include <utility>
#include "base/no_destructor.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_platform_part_chromeos.h"
#include "chromeos/components/account_manager/account_manager.h"
#include "chromeos/components/account_manager/account_manager_facade_ash.h"
#include "chromeos/components/account_manager/account_manager_factory.h"
namespace {
// TODO(sinhak): Move ownership of AccountManager and remove this method.
chromeos::AccountManager* GetAccountManager(const std::string& profile_path) {
chromeos::AccountManager* account_manager =
g_browser_process->platform_part()
->GetAccountManagerFactory()
->GetAccountManager(profile_path);
DCHECK(account_manager);
return account_manager;
}
} // namespace
AccountManagerFacade* GetAccountManagerFacade(const std::string& profile_path) {
// Map from |profile_path| to AccountManagerFacade.
static base::NoDestructor<
std::map<std::string, std::unique_ptr<chromeos::AccountManagerFacadeAsh>>>
account_manager_facade_map;
auto it = account_manager_facade_map->find(profile_path);
if (it == account_manager_facade_map->end()) {
it = account_manager_facade_map
->emplace(profile_path,
std::make_unique<chromeos::AccountManagerFacadeAsh>(
GetAccountManager(profile_path)))
.first;
}
return it->second.get();
}
// Copyright 2020 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/account_manager_facade_factory.h"
#include "base/no_destructor.h"
#include "chrome/browser/lacros/account_manager_facade_lacros.h"
#include "chromeos/components/account_manager/account_manager_facade.h"
AccountManagerFacade* GetAccountManagerFacade(const std::string& profile_path) {
// Multi-Login is disabled with Lacros. Always return the same instance.
static base::NoDestructor<AccountManagerFacadeLacros> facade;
return facade.get();
}
// Copyright 2020 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/lacros/account_manager_facade_lacros.h"
AccountManagerFacadeLacros::AccountManagerFacadeLacros() = default;
AccountManagerFacadeLacros::~AccountManagerFacadeLacros() = default;
bool AccountManagerFacadeLacros::IsInitialized() {
// TODO(sinhak): Implement stub.
return false;
}
// Copyright 2020 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.
#ifndef CHROME_BROWSER_LACROS_ACCOUNT_MANAGER_FACADE_LACROS_H_
#define CHROME_BROWSER_LACROS_ACCOUNT_MANAGER_FACADE_LACROS_H_
#include "chromeos/components/account_manager/account_manager_facade.h"
// Lacros specific implementation of |AccountManagerFacade| that talks to
// |chromeos::AccountManager|, residing in ash-chrome, over Mojo.
class AccountManagerFacadeLacros : public AccountManagerFacade {
public:
AccountManagerFacadeLacros();
AccountManagerFacadeLacros(const AccountManagerFacadeLacros&) = delete;
AccountManagerFacadeLacros& operator=(const AccountManagerFacadeLacros&) =
delete;
~AccountManagerFacadeLacros() override;
// AccountManagerFacade overrides:
bool IsInitialized() override;
};
#endif // CHROME_BROWSER_LACROS_ACCOUNT_MANAGER_FACADE_LACROS_H_
......@@ -10,6 +10,10 @@ component("account_manager") {
sources = [
"account_manager.cc",
"account_manager.h",
"account_manager_facade.cc",
"account_manager_facade.h",
"account_manager_facade_ash.cc",
"account_manager_facade_ash.h",
"account_manager_factory.cc",
"account_manager_factory.h",
]
......
// Copyright 2020 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 "chromeos/components/account_manager/account_manager_facade.h"
AccountManagerFacade::AccountManagerFacade() = default;
AccountManagerFacade::~AccountManagerFacade() = default;
// Copyright 2020 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.
#ifndef CHROMEOS_COMPONENTS_ACCOUNT_MANAGER_ACCOUNT_MANAGER_FACADE_H_
#define CHROMEOS_COMPONENTS_ACCOUNT_MANAGER_ACCOUNT_MANAGER_FACADE_H_
#include "base/component_export.h"
// An interface to talk to |AccountManager|.
// Implementations of this interface hide the in-process / out-of-process nature
// of this communication.
// Instances of this class are singletons, and are independent of a |Profile|.
// Use |GetAccountManagerFacade()| to get an instance of this class.
class COMPONENT_EXPORT(ACCOUNT_MANAGER) AccountManagerFacade {
public:
AccountManagerFacade();
AccountManagerFacade(const AccountManagerFacade&) = delete;
AccountManagerFacade& operator=(const AccountManagerFacade&) = delete;
virtual ~AccountManagerFacade() = 0;
// Returns |true| if |AccountManager| is connected and has been fully
// initialized.
// Note: For out-of-process implementations, it returns |false| if the IPC
// pipe to |AccountManager| is disconnected.
virtual bool IsInitialized() = 0;
};
#endif // CHROMEOS_COMPONENTS_ACCOUNT_MANAGER_ACCOUNT_MANAGER_FACADE_H_
// Copyright 2020 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 "chromeos/components/account_manager/account_manager_facade_ash.h"
#include "chromeos/components/account_manager/account_manager.h"
namespace chromeos {
AccountManagerFacadeAsh::AccountManagerFacadeAsh(
AccountManager* account_manager)
: account_manager_(account_manager) {}
AccountManagerFacadeAsh::~AccountManagerFacadeAsh() = default;
bool AccountManagerFacadeAsh::IsInitialized() {
return account_manager_->IsInitialized();
}
} // namespace chromeos
// Copyright 2020 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.
#ifndef CHROMEOS_COMPONENTS_ACCOUNT_MANAGER_ACCOUNT_MANAGER_FACADE_ASH_H_
#define CHROMEOS_COMPONENTS_ACCOUNT_MANAGER_ACCOUNT_MANAGER_FACADE_ASH_H_
#include "chromeos/components/account_manager/account_manager_facade.h"
namespace chromeos {
class AccountManager;
// Ash-chrome specific implementation of |AccountManagerFacade| that talks to
// |chromeos::AccountManager| in-process.
class COMPONENT_EXPORT(ACCOUNT_MANAGER) AccountManagerFacadeAsh
: public AccountManagerFacade {
public:
explicit AccountManagerFacadeAsh(AccountManager* account_manager);
AccountManagerFacadeAsh(const AccountManagerFacadeAsh&) = delete;
AccountManagerFacadeAsh& operator=(const AccountManagerFacadeAsh&) = delete;
~AccountManagerFacadeAsh() override;
// AccountManagerFacade overrides:
bool IsInitialized() override;
private:
AccountManager* const account_manager_;
};
} // namespace chromeos
#endif // CHROMEOS_COMPONENTS_ACCOUNT_MANAGER_ACCOUNT_MANAGER_FACADE_ASH_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment