Chromium Code Reviews| 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/content_settings/permission_bubble_request_impl.h" | 5 #include "chrome/browser/content_settings/permission_bubble_request_impl.h" |
| 6 | 6 |
| 7 #include "chrome/browser/content_settings/permission_context_base.h" | 7 #include "chrome/browser/content_settings/permission_context_base.h" |
| 8 #include "chrome/browser/content_settings/permission_context_uma_util.h" | 8 #include "chrome/browser/content_settings/permission_context_uma_util.h" |
| 9 #include "grit/generated_resources.h" | 9 #include "grit/generated_resources.h" |
| 10 #include "grit/theme_resources.h" | 10 #include "grit/theme_resources.h" |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 30 | 30 |
| 31 PermissionBubbleRequestImpl::~PermissionBubbleRequestImpl() { | 31 PermissionBubbleRequestImpl::~PermissionBubbleRequestImpl() { |
| 32 DCHECK(is_finished_); | 32 DCHECK(is_finished_); |
| 33 if (!action_taken_) | 33 if (!action_taken_) |
| 34 PermissionContextUmaUtil::PermissionIgnored(type_); | 34 PermissionContextUmaUtil::PermissionIgnored(type_); |
| 35 } | 35 } |
| 36 | 36 |
| 37 int PermissionBubbleRequestImpl::GetIconID() const { | 37 int PermissionBubbleRequestImpl::GetIconID() const { |
| 38 int icon_id; | 38 int icon_id; |
| 39 switch (type_) { | 39 switch (type_) { |
| 40 #if defined(ENABLE_NOTIFICATIONS) | |
| 41 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: | |
| 42 icon_id = IDR_INFOBAR_DESKTOP_NOTIFICATIONS; | |
| 43 break; | |
| 44 #endif // ENABLE_NOTIFICATIONS | |
|
Peter Beverloo
2014/07/18 10:42:38
nit: don't need the comment after the #endif if th
Miguel Garcia
2014/07/18 12:27:08
Done.
| |
| 40 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX: | 45 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX: |
| 41 icon_id = IDR_ALLOWED_MIDI_SYSEX; | 46 icon_id = IDR_ALLOWED_MIDI_SYSEX; |
| 42 break; | 47 break; |
| 43 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING: | 48 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING: |
| 44 icon_id = IDR_INFOBAR_WARNING; | 49 icon_id = IDR_INFOBAR_WARNING; |
| 45 break; | 50 break; |
| 46 default: | 51 default: |
| 47 NOTREACHED(); | 52 NOTREACHED(); |
| 48 return IDR_INFOBAR_WARNING; | 53 return IDR_INFOBAR_WARNING; |
| 49 } | 54 } |
| 50 return icon_id; | 55 return icon_id; |
| 51 } | 56 } |
| 52 | 57 |
| 53 base::string16 PermissionBubbleRequestImpl::GetMessageText() const { | 58 base::string16 PermissionBubbleRequestImpl::GetMessageText() const { |
| 54 int message_id; | 59 int message_id; |
| 55 switch (type_) { | 60 switch (type_) { |
| 61 #if defined(ENABLE_NOTIFICATIONS) | |
| 62 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: | |
| 63 message_id = IDS_NOTIFICATION_PERMISSIONS; | |
| 64 break; | |
| 65 #endif // ENABLE_NOTIFICATIONS | |
| 56 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX: | 66 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX: |
| 57 message_id = IDS_MIDI_SYSEX_INFOBAR_QUESTION; | 67 message_id = IDS_MIDI_SYSEX_INFOBAR_QUESTION; |
| 58 break; | 68 break; |
| 59 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING: | 69 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING: |
| 60 message_id = IDS_PUSH_MESSAGES_PERMISSION_QUESTION; | 70 message_id = IDS_PUSH_MESSAGES_PERMISSION_QUESTION; |
| 61 break; | 71 break; |
| 62 default: | 72 default: |
| 63 NOTREACHED(); | 73 NOTREACHED(); |
| 64 return base::string16(); | 74 return base::string16(); |
| 65 } | 75 } |
| 66 return l10n_util::GetStringFUTF16( | 76 return l10n_util::GetStringFUTF16( |
| 67 message_id, | 77 message_id, |
| 68 net::FormatUrl(request_origin_, display_languages_, | 78 net::FormatUrl(request_origin_, display_languages_, |
| 69 net::kFormatUrlOmitUsernamePassword | | 79 net::kFormatUrlOmitUsernamePassword | |
| 70 net::kFormatUrlOmitTrailingSlashOnBareHostname, | 80 net::kFormatUrlOmitTrailingSlashOnBareHostname, |
| 71 net::UnescapeRule::SPACES, NULL, NULL, NULL)); | 81 net::UnescapeRule::SPACES, NULL, NULL, NULL)); |
| 72 } | 82 } |
| 73 | 83 |
| 74 base::string16 PermissionBubbleRequestImpl::GetMessageTextFragment() const { | 84 base::string16 PermissionBubbleRequestImpl::GetMessageTextFragment() const { |
| 75 int message_id; | 85 int message_id; |
| 76 switch (type_) { | 86 switch (type_) { |
| 87 #if defined(ENABLE_NOTIFICATIONS) | |
| 88 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: | |
| 89 message_id = IDS_NOTIFICATION_PERMISSIONS_FRAGMENT; | |
| 90 break; | |
| 91 #endif // ENABLE_NOTIFICATIONS | |
| 77 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX: | 92 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX: |
| 78 message_id = IDS_MIDI_SYSEX_PERMISSION_FRAGMENT; | 93 message_id = IDS_MIDI_SYSEX_PERMISSION_FRAGMENT; |
| 79 break; | 94 break; |
| 80 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING: | 95 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING: |
| 81 message_id = IDS_PUSH_MESSAGES_BUBBLE_FRAGMENT; | 96 message_id = IDS_PUSH_MESSAGES_BUBBLE_FRAGMENT; |
| 82 break; | 97 break; |
| 83 default: | 98 default: |
| 84 NOTREACHED(); | 99 NOTREACHED(); |
| 85 return base::string16(); | 100 return base::string16(); |
| 86 } | 101 } |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 107 | 122 |
| 108 void PermissionBubbleRequestImpl::Cancelled() { | 123 void PermissionBubbleRequestImpl::Cancelled() { |
| 109 RegisterActionTaken(); | 124 RegisterActionTaken(); |
| 110 permission_decided_callback_.Run(false, false); | 125 permission_decided_callback_.Run(false, false); |
| 111 } | 126 } |
| 112 | 127 |
| 113 void PermissionBubbleRequestImpl::RequestFinished() { | 128 void PermissionBubbleRequestImpl::RequestFinished() { |
| 114 is_finished_ = true; | 129 is_finished_ = true; |
| 115 delete_callback_.Run(); | 130 delete_callback_.Run(); |
| 116 } | 131 } |
| OLD | NEW |