OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 #include "chrome/browser/extensions/extension_install_prompt.h" | 5 #include "chrome/browser/extensions/extension_install_prompt.h" |
6 #include "chrome/browser/extensions/extension_service.h" | 6 #include "chrome/browser/extensions/extension_service.h" |
7 #include "chrome/browser/extensions/tab_helper.h" | 7 #include "chrome/browser/extensions/tab_helper.h" |
8 #include "chrome/browser/extensions/webstore_inline_installer.h" | 8 #include "chrome/browser/extensions/webstore_inline_installer.h" |
9 #include "chrome/browser/extensions/webstore_inline_installer_factory.h" | 9 #include "chrome/browser/extensions/webstore_inline_installer_factory.h" |
10 #include "chrome/browser/extensions/webstore_installer_test.h" | 10 #include "chrome/browser/extensions/webstore_installer_test.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 explicit ProgrammableInstallPrompt(WebContents* contents) | 48 explicit ProgrammableInstallPrompt(WebContents* contents) |
49 : ExtensionInstallPrompt(contents) | 49 : ExtensionInstallPrompt(contents) |
50 {} | 50 {} |
51 | 51 |
52 virtual ~ProgrammableInstallPrompt() {} | 52 virtual ~ProgrammableInstallPrompt() {} |
53 | 53 |
54 virtual void ConfirmStandaloneInstall( | 54 virtual void ConfirmStandaloneInstall( |
55 Delegate* delegate, | 55 Delegate* delegate, |
56 const Extension* extension, | 56 const Extension* extension, |
57 SkBitmap* icon, | 57 SkBitmap* icon, |
58 scoped_refptr<ExtensionInstallPrompt::Prompt> prompt) OVERRIDE { | 58 scoped_refptr<ExtensionInstallPrompt::Prompt> prompt) override { |
59 delegate_ = delegate; | 59 delegate_ = delegate; |
60 } | 60 } |
61 | 61 |
62 static bool Ready() { | 62 static bool Ready() { |
63 return delegate_ != NULL; | 63 return delegate_ != NULL; |
64 } | 64 } |
65 | 65 |
66 static void Accept() { | 66 static void Accept() { |
67 delegate_->InstallUIProceed(); | 67 delegate_->InstallUIProceed(); |
68 } | 68 } |
(...skipping 17 matching lines...) Expand all Loading... |
86 const GURL& requestor_url, | 86 const GURL& requestor_url, |
87 const Callback& callback) | 87 const Callback& callback) |
88 : WebstoreInlineInstaller( | 88 : WebstoreInlineInstaller( |
89 contents, | 89 contents, |
90 kTestExtensionId, | 90 kTestExtensionId, |
91 requestor_url, | 91 requestor_url, |
92 base::Bind(DummyCallback)), | 92 base::Bind(DummyCallback)), |
93 programmable_prompt_(NULL) { | 93 programmable_prompt_(NULL) { |
94 } | 94 } |
95 | 95 |
96 virtual scoped_ptr<ExtensionInstallPrompt> CreateInstallUI() OVERRIDE { | 96 virtual scoped_ptr<ExtensionInstallPrompt> CreateInstallUI() override { |
97 programmable_prompt_ = new ProgrammableInstallPrompt(web_contents()); | 97 programmable_prompt_ = new ProgrammableInstallPrompt(web_contents()); |
98 return make_scoped_ptr(programmable_prompt_). | 98 return make_scoped_ptr(programmable_prompt_). |
99 PassAs<ExtensionInstallPrompt>(); | 99 PassAs<ExtensionInstallPrompt>(); |
100 } | 100 } |
101 | 101 |
102 private: | 102 private: |
103 virtual ~WebstoreInlineInstallerForTest() {} | 103 virtual ~WebstoreInlineInstallerForTest() {} |
104 | 104 |
105 friend class base::RefCountedThreadSafe<WebstoreStandaloneInstaller>; | 105 friend class base::RefCountedThreadSafe<WebstoreStandaloneInstaller>; |
106 | 106 |
107 static void DummyCallback(bool success, | 107 static void DummyCallback(bool success, |
108 const std::string& error, | 108 const std::string& error, |
109 webstore_install::Result result) { | 109 webstore_install::Result result) { |
110 } | 110 } |
111 | 111 |
112 ProgrammableInstallPrompt* programmable_prompt_; | 112 ProgrammableInstallPrompt* programmable_prompt_; |
113 }; | 113 }; |
114 | 114 |
115 class WebstoreInlineInstallerForTestFactory : | 115 class WebstoreInlineInstallerForTestFactory : |
116 public WebstoreInlineInstallerFactory { | 116 public WebstoreInlineInstallerFactory { |
117 virtual ~WebstoreInlineInstallerForTestFactory() {} | 117 virtual ~WebstoreInlineInstallerForTestFactory() {} |
118 virtual WebstoreInlineInstaller* CreateInstaller( | 118 virtual WebstoreInlineInstaller* CreateInstaller( |
119 WebContents* contents, | 119 WebContents* contents, |
120 const std::string& webstore_item_id, | 120 const std::string& webstore_item_id, |
121 const GURL& requestor_url, | 121 const GURL& requestor_url, |
122 const WebstoreStandaloneInstaller::Callback& callback) OVERRIDE { | 122 const WebstoreStandaloneInstaller::Callback& callback) override { |
123 return new WebstoreInlineInstallerForTest( | 123 return new WebstoreInlineInstallerForTest( |
124 contents, webstore_item_id, requestor_url, callback); | 124 contents, webstore_item_id, requestor_url, callback); |
125 } | 125 } |
126 }; | 126 }; |
127 | 127 |
128 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerTest, | 128 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerTest, |
129 CloseTabBeforeInstallConfirmation) { | 129 CloseTabBeforeInstallConfirmation) { |
130 GURL install_url = GenerateTestServerUrl(kAppDomain, "install.html"); | 130 GURL install_url = GenerateTestServerUrl(kAppDomain, "install.html"); |
131 ui_test_utils::NavigateToURL(browser(), install_url); | 131 ui_test_utils::NavigateToURL(browser(), install_url); |
132 WebContents* web_contents = | 132 WebContents* web_contents = |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerListenerTest, | 190 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerListenerTest, |
191 DownloadProgressListenerTest) { | 191 DownloadProgressListenerTest) { |
192 RunTest("download_progress_listener.html"); | 192 RunTest("download_progress_listener.html"); |
193 } | 193 } |
194 | 194 |
195 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerListenerTest, BothListenersTest) { | 195 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerListenerTest, BothListenersTest) { |
196 RunTest("both_listeners.html"); | 196 RunTest("both_listeners.html"); |
197 } | 197 } |
198 | 198 |
199 } // namespace extensions | 199 } // namespace extensions |
OLD | NEW |