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

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: Add comment. 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 // This is safe even if we were already removed as an observer in
21 // OnInfoBarAdded().
22 infobar_service_->RemoveObserver(this);
23 }
24
25 void InfoBarResponder::OnInfoBarAdded(infobars::InfoBar* infobar) {
26 infobar_service_->RemoveObserver(this);
27 ConfirmInfoBarDelegate* delegate =
28 infobar->delegate()->AsConfirmInfoBarDelegate();
29 DCHECK(delegate);
30
31 base::MessageLoop::current()->PostTask(
32 FROM_HERE,
33 base::Bind(&InfoBarResponder::Respond, base::Unretained(this), delegate));
34 }
35
36 void InfoBarResponder::Respond(ConfirmInfoBarDelegate* delegate) {
37 if (should_accept_)
38 delegate->Accept();
39 else
40 delegate->Cancel();
41 }
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