| Index: chrome/browser/extensions/bundle_installer.h
|
| diff --git a/chrome/browser/extensions/bundle_installer.h b/chrome/browser/extensions/bundle_installer.h
|
| index d60984fa3841b463b61ee0a79fbc343d0666a199..a4f49740725ff03fe8e83e77a8b2c248d45afb2c 100644
|
| --- a/chrome/browser/extensions/bundle_installer.h
|
| +++ b/chrome/browser/extensions/bundle_installer.h
|
| @@ -8,6 +8,7 @@
|
| #include <string>
|
| #include <vector>
|
|
|
| +#include "base/callback_forward.h"
|
| #include "base/memory/linked_ptr.h"
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/strings/string16.h"
|
| @@ -17,6 +18,8 @@
|
| #include "chrome/browser/ui/browser_list_observer.h"
|
| #include "chrome/browser/ui/host_desktop.h"
|
| #include "extensions/common/extension.h"
|
| +#include "third_party/skia/include/core/SkBitmap.h"
|
| +#include "url/gurl.h"
|
|
|
| namespace base {
|
| class DictionaryValue;
|
| @@ -40,22 +43,11 @@ namespace extensions {
|
| class BundleInstaller : public WebstoreInstallHelper::Delegate,
|
| public ExtensionInstallPrompt::Delegate,
|
| public WebstoreInstaller::Delegate,
|
| - public chrome::BrowserListObserver,
|
| - public base::RefCountedThreadSafe<BundleInstaller> {
|
| + public chrome::BrowserListObserver {
|
| public:
|
| // Auto approve or cancel the permission prompt.
|
| static void SetAutoApproveForTesting(bool approve);
|
|
|
| - class Delegate {
|
| - public:
|
| - virtual void OnBundleInstallApproved() {}
|
| - virtual void OnBundleInstallCanceled(bool user_initiated) {}
|
| - virtual void OnBundleInstallCompleted() {}
|
| -
|
| - protected:
|
| - virtual ~Delegate() {}
|
| - };
|
| -
|
| // Represents an individual member of the bundle.
|
| struct Item {
|
| // Items are in the PENDING state until they've been installed, or the
|
| @@ -67,39 +59,61 @@ class BundleInstaller : public WebstoreInstallHelper::Delegate,
|
| };
|
|
|
| Item();
|
| + ~Item();
|
|
|
| - // Gets the localized name, formatted for display in the prompt or bubble.
|
| - base::string16 GetNameForDisplay();
|
| + // Gets the localized name, formatted for display in the bubble.
|
| + base::string16 GetNameForDisplay() const;
|
|
|
| std::string id;
|
| std::string manifest;
|
| std::string localized_name;
|
| + GURL icon_url;
|
| + SkBitmap icon;
|
| State state;
|
| };
|
|
|
| + enum ApprovalState {
|
| + APPROVED,
|
| + USER_CANCELED,
|
| + APPROVAL_ERROR
|
| + };
|
| +
|
| + typedef base::Callback<void(ApprovalState)> ApprovalCallback;
|
| +
|
| typedef std::vector<Item> ItemList;
|
|
|
| - BundleInstaller(Browser* browser, const ItemList& items);
|
| + BundleInstaller(Browser* browser,
|
| + const std::string& name,
|
| + const SkBitmap& icon,
|
| + const std::string& authuser,
|
| + const ItemList& items);
|
| + ~BundleInstaller() override;
|
|
|
| // Returns true if the user has approved the bundle's permissions.
|
| bool approved() const { return approved_; }
|
|
|
| - // Gets the items in the given state.
|
| + // Returns the browser window associated with the bundle's installation.
|
| + // Can return null if the browser is closed during the installation.
|
| + Browser* browser() { return browser_; }
|
| +
|
| + // Gets the items in the given |state|.
|
| ItemList GetItemsWithState(Item::State state) const;
|
|
|
| + // Returns whether there is at least one item with the given |state|.
|
| + bool HasItemWithState(Item::State state) const;
|
| +
|
| + // Returns the number of items with the given |state|.
|
| + size_t CountItemsWithState(Item::State state) const;
|
| +
|
| // Parses the extension manifests and then prompts the user to approve their
|
| - // permissions. One of OnBundleInstallApproved or OnBundleInstallCanceled
|
| - // will be called when complete if |delegate| is not NULL.
|
| - // Note: the |delegate| must stay alive until receiving the callback.
|
| - void PromptForApproval(Delegate* delegate);
|
| + // permissions.
|
| + void PromptForApproval(const ApprovalCallback& callback);
|
|
|
| // If the bundle has been approved, this downloads and installs the member
|
| - // extensions. OnBundleInstallComplete will be called when the process is
|
| - // complete and |delegate| is not NULL. The download process uses the
|
| - // NavigationController of the specified |web_contents|. When complete, we
|
| - // show a confirmation bubble in the specified |browser|.
|
| - // Note: the |delegate| must stay alive until receiving the callback.
|
| - void CompleteInstall(content::WebContents* web_contents, Delegate* delegate);
|
| + // extensions. The download process uses the NavigationController of the
|
| + // specified |web_contents|. When complete, we show a confirmation bubble.
|
| + void CompleteInstall(content::WebContents* web_contents,
|
| + const base::Closure& callback);
|
|
|
| // We change the headings in the install prompt and installed bubble depending
|
| // on whether the bundle contains apps, extensions or both. This method gets
|
| @@ -111,13 +125,9 @@ class BundleInstaller : public WebstoreInstallHelper::Delegate,
|
| base::string16 GetHeadingTextFor(Item::State state) const;
|
|
|
| private:
|
| - friend class base::RefCountedThreadSafe<BundleInstaller>;
|
| -
|
| typedef std::map<std::string, Item> ItemMap;
|
| typedef std::map<std::string, linked_ptr<base::DictionaryValue> > ManifestMap;
|
|
|
| - ~BundleInstaller() override;
|
| -
|
| // Displays the install bubble for |bundle| on |browser|.
|
| // Note: this is a platform specific implementation.
|
| static void ShowInstalledBubble(const BundleInstaller* bundle,
|
| @@ -126,15 +136,6 @@ class BundleInstaller : public WebstoreInstallHelper::Delegate,
|
| // Parses the manifests using WebstoreInstallHelper.
|
| void ParseManifests();
|
|
|
| - // Notifies the delegate that the installation has been approved.
|
| - void ReportApproved();
|
| -
|
| - // Notifies the delegate that the installation was canceled.
|
| - void ReportCanceled(bool user_initiated);
|
| -
|
| - // Notifies the delegate that the installation is complete.
|
| - void ReportComplete();
|
| -
|
| // Prompts the user to install the bundle once we have dummy extensions for
|
| // all the pending items.
|
| void ShowPromptIfDoneParsing();
|
| @@ -165,9 +166,7 @@ class BundleInstaller : public WebstoreInstallHelper::Delegate,
|
| WebstoreInstaller::FailureReason reason) override;
|
|
|
| // chrome::BrowserListObserver implementation:
|
| - void OnBrowserAdded(Browser* browser) override;
|
| void OnBrowserRemoved(Browser* browser) override;
|
| - void OnBrowserSetLastActive(Browser* browser) override;
|
|
|
| // Holds the Extensions used to generate the permission warnings.
|
| ExtensionList dummy_extensions_;
|
| @@ -184,6 +183,16 @@ class BundleInstaller : public WebstoreInstallHelper::Delegate,
|
| // The browser to show the confirmation bubble for.
|
| Browser* browser_;
|
|
|
| + // The bundle's display name.
|
| + std::string name_;
|
| +
|
| + // The bundle's icon.
|
| + SkBitmap icon_;
|
| +
|
| + // The authuser query parameter value which should be used with CRX download
|
| + // requests. May be empty.
|
| + std::string authuser_;
|
| +
|
| // The desktop type of the browser.
|
| chrome::HostDesktopType host_desktop_type_;
|
|
|
| @@ -193,7 +202,8 @@ class BundleInstaller : public WebstoreInstallHelper::Delegate,
|
| // The UI that shows the confirmation prompt.
|
| scoped_ptr<ExtensionInstallPrompt> install_ui_;
|
|
|
| - Delegate* delegate_;
|
| + ApprovalCallback approval_callback_;
|
| + base::Closure install_callback_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(BundleInstaller);
|
| };
|
|
|