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