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

Side by Side Diff: chrome/browser/extensions/extension_install_prompt_test_helper.cc

Issue 1534123002: [Extensions] Migrate ExtensionInstallPrompt::Delegate to be a callback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/extensions/extension_install_prompt_test_helper.h"
6
7 #include "base/bind.h"
8 #include "base/callback_helpers.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 ExtensionInstallPromptTestHelper::ExtensionInstallPromptTestHelper() {}
12 ExtensionInstallPromptTestHelper::ExtensionInstallPromptTestHelper(
13 const base::Closure& quit_closure) : quit_closure_(quit_closure) {}
14 ExtensionInstallPromptTestHelper::~ExtensionInstallPromptTestHelper() {}
15
16 ExtensionInstallPrompt::DoneCallback
17 ExtensionInstallPromptTestHelper::GetCallback() {
18 return base::Bind(&ExtensionInstallPromptTestHelper::HandleResult,
19 base::Unretained(this));
20 }
21
22 ExtensionInstallPrompt::Result
23 ExtensionInstallPromptTestHelper::result() const {
24 if (!result_.get()) {
25 ADD_FAILURE() << "Result was never set!";
26 return ExtensionInstallPrompt::Result::ACCEPTED; // Avoid crashing.
27 }
28 return *result_;
29 }
30
31 void ExtensionInstallPromptTestHelper::HandleResult(
32 ExtensionInstallPrompt::Result result) {
33 if (result_.get())
34 ADD_FAILURE() << "HandleResult() called twice!";
35 if (!quit_closure_.is_null())
36 base::ResetAndReturn(&quit_closure_).Run();
37 result_.reset(new ExtensionInstallPrompt::Result(result));
38 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698