| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <sstream> | 5 #include <sstream> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 // Mock that simulates a permissions dialog where the user denies | 142 // Mock that simulates a permissions dialog where the user denies |
| 143 // permission to install. TODO(skerner): This could be shared with | 143 // permission to install. TODO(skerner): This could be shared with |
| 144 // extensions tests. Find a common place for this class. | 144 // extensions tests. Find a common place for this class. |
| 145 class MockAbortExtensionInstallPrompt : public ExtensionInstallPrompt { | 145 class MockAbortExtensionInstallPrompt : public ExtensionInstallPrompt { |
| 146 public: | 146 public: |
| 147 MockAbortExtensionInstallPrompt() : | 147 MockAbortExtensionInstallPrompt() : |
| 148 ExtensionInstallPrompt(NULL, NULL, NULL) { | 148 ExtensionInstallPrompt(NULL, NULL, NULL) { |
| 149 } | 149 } |
| 150 | 150 |
| 151 // Simulate a user abort on an extension installation. | 151 // Simulate a user abort on an extension installation. |
| 152 virtual void ConfirmInstall(Delegate* delegate, const Extension* extension) { | 152 virtual void ConfirmInstall(Delegate* delegate, |
| 153 const Extension* extension, |
| 154 const ShowDialogCallback& show_dialog_callback) { |
| 153 delegate->InstallUIAbort(true); | 155 delegate->InstallUIAbort(true); |
| 154 MessageLoopForUI::current()->Quit(); | 156 MessageLoopForUI::current()->Quit(); |
| 155 } | 157 } |
| 156 | 158 |
| 157 virtual void OnInstallSuccess(const Extension* extension, SkBitmap* icon) {} | 159 virtual void OnInstallSuccess(const Extension* extension, SkBitmap* icon) {} |
| 158 virtual void OnInstallFailure(const extensions::CrxInstallerError& error) {} | 160 virtual void OnInstallFailure(const extensions::CrxInstallerError& error) {} |
| 159 }; | 161 }; |
| 160 | 162 |
| 161 // Mock that simulates a permissions dialog where the user allows | 163 // Mock that simulates a permissions dialog where the user allows |
| 162 // installation. | 164 // installation. |
| 163 class MockAutoConfirmExtensionInstallPrompt : public ExtensionInstallPrompt { | 165 class MockAutoConfirmExtensionInstallPrompt : public ExtensionInstallPrompt { |
| 164 public: | 166 public: |
| 165 explicit MockAutoConfirmExtensionInstallPrompt( | 167 explicit MockAutoConfirmExtensionInstallPrompt( |
| 166 gfx::NativeWindow parent, | 168 gfx::NativeWindow parent, |
| 167 content::PageNavigator* navigator, | 169 content::PageNavigator* navigator, |
| 168 Profile* profile) | 170 Profile* profile) |
| 169 : ExtensionInstallPrompt(parent, navigator, profile) {} | 171 : ExtensionInstallPrompt(parent, navigator, profile) {} |
| 170 | 172 |
| 171 // Proceed without confirmation prompt. | 173 // Proceed without confirmation prompt. |
| 172 virtual void ConfirmInstall(Delegate* delegate, const Extension* extension) { | 174 virtual void ConfirmInstall(Delegate* delegate, |
| 175 const Extension* extension, |
| 176 const ShowDialogCallback& show_dialog_callback) { |
| 173 delegate->InstallUIProceed(); | 177 delegate->InstallUIProceed(); |
| 174 } | 178 } |
| 175 | 179 |
| 176 virtual void OnInstallSuccess(const Extension* extension, SkBitmap* icon) {} | 180 virtual void OnInstallSuccess(const Extension* extension, SkBitmap* icon) {} |
| 177 virtual void OnInstallFailure(const extensions::CrxInstallerError& error) {} | 181 virtual void OnInstallFailure(const extensions::CrxInstallerError& error) {} |
| 178 }; | 182 }; |
| 179 | 183 |
| 180 static DownloadManager* DownloadManagerForBrowser(Browser* browser) { | 184 static DownloadManager* DownloadManagerForBrowser(Browser* browser) { |
| 181 return BrowserContext::GetDownloadManager(browser->profile()); | 185 return BrowserContext::GetDownloadManager(browser->profile()); |
| 182 } | 186 } |
| (...skipping 2084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2267 scoped_ptr<DownloadUrlParameters> params( | 2271 scoped_ptr<DownloadUrlParameters> params( |
| 2268 DownloadUrlParameters::FromWebContents(web_contents, url, save_info)); | 2272 DownloadUrlParameters::FromWebContents(web_contents, url, save_info)); |
| 2269 params->set_callback( | 2273 params->set_callback( |
| 2270 base::Bind(&SetHiddenDownloadCallback, download_manager)); | 2274 base::Bind(&SetHiddenDownloadCallback, download_manager)); |
| 2271 download_manager->DownloadUrl(params.Pass()); | 2275 download_manager->DownloadUrl(params.Pass()); |
| 2272 observer->WaitForFinished(); | 2276 observer->WaitForFinished(); |
| 2273 | 2277 |
| 2274 // Verify that download shelf is not shown. | 2278 // Verify that download shelf is not shown. |
| 2275 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); | 2279 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); |
| 2276 } | 2280 } |
| OLD | NEW |