| 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 // Mock that simulates a permissions dialog where the user denies | 137 // Mock that simulates a permissions dialog where the user denies |
| 138 // permission to install. TODO(skerner): This could be shared with | 138 // permission to install. TODO(skerner): This could be shared with |
| 139 // extensions tests. Find a common place for this class. | 139 // extensions tests. Find a common place for this class. |
| 140 class MockAbortExtensionInstallPrompt : public ExtensionInstallPrompt { | 140 class MockAbortExtensionInstallPrompt : public ExtensionInstallPrompt { |
| 141 public: | 141 public: |
| 142 MockAbortExtensionInstallPrompt() : | 142 MockAbortExtensionInstallPrompt() : |
| 143 ExtensionInstallPrompt(NULL) { | 143 ExtensionInstallPrompt(NULL) { |
| 144 } | 144 } |
| 145 | 145 |
| 146 // Simulate a user abort on an extension installation. | 146 // Simulate a user abort on an extension installation. |
| 147 virtual void ConfirmInstall(Delegate* delegate, | 147 virtual void ConfirmInstall( |
| 148 const Extension* extension, | 148 Delegate* delegate, |
| 149 const ShowDialogCallback& show_dialog_callback) { | 149 const Extension* extension, |
| 150 const ShowDialogCallback& show_dialog_callback) OVERRIDE { |
| 150 delegate->InstallUIAbort(true); | 151 delegate->InstallUIAbort(true); |
| 151 MessageLoopForUI::current()->Quit(); | 152 MessageLoopForUI::current()->Quit(); |
| 152 } | 153 } |
| 153 | 154 |
| 154 virtual void OnInstallSuccess(const Extension* extension, SkBitmap* icon) {} | 155 virtual void OnInstallSuccess(const Extension* extension, |
| 155 virtual void OnInstallFailure(const extensions::CrxInstallerError& error) {} | 156 SkBitmap* icon) OVERRIDE { |
| 157 } |
| 158 virtual void OnInstallFailure( |
| 159 const extensions::CrxInstallerError& error) OVERRIDE { |
| 160 } |
| 156 }; | 161 }; |
| 157 | 162 |
| 158 // Mock that simulates a permissions dialog where the user allows | 163 // Mock that simulates a permissions dialog where the user allows |
| 159 // installation. | 164 // installation. |
| 160 class MockAutoConfirmExtensionInstallPrompt : public ExtensionInstallPrompt { | 165 class MockAutoConfirmExtensionInstallPrompt : public ExtensionInstallPrompt { |
| 161 public: | 166 public: |
| 162 explicit MockAutoConfirmExtensionInstallPrompt( | 167 explicit MockAutoConfirmExtensionInstallPrompt( |
| 163 content::WebContents* web_contents) | 168 content::WebContents* web_contents) |
| 164 : ExtensionInstallPrompt(web_contents) {} | 169 : ExtensionInstallPrompt(web_contents) {} |
| 165 | 170 |
| 166 // Proceed without confirmation prompt. | 171 // Proceed without confirmation prompt. |
| 167 virtual void ConfirmInstall(Delegate* delegate, | 172 virtual void ConfirmInstall( |
| 168 const Extension* extension, | 173 Delegate* delegate, |
| 169 const ShowDialogCallback& show_dialog_callback) { | 174 const Extension* extension, |
| 175 const ShowDialogCallback& show_dialog_callback) OVERRIDE { |
| 170 delegate->InstallUIProceed(); | 176 delegate->InstallUIProceed(); |
| 171 } | 177 } |
| 172 | 178 |
| 173 virtual void OnInstallSuccess(const Extension* extension, SkBitmap* icon) {} | 179 virtual void OnInstallSuccess(const Extension* extension, |
| 174 virtual void OnInstallFailure(const extensions::CrxInstallerError& error) {} | 180 SkBitmap* icon) OVERRIDE { |
| 181 } |
| 182 virtual void OnInstallFailure( |
| 183 const extensions::CrxInstallerError& error) OVERRIDE { |
| 184 } |
| 175 }; | 185 }; |
| 176 | 186 |
| 177 static DownloadManager* DownloadManagerForBrowser(Browser* browser) { | 187 static DownloadManager* DownloadManagerForBrowser(Browser* browser) { |
| 178 return BrowserContext::GetDownloadManager(browser->profile()); | 188 return BrowserContext::GetDownloadManager(browser->profile()); |
| 179 } | 189 } |
| 180 | 190 |
| 181 class TestRenderViewContextMenu : public RenderViewContextMenu { | 191 class TestRenderViewContextMenu : public RenderViewContextMenu { |
| 182 public: | 192 public: |
| 183 TestRenderViewContextMenu(WebContents* web_contents, | 193 TestRenderViewContextMenu(WebContents* web_contents, |
| 184 const content::ContextMenuParams& params) | 194 const content::ContextMenuParams& params) |
| 185 : RenderViewContextMenu(web_contents, params) { | 195 : RenderViewContextMenu(web_contents, params) { |
| 186 } | 196 } |
| 187 virtual ~TestRenderViewContextMenu() {} | 197 virtual ~TestRenderViewContextMenu() {} |
| 188 | 198 |
| 189 private: | 199 private: |
| 190 virtual void PlatformInit() {} | 200 virtual void PlatformInit() OVERRIDE {} |
| 191 virtual void PlatformCancel() {} | 201 virtual void PlatformCancel() OVERRIDE {} |
| 192 virtual bool GetAcceleratorForCommandId(int, ui::Accelerator*) { | 202 virtual bool GetAcceleratorForCommandId(int, ui::Accelerator*) OVERRIDE { |
| 193 return false; | 203 return false; |
| 194 } | 204 } |
| 195 | 205 |
| 196 DISALLOW_COPY_AND_ASSIGN(TestRenderViewContextMenu); | 206 DISALLOW_COPY_AND_ASSIGN(TestRenderViewContextMenu); |
| 197 }; | 207 }; |
| 198 | 208 |
| 199 bool WasAutoOpened(DownloadItem* item) { | 209 bool WasAutoOpened(DownloadItem* item) { |
| 200 return item->GetAutoOpened(); | 210 return item->GetAutoOpened(); |
| 201 } | 211 } |
| 202 | 212 |
| (...skipping 2194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2397 browser()->tab_strip_model()->GetActiveWebContents(); | 2407 browser()->tab_strip_model()->GetActiveWebContents(); |
| 2398 scoped_ptr<DownloadUrlParameters> params( | 2408 scoped_ptr<DownloadUrlParameters> params( |
| 2399 DownloadUrlParameters::FromWebContents(web_contents, url)); | 2409 DownloadUrlParameters::FromWebContents(web_contents, url)); |
| 2400 params->set_callback(base::Bind(&SetHiddenDownloadCallback)); | 2410 params->set_callback(base::Bind(&SetHiddenDownloadCallback)); |
| 2401 download_manager->DownloadUrl(params.Pass()); | 2411 download_manager->DownloadUrl(params.Pass()); |
| 2402 observer->WaitForFinished(); | 2412 observer->WaitForFinished(); |
| 2403 | 2413 |
| 2404 // Verify that download shelf is not shown. | 2414 // Verify that download shelf is not shown. |
| 2405 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); | 2415 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); |
| 2406 } | 2416 } |
| OLD | NEW |