Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / extensions / webstore_install_with_prompt.h
blob7166d58de4058553043c6bbbf731840dc6448077
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.
5 #ifndef CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALL_WITH_PROMPT_H_
6 #define CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALL_WITH_PROMPT_H_
8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "chrome/browser/extensions/webstore_standalone_installer.h"
11 #include "chrome/browser/ui/native_window_tracker.h"
12 #include "ui/gfx/native_widget_types.h"
13 #include "url/gurl.h"
15 namespace content {
16 class WebContents;
19 namespace extensions {
21 // Initiates the install of an extension from the webstore. Downloads and parses
22 // metadata from the webstore, shows an install UI and starts the download once
23 // the user confirms. No post-install UI is shown.
25 // Clients will be notified of success or failure via the |callback| argument
26 // passed into the constructor.
28 // Clients of this class must be trusted, as verification of the requestor is
29 // skipped. This class stubs out many WebstoreStandaloneInstaller abstract
30 // methods and can be used as a base class.
31 class WebstoreInstallWithPrompt : public WebstoreStandaloneInstaller {
32 public:
33 // Use this constructor when there is no parent window. The install dialog
34 // will be centered on the screen.
35 WebstoreInstallWithPrompt(const std::string& webstore_item_id,
36 Profile* profile,
37 const Callback& callback);
39 // If this constructor is used, the parent of the install dialog will be
40 // |parent_window|.
41 WebstoreInstallWithPrompt(const std::string& webstore_item_id,
42 Profile* profile,
43 gfx::NativeWindow parent_window,
44 const Callback& callback);
46 protected:
47 friend class base::RefCountedThreadSafe<WebstoreInstallWithPrompt>;
48 ~WebstoreInstallWithPrompt() override;
50 void set_show_post_install_ui(bool show) { show_post_install_ui_ = show; }
52 // extensions::WebstoreStandaloneInstaller overrides:
53 bool CheckRequestorAlive() const override;
54 const GURL& GetRequestorURL() const override;
55 bool ShouldShowPostInstallUI() const override;
56 bool ShouldShowAppInstalledBubble() const override;
57 content::WebContents* GetWebContents() const override;
58 scoped_refptr<ExtensionInstallPrompt::Prompt> CreateInstallPrompt()
59 const override;
60 scoped_ptr<ExtensionInstallPrompt> CreateInstallUI() override;
61 bool CheckInlineInstallPermitted(const base::DictionaryValue& webstore_data,
62 std::string* error) const override;
63 bool CheckRequestorPermitted(const base::DictionaryValue& webstore_data,
64 std::string* error) const override;
66 private:
67 bool show_post_install_ui_;
69 GURL dummy_requestor_url_;
71 // A non-visible WebContents used to download data from the webstore.
72 scoped_ptr<content::WebContents> dummy_web_contents_;
74 gfx::NativeWindow parent_window_;
75 scoped_ptr<NativeWindowTracker> parent_window_tracker_;
77 DISALLOW_COPY_AND_ASSIGN(WebstoreInstallWithPrompt);
80 } // namespace extensions
82 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALL_WITH_PROMPT_H_