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.
5 #include "chrome/browser/ui/website_settings/mock_permission_bubble_view.h"
8 #include "base/run_loop.h"
9 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h"
11 MockPermissionBubbleView::~MockPermissionBubbleView() {}
14 scoped_ptr
<PermissionBubbleView
> MockPermissionBubbleView::CreateBrowserMock(
16 return make_scoped_ptr(new MockPermissionBubbleView(true));
20 scoped_ptr
<PermissionBubbleView
> MockPermissionBubbleView::CreateUnitMock(
22 return make_scoped_ptr(new MockPermissionBubbleView(false));
26 MockPermissionBubbleView
* MockPermissionBubbleView::GetFrom(
27 PermissionBubbleManager
* manager
) {
28 return static_cast<MockPermissionBubbleView
*>(manager
->view_
.get());
32 void MockPermissionBubbleView::SetFactory(PermissionBubbleManager
* manager
,
33 bool is_browser_test
) {
34 if (is_browser_test
) {
35 manager
->view_factory_
=
36 base::Bind(&MockPermissionBubbleView::CreateBrowserMock
);
38 manager
->view_factory_
=
39 base::Bind(&MockPermissionBubbleView::CreateUnitMock
);
41 manager
->HideBubble();
44 void MockPermissionBubbleView::SetDelegate(Delegate
* delegate
) {
48 void MockPermissionBubbleView::Show(
49 const std::vector
<PermissionBubbleRequest
*>& requests
,
50 const std::vector
<bool>& accept_state
) {
53 requests_count_
+= requests
.size();
54 permission_requests_
= requests
;
55 permission_states_
= accept_state
;
57 base::MessageLoopForUI::current()->Quit();
60 void MockPermissionBubbleView::Hide() {
64 bool MockPermissionBubbleView::IsVisible() {
68 void MockPermissionBubbleView::UpdateAnchorPosition() {
71 gfx::NativeWindow
MockPermissionBubbleView::GetNativeWindow() {
75 bool MockPermissionBubbleView::CanAcceptRequestUpdate() {
76 return can_accept_updates_
;
79 void MockPermissionBubbleView::Accept() {
83 void MockPermissionBubbleView::Deny() {
87 void MockPermissionBubbleView::Close() {
91 void MockPermissionBubbleView::Clear() {
93 can_accept_updates_
= true;
95 permission_requests_
.clear();
96 permission_states_
.clear();
99 void MockPermissionBubbleView::SetBrowserTest(bool browser_test
) {
100 browser_test_
= browser_test
;
103 MockPermissionBubbleView::MockPermissionBubbleView(bool browser_test
)
107 can_accept_updates_(true),
109 browser_test_(browser_test
) {}