blob: a9334c41d08b5759469765a43df1219a828082dd [file] [log] [blame]
// Copyright 2018 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 "base/callback_forward.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/optional.h"
#include "extensions/common/extension_id.h"
class GURL;
class Profile;
struct WebApplicationInfo;
namespace extensions {
class CrxInstaller;
class CrxInstallError;
// Class used by BookmarkAppInstallationTask to actually install the Bookmark
// App in the system.
class BookmarkAppInstaller {
using ResultCallback = base::OnceCallback<void(const ExtensionId&)>;
// Constructs a BookmarkAppInstaller that will install the Bookmark App in
// |profile|.
explicit BookmarkAppInstaller(Profile* profile);
virtual ~BookmarkAppInstaller();
// TODO( This should take more options e.g. what container
// to launch the app in, should the app sync, etc.
virtual void Install(const WebApplicationInfo& web_app_info,
ResultCallback callback);
void SetCrxInstallerForTesting(scoped_refptr<CrxInstaller> crx_installer);
void OnInstall(ResultCallback callback,
const GURL& app_url,
const base::Optional<CrxInstallError>& error);
scoped_refptr<CrxInstaller> crx_installer_;
// We need a WeakPtr because CrxInstaller is refcounted and it can run its
// callback after this class has been destroyed.
base::WeakPtrFactory<BookmarkAppInstaller> weak_ptr_factory_{this};
} // namespace extensions