NaCl: Update revision in DEPS, r12770 -> r12773
[chromium-blink-merge.git] / chrome / browser / extensions / webstore_inline_installer.h
blob59fcb40a95f11c9fcfdac85ee45a5c59c74f7756
1 // Copyright (c) 2012 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.
5 #ifndef CHROME_BROWSER_EXTENSIONS_WEBSTORE_INLINE_INSTALLER_H_
6 #define CHROME_BROWSER_EXTENSIONS_WEBSTORE_INLINE_INSTALLER_H_
8 #include <string>
10 #include "base/memory/ref_counted.h"
11 #include "content/public/browser/web_contents_observer.h"
12 #include "webstore_standalone_installer.h"
14 namespace content {
15 class WebContents;
18 namespace extensions {
20 // Manages inline installs requested by a page: downloads and parses metadata
21 // from the webstore, shows the install UI, starts the download once the user
22 // confirms, optionally transfers the user to the store if the "View details"
23 // link is clicked in the UI, shows the "App installed" bubble and the
24 // post-install UI after successful installation.
26 // Clients will be notified of success or failure via the |callback| argument
27 // passed into the constructor.
28 class WebstoreInlineInstaller
29 : public WebstoreStandaloneInstaller,
30 public content::WebContentsObserver {
31 public:
32 typedef WebstoreStandaloneInstaller::Callback Callback;
34 WebstoreInlineInstaller(content::WebContents* web_contents,
35 const std::string& webstore_item_id,
36 const GURL& requestor_url,
37 const Callback& callback);
39 protected:
40 friend class base::RefCountedThreadSafe<WebstoreInlineInstaller>;
42 virtual ~WebstoreInlineInstaller();
44 // Implementations WebstoreStandaloneInstaller Template Method's hooks.
45 virtual bool CheckRequestorAlive() const OVERRIDE;
46 virtual const GURL& GetRequestorURL() const OVERRIDE;
47 virtual bool ShouldShowPostInstallUI() const OVERRIDE;
48 virtual bool ShouldShowAppInstalledBubble() const OVERRIDE;
49 virtual content::WebContents* GetWebContents() const OVERRIDE;
50 virtual scoped_ptr<ExtensionInstallPrompt::Prompt>
51 CreateInstallPrompt() const OVERRIDE;
52 virtual bool CheckInlineInstallPermitted(
53 const base::DictionaryValue& webstore_data,
54 std::string* error) const OVERRIDE;
55 virtual bool CheckRequestorPermitted(
56 const base::DictionaryValue& webstore_data,
57 std::string* error) const OVERRIDE;
59 private:
60 // content::WebContentsObserver interface implementation.
61 virtual void WebContentsDestroyed(
62 content::WebContents* web_contents) OVERRIDE;
64 // Checks whether the install is initiated by a page in a verified site
65 // (which is at least a domain, but can also have a port or a path).
66 static bool IsRequestorURLInVerifiedSite(const GURL& requestor_url,
67 const std::string& verified_site);
69 GURL requestor_url_;
71 DISALLOW_IMPLICIT_CONSTRUCTORS(WebstoreInlineInstaller);
74 } // namespace extensions
76 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_INLINE_INSTALLER_H_