1// Copyright 2014 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_EXTENSIONS_WEBSTORE_REINSTALLER_H_
6#define CHROME_BROWSER_EXTENSIONS_WEBSTORE_REINSTALLER_H_
7
8#include "chrome/browser/extensions/webstore_standalone_installer.h"
9#include "content/public/browser/web_contents_observer.h"
10
11namespace extensions {
12
13// Reinstalls an extension from the webstore. This will first prompt the user if
14// they want to reinstall (using the verbase "Repair", since this is our action
15// for repairing corrupted extensions), and, if the user agrees, will uninstall
16// the extension and reinstall it directly from the webstore.
17class WebstoreReinstaller : public WebstoreStandaloneInstaller,
18                            public content::WebContentsObserver {
19 public:
20  WebstoreReinstaller(content::WebContents* web_contents,
21                      const std::string& extension_id,
22                      const WebstoreStandaloneInstaller::Callback& callback);
23
24  // Begin the reinstall process. |callback| (from the constructor) will be
25  // called upon completion.
26  void BeginReinstall();
27
28 private:
29  virtual ~WebstoreReinstaller();
30
31  // WebstoreStandaloneInstaller:
32  virtual bool CheckRequestorAlive() const OVERRIDE;
33  virtual const GURL& GetRequestorURL() const OVERRIDE;
34  virtual bool ShouldShowPostInstallUI() const OVERRIDE;
35  virtual bool ShouldShowAppInstalledBubble() const OVERRIDE;
36  virtual content::WebContents* GetWebContents() const OVERRIDE;
37  virtual scoped_refptr<ExtensionInstallPrompt::Prompt> CreateInstallPrompt()
38      const OVERRIDE;
39  virtual bool CheckInlineInstallPermitted(
40      const base::DictionaryValue& webstore_data,
41      std::string* error) const OVERRIDE;
42  virtual bool CheckRequestorPermitted(
43      const base::DictionaryValue& webstore_data,
44      std::string* error) const OVERRIDE;
45  virtual void InstallUIProceed() OVERRIDE;
46
47  // content::WebContentsObserver:
48  virtual void WebContentsDestroyed() OVERRIDE;
49
50  // Called once all data from the old extension installation is removed.
51  void OnDeletionDone();
52};
53
54}  // namespace extensions
55
56#endif  // CHROME_BROWSER_EXTENSIONS_WEBSTORE_REINSTALLER_H_
57