1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/website_settings/mock_permission_bubble_request.h"
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "grit/theme_resources.h"
MockPermissionBubbleRequest::MockPermissionBubbleRequest()
: granted_(false),
cancelled_(false),
finished_(false),
user_gesture_(false) {
text_ = base::ASCIIToUTF16("test");
accept_label_ = base::ASCIIToUTF16("button");
deny_label_ = base::ASCIIToUTF16("button");
hostname_ = GURL("http://www.google.com");
}
MockPermissionBubbleRequest::MockPermissionBubbleRequest(
const std::string& text)
: granted_(false),
cancelled_(false),
finished_(false),
user_gesture_(false) {
text_ = base::UTF8ToUTF16(text);
accept_label_ = base::ASCIIToUTF16("button");
deny_label_ = base::ASCIIToUTF16("button");
hostname_ = GURL("http://www.google.com");
}
MockPermissionBubbleRequest::MockPermissionBubbleRequest(
const std::string& text,
const GURL& url)
: granted_(false),
cancelled_(false),
finished_(false),
user_gesture_(false) {
text_ = base::UTF8ToUTF16(text);
accept_label_ = base::ASCIIToUTF16("button");
deny_label_ = base::ASCIIToUTF16("button");
hostname_ = url;
}
MockPermissionBubbleRequest::MockPermissionBubbleRequest(
const std::string& text,
const std::string& accept_label,
const std::string& deny_label)
: granted_(false),
cancelled_(false),
finished_(false),
user_gesture_(false) {
text_ = base::UTF8ToUTF16(text);
accept_label_ = base::UTF8ToUTF16(accept_label);
deny_label_ = base::UTF8ToUTF16(deny_label);
hostname_ = GURL("http://www.google.com");
}
MockPermissionBubbleRequest::~MockPermissionBubbleRequest() {}
int MockPermissionBubbleRequest::GetIconID() const {
// Use a valid icon ID to support UI tests.
return IDR_INFOBAR_MEDIA_STREAM_CAMERA;
}
base::string16 MockPermissionBubbleRequest::GetMessageText() const {
return text_;
}
base::string16 MockPermissionBubbleRequest::GetMessageTextFragment() const {
return text_;
}
bool MockPermissionBubbleRequest::HasUserGesture() const {
return user_gesture_;
}
GURL MockPermissionBubbleRequest::GetRequestingHostname() const {
return hostname_;
}
void MockPermissionBubbleRequest::PermissionGranted() {
granted_ = true;
}
void MockPermissionBubbleRequest::PermissionDenied() {
granted_ = false;
}
void MockPermissionBubbleRequest::Cancelled() {
granted_ = false;
cancelled_ = true;
}
void MockPermissionBubbleRequest::RequestFinished() {
finished_ = true;
}
bool MockPermissionBubbleRequest::granted() {
return granted_;
}
bool MockPermissionBubbleRequest::cancelled() {
return cancelled_;
}
bool MockPermissionBubbleRequest::finished() {
return finished_;
}
void MockPermissionBubbleRequest::SetHasUserGesture() {
user_gesture_ = true;
}
|