OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/browser/infobars/infobar_responder.h" | 5 #include "chrome/browser/infobars/infobar_responder.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 infobar_service_->RemoveObserver(this); | 24 infobar_service_->RemoveObserver(this); |
25 } | 25 } |
26 | 26 |
27 void InfoBarResponder::OnInfoBarAdded(infobars::InfoBar* infobar) { | 27 void InfoBarResponder::OnInfoBarAdded(infobars::InfoBar* infobar) { |
28 infobar_service_->RemoveObserver(this); | 28 infobar_service_->RemoveObserver(this); |
29 ConfirmInfoBarDelegate* delegate = | 29 ConfirmInfoBarDelegate* delegate = |
30 infobar->delegate()->AsConfirmInfoBarDelegate(); | 30 infobar->delegate()->AsConfirmInfoBarDelegate(); |
31 DCHECK(delegate); | 31 DCHECK(delegate); |
32 | 32 |
33 base::ThreadTaskRunnerHandle::Get()->PostTask( | 33 base::ThreadTaskRunnerHandle::Get()->PostTask( |
34 FROM_HERE, | 34 FROM_HERE, base::BindOnce(&InfoBarResponder::Respond, |
35 base::Bind(&InfoBarResponder::Respond, base::Unretained(this), delegate)); | 35 base::Unretained(this), delegate)); |
36 } | 36 } |
37 | 37 |
38 void InfoBarResponder::OnInfoBarReplaced(infobars::InfoBar* old_infobar, | 38 void InfoBarResponder::OnInfoBarReplaced(infobars::InfoBar* old_infobar, |
39 infobars::InfoBar* new_infobar) { | 39 infobars::InfoBar* new_infobar) { |
40 OnInfoBarAdded(new_infobar); | 40 OnInfoBarAdded(new_infobar); |
41 } | 41 } |
42 | 42 |
43 void InfoBarResponder::Respond(ConfirmInfoBarDelegate* delegate) { | 43 void InfoBarResponder::Respond(ConfirmInfoBarDelegate* delegate) { |
44 switch (response_) { | 44 switch (response_) { |
45 case ACCEPT: | 45 case ACCEPT: |
46 delegate->Accept(); | 46 delegate->Accept(); |
47 break; | 47 break; |
48 case DENY: | 48 case DENY: |
49 delegate->Cancel(); | 49 delegate->Cancel(); |
50 break; | 50 break; |
51 case DISMISS: | 51 case DISMISS: |
52 delegate->InfoBarDismissed(); | 52 delegate->InfoBarDismissed(); |
53 break; | 53 break; |
54 } | 54 } |
55 } | 55 } |
OLD | NEW |