Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / ui / website_settings / mock_permission_bubble_request.cc
blob0cfd934d2aa8ee0c32fe43b41e1d3025fef86fb3
1 // Copyright 2014 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_request.h"
7 #include "base/strings/string16.h"
8 #include "base/strings/utf_string_conversions.h"
9 #include "grit/theme_resources.h"
11 MockPermissionBubbleRequest::MockPermissionBubbleRequest()
12 : granted_(false),
13 cancelled_(false),
14 finished_(false),
15 user_gesture_(false) {
16 text_ = base::ASCIIToUTF16("test");
17 accept_label_ = base::ASCIIToUTF16("button");
18 deny_label_ = base::ASCIIToUTF16("button");
19 hostname_ = GURL("http://www.google.com");
22 MockPermissionBubbleRequest::MockPermissionBubbleRequest(
23 const std::string& text)
24 : granted_(false),
25 cancelled_(false),
26 finished_(false),
27 user_gesture_(false) {
28 text_ = base::UTF8ToUTF16(text);
29 accept_label_ = base::ASCIIToUTF16("button");
30 deny_label_ = base::ASCIIToUTF16("button");
31 hostname_ = GURL("http://www.google.com");
34 MockPermissionBubbleRequest::MockPermissionBubbleRequest(
35 const std::string& text,
36 const GURL& url)
37 : granted_(false),
38 cancelled_(false),
39 finished_(false),
40 user_gesture_(false) {
41 text_ = base::UTF8ToUTF16(text);
42 accept_label_ = base::ASCIIToUTF16("button");
43 deny_label_ = base::ASCIIToUTF16("button");
44 hostname_ = url;
47 MockPermissionBubbleRequest::MockPermissionBubbleRequest(
48 const std::string& text,
49 const std::string& accept_label,
50 const std::string& deny_label)
51 : granted_(false),
52 cancelled_(false),
53 finished_(false),
54 user_gesture_(false) {
55 text_ = base::UTF8ToUTF16(text);
56 accept_label_ = base::UTF8ToUTF16(accept_label);
57 deny_label_ = base::UTF8ToUTF16(deny_label);
58 hostname_ = GURL("http://www.google.com");
61 MockPermissionBubbleRequest::~MockPermissionBubbleRequest() {}
63 int MockPermissionBubbleRequest::GetIconId() const {
64 // Use a valid icon ID to support UI tests.
65 return IDR_INFOBAR_MEDIA_STREAM_CAMERA;
68 base::string16 MockPermissionBubbleRequest::GetMessageText() const {
69 return text_;
72 base::string16 MockPermissionBubbleRequest::GetMessageTextFragment() const {
73 return text_;
76 bool MockPermissionBubbleRequest::HasUserGesture() const {
77 return user_gesture_;
80 GURL MockPermissionBubbleRequest::GetRequestingHostname() const {
81 return hostname_;
84 void MockPermissionBubbleRequest::PermissionGranted() {
85 granted_ = true;
88 void MockPermissionBubbleRequest::PermissionDenied() {
89 granted_ = false;
92 void MockPermissionBubbleRequest::Cancelled() {
93 granted_ = false;
94 cancelled_ = true;
97 void MockPermissionBubbleRequest::RequestFinished() {
98 finished_ = true;
101 bool MockPermissionBubbleRequest::granted() {
102 return granted_;
105 bool MockPermissionBubbleRequest::cancelled() {
106 return cancelled_;
109 bool MockPermissionBubbleRequest::finished() {
110 return finished_;
113 void MockPermissionBubbleRequest::SetHasUserGesture() {
114 user_gesture_ = true;