| 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 : MockPermissionBubbleRequest("test", |
| 13 cancelled_(false), | 13 "button", |
| 14 finished_(false) { | 14 "button", |
| 15 text_ = base::ASCIIToUTF16("test"); | 15 GURL("http://www.google.com"), |
| 16 accept_label_ = base::ASCIIToUTF16("button"); | 16 PermissionBubbleType::UNKNOWN) {} |
| 17 deny_label_ = base::ASCIIToUTF16("button"); | |
| 18 origin_ = GURL("http://www.google.com"); | |
| 19 } | |
| 20 | 17 |
| 21 MockPermissionBubbleRequest::MockPermissionBubbleRequest( | 18 MockPermissionBubbleRequest::MockPermissionBubbleRequest( |
| 22 const std::string& text) | 19 const std::string& text) |
| 23 : granted_(false), | 20 : MockPermissionBubbleRequest(text, |
| 24 cancelled_(false), | 21 "button", |
| 25 finished_(false) { | 22 "button", |
| 26 text_ = base::UTF8ToUTF16(text); | 23 GURL("http://www.google.com"), |
| 27 accept_label_ = base::ASCIIToUTF16("button"); | 24 PermissionBubbleType::UNKNOWN) {} |
| 28 deny_label_ = base::ASCIIToUTF16("button"); | 25 |
| 29 origin_ = GURL("http://www.google.com"); | 26 MockPermissionBubbleRequest::MockPermissionBubbleRequest( |
| 30 } | 27 const std::string& text, PermissionBubbleType bubble_type) |
| 28 : MockPermissionBubbleRequest(text, |
| 29 "button", |
| 30 "button", |
| 31 GURL("http://www.google.com"), |
| 32 bubble_type) {} |
| 31 | 33 |
| 32 MockPermissionBubbleRequest::MockPermissionBubbleRequest( | 34 MockPermissionBubbleRequest::MockPermissionBubbleRequest( |
| 33 const std::string& text, | 35 const std::string& text, |
| 34 const GURL& url) | 36 const GURL& url) |
| 35 : granted_(false), | 37 : MockPermissionBubbleRequest(text, |
| 36 cancelled_(false), | 38 "button", |
| 37 finished_(false) { | 39 "button", |
| 38 text_ = base::UTF8ToUTF16(text); | 40 url, |
| 39 accept_label_ = base::ASCIIToUTF16("button"); | 41 PermissionBubbleType::UNKNOWN) {} |
| 40 deny_label_ = base::ASCIIToUTF16("button"); | |
| 41 origin_ = url.GetOrigin(); | |
| 42 } | |
| 43 | 42 |
| 44 MockPermissionBubbleRequest::MockPermissionBubbleRequest( | 43 MockPermissionBubbleRequest::MockPermissionBubbleRequest( |
| 45 const std::string& text, | 44 const std::string& text, |
| 46 const std::string& accept_label, | 45 const std::string& accept_label, |
| 47 const std::string& deny_label) | 46 const std::string& deny_label) |
| 48 : granted_(false), | 47 : MockPermissionBubbleRequest(text, |
| 49 cancelled_(false), | 48 accept_label, |
| 50 finished_(false) { | 49 deny_label, |
| 51 text_ = base::UTF8ToUTF16(text); | 50 GURL("http://www.google.com"), |
| 52 accept_label_ = base::UTF8ToUTF16(accept_label); | 51 PermissionBubbleType::UNKNOWN) {} |
| 53 deny_label_ = base::UTF8ToUTF16(deny_label); | |
| 54 origin_ = GURL("http://www.google.com"); | |
| 55 } | |
| 56 | 52 |
| 57 MockPermissionBubbleRequest::~MockPermissionBubbleRequest() {} | 53 MockPermissionBubbleRequest::~MockPermissionBubbleRequest() {} |
| 58 | 54 |
| 59 int MockPermissionBubbleRequest::GetIconId() const { | 55 int MockPermissionBubbleRequest::GetIconId() const { |
| 60 // Use a valid icon ID to support UI tests. | 56 // Use a valid icon ID to support UI tests. |
| 61 return IDR_INFOBAR_MEDIA_STREAM_CAMERA; | 57 return IDR_INFOBAR_MEDIA_STREAM_CAMERA; |
| 62 } | 58 } |
| 63 | 59 |
| 64 base::string16 MockPermissionBubbleRequest::GetMessageTextFragment() const { | 60 base::string16 MockPermissionBubbleRequest::GetMessageTextFragment() const { |
| 65 return text_; | 61 return text_; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 79 | 75 |
| 80 void MockPermissionBubbleRequest::Cancelled() { | 76 void MockPermissionBubbleRequest::Cancelled() { |
| 81 granted_ = false; | 77 granted_ = false; |
| 82 cancelled_ = true; | 78 cancelled_ = true; |
| 83 } | 79 } |
| 84 | 80 |
| 85 void MockPermissionBubbleRequest::RequestFinished() { | 81 void MockPermissionBubbleRequest::RequestFinished() { |
| 86 finished_ = true; | 82 finished_ = true; |
| 87 } | 83 } |
| 88 | 84 |
| 85 PermissionBubbleType MockPermissionBubbleRequest::GetPermissionBubbleType() |
| 86 const { |
| 87 return bubble_type_; |
| 88 } |
| 89 |
| 89 bool MockPermissionBubbleRequest::granted() { | 90 bool MockPermissionBubbleRequest::granted() { |
| 90 return granted_; | 91 return granted_; |
| 91 } | 92 } |
| 92 | 93 |
| 93 bool MockPermissionBubbleRequest::cancelled() { | 94 bool MockPermissionBubbleRequest::cancelled() { |
| 94 return cancelled_; | 95 return cancelled_; |
| 95 } | 96 } |
| 96 | 97 |
| 97 bool MockPermissionBubbleRequest::finished() { | 98 bool MockPermissionBubbleRequest::finished() { |
| 98 return finished_; | 99 return finished_; |
| 99 } | 100 } |
| 100 | 101 |
| 102 MockPermissionBubbleRequest::MockPermissionBubbleRequest( |
| 103 const std::string& text, |
| 104 const std::string& accept_label, |
| 105 const std::string& deny_label, |
| 106 const GURL& origin, |
| 107 PermissionBubbleType bubble_type) |
| 108 : granted_(false), |
| 109 cancelled_(false), |
| 110 finished_(false), |
| 111 bubble_type_(bubble_type) { |
| 112 text_ = base::UTF8ToUTF16(text); |
| 113 accept_label_ = base::UTF8ToUTF16(accept_label); |
| 114 deny_label_ = base::UTF8ToUTF16(deny_label); |
| 115 origin_ = origin.GetOrigin(); |
| 116 } |
| OLD | NEW |