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_infobar_delegate.h" |
| 6 |
| 7 #include "chrome/browser/content_settings/permission_queue_controller.h" |
| 8 #include "components/infobars/core/infobar.h" |
| 9 #include "grit/generated_resources.h" |
| 10 #include "ui/base/l10n/l10n_util.h" |
| 11 |
| 12 namespace gcm { |
| 13 |
| 14 PermissionInfobarDelegate::~PermissionInfobarDelegate() { |
| 15 } |
| 16 |
| 17 PermissionInfobarDelegate::PermissionInfobarDelegate( |
| 18 PermissionQueueController* controller, |
| 19 const PermissionRequestID& id, |
| 20 GURL& requesting_frame) |
| 21 : controller_(controller), id_(id), requesting_frame_(requesting_frame) { |
| 22 } |
| 23 |
| 24 void PermissionInfobarDelegate::InfoBarDismissed() { |
| 25 SetPermission(false, false); |
| 26 } |
| 27 |
| 28 infobars::InfoBarDelegate::Type |
| 29 PermissionInfobarDelegate::GetInfoBarType() const { |
| 30 return PAGE_ACTION_TYPE; |
| 31 } |
| 32 |
| 33 base::string16 PermissionInfobarDelegate::GetButtonLabel( |
| 34 InfoBarButton button) const { |
| 35 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? |
| 36 IDS_PERMISSION_ALLOW : IDS_PERMISSION_DENY); |
| 37 } |
| 38 |
| 39 bool PermissionInfobarDelegate::Accept() { |
| 40 SetPermission(true, true); |
| 41 return true; |
| 42 } |
| 43 |
| 44 bool PermissionInfobarDelegate::Cancel() { |
| 45 SetPermission(true, false); |
| 46 return true; |
| 47 } |
| 48 |
| 49 void PermissionInfobarDelegate::SetPermission(bool update_content_setting, |
| 50 bool allowed) { |
| 51 controller_->OnPermissionSet( |
| 52 id_, requesting_frame_, |
| 53 InfoBarService::WebContentsFromInfoBar(infobar())->GetURL(), |
| 54 update_content_setting, allowed); |
| 55 } |
| 56 } // namespace gcm |
OLD | NEW |