[safe-browsing] Database full hash matches like prefix match.
[chromium-blink-merge.git] / chrome / browser / apps / ephemeral_app_launcher.h
blobbaefed52c260c09b255235fe205b60d8681c2130
1 // Copyright 2013 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_APPS_EPHEMERAL_APP_LAUNCHER_H_
6 #define CHROME_BROWSER_APPS_EPHEMERAL_APP_LAUNCHER_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/scoped_observer.h"
12 #include "chrome/browser/extensions/webstore_standalone_installer.h"
13 #include "chrome/browser/ui/extensions/extension_enable_flow_delegate.h"
14 #include "content/public/browser/web_contents_observer.h"
15 #include "extensions/browser/extension_registry_observer.h"
17 class ExtensionEnableFlow;
18 class Profile;
20 namespace content {
21 class WebContents;
24 namespace extensions {
25 class Extension;
26 class ExtensionRegistry;
29 // EphemeralAppLauncher manages the launching of ephemeral apps. It handles
30 // display of a prompt, initiates install of the app (if necessary) and finally
31 // launches the app.
32 class EphemeralAppLauncher : public extensions::WebstoreStandaloneInstaller,
33 public content::WebContentsObserver,
34 public extensions::ExtensionRegistryObserver,
35 public ExtensionEnableFlowDelegate {
36 public:
37 typedef WebstoreStandaloneInstaller::Callback Callback;
39 // Create for the app launcher.
40 static scoped_refptr<EphemeralAppLauncher> CreateForLauncher(
41 const std::string& webstore_item_id,
42 Profile* profile,
43 gfx::NativeWindow parent_window,
44 const Callback& callback);
46 // Create for a link within a browser tab.
47 static scoped_refptr<EphemeralAppLauncher> CreateForLink(
48 const std::string& webstore_item_id,
49 content::WebContents* web_contents);
51 // Initiate app launch.
52 void Start();
54 private:
55 friend class base::RefCountedThreadSafe<EphemeralAppLauncher>;
57 EphemeralAppLauncher(const std::string& webstore_item_id,
58 Profile* profile,
59 gfx::NativeWindow parent_window,
60 const Callback& callback);
61 EphemeralAppLauncher(const std::string& webstore_item_id,
62 content::WebContents* web_contents,
63 const Callback& callback);
65 virtual ~EphemeralAppLauncher();
67 void StartObserving();
68 void LaunchApp(const extensions::Extension* extension) const;
70 // WebstoreStandaloneInstaller implementation.
71 virtual bool CheckRequestorAlive() const OVERRIDE;
72 virtual const GURL& GetRequestorURL() const OVERRIDE;
73 virtual bool ShouldShowPostInstallUI() const OVERRIDE;
74 virtual bool ShouldShowAppInstalledBubble() const OVERRIDE;
75 virtual content::WebContents* GetWebContents() const OVERRIDE;
76 virtual scoped_ptr<ExtensionInstallPrompt::Prompt>
77 CreateInstallPrompt() const OVERRIDE;
78 virtual bool CheckInlineInstallPermitted(
79 const base::DictionaryValue& webstore_data,
80 std::string* error) const OVERRIDE;
81 virtual bool CheckRequestorPermitted(
82 const base::DictionaryValue& webstore_data,
83 std::string* error) const OVERRIDE;
84 virtual bool CheckInstallValid(
85 const base::DictionaryValue& manifest,
86 std::string* error) OVERRIDE;
87 virtual scoped_ptr<ExtensionInstallPrompt> CreateInstallUI() OVERRIDE;
88 virtual scoped_ptr<extensions::WebstoreInstaller::Approval>
89 CreateApproval() const OVERRIDE;
90 virtual void CompleteInstall(const std::string& error) OVERRIDE;
92 // content::WebContentsObserver implementation.
93 virtual void WebContentsDestroyed(
94 content::WebContents* web_contents) OVERRIDE;
96 // ExtensionRegistryObserver implementation.
97 virtual void OnExtensionLoaded(
98 content::BrowserContext* browser_context,
99 const extensions::Extension* extension) OVERRIDE;
101 // ExtensionEnableFlowDelegate implementation.
102 virtual void ExtensionEnableFlowFinished() OVERRIDE;
103 virtual void ExtensionEnableFlowAborted(bool user_initiated) OVERRIDE;
105 // Listen to extension unloaded notifications.
106 ScopedObserver<extensions::ExtensionRegistry,
107 extensions::ExtensionRegistryObserver>
108 extension_registry_observer_;
110 gfx::NativeWindow parent_window_;
111 scoped_ptr<content::WebContents> dummy_web_contents_;
113 // Created in CheckInstallValid().
114 scoped_refptr<extensions::Extension> extension_;
116 scoped_ptr<ExtensionEnableFlow> extension_enable_flow_;
118 DISALLOW_COPY_AND_ASSIGN(EphemeralAppLauncher);
121 #endif // CHROME_BROWSER_APPS_EPHEMERAL_APP_LAUNCHER_H_