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 case CONTENT_SETTINGS_TYPE_GEOLOCATION: | |
| 41 icon_id = IDR_INFOBAR_GEOLOCATION; | |
| 42 break; | |
| 40 #if defined(ENABLE_NOTIFICATIONS) | 43 #if defined(ENABLE_NOTIFICATIONS) |
| 41 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: | 44 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: |
| 42 icon_id = IDR_INFOBAR_DESKTOP_NOTIFICATIONS; | 45 icon_id = IDR_INFOBAR_DESKTOP_NOTIFICATIONS; |
| 43 break; | 46 break; |
| 44 #endif | 47 #endif |
| 45 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX: | 48 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX: |
| 46 icon_id = IDR_ALLOWED_MIDI_SYSEX; | 49 icon_id = IDR_ALLOWED_MIDI_SYSEX; |
| 47 break; | 50 break; |
| 48 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING: | 51 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING: |
| 49 icon_id = IDR_INFOBAR_WARNING; | 52 icon_id = IDR_INFOBAR_WARNING; |
| 50 break; | 53 break; |
| 51 default: | 54 default: |
| 52 NOTREACHED(); | 55 NOTREACHED(); |
| 53 return IDR_INFOBAR_WARNING; | 56 return IDR_INFOBAR_WARNING; |
| 54 } | 57 } |
| 55 return icon_id; | 58 return icon_id; |
| 56 } | 59 } |
| 57 | 60 |
| 58 base::string16 PermissionBubbleRequestImpl::GetMessageText() const { | 61 base::string16 PermissionBubbleRequestImpl::GetMessageText() const { |
| 59 int message_id; | 62 int message_id; |
| 60 switch (type_) { | 63 switch (type_) { |
| 64 case CONTENT_SETTINGS_TYPE_GEOLOCATION: | |
| 65 message_id = IDS_GEOLOCATION_INFOBAR_QUESTION; | |
| 66 break; | |
| 61 #if defined(ENABLE_NOTIFICATIONS) | 67 #if defined(ENABLE_NOTIFICATIONS) |
| 62 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: | 68 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: |
|
Bernhard Bauer
2014/08/13 13:34:32
Nit: these case statements aren't correctly aligne
Miguel Garcia
2014/08/13 14:25:50
Done.
| |
| 63 message_id = IDS_NOTIFICATION_PERMISSIONS; | 69 message_id = IDS_NOTIFICATION_PERMISSIONS; |
| 64 break; | 70 break; |
| 65 #endif | 71 #endif |
| 66 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX: | 72 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX: |
| 67 message_id = IDS_MIDI_SYSEX_INFOBAR_QUESTION; | 73 message_id = IDS_MIDI_SYSEX_INFOBAR_QUESTION; |
| 68 break; | 74 break; |
| 69 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING: | 75 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING: |
| 70 message_id = IDS_PUSH_MESSAGES_PERMISSION_QUESTION; | 76 message_id = IDS_PUSH_MESSAGES_PERMISSION_QUESTION; |
| 71 break; | 77 break; |
| 72 default: | 78 default: |
| 73 NOTREACHED(); | 79 NOTREACHED(); |
| 74 return base::string16(); | 80 return base::string16(); |
| 75 } | 81 } |
| 76 return l10n_util::GetStringFUTF16( | 82 return l10n_util::GetStringFUTF16( |
| 77 message_id, | 83 message_id, |
| 78 net::FormatUrl(request_origin_, display_languages_, | 84 net::FormatUrl(request_origin_, display_languages_, |
| 79 net::kFormatUrlOmitUsernamePassword | | 85 net::kFormatUrlOmitUsernamePassword | |
| 80 net::kFormatUrlOmitTrailingSlashOnBareHostname, | 86 net::kFormatUrlOmitTrailingSlashOnBareHostname, |
| 81 net::UnescapeRule::SPACES, NULL, NULL, NULL)); | 87 net::UnescapeRule::SPACES, NULL, NULL, NULL)); |
| 82 } | 88 } |
| 83 | 89 |
| 84 base::string16 PermissionBubbleRequestImpl::GetMessageTextFragment() const { | 90 base::string16 PermissionBubbleRequestImpl::GetMessageTextFragment() const { |
| 85 int message_id; | 91 int message_id; |
| 86 switch (type_) { | 92 switch (type_) { |
| 93 case CONTENT_SETTINGS_TYPE_GEOLOCATION: | |
| 94 message_id = IDS_GEOLOCATION_INFOBAR_PERMISSION_FRAGMENT; | |
| 95 break; | |
| 87 #if defined(ENABLE_NOTIFICATIONS) | 96 #if defined(ENABLE_NOTIFICATIONS) |
| 88 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: | 97 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: |
| 89 message_id = IDS_NOTIFICATION_PERMISSIONS_FRAGMENT; | 98 message_id = IDS_NOTIFICATION_PERMISSIONS_FRAGMENT; |
| 90 break; | 99 break; |
| 91 #endif | 100 #endif |
| 92 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX: | 101 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX: |
| 93 message_id = IDS_MIDI_SYSEX_PERMISSION_FRAGMENT; | 102 message_id = IDS_MIDI_SYSEX_PERMISSION_FRAGMENT; |
| 94 break; | 103 break; |
| 95 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING: | 104 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING: |
| 96 message_id = IDS_PUSH_MESSAGES_BUBBLE_FRAGMENT; | 105 message_id = IDS_PUSH_MESSAGES_BUBBLE_FRAGMENT; |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 122 | 131 |
| 123 void PermissionBubbleRequestImpl::Cancelled() { | 132 void PermissionBubbleRequestImpl::Cancelled() { |
| 124 RegisterActionTaken(); | 133 RegisterActionTaken(); |
| 125 permission_decided_callback_.Run(false, false); | 134 permission_decided_callback_.Run(false, false); |
| 126 } | 135 } |
| 127 | 136 |
| 128 void PermissionBubbleRequestImpl::RequestFinished() { | 137 void PermissionBubbleRequestImpl::RequestFinished() { |
| 129 is_finished_ = true; | 138 is_finished_ = true; |
| 130 delete_callback_.Run(); | 139 delete_callback_.Run(); |
| 131 } | 140 } |
| OLD | NEW |