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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 public: | 160 public: |
161 MockAbortExtensionInstallPrompt() : ExtensionInstallPrompt(NULL) {} | 161 MockAbortExtensionInstallPrompt() : ExtensionInstallPrompt(NULL) {} |
162 | 162 |
163 // Simulate a user abort on an extension installation. | 163 // Simulate a user abort on an extension installation. |
164 virtual void ConfirmInstall(Delegate* delegate, const Extension* extension) { | 164 virtual void ConfirmInstall(Delegate* delegate, const Extension* extension) { |
165 delegate->InstallUIAbort(true); | 165 delegate->InstallUIAbort(true); |
166 MessageLoopForUI::current()->Quit(); | 166 MessageLoopForUI::current()->Quit(); |
167 } | 167 } |
168 | 168 |
169 virtual void OnInstallSuccess(const Extension* extension, SkBitmap* icon) {} | 169 virtual void OnInstallSuccess(const Extension* extension, SkBitmap* icon) {} |
170 virtual void OnInstallFailure(const CrxInstallerError& error) {} | 170 virtual void OnInstallFailure(const extensions::CrxInstallerError& error) {} |
171 }; | 171 }; |
172 | 172 |
173 // Mock that simulates a permissions dialog where the user allows | 173 // Mock that simulates a permissions dialog where the user allows |
174 // installation. | 174 // installation. |
175 class MockAutoConfirmExtensionInstallPrompt : public ExtensionInstallPrompt { | 175 class MockAutoConfirmExtensionInstallPrompt : public ExtensionInstallPrompt { |
176 public: | 176 public: |
177 explicit MockAutoConfirmExtensionInstallPrompt(Browser* browser) | 177 explicit MockAutoConfirmExtensionInstallPrompt(Browser* browser) |
178 : ExtensionInstallPrompt(browser) {} | 178 : ExtensionInstallPrompt(browser) {} |
179 | 179 |
180 // Proceed without confirmation prompt. | 180 // Proceed without confirmation prompt. |
181 virtual void ConfirmInstall(Delegate* delegate, const Extension* extension) { | 181 virtual void ConfirmInstall(Delegate* delegate, const Extension* extension) { |
182 delegate->InstallUIProceed(); | 182 delegate->InstallUIProceed(); |
183 } | 183 } |
184 | 184 |
185 virtual void OnInstallSuccess(const Extension* extension, SkBitmap* icon) {} | 185 virtual void OnInstallSuccess(const Extension* extension, SkBitmap* icon) {} |
186 virtual void OnInstallFailure(const CrxInstallerError& error) {} | 186 virtual void OnInstallFailure(const extensions::CrxInstallerError& error) {} |
187 }; | 187 }; |
188 | 188 |
189 static DownloadManager* DownloadManagerForBrowser(Browser* browser) { | 189 static DownloadManager* DownloadManagerForBrowser(Browser* browser) { |
190 return BrowserContext::GetDownloadManager(browser->profile()); | 190 return BrowserContext::GetDownloadManager(browser->profile()); |
191 } | 191 } |
192 | 192 |
193 class TestRenderViewContextMenu : public RenderViewContextMenu { | 193 class TestRenderViewContextMenu : public RenderViewContextMenu { |
194 public: | 194 public: |
195 TestRenderViewContextMenu(WebContents* web_contents, | 195 TestRenderViewContextMenu(WebContents* web_contents, |
196 const content::ContextMenuParams& params) | 196 const content::ContextMenuParams& params) |
(...skipping 2253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2450 GetDownloads(browser(), &download_items); | 2450 GetDownloads(browser(), &download_items); |
2451 ASSERT_EQ(1u, download_items.size()); | 2451 ASSERT_EQ(1u, download_items.size()); |
2452 ASSERT_EQ(test_server()->GetURL("echoheader?Referer"), | 2452 ASSERT_EQ(test_server()->GetURL("echoheader?Referer"), |
2453 download_items[0]->GetOriginalUrl()); | 2453 download_items[0]->GetOriginalUrl()); |
2454 | 2454 |
2455 // Check that the file contains the expected referrer. | 2455 // Check that the file contains the expected referrer. |
2456 FilePath file(download_items[0]->GetFullPath()); | 2456 FilePath file(download_items[0]->GetFullPath()); |
2457 std::string expected_contents = test_server()->GetURL("").spec(); | 2457 std::string expected_contents = test_server()->GetURL("").spec(); |
2458 ASSERT_TRUE(VerifyFile(file, expected_contents, expected_contents.length())); | 2458 ASSERT_TRUE(VerifyFile(file, expected_contents, expected_contents.length())); |
2459 } | 2459 } |
OLD | NEW |