Home | History | Annotate | Download | only in website_settings
      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.
      4 
      5 #include "chrome/browser/ui/website_settings/mock_permission_bubble_request.h"
      6 
      7 #include "base/strings/string16.h"
      8 #include "base/strings/utf_string_conversions.h"
      9 #include "grit/theme_resources.h"
     10 
     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");
     20 }
     21 
     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");
     32 }
     33 
     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;
     45 }
     46 
     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");
     59 }
     60 
     61 MockPermissionBubbleRequest::~MockPermissionBubbleRequest() {}
     62 
     63 int MockPermissionBubbleRequest::GetIconID() const {
     64   // Use a valid icon ID to support UI tests.
     65   return IDR_INFOBAR_MEDIA_STREAM_CAMERA;
     66 }
     67 
     68 base::string16 MockPermissionBubbleRequest::GetMessageText() const {
     69   return text_;
     70 }
     71 
     72 base::string16 MockPermissionBubbleRequest::GetMessageTextFragment() const {
     73   return text_;
     74 }
     75 
     76 bool MockPermissionBubbleRequest::HasUserGesture() const {
     77   return user_gesture_;
     78 }
     79 
     80 GURL MockPermissionBubbleRequest::GetRequestingHostname() const {
     81   return hostname_;
     82 }
     83 
     84 void MockPermissionBubbleRequest::PermissionGranted() {
     85   granted_ = true;
     86 }
     87 
     88 void MockPermissionBubbleRequest::PermissionDenied() {
     89   granted_ = false;
     90 }
     91 
     92 void MockPermissionBubbleRequest::Cancelled() {
     93   granted_ = false;
     94   cancelled_ = true;
     95 }
     96 
     97 void MockPermissionBubbleRequest::RequestFinished() {
     98   finished_ = true;
     99 }
    100 
    101 bool MockPermissionBubbleRequest::granted() {
    102   return granted_;
    103 }
    104 
    105 bool MockPermissionBubbleRequest::cancelled() {
    106   return cancelled_;
    107 }
    108 
    109 bool MockPermissionBubbleRequest::finished() {
    110   return finished_;
    111 }
    112 
    113 void MockPermissionBubbleRequest::SetHasUserGesture() {
    114   user_gesture_ = true;
    115 }
    116