OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALL_WITH_PROMPT_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALL_WITH_PROMPT_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALL_WITH_PROMPT_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALL_WITH_PROMPT_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "chrome/browser/extensions/webstore_standalone_installer.h" | 10 #include "chrome/browser/extensions/webstore_standalone_installer.h" |
11 #include "content/public/browser/page_navigator.h" | |
12 #include "ui/gfx/native_widget_types.h" | 11 #include "ui/gfx/native_widget_types.h" |
13 #include "url/gurl.h" | 12 #include "url/gurl.h" |
14 | 13 |
15 namespace content { | 14 namespace content { |
16 class WebContents; | 15 class WebContents; |
17 } | 16 } |
18 | 17 |
19 namespace extensions { | 18 namespace extensions { |
20 | 19 |
21 // Initiates the install of an extension from the webstore. Downloads and parses | 20 // 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 | 21 // metadata from the webstore, shows an install UI and starts the download once |
23 // the user confirms. No post-install UI is shown. | 22 // the user confirms. No post-install UI is shown. |
24 // | 23 // |
25 // Clients will be notified of success or failure via the |callback| argument | 24 // Clients will be notified of success or failure via the |callback| argument |
26 // passed into the constructor. | 25 // passed into the constructor. |
27 // | 26 // |
28 // Clients of this class must be trusted, as verification of the requestor is | 27 // Clients of this class must be trusted, as verification of the requestor is |
29 // skipped. This class stubs out many WebstoreStandaloneInstaller abstract | 28 // skipped. This class stubs out many WebstoreStandaloneInstaller abstract |
30 // methods and can be used as a base class. | 29 // methods and can be used as a base class. |
31 class WebstoreInstallWithPrompt : public WebstoreStandaloneInstaller, | 30 class WebstoreInstallWithPrompt : public WebstoreStandaloneInstaller { |
32 public content::PageNavigator { | |
33 public: | 31 public: |
34 // Use this constructor when there is no parent window. The install dialog | 32 // Use this constructor when there is no parent window. The install dialog |
35 // will be centered on the screen. | 33 // will be centered on the screen. |
36 WebstoreInstallWithPrompt(const std::string& webstore_item_id, | 34 WebstoreInstallWithPrompt(const std::string& webstore_item_id, |
37 Profile* profile, | 35 Profile* profile, |
38 const Callback& callback); | 36 const Callback& callback); |
39 | 37 |
40 // If this constructor is used, the parent of the install dialog will be | 38 // If this constructor is used, the parent of the install dialog will be |
41 // |parent_window|. | 39 // |parent_window|. |
42 WebstoreInstallWithPrompt(const std::string& webstore_item_id, | 40 WebstoreInstallWithPrompt(const std::string& webstore_item_id, |
(...skipping 14 matching lines...) Expand all Loading... |
57 bool ShouldShowAppInstalledBubble() const override; | 55 bool ShouldShowAppInstalledBubble() const override; |
58 content::WebContents* GetWebContents() const override; | 56 content::WebContents* GetWebContents() const override; |
59 scoped_refptr<ExtensionInstallPrompt::Prompt> CreateInstallPrompt() | 57 scoped_refptr<ExtensionInstallPrompt::Prompt> CreateInstallPrompt() |
60 const override; | 58 const override; |
61 scoped_ptr<ExtensionInstallPrompt> CreateInstallUI() override; | 59 scoped_ptr<ExtensionInstallPrompt> CreateInstallUI() override; |
62 bool CheckInlineInstallPermitted(const base::DictionaryValue& webstore_data, | 60 bool CheckInlineInstallPermitted(const base::DictionaryValue& webstore_data, |
63 std::string* error) const override; | 61 std::string* error) const override; |
64 bool CheckRequestorPermitted(const base::DictionaryValue& webstore_data, | 62 bool CheckRequestorPermitted(const base::DictionaryValue& webstore_data, |
65 std::string* error) const override; | 63 std::string* error) const override; |
66 | 64 |
67 // content::PageNavigator overrides: | |
68 content::WebContents* OpenURL(const content::OpenURLParams& params) override; | |
69 | |
70 private: | 65 private: |
71 bool show_post_install_ui_; | 66 bool show_post_install_ui_; |
72 | 67 |
73 GURL dummy_requestor_url_; | 68 GURL dummy_requestor_url_; |
74 | 69 |
75 // A non-visible WebContents used to download data from the webstore. | 70 // A non-visible WebContents used to download data from the webstore. |
76 scoped_ptr<content::WebContents> dummy_web_contents_; | 71 scoped_ptr<content::WebContents> dummy_web_contents_; |
77 | 72 |
78 gfx::NativeWindow parent_window_; | 73 gfx::NativeWindow parent_window_; |
79 | 74 |
80 DISALLOW_COPY_AND_ASSIGN(WebstoreInstallWithPrompt); | 75 DISALLOW_COPY_AND_ASSIGN(WebstoreInstallWithPrompt); |
81 }; | 76 }; |
82 | 77 |
83 } // namespace extensions | 78 } // namespace extensions |
84 | 79 |
85 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALL_WITH_PROMPT_H_ | 80 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALL_WITH_PROMPT_H_ |
OLD | NEW |