| OLD | NEW |
| (Empty) |
| 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/services/gcm/permission_bubble_request_impl.h" | |
| 6 | |
| 7 #include "chrome/browser/services/gcm/permission_context_base.h" | |
| 8 #include "grit/generated_resources.h" | |
| 9 #include "grit/theme_resources.h" | |
| 10 #include "net/base/net_util.h" | |
| 11 #include "ui/base/l10n/l10n_util.h" | |
| 12 | |
| 13 namespace gcm { | |
| 14 | |
| 15 PermissionBubbleRequestImpl::PermissionBubbleRequestImpl( | |
| 16 const GURL& request_origin, | |
| 17 bool user_gesture, | |
| 18 ContentSettingsType type, | |
| 19 const std::string& display_languages, | |
| 20 const base::Callback<void(bool, bool)> permission_decided_callback, | |
| 21 const base::Closure delete_callback) | |
| 22 : request_origin_(request_origin), | |
| 23 user_gesture_(user_gesture), | |
| 24 type_(type), | |
| 25 display_languages_(display_languages), | |
| 26 permission_decided_callback_(permission_decided_callback), | |
| 27 delete_callback_(delete_callback), | |
| 28 is_finished_(false) {} | |
| 29 | |
| 30 PermissionBubbleRequestImpl::~PermissionBubbleRequestImpl() { | |
| 31 DCHECK(is_finished_); | |
| 32 } | |
| 33 | |
| 34 int PermissionBubbleRequestImpl::GetIconID() const { | |
| 35 switch (type_) { | |
| 36 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING: | |
| 37 return IDR_INFOBAR_WARNING; | |
| 38 default: | |
| 39 NOTREACHED(); | |
| 40 } | |
| 41 return IDR_INFOBAR_WARNING; | |
| 42 } | |
| 43 | |
| 44 base::string16 PermissionBubbleRequestImpl::GetMessageText() const { | |
| 45 switch (type_) { | |
| 46 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING: | |
| 47 return l10n_util::GetStringUTF16(IDS_PUSH_MESSAGES_BUBBLE_TEXT); | |
| 48 default: | |
| 49 NOTREACHED(); | |
| 50 } | |
| 51 return base::string16(); | |
| 52 } | |
| 53 | |
| 54 base::string16 PermissionBubbleRequestImpl::GetMessageTextFragment() const { | |
| 55 switch (type_) { | |
| 56 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING: | |
| 57 return l10n_util::GetStringUTF16(IDS_PUSH_MESSAGES_BUBBLE_FRAGMENT); | |
| 58 default: | |
| 59 NOTREACHED(); | |
| 60 } | |
| 61 return base::string16(); | |
| 62 } | |
| 63 | |
| 64 bool PermissionBubbleRequestImpl::HasUserGesture() const { | |
| 65 return user_gesture_; | |
| 66 } | |
| 67 | |
| 68 GURL PermissionBubbleRequestImpl::GetRequestingHostname() const { | |
| 69 return request_origin_; | |
| 70 } | |
| 71 | |
| 72 void PermissionBubbleRequestImpl::PermissionGranted() { | |
| 73 permission_decided_callback_.Run(true, true); | |
| 74 } | |
| 75 | |
| 76 void PermissionBubbleRequestImpl::PermissionDenied() { | |
| 77 permission_decided_callback_.Run(true, false); | |
| 78 } | |
| 79 | |
| 80 void PermissionBubbleRequestImpl::Cancelled() { | |
| 81 permission_decided_callback_.Run(false, false); | |
| 82 } | |
| 83 | |
| 84 void PermissionBubbleRequestImpl::RequestFinished() { | |
| 85 is_finished_ = true; | |
| 86 delete_callback_.Run(); | |
| 87 } | |
| 88 | |
| 89 } // namespace gcm | |
| OLD | NEW |