Adding instrumentation to locate the source of jankiness
[chromium-blink-merge.git] / chrome / browser / extensions / webstore_install_with_prompt.h
blob91ec9be0f732035f1910496a9c19a9d859b5ec63
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 "content/public/browser/page_navigator.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 content::PageNavigator {
33 public:
34 // Use this constructor when there is no parent window. The install dialog
35 // will be centered on the screen.
36 WebstoreInstallWithPrompt(const std::string& webstore_item_id,
37 Profile* profile,
38 const Callback& callback);
40 // If this constructor is used, the parent of the install dialog will be
41 // |parent_window|.
42 WebstoreInstallWithPrompt(const std::string& webstore_item_id,
43 Profile* profile,
44 gfx::NativeWindow parent_window,
45 const Callback& callback);
47 protected:
48 friend class base::RefCountedThreadSafe<WebstoreInstallWithPrompt>;
49 virtual ~WebstoreInstallWithPrompt();
51 void set_show_post_install_ui(bool show) { show_post_install_ui_ = show; }
53 // extensions::WebstoreStandaloneInstaller overrides:
54 virtual bool CheckRequestorAlive() const override;
55 virtual const GURL& GetRequestorURL() const override;
56 virtual bool ShouldShowPostInstallUI() const override;
57 virtual bool ShouldShowAppInstalledBubble() const override;
58 virtual content::WebContents* GetWebContents() const override;
59 virtual scoped_refptr<ExtensionInstallPrompt::Prompt> CreateInstallPrompt()
60 const override;
61 virtual scoped_ptr<ExtensionInstallPrompt> CreateInstallUI() override;
62 virtual bool CheckInlineInstallPermitted(
63 const base::DictionaryValue& webstore_data,
64 std::string* error) const override;
65 virtual bool CheckRequestorPermitted(
66 const base::DictionaryValue& webstore_data,
67 std::string* error) const override;
69 // content::PageNavigator overrides:
70 virtual content::WebContents* OpenURL(
71 const content::OpenURLParams& params) override;
73 private:
74 bool show_post_install_ui_;
76 GURL dummy_requestor_url_;
78 // A non-visible WebContents used to download data from the webstore.
79 scoped_ptr<content::WebContents> dummy_web_contents_;
81 gfx::NativeWindow parent_window_;
83 DISALLOW_COPY_AND_ASSIGN(WebstoreInstallWithPrompt);
86 } // namespace extensions
88 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALL_WITH_PROMPT_H_