OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/chrome_quota_permission_context.h" | 5 #include "chrome/browser/chrome_quota_permission_context.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "chrome/browser/infobars/infobar_service.h" | 12 #include "chrome/browser/infobars/infobar_service.h" |
13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/tab_contents/tab_util.h" | 14 #include "chrome/browser/tab_contents/tab_util.h" |
15 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" | 15 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" |
16 #include "chrome/browser/ui/website_settings/permission_bubble_request.h" | 16 #include "chrome/browser/ui/website_settings/permission_bubble_request.h" |
17 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
18 #include "chrome/grit/generated_resources.h" | 18 #include "chrome/grit/generated_resources.h" |
19 #include "chrome/grit/locale_settings.h" | 19 #include "chrome/grit/locale_settings.h" |
20 #include "components/infobars/core/confirm_infobar_delegate.h" | 20 #include "components/infobars/core/confirm_infobar_delegate.h" |
21 #include "components/infobars/core/infobar.h" | 21 #include "components/infobars/core/infobar.h" |
| 22 #include "components/url_formatter/url_formatter.h" |
22 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
23 #include "content/public/browser/navigation_details.h" | 24 #include "content/public/browser/navigation_details.h" |
24 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
25 #include "grit/theme_resources.h" | 26 #include "grit/theme_resources.h" |
26 #include "net/base/net_util.h" | |
27 #include "storage/common/quota/quota_types.h" | 27 #include "storage/common/quota/quota_types.h" |
28 #include "ui/base/l10n/l10n_util.h" | 28 #include "ui/base/l10n/l10n_util.h" |
29 #include "url/gurl.h" | 29 #include "url/gurl.h" |
30 | 30 |
31 namespace { | 31 namespace { |
32 | 32 |
33 // If the site requested larger quota than this threshold, show a different | 33 // If the site requested larger quota than this threshold, show a different |
34 // message to the user. | 34 // message to the user. |
35 const int64 kRequestLargeQuotaThreshold = 5 * 1024 * 1024; | 35 const int64 kRequestLargeQuotaThreshold = 5 * 1024 * 1024; |
36 | 36 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 86 |
87 QuotaPermissionRequest::~QuotaPermissionRequest() {} | 87 QuotaPermissionRequest::~QuotaPermissionRequest() {} |
88 | 88 |
89 int QuotaPermissionRequest::GetIconID() const { | 89 int QuotaPermissionRequest::GetIconID() const { |
90 // TODO(gbillock): get the proper image here | 90 // TODO(gbillock): get the proper image here |
91 return IDR_INFOBAR_WARNING; | 91 return IDR_INFOBAR_WARNING; |
92 } | 92 } |
93 | 93 |
94 base::string16 QuotaPermissionRequest::GetMessageText() const { | 94 base::string16 QuotaPermissionRequest::GetMessageText() const { |
95 return l10n_util::GetStringFUTF16( | 95 return l10n_util::GetStringFUTF16( |
96 (requested_quota_ > kRequestLargeQuotaThreshold ? | 96 (requested_quota_ > kRequestLargeQuotaThreshold |
97 IDS_REQUEST_LARGE_QUOTA_INFOBAR_QUESTION : | 97 ? IDS_REQUEST_LARGE_QUOTA_INFOBAR_QUESTION |
98 IDS_REQUEST_QUOTA_INFOBAR_QUESTION), | 98 : IDS_REQUEST_QUOTA_INFOBAR_QUESTION), |
99 net::FormatUrl(origin_url_, display_languages_, | 99 url_formatter::FormatUrl( |
100 net::kFormatUrlOmitUsernamePassword | | 100 origin_url_, display_languages_, |
101 net::kFormatUrlOmitTrailingSlashOnBareHostname, | 101 url_formatter::kFormatUrlOmitUsernamePassword | |
102 net::UnescapeRule::SPACES, NULL, NULL, NULL) | 102 url_formatter::kFormatUrlOmitTrailingSlashOnBareHostname, |
103 ); | 103 net::UnescapeRule::SPACES, nullptr, nullptr, nullptr)); |
104 } | 104 } |
105 | 105 |
106 base::string16 QuotaPermissionRequest::GetMessageTextFragment() const { | 106 base::string16 QuotaPermissionRequest::GetMessageTextFragment() const { |
107 return l10n_util::GetStringUTF16(IDS_REQUEST_QUOTA_PERMISSION_FRAGMENT); | 107 return l10n_util::GetStringUTF16(IDS_REQUEST_QUOTA_PERMISSION_FRAGMENT); |
108 } | 108 } |
109 | 109 |
110 bool QuotaPermissionRequest::HasUserGesture() const { | 110 bool QuotaPermissionRequest::HasUserGesture() const { |
111 return user_gesture_; | 111 return user_gesture_; |
112 } | 112 } |
113 | 113 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 context_->DispatchCallbackOnIOThread( | 212 context_->DispatchCallbackOnIOThread( |
213 callback_, | 213 callback_, |
214 content::QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_CANCELLED); | 214 content::QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_CANCELLED); |
215 } | 215 } |
216 } | 216 } |
217 | 217 |
218 base::string16 RequestQuotaInfoBarDelegate::GetMessageText() const { | 218 base::string16 RequestQuotaInfoBarDelegate::GetMessageText() const { |
219 // If the site requested larger quota than this threshold, show a different | 219 // If the site requested larger quota than this threshold, show a different |
220 // message to the user. | 220 // message to the user. |
221 return l10n_util::GetStringFUTF16( | 221 return l10n_util::GetStringFUTF16( |
222 (requested_quota_ > kRequestLargeQuotaThreshold ? | 222 (requested_quota_ > kRequestLargeQuotaThreshold |
223 IDS_REQUEST_LARGE_QUOTA_INFOBAR_QUESTION : | 223 ? IDS_REQUEST_LARGE_QUOTA_INFOBAR_QUESTION |
224 IDS_REQUEST_QUOTA_INFOBAR_QUESTION), | 224 : IDS_REQUEST_QUOTA_INFOBAR_QUESTION), |
225 net::FormatUrl(origin_url_, display_languages_, | 225 url_formatter::FormatUrl( |
226 net::kFormatUrlOmitUsernamePassword | | 226 origin_url_, display_languages_, |
227 net::kFormatUrlOmitTrailingSlashOnBareHostname, | 227 url_formatter::kFormatUrlOmitUsernamePassword | |
228 net::UnescapeRule::SPACES, NULL, NULL, NULL) | 228 url_formatter::kFormatUrlOmitTrailingSlashOnBareHostname, |
229 ); | 229 net::UnescapeRule::SPACES, nullptr, nullptr, nullptr)); |
230 } | 230 } |
231 | 231 |
232 bool RequestQuotaInfoBarDelegate::Accept() { | 232 bool RequestQuotaInfoBarDelegate::Accept() { |
233 context_->DispatchCallbackOnIOThread( | 233 context_->DispatchCallbackOnIOThread( |
234 callback_, | 234 callback_, |
235 content::QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_ALLOW); | 235 content::QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_ALLOW); |
236 return true; | 236 return true; |
237 } | 237 } |
238 | 238 |
239 bool RequestQuotaInfoBarDelegate::Cancel() { | 239 bool RequestQuotaInfoBarDelegate::Cancel() { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 content::BrowserThread::IO, FROM_HERE, | 321 content::BrowserThread::IO, FROM_HERE, |
322 base::Bind(&ChromeQuotaPermissionContext::DispatchCallbackOnIOThread, | 322 base::Bind(&ChromeQuotaPermissionContext::DispatchCallbackOnIOThread, |
323 this, callback, response)); | 323 this, callback, response)); |
324 return; | 324 return; |
325 } | 325 } |
326 | 326 |
327 callback.Run(response); | 327 callback.Run(response); |
328 } | 328 } |
329 | 329 |
330 ChromeQuotaPermissionContext::~ChromeQuotaPermissionContext() {} | 330 ChromeQuotaPermissionContext::~ChromeQuotaPermissionContext() {} |
OLD | NEW |