Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: chrome/browser/download/download_browsertest.cc

Issue 11087071: Making ShowExtensionInstallDialog a callback (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address review comments Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 scoped_refptr<ExtensionInstallDialog> dialog) {
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 scoped_refptr<ExtensionInstallDialog> dialog) {
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 2054 matching lines...) Expand 10 before | Expand all | Expand 10 after
2237 GetDownloads(browser(), &download_items); 2241 GetDownloads(browser(), &download_items);
2238 ASSERT_EQ(1u, download_items.size()); 2242 ASSERT_EQ(1u, download_items.size());
2239 ASSERT_EQ(test_server()->GetURL("echoheader?Referer"), 2243 ASSERT_EQ(test_server()->GetURL("echoheader?Referer"),
2240 download_items[0]->GetOriginalUrl()); 2244 download_items[0]->GetOriginalUrl());
2241 2245
2242 // Check that the file contains the expected referrer. 2246 // Check that the file contains the expected referrer.
2243 FilePath file(download_items[0]->GetFullPath()); 2247 FilePath file(download_items[0]->GetFullPath());
2244 std::string expected_contents = test_server()->GetURL("").spec(); 2248 std::string expected_contents = test_server()->GetURL("").spec();
2245 ASSERT_TRUE(VerifyFile(file, expected_contents, expected_contents.length())); 2249 ASSERT_TRUE(VerifyFile(file, expected_contents, expected_contents.length()));
2246 } 2250 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698