| 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/permissions/mock_permission_request.h" | 5 #include "chrome/browser/permissions/mock_permission_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 MockPermissionRequest::MockPermissionRequest() | 11 MockPermissionRequest::MockPermissionRequest() |
| 12 : MockPermissionRequest("test", | 12 : MockPermissionRequest("test", |
| 13 "button", | 13 "button", |
| 14 "button", | 14 "button", |
| 15 GURL("http://www.google.com"), | 15 GURL("http://www.google.com"), |
| 16 PermissionRequestType::UNKNOWN) {} | 16 PermissionRequestType::UNKNOWN, |
| 17 PermissionRequestGestureType::UNKNOWN) {} |
| 17 | 18 |
| 18 MockPermissionRequest::MockPermissionRequest( | 19 MockPermissionRequest::MockPermissionRequest( |
| 19 const std::string& text) | 20 const std::string& text) |
| 20 : MockPermissionRequest(text, | 21 : MockPermissionRequest(text, |
| 21 "button", | 22 "button", |
| 22 "button", | 23 "button", |
| 23 GURL("http://www.google.com"), | 24 GURL("http://www.google.com"), |
| 24 PermissionRequestType::UNKNOWN) {} | 25 PermissionRequestType::UNKNOWN, |
| 26 PermissionRequestGestureType::UNKNOWN) {} |
| 25 | 27 |
| 26 MockPermissionRequest::MockPermissionRequest( | 28 MockPermissionRequest::MockPermissionRequest( |
| 27 const std::string& text, PermissionRequestType request_type) | 29 const std::string& text, |
| 30 PermissionRequestType request_type, |
| 31 PermissionRequestGestureType gesture_type) |
| 28 : MockPermissionRequest(text, | 32 : MockPermissionRequest(text, |
| 29 "button", | 33 "button", |
| 30 "button", | 34 "button", |
| 31 GURL("http://www.google.com"), | 35 GURL("http://www.google.com"), |
| 32 request_type) {} | 36 request_type, |
| 37 gesture_type) {} |
| 33 | 38 |
| 34 MockPermissionRequest::MockPermissionRequest( | 39 MockPermissionRequest::MockPermissionRequest( |
| 35 const std::string& text, | 40 const std::string& text, |
| 36 const GURL& url) | 41 const GURL& url) |
| 37 : MockPermissionRequest(text, | 42 : MockPermissionRequest(text, |
| 38 "button", | 43 "button", |
| 39 "button", | 44 "button", |
| 40 url, | 45 url, |
| 41 PermissionRequestType::UNKNOWN) {} | 46 PermissionRequestType::UNKNOWN, |
| 47 PermissionRequestGestureType::UNKNOWN) {} |
| 42 | 48 |
| 43 MockPermissionRequest::MockPermissionRequest( | 49 MockPermissionRequest::MockPermissionRequest( |
| 44 const std::string& text, | 50 const std::string& text, |
| 45 const std::string& accept_label, | 51 const std::string& accept_label, |
| 46 const std::string& deny_label) | 52 const std::string& deny_label) |
| 47 : MockPermissionRequest(text, | 53 : MockPermissionRequest(text, |
| 48 accept_label, | 54 accept_label, |
| 49 deny_label, | 55 deny_label, |
| 50 GURL("http://www.google.com"), | 56 GURL("http://www.google.com"), |
| 51 PermissionRequestType::UNKNOWN) {} | 57 PermissionRequestType::UNKNOWN, |
| 58 PermissionRequestGestureType::UNKNOWN) {} |
| 52 | 59 |
| 53 MockPermissionRequest::~MockPermissionRequest() {} | 60 MockPermissionRequest::~MockPermissionRequest() {} |
| 54 | 61 |
| 55 int MockPermissionRequest::GetIconId() const { | 62 int MockPermissionRequest::GetIconId() const { |
| 56 // Use a valid icon ID to support UI tests. | 63 // Use a valid icon ID to support UI tests. |
| 57 return IDR_INFOBAR_MEDIA_STREAM_CAMERA; | 64 return IDR_INFOBAR_MEDIA_STREAM_CAMERA; |
| 58 } | 65 } |
| 59 | 66 |
| 60 base::string16 MockPermissionRequest::GetMessageTextFragment() const { | 67 base::string16 MockPermissionRequest::GetMessageTextFragment() const { |
| 61 return text_; | 68 return text_; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 80 | 87 |
| 81 void MockPermissionRequest::RequestFinished() { | 88 void MockPermissionRequest::RequestFinished() { |
| 82 finished_ = true; | 89 finished_ = true; |
| 83 } | 90 } |
| 84 | 91 |
| 85 PermissionRequestType MockPermissionRequest::GetPermissionRequestType() | 92 PermissionRequestType MockPermissionRequest::GetPermissionRequestType() |
| 86 const { | 93 const { |
| 87 return request_type_; | 94 return request_type_; |
| 88 } | 95 } |
| 89 | 96 |
| 97 PermissionRequestGestureType MockPermissionRequest::GetGestureType() |
| 98 const { |
| 99 return gesture_type_; |
| 100 } |
| 101 |
| 90 bool MockPermissionRequest::granted() { | 102 bool MockPermissionRequest::granted() { |
| 91 return granted_; | 103 return granted_; |
| 92 } | 104 } |
| 93 | 105 |
| 94 bool MockPermissionRequest::cancelled() { | 106 bool MockPermissionRequest::cancelled() { |
| 95 return cancelled_; | 107 return cancelled_; |
| 96 } | 108 } |
| 97 | 109 |
| 98 bool MockPermissionRequest::finished() { | 110 bool MockPermissionRequest::finished() { |
| 99 return finished_; | 111 return finished_; |
| 100 } | 112 } |
| 101 | 113 |
| 102 MockPermissionRequest::MockPermissionRequest( | 114 MockPermissionRequest::MockPermissionRequest( |
| 103 const std::string& text, | 115 const std::string& text, |
| 104 const std::string& accept_label, | 116 const std::string& accept_label, |
| 105 const std::string& deny_label, | 117 const std::string& deny_label, |
| 106 const GURL& origin, | 118 const GURL& origin, |
| 107 PermissionRequestType request_type) | 119 PermissionRequestType request_type, |
| 120 PermissionRequestGestureType gesture_type) |
| 108 : granted_(false), | 121 : granted_(false), |
| 109 cancelled_(false), | 122 cancelled_(false), |
| 110 finished_(false), | 123 finished_(false), |
| 111 request_type_(request_type) { | 124 request_type_(request_type), |
| 125 gesture_type_(gesture_type) { |
| 112 text_ = base::UTF8ToUTF16(text); | 126 text_ = base::UTF8ToUTF16(text); |
| 113 accept_label_ = base::UTF8ToUTF16(accept_label); | 127 accept_label_ = base::UTF8ToUTF16(accept_label); |
| 114 deny_label_ = base::UTF8ToUTF16(deny_label); | 128 deny_label_ = base::UTF8ToUTF16(deny_label); |
| 115 origin_ = origin.GetOrigin(); | 129 origin_ = origin.GetOrigin(); |
| 116 } | 130 } |
| OLD | NEW |