Rename GetIconID to GetIconId
[chromium-blink-merge.git] / chrome / browser / extensions / webstore_inline_installer.h
blob583a6c351de6fb31bd0ba67319aa22155d71bbe6
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 "chrome/browser/extensions/webstore_standalone_installer.h"
12 #include "content/public/browser/web_contents_observer.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 : public WebstoreStandaloneInstaller,
29 public content::WebContentsObserver {
30 public:
31 typedef WebstoreStandaloneInstaller::Callback Callback;
33 WebstoreInlineInstaller(content::WebContents* web_contents,
34 const std::string& webstore_item_id,
35 const GURL& requestor_url,
36 const Callback& callback);
38 // Returns true if given |requestor_url| is a verified site according to the
39 // given |webstore_data|.
40 static bool IsRequestorPermitted(const base::DictionaryValue& webstore_data,
41 const GURL& requestor_url,
42 std::string* error);
44 protected:
45 friend class base::RefCountedThreadSafe<WebstoreInlineInstaller>;
47 ~WebstoreInlineInstaller() override;
49 // Implementations WebstoreStandaloneInstaller Template Method's hooks.
50 bool CheckRequestorAlive() const override;
51 const GURL& GetRequestorURL() const override;
52 bool ShouldShowPostInstallUI() const override;
53 bool ShouldShowAppInstalledBubble() const override;
54 content::WebContents* GetWebContents() const override;
55 scoped_refptr<ExtensionInstallPrompt::Prompt> CreateInstallPrompt()
56 const override;
57 bool CheckInlineInstallPermitted(const base::DictionaryValue& webstore_data,
58 std::string* error) const override;
59 bool CheckRequestorPermitted(const base::DictionaryValue& webstore_data,
60 std::string* error) const override;
62 private:
63 // content::WebContentsObserver interface implementation.
64 void WebContentsDestroyed() override;
66 // Checks whether the install is initiated by a page in a verified site
67 // (which is at least a domain, but can also have a port or a path).
68 static bool IsRequestorURLInVerifiedSite(const GURL& requestor_url,
69 const std::string& verified_site);
71 GURL requestor_url_;
73 DISALLOW_IMPLICIT_CONSTRUCTORS(WebstoreInlineInstaller);
76 } // namespace extensions
78 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_INLINE_INSTALLER_H_