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

Side by Side Diff: chrome/browser/infobars/infobar_responder.cc

Issue 1100953002: Move InfoBarResponder into its own file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments. Created 5 years, 8 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/infobars/infobar_responder.h"
6
7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h"
9 #include "chrome/browser/infobars/infobar_service.h"
10 #include "components/infobars/core/confirm_infobar_delegate.h"
11 #include "components/infobars/core/infobar.h"
12
13 InfoBarResponder::InfoBarResponder(InfoBarService* infobar_service,
14 bool should_accept)
15 : infobar_service_(infobar_service), should_accept_(should_accept) {
16 infobar_service_->AddObserver(this);
17 }
18
19 InfoBarResponder::~InfoBarResponder() {
20 infobar_service_->RemoveObserver(this);
Peter Kasting 2015/04/23 22:54:48 Nit: Might want to comment: "This is safe even if
Michael van Ouwerkerk 2015/04/24 11:16:38 Done.
21 }
22
23 void InfoBarResponder::OnInfoBarAdded(infobars::InfoBar* infobar) {
24 infobar_service_->RemoveObserver(this);
25 ConfirmInfoBarDelegate* delegate =
26 infobar->delegate()->AsConfirmInfoBarDelegate();
27 DCHECK(delegate);
28
29 base::MessageLoop::current()->PostTask(
30 FROM_HERE,
31 base::Bind(&InfoBarResponder::Respond, base::Unretained(this), delegate));
32 }
33
34 void InfoBarResponder::Respond(ConfirmInfoBarDelegate* delegate) {
35 if (should_accept_)
36 delegate->Accept();
37 else
38 delegate->Cancel();
39 }
OLDNEW
« no previous file with comments | « chrome/browser/infobars/infobar_responder.h ('k') | chrome/browser/notifications/platform_notification_service_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698