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/permissions/permission_bubble_request_impl.h" | 5 #include "chrome/browser/permissions/permission_bubble_request_impl.h" |
6 | 6 |
7 #include "chrome/browser/permissions/permission_context_base.h" | 7 #include "chrome/browser/permissions/permission_context_base.h" |
8 #include "chrome/browser/permissions/permission_context_uma_util.h" | 8 #include "chrome/browser/permissions/permission_context_uma_util.h" |
9 #include "chrome/grit/generated_resources.h" | 9 #include "chrome/grit/generated_resources.h" |
10 #include "components/url_formatter/url_formatter.h" | |
11 #include "grit/theme_resources.h" | 10 #include "grit/theme_resources.h" |
12 #include "net/base/escape.h" | 11 #include "net/base/net_util.h" |
13 #include "ui/base/l10n/l10n_util.h" | 12 #include "ui/base/l10n/l10n_util.h" |
14 #include "ui/gfx/vector_icons_public2.h" | 13 #include "ui/gfx/vector_icons_public2.h" |
15 | 14 |
16 PermissionBubbleRequestImpl::PermissionBubbleRequestImpl( | 15 PermissionBubbleRequestImpl::PermissionBubbleRequestImpl( |
17 const GURL& request_origin, | 16 const GURL& request_origin, |
18 bool user_gesture, | 17 bool user_gesture, |
19 ContentSettingsType type, | 18 ContentSettingsType type, |
20 const std::string& display_languages, | 19 const std::string& display_languages, |
21 const PermissionDecidedCallback& permission_decided_callback, | 20 const PermissionDecidedCallback& permission_decided_callback, |
22 const base::Closure delete_callback) | 21 const base::Closure delete_callback) |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 case CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER: | 102 case CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER: |
104 message_id = IDS_PROTECTED_MEDIA_IDENTIFIER_INFOBAR_QUESTION; | 103 message_id = IDS_PROTECTED_MEDIA_IDENTIFIER_INFOBAR_QUESTION; |
105 break; | 104 break; |
106 #endif | 105 #endif |
107 default: | 106 default: |
108 NOTREACHED(); | 107 NOTREACHED(); |
109 return base::string16(); | 108 return base::string16(); |
110 } | 109 } |
111 return l10n_util::GetStringFUTF16( | 110 return l10n_util::GetStringFUTF16( |
112 message_id, | 111 message_id, |
113 url_formatter::FormatUrl( | 112 net::FormatUrl(request_origin_, display_languages_, |
114 request_origin_, display_languages_, | 113 net::kFormatUrlOmitUsernamePassword | |
115 url_formatter::kFormatUrlOmitUsernamePassword | | 114 net::kFormatUrlOmitTrailingSlashOnBareHostname, |
116 url_formatter::kFormatUrlOmitTrailingSlashOnBareHostname, | 115 net::UnescapeRule::SPACES, NULL, NULL, NULL)); |
117 net::UnescapeRule::SPACES, nullptr, nullptr, nullptr)); | |
118 } | 116 } |
119 | 117 |
120 base::string16 PermissionBubbleRequestImpl::GetMessageTextFragment() const { | 118 base::string16 PermissionBubbleRequestImpl::GetMessageTextFragment() const { |
121 int message_id; | 119 int message_id; |
122 switch (type_) { | 120 switch (type_) { |
123 case CONTENT_SETTINGS_TYPE_GEOLOCATION: | 121 case CONTENT_SETTINGS_TYPE_GEOLOCATION: |
124 message_id = IDS_GEOLOCATION_INFOBAR_PERMISSION_FRAGMENT; | 122 message_id = IDS_GEOLOCATION_INFOBAR_PERMISSION_FRAGMENT; |
125 break; | 123 break; |
126 #if defined(ENABLE_NOTIFICATIONS) | 124 #if defined(ENABLE_NOTIFICATIONS) |
127 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: | 125 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 | 164 |
167 void PermissionBubbleRequestImpl::Cancelled() { | 165 void PermissionBubbleRequestImpl::Cancelled() { |
168 RegisterActionTaken(); | 166 RegisterActionTaken(); |
169 permission_decided_callback_.Run(false, CONTENT_SETTING_DEFAULT); | 167 permission_decided_callback_.Run(false, CONTENT_SETTING_DEFAULT); |
170 } | 168 } |
171 | 169 |
172 void PermissionBubbleRequestImpl::RequestFinished() { | 170 void PermissionBubbleRequestImpl::RequestFinished() { |
173 is_finished_ = true; | 171 is_finished_ = true; |
174 delete_callback_.Run(); | 172 delete_callback_.Run(); |
175 } | 173 } |
OLD | NEW |