| 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 140 |
| 141 // Mock that simulates a permissions dialog where the user denies | 141 // Mock that simulates a permissions dialog where the user denies |
| 142 // permission to install. TODO(skerner): This could be shared with | 142 // permission to install. TODO(skerner): This could be shared with |
| 143 // extensions tests. Find a common place for this class. | 143 // extensions tests. Find a common place for this class. |
| 144 class MockAbortExtensionInstallPrompt : public ExtensionInstallPrompt { | 144 class MockAbortExtensionInstallPrompt : public ExtensionInstallPrompt { |
| 145 public: | 145 public: |
| 146 MockAbortExtensionInstallPrompt() : ExtensionInstallPrompt(NULL, NULL, NULL) { | 146 MockAbortExtensionInstallPrompt() : ExtensionInstallPrompt(NULL, NULL, NULL) { |
| 147 } | 147 } |
| 148 | 148 |
| 149 // Simulate a user abort on an extension installation. | 149 // Simulate a user abort on an extension installation. |
| 150 virtual void ConfirmInstall(Delegate* delegate, const Extension* extension) { | 150 virtual void ConfirmInstall(Delegate* delegate, |
| 151 const Extension* extension, |
| 152 const ShowDialogCallback& callback) { |
| 151 delegate->InstallUIAbort(true); | 153 delegate->InstallUIAbort(true); |
| 152 MessageLoopForUI::current()->Quit(); | 154 MessageLoopForUI::current()->Quit(); |
| 153 } | 155 } |
| 154 | 156 |
| 155 virtual void OnInstallSuccess(const Extension* extension, SkBitmap* icon) {} | 157 virtual void OnInstallSuccess(const Extension* extension, SkBitmap* icon) {} |
| 156 virtual void OnInstallFailure(const extensions::CrxInstallerError& error) {} | 158 virtual void OnInstallFailure(const extensions::CrxInstallerError& error) {} |
| 157 }; | 159 }; |
| 158 | 160 |
| 159 // Mock that simulates a permissions dialog where the user allows | 161 // Mock that simulates a permissions dialog where the user allows |
| 160 // installation. | 162 // installation. |
| 161 class MockAutoConfirmExtensionInstallPrompt : public ExtensionInstallPrompt { | 163 class MockAutoConfirmExtensionInstallPrompt : public ExtensionInstallPrompt { |
| 162 public: | 164 public: |
| 163 explicit MockAutoConfirmExtensionInstallPrompt( | 165 explicit MockAutoConfirmExtensionInstallPrompt( |
| 164 gfx::NativeWindow parent, | 166 gfx::NativeWindow parent, |
| 165 content::PageNavigator* navigator, | 167 content::PageNavigator* navigator, |
| 166 Profile* profile) | 168 Profile* profile) |
| 167 : ExtensionInstallPrompt(parent, navigator, profile) {} | 169 : ExtensionInstallPrompt(parent, navigator, profile) {} |
| 168 | 170 |
| 169 // Proceed without confirmation prompt. | 171 // Proceed without confirmation prompt. |
| 170 virtual void ConfirmInstall(Delegate* delegate, const Extension* extension) { | 172 virtual void ConfirmInstall(Delegate* delegate, |
| 173 const Extension* extension, |
| 174 const ShowDialogCallback& callback) { |
| 171 delegate->InstallUIProceed(); | 175 delegate->InstallUIProceed(); |
| 172 } | 176 } |
| 173 | 177 |
| 174 virtual void OnInstallSuccess(const Extension* extension, SkBitmap* icon) {} | 178 virtual void OnInstallSuccess(const Extension* extension, SkBitmap* icon) {} |
| 175 virtual void OnInstallFailure(const extensions::CrxInstallerError& error) {} | 179 virtual void OnInstallFailure(const extensions::CrxInstallerError& error) {} |
| 176 }; | 180 }; |
| 177 | 181 |
| 178 static DownloadManager* DownloadManagerForBrowser(Browser* browser) { | 182 static DownloadManager* DownloadManagerForBrowser(Browser* browser) { |
| 179 return BrowserContext::GetDownloadManager(browser->profile()); | 183 return BrowserContext::GetDownloadManager(browser->profile()); |
| 180 } | 184 } |
| (...skipping 2054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2235 GetDownloads(browser(), &download_items); | 2239 GetDownloads(browser(), &download_items); |
| 2236 ASSERT_EQ(1u, download_items.size()); | 2240 ASSERT_EQ(1u, download_items.size()); |
| 2237 ASSERT_EQ(test_server()->GetURL("echoheader?Referer"), | 2241 ASSERT_EQ(test_server()->GetURL("echoheader?Referer"), |
| 2238 download_items[0]->GetOriginalUrl()); | 2242 download_items[0]->GetOriginalUrl()); |
| 2239 | 2243 |
| 2240 // Check that the file contains the expected referrer. | 2244 // Check that the file contains the expected referrer. |
| 2241 FilePath file(download_items[0]->GetFullPath()); | 2245 FilePath file(download_items[0]->GetFullPath()); |
| 2242 std::string expected_contents = test_server()->GetURL("").spec(); | 2246 std::string expected_contents = test_server()->GetURL("").spec(); |
| 2243 ASSERT_TRUE(VerifyFile(file, expected_contents, expected_contents.length())); | 2247 ASSERT_TRUE(VerifyFile(file, expected_contents, expected_contents.length())); |
| 2244 } | 2248 } |
| OLD | NEW |