OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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/ui/website_settings/mock_permission_bubble_request.h" | 5 #include "chrome/browser/ui/website_settings/mock_permission_bubble_request.h" |
6 | 6 |
7 #include "base/strings/string16.h" | 7 #include "base/strings/string16.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "grit/theme_resources.h" | 9 #include "grit/theme_resources.h" |
10 | 10 |
11 MockPermissionBubbleRequest::MockPermissionBubbleRequest() | 11 MockPermissionBubbleRequest::MockPermissionBubbleRequest() |
12 : granted_(false), | 12 : granted_(false), |
13 cancelled_(false), | 13 cancelled_(false), |
14 finished_(false), | 14 finished_(false), |
15 user_gesture_(false) { | 15 user_gesture_(false) { |
16 text_ = base::ASCIIToUTF16("test"); | 16 text_ = base::ASCIIToUTF16("test"); |
17 accept_label_ = base::ASCIIToUTF16("button"); | 17 accept_label_ = base::ASCIIToUTF16("button"); |
18 deny_label_ = base::ASCIIToUTF16("button"); | 18 deny_label_ = base::ASCIIToUTF16("button"); |
19 hostname_ = GURL("http://www.google.com"); | 19 origin_ = GURL("http://www.google.com"); |
20 } | 20 } |
21 | 21 |
22 MockPermissionBubbleRequest::MockPermissionBubbleRequest( | 22 MockPermissionBubbleRequest::MockPermissionBubbleRequest( |
23 const std::string& text) | 23 const std::string& text) |
24 : granted_(false), | 24 : granted_(false), |
25 cancelled_(false), | 25 cancelled_(false), |
26 finished_(false), | 26 finished_(false), |
27 user_gesture_(false) { | 27 user_gesture_(false) { |
28 text_ = base::UTF8ToUTF16(text); | 28 text_ = base::UTF8ToUTF16(text); |
29 accept_label_ = base::ASCIIToUTF16("button"); | 29 accept_label_ = base::ASCIIToUTF16("button"); |
30 deny_label_ = base::ASCIIToUTF16("button"); | 30 deny_label_ = base::ASCIIToUTF16("button"); |
31 hostname_ = GURL("http://www.google.com"); | 31 origin_ = GURL("http://www.google.com"); |
32 } | 32 } |
33 | 33 |
34 MockPermissionBubbleRequest::MockPermissionBubbleRequest( | 34 MockPermissionBubbleRequest::MockPermissionBubbleRequest( |
35 const std::string& text, | 35 const std::string& text, |
36 const GURL& url) | 36 const GURL& url) |
37 : granted_(false), | 37 : granted_(false), |
38 cancelled_(false), | 38 cancelled_(false), |
39 finished_(false), | 39 finished_(false), |
40 user_gesture_(false) { | 40 user_gesture_(false) { |
41 text_ = base::UTF8ToUTF16(text); | 41 text_ = base::UTF8ToUTF16(text); |
42 accept_label_ = base::ASCIIToUTF16("button"); | 42 accept_label_ = base::ASCIIToUTF16("button"); |
43 deny_label_ = base::ASCIIToUTF16("button"); | 43 deny_label_ = base::ASCIIToUTF16("button"); |
44 hostname_ = url; | 44 origin_ = url.GetOrigin(); |
45 } | 45 } |
46 | 46 |
47 MockPermissionBubbleRequest::MockPermissionBubbleRequest( | 47 MockPermissionBubbleRequest::MockPermissionBubbleRequest( |
48 const std::string& text, | 48 const std::string& text, |
49 const std::string& accept_label, | 49 const std::string& accept_label, |
50 const std::string& deny_label) | 50 const std::string& deny_label) |
51 : granted_(false), | 51 : granted_(false), |
52 cancelled_(false), | 52 cancelled_(false), |
53 finished_(false), | 53 finished_(false), |
54 user_gesture_(false) { | 54 user_gesture_(false) { |
55 text_ = base::UTF8ToUTF16(text); | 55 text_ = base::UTF8ToUTF16(text); |
56 accept_label_ = base::UTF8ToUTF16(accept_label); | 56 accept_label_ = base::UTF8ToUTF16(accept_label); |
57 deny_label_ = base::UTF8ToUTF16(deny_label); | 57 deny_label_ = base::UTF8ToUTF16(deny_label); |
58 hostname_ = GURL("http://www.google.com"); | 58 origin_ = GURL("http://www.google.com"); |
59 } | 59 } |
60 | 60 |
61 MockPermissionBubbleRequest::~MockPermissionBubbleRequest() {} | 61 MockPermissionBubbleRequest::~MockPermissionBubbleRequest() {} |
62 | 62 |
63 int MockPermissionBubbleRequest::GetIconId() const { | 63 int MockPermissionBubbleRequest::GetIconId() const { |
64 // Use a valid icon ID to support UI tests. | 64 // Use a valid icon ID to support UI tests. |
65 return IDR_INFOBAR_MEDIA_STREAM_CAMERA; | 65 return IDR_INFOBAR_MEDIA_STREAM_CAMERA; |
66 } | 66 } |
67 | 67 |
68 base::string16 MockPermissionBubbleRequest::GetMessageText() const { | 68 base::string16 MockPermissionBubbleRequest::GetMessageText() const { |
69 return text_; | 69 return text_; |
70 } | 70 } |
71 | 71 |
72 base::string16 MockPermissionBubbleRequest::GetMessageTextFragment() const { | 72 base::string16 MockPermissionBubbleRequest::GetMessageTextFragment() const { |
73 return text_; | 73 return text_; |
74 } | 74 } |
75 | 75 |
76 bool MockPermissionBubbleRequest::HasUserGesture() const { | 76 bool MockPermissionBubbleRequest::HasUserGesture() const { |
77 return user_gesture_; | 77 return user_gesture_; |
78 } | 78 } |
79 | 79 |
80 GURL MockPermissionBubbleRequest::GetRequestingHostname() const { | 80 GURL MockPermissionBubbleRequest::GetOrigin() const { |
81 return hostname_; | 81 return origin_; |
82 } | 82 } |
83 | 83 |
84 void MockPermissionBubbleRequest::PermissionGranted() { | 84 void MockPermissionBubbleRequest::PermissionGranted() { |
85 granted_ = true; | 85 granted_ = true; |
86 } | 86 } |
87 | 87 |
88 void MockPermissionBubbleRequest::PermissionDenied() { | 88 void MockPermissionBubbleRequest::PermissionDenied() { |
89 granted_ = false; | 89 granted_ = false; |
90 } | 90 } |
91 | 91 |
(...skipping 14 matching lines...) Expand all Loading... |
106 return cancelled_; | 106 return cancelled_; |
107 } | 107 } |
108 | 108 |
109 bool MockPermissionBubbleRequest::finished() { | 109 bool MockPermissionBubbleRequest::finished() { |
110 return finished_; | 110 return finished_; |
111 } | 111 } |
112 | 112 |
113 void MockPermissionBubbleRequest::SetHasUserGesture() { | 113 void MockPermissionBubbleRequest::SetHasUserGesture() { |
114 user_gesture_ = true; | 114 user_gesture_ = true; |
115 } | 115 } |
OLD | NEW |