| Index: chrome/browser/extensions/api/webstore/webstore_api.h
|
| diff --git a/chrome/browser/extensions/api/webstore/webstore_api.h b/chrome/browser/extensions/api/webstore/webstore_api.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..f009c58670ee7a3d2e02276aeba38e0d8f001cbd
|
| --- /dev/null
|
| +++ b/chrome/browser/extensions/api/webstore/webstore_api.h
|
| @@ -0,0 +1,106 @@
|
| +// Copyright 2014 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_EXTENSIONS_API_WEBSTORE_WEBSTORE_API_H_
|
| +#define CHROME_BROWSER_EXTENSIONS_API_WEBSTORE_WEBSTORE_API_H_
|
| +
|
| +#include <list>
|
| +#include <string>
|
| +
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "chrome/browser/extensions/api/profile_keyed_api_factory.h"
|
| +#include "chrome/browser/extensions/install_observer.h"
|
| +#include "extensions/browser/event_router.h"
|
| +
|
| +class Profile;
|
| +
|
| +namespace base {
|
| +class ListValue;
|
| +}
|
| +
|
| +namespace ipc {
|
| +class Sender;
|
| +}
|
| +
|
| +namespace extensions {
|
| +
|
| +class ListenerSet;
|
| +
|
| +class WebstoreAPI : public ProfileKeyedAPI, public InstallObserver {
|
| + public:
|
| + explicit WebstoreAPI(Profile* profile);
|
| + virtual ~WebstoreAPI();
|
| +
|
| + static WebstoreAPI* Get(Profile* profile);
|
| +
|
| + // Called whenever an inline extension install is started. Examines
|
| + // |listener_mask| to determine if a download progress or install
|
| + // stage listener should be added.
|
| + // |routing_id| refers to the id to which we send any return messages;
|
| + // |ipc_sender| is the sender through which we send them (typically this
|
| + // is the TabHelper which started the inline install).
|
| + void OnInlineInstallStart(int routing_id,
|
| + IPC::Sender* ipc_sender,
|
| + const std::string& extension_id,
|
| + int listener_mask);
|
| +
|
| + // Called when an inline extension install finishes. Removes any listeners
|
| + // related to the |routing_id|-|extension_id| pair.
|
| + void OnInlineInstallFinished(int routing_id, const std::string& extension_id);
|
| +
|
| + // InstallObserver implementation.
|
| + virtual void OnBeginExtensionDownload(const std::string& extension_id)
|
| + OVERRIDE;
|
| + virtual void OnDownloadProgress(const std::string& extension_id,
|
| + int percent_downloaded) OVERRIDE;
|
| + virtual void OnBeginCrxInstall(const std::string& extension_id) OVERRIDE;
|
| +
|
| + // BrowserContextKeyedService implementation.
|
| + virtual void Shutdown() OVERRIDE;
|
| +
|
| + // ProfileKeyedAPI implementation.
|
| + static ProfileKeyedAPIFactory<WebstoreAPI>* GetFactoryInstance();
|
| +
|
| + private:
|
| + friend class ProfileKeyedAPIFactory<WebstoreAPI>;
|
| +
|
| + // A simple struct to hold our listeners' information for each observed
|
| + // install.
|
| + struct ObservedInstallInfo {
|
| + ObservedInstallInfo(int routing_id,
|
| + const std::string& extension_id,
|
| + IPC::Sender* ipc_sender);
|
| + ~ObservedInstallInfo();
|
| +
|
| + int routing_id;
|
| + std::string extension_id;
|
| + IPC::Sender* ipc_sender;
|
| + };
|
| + typedef std::list<ObservedInstallInfo> ObservedInstallInfoList;
|
| +
|
| + // Sends an installation stage update message if we are observing
|
| + // the extension's install.
|
| + void SendInstallMessageIfObserved(const std::string& extension_id,
|
| + const std::string& install_stage);
|
| +
|
| + // Removes listeners for the given |extension_id|-|routing_id| pair from
|
| + // |listeners|.
|
| + void RemoveListeners(int routing_id,
|
| + const std::string& extension_id,
|
| + ObservedInstallInfoList* listeners);
|
| +
|
| + // ProfileKeyedAPI implementation.
|
| + static const char* service_name() { return "WebstoreAPI"; }
|
| + static const bool kServiceIsNULLWhileTesting = true;
|
| +
|
| + std::list<ObservedInstallInfo> download_progress_listeners_;
|
| + std::list<ObservedInstallInfo> install_stage_listeners_;
|
| + Profile* profile_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(WebstoreAPI);
|
| +};
|
| +
|
| +} // namespace extensions
|
| +
|
| +#endif // CHROME_BROWSER_EXTENSIONS_API_WEBSTORE_WEBSTORE_API_H_
|
|
|