[email protected] | 9f9749a | 2012-03-02 19:37:00 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 317f96c9 | 2011-05-31 06:53:41 | [diff] [blame] | 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/chrome_quota_permission_context.h" |
| 6 | |
| 7 | #include <string> |
| 8 | |
[email protected] | c8d98dd | 2011-10-18 23:12:08 | [diff] [blame] | 9 | #include "base/bind.h" |
[email protected] | 3853a4c | 2013-02-11 17:15:57 | [diff] [blame] | 10 | #include "base/prefs/pref_service.h" |
[email protected] | 135cb80 | 2013-06-09 16:44:20 | [diff] [blame] | 11 | #include "base/strings/utf_string_conversions.h" |
[email protected] | 4a8adfa0 | 2013-03-19 22:37:46 | [diff] [blame] | 12 | #include "chrome/browser/infobars/infobar_service.h" |
[email protected] | 317f96c9 | 2011-05-31 06:53:41 | [diff] [blame] | 13 | #include "chrome/browser/profiles/profile.h" |
[email protected] | 317f96c9 | 2011-05-31 06:53:41 | [diff] [blame] | 14 | #include "chrome/browser/tab_contents/tab_util.h" |
[email protected] | c032489d | 2014-02-11 19:07:24 | [diff] [blame] | 15 | #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" |
| 16 | #include "chrome/browser/ui/website_settings/permission_bubble_request.h" |
[email protected] | 317f96c9 | 2011-05-31 06:53:41 | [diff] [blame] | 17 | #include "chrome/common/pref_names.h" |
[email protected] | af39f00 | 2014-08-22 10:18:18 | [diff] [blame] | 18 | #include "chrome/grit/generated_resources.h" |
thestig | aeddd32 | 2014-08-27 06:58:39 | [diff] [blame] | 19 | #include "chrome/grit/locale_settings.h" |
[email protected] | f9b2160 | 2014-05-22 00:53:12 | [diff] [blame] | 20 | #include "components/infobars/core/confirm_infobar_delegate.h" |
[email protected] | 051655ad | 2014-04-18 15:09:41 | [diff] [blame] | 21 | #include "components/infobars/core/infobar.h" |
rsleevi | 24f64dc2 | 2015-08-07 21:39:21 | [diff] [blame^] | 22 | #include "components/url_formatter/url_formatter.h" |
[email protected] | c38831a1 | 2011-10-28 12:44:49 | [diff] [blame] | 23 | #include "content/public/browser/browser_thread.h" |
[email protected] | 5b96836f | 2011-12-22 07:39:00 | [diff] [blame] | 24 | #include "content/public/browser/navigation_details.h" |
[email protected] | 4f822f02 | 2012-12-20 19:11:42 | [diff] [blame] | 25 | #include "content/public/browser/web_contents.h" |
[email protected] | d23cdeee | 2014-03-10 06:39:53 | [diff] [blame] | 26 | #include "grit/theme_resources.h" |
pilgrim | 1633055 | 2014-09-10 01:32:22 | [diff] [blame] | 27 | #include "storage/common/quota/quota_types.h" |
[email protected] | 317f96c9 | 2011-05-31 06:53:41 | [diff] [blame] | 28 | #include "ui/base/l10n/l10n_util.h" |
[email protected] | 761fa470 | 2013-07-02 15:25:15 | [diff] [blame] | 29 | #include "url/gurl.h" |
[email protected] | 317f96c9 | 2011-05-31 06:53:41 | [diff] [blame] | 30 | |
[email protected] | c032489d | 2014-02-11 19:07:24 | [diff] [blame] | 31 | namespace { |
| 32 | |
| 33 | // If the site requested larger quota than this threshold, show a different |
| 34 | // message to the user. |
| 35 | const int64 kRequestLargeQuotaThreshold = 5 * 1024 * 1024; |
| 36 | |
| 37 | // QuotaPermissionRequest --------------------------------------------- |
| 38 | |
| 39 | class QuotaPermissionRequest : public PermissionBubbleRequest { |
| 40 | public: |
| 41 | QuotaPermissionRequest( |
| 42 | ChromeQuotaPermissionContext* context, |
| 43 | const GURL& origin_url, |
| 44 | int64 requested_quota, |
[email protected] | f78aa772 | 2014-04-04 00:04:25 | [diff] [blame] | 45 | bool user_gesture, |
[email protected] | c032489d | 2014-02-11 19:07:24 | [diff] [blame] | 46 | const std::string& display_languages, |
| 47 | const content::QuotaPermissionContext::PermissionCallback& callback); |
| 48 | |
Daniel Cheng | a542fca | 2014-10-21 09:51:29 | [diff] [blame] | 49 | ~QuotaPermissionRequest() override; |
[email protected] | c032489d | 2014-02-11 19:07:24 | [diff] [blame] | 50 | |
| 51 | // PermissionBubbleRequest: |
Daniel Cheng | a542fca | 2014-10-21 09:51:29 | [diff] [blame] | 52 | int GetIconID() const override; |
| 53 | base::string16 GetMessageText() const override; |
| 54 | base::string16 GetMessageTextFragment() const override; |
| 55 | bool HasUserGesture() const override; |
| 56 | GURL GetRequestingHostname() const override; |
| 57 | void PermissionGranted() override; |
| 58 | void PermissionDenied() override; |
| 59 | void Cancelled() override; |
| 60 | void RequestFinished() override; |
[email protected] | c032489d | 2014-02-11 19:07:24 | [diff] [blame] | 61 | |
| 62 | private: |
| 63 | scoped_refptr<ChromeQuotaPermissionContext> context_; |
| 64 | GURL origin_url_; |
| 65 | std::string display_languages_; |
| 66 | int64 requested_quota_; |
[email protected] | f78aa772 | 2014-04-04 00:04:25 | [diff] [blame] | 67 | bool user_gesture_; |
[email protected] | c032489d | 2014-02-11 19:07:24 | [diff] [blame] | 68 | content::QuotaPermissionContext::PermissionCallback callback_; |
| 69 | |
| 70 | DISALLOW_COPY_AND_ASSIGN(QuotaPermissionRequest); |
| 71 | }; |
| 72 | |
| 73 | QuotaPermissionRequest::QuotaPermissionRequest( |
| 74 | ChromeQuotaPermissionContext* context, |
| 75 | const GURL& origin_url, |
| 76 | int64 requested_quota, |
[email protected] | f78aa772 | 2014-04-04 00:04:25 | [diff] [blame] | 77 | bool user_gesture, |
[email protected] | c032489d | 2014-02-11 19:07:24 | [diff] [blame] | 78 | const std::string& display_languages, |
| 79 | const content::QuotaPermissionContext::PermissionCallback& callback) |
| 80 | : context_(context), |
| 81 | origin_url_(origin_url), |
| 82 | display_languages_(display_languages), |
| 83 | requested_quota_(requested_quota), |
[email protected] | f78aa772 | 2014-04-04 00:04:25 | [diff] [blame] | 84 | user_gesture_(user_gesture), |
[email protected] | c032489d | 2014-02-11 19:07:24 | [diff] [blame] | 85 | callback_(callback) {} |
| 86 | |
| 87 | QuotaPermissionRequest::~QuotaPermissionRequest() {} |
| 88 | |
[email protected] | d23cdeee | 2014-03-10 06:39:53 | [diff] [blame] | 89 | int QuotaPermissionRequest::GetIconID() const { |
| 90 | // TODO(gbillock): get the proper image here |
| 91 | return IDR_INFOBAR_WARNING; |
| 92 | } |
| 93 | |
[email protected] | c032489d | 2014-02-11 19:07:24 | [diff] [blame] | 94 | base::string16 QuotaPermissionRequest::GetMessageText() const { |
| 95 | return l10n_util::GetStringFUTF16( |
rsleevi | 24f64dc2 | 2015-08-07 21:39:21 | [diff] [blame^] | 96 | (requested_quota_ > kRequestLargeQuotaThreshold |
| 97 | ? IDS_REQUEST_LARGE_QUOTA_INFOBAR_QUESTION |
| 98 | : IDS_REQUEST_QUOTA_INFOBAR_QUESTION), |
| 99 | url_formatter::FormatUrl( |
| 100 | origin_url_, display_languages_, |
| 101 | url_formatter::kFormatUrlOmitUsernamePassword | |
| 102 | url_formatter::kFormatUrlOmitTrailingSlashOnBareHostname, |
| 103 | net::UnescapeRule::SPACES, nullptr, nullptr, nullptr)); |
[email protected] | c032489d | 2014-02-11 19:07:24 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | base::string16 QuotaPermissionRequest::GetMessageTextFragment() const { |
| 107 | return l10n_util::GetStringUTF16(IDS_REQUEST_QUOTA_PERMISSION_FRAGMENT); |
| 108 | } |
| 109 | |
[email protected] | d23cdeee | 2014-03-10 06:39:53 | [diff] [blame] | 110 | bool QuotaPermissionRequest::HasUserGesture() const { |
[email protected] | f78aa772 | 2014-04-04 00:04:25 | [diff] [blame] | 111 | return user_gesture_; |
[email protected] | c032489d | 2014-02-11 19:07:24 | [diff] [blame] | 112 | } |
| 113 | |
[email protected] | d23cdeee | 2014-03-10 06:39:53 | [diff] [blame] | 114 | GURL QuotaPermissionRequest::GetRequestingHostname() const { |
| 115 | return origin_url_; |
[email protected] | c032489d | 2014-02-11 19:07:24 | [diff] [blame] | 116 | } |
| 117 | |
| 118 | void QuotaPermissionRequest::PermissionGranted() { |
| 119 | context_->DispatchCallbackOnIOThread( |
| 120 | callback_, |
| 121 | content::QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_ALLOW); |
| 122 | callback_ = content::QuotaPermissionContext::PermissionCallback(); |
| 123 | } |
| 124 | |
| 125 | void QuotaPermissionRequest::PermissionDenied() { |
| 126 | context_->DispatchCallbackOnIOThread( |
| 127 | callback_, |
| 128 | content::QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_DISALLOW); |
| 129 | callback_ = content::QuotaPermissionContext::PermissionCallback(); |
| 130 | } |
| 131 | |
| 132 | void QuotaPermissionRequest::Cancelled() { |
| 133 | } |
| 134 | |
| 135 | void QuotaPermissionRequest::RequestFinished() { |
| 136 | if (!callback_.is_null()) { |
| 137 | context_->DispatchCallbackOnIOThread( |
| 138 | callback_, |
| 139 | content::QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_CANCELLED); |
| 140 | } |
| 141 | |
| 142 | delete this; |
| 143 | } |
[email protected] | 631bb74 | 2011-11-02 11:29:39 | [diff] [blame] | 144 | |
[email protected] | 49c71ac | 2013-05-03 01:36:22 | [diff] [blame] | 145 | |
| 146 | // RequestQuotaInfoBarDelegate ------------------------------------------------ |
| 147 | |
[email protected] | 317f96c9 | 2011-05-31 06:53:41 | [diff] [blame] | 148 | class RequestQuotaInfoBarDelegate : public ConfirmInfoBarDelegate { |
| 149 | public: |
[email protected] | 39308cb | 2013-12-06 03:01:48 | [diff] [blame] | 150 | // Creates a request quota infobar and delegate and adds the infobar to |
| 151 | // |infobar_service|. |
[email protected] | 0be0993 | 2013-01-08 02:03:50 | [diff] [blame] | 152 | static void Create( |
| 153 | InfoBarService* infobar_service, |
| 154 | ChromeQuotaPermissionContext* context, |
| 155 | const GURL& origin_url, |
| 156 | int64 requested_quota, |
| 157 | const std::string& display_languages, |
[email protected] | 9a88ea99 | 2013-07-10 21:21:57 | [diff] [blame] | 158 | const content::QuotaPermissionContext::PermissionCallback& callback); |
[email protected] | 0be0993 | 2013-01-08 02:03:50 | [diff] [blame] | 159 | |
| 160 | private: |
[email protected] | 317f96c9 | 2011-05-31 06:53:41 | [diff] [blame] | 161 | RequestQuotaInfoBarDelegate( |
[email protected] | 317f96c9 | 2011-05-31 06:53:41 | [diff] [blame] | 162 | ChromeQuotaPermissionContext* context, |
| 163 | const GURL& origin_url, |
| 164 | int64 requested_quota, |
| 165 | const std::string& display_languages, |
[email protected] | 9a88ea99 | 2013-07-10 21:21:57 | [diff] [blame] | 166 | const content::QuotaPermissionContext::PermissionCallback& callback); |
Daniel Cheng | a542fca | 2014-10-21 09:51:29 | [diff] [blame] | 167 | ~RequestQuotaInfoBarDelegate() override; |
[email protected] | 317f96c9 | 2011-05-31 06:53:41 | [diff] [blame] | 168 | |
[email protected] | 49c71ac | 2013-05-03 01:36:22 | [diff] [blame] | 169 | // ConfirmInfoBarDelegate: |
Daniel Cheng | a542fca | 2014-10-21 09:51:29 | [diff] [blame] | 170 | base::string16 GetMessageText() const override; |
| 171 | bool Accept() override; |
| 172 | bool Cancel() override; |
[email protected] | 317f96c9 | 2011-05-31 06:53:41 | [diff] [blame] | 173 | |
| 174 | scoped_refptr<ChromeQuotaPermissionContext> context_; |
| 175 | GURL origin_url_; |
| 176 | std::string display_languages_; |
| 177 | int64 requested_quota_; |
[email protected] | 9a88ea99 | 2013-07-10 21:21:57 | [diff] [blame] | 178 | content::QuotaPermissionContext::PermissionCallback callback_; |
[email protected] | 49c71ac | 2013-05-03 01:36:22 | [diff] [blame] | 179 | |
[email protected] | 317f96c9 | 2011-05-31 06:53:41 | [diff] [blame] | 180 | DISALLOW_COPY_AND_ASSIGN(RequestQuotaInfoBarDelegate); |
| 181 | }; |
| 182 | |
[email protected] | 0be0993 | 2013-01-08 02:03:50 | [diff] [blame] | 183 | // static |
| 184 | void RequestQuotaInfoBarDelegate::Create( |
| 185 | InfoBarService* infobar_service, |
| 186 | ChromeQuotaPermissionContext* context, |
| 187 | const GURL& origin_url, |
| 188 | int64 requested_quota, |
| 189 | const std::string& display_languages, |
[email protected] | 9a88ea99 | 2013-07-10 21:21:57 | [diff] [blame] | 190 | const content::QuotaPermissionContext::PermissionCallback& callback) { |
sdefresne | 316da45 | 2014-12-22 17:30:59 | [diff] [blame] | 191 | infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar( |
[email protected] | 39308cb | 2013-12-06 03:01:48 | [diff] [blame] | 192 | scoped_ptr<ConfirmInfoBarDelegate>(new RequestQuotaInfoBarDelegate( |
| 193 | context, origin_url, requested_quota, display_languages, callback)))); |
[email protected] | 0be0993 | 2013-01-08 02:03:50 | [diff] [blame] | 194 | } |
| 195 | |
[email protected] | 49c71ac | 2013-05-03 01:36:22 | [diff] [blame] | 196 | RequestQuotaInfoBarDelegate::RequestQuotaInfoBarDelegate( |
[email protected] | 49c71ac | 2013-05-03 01:36:22 | [diff] [blame] | 197 | ChromeQuotaPermissionContext* context, |
| 198 | const GURL& origin_url, |
| 199 | int64 requested_quota, |
| 200 | const std::string& display_languages, |
[email protected] | 9a88ea99 | 2013-07-10 21:21:57 | [diff] [blame] | 201 | const content::QuotaPermissionContext::PermissionCallback& callback) |
[email protected] | 39308cb | 2013-12-06 03:01:48 | [diff] [blame] | 202 | : ConfirmInfoBarDelegate(), |
[email protected] | 49c71ac | 2013-05-03 01:36:22 | [diff] [blame] | 203 | context_(context), |
| 204 | origin_url_(origin_url), |
| 205 | display_languages_(display_languages), |
| 206 | requested_quota_(requested_quota), |
| 207 | callback_(callback) { |
| 208 | } |
| 209 | |
| 210 | RequestQuotaInfoBarDelegate::~RequestQuotaInfoBarDelegate() { |
| 211 | if (!callback_.is_null()) { |
| 212 | context_->DispatchCallbackOnIOThread( |
| 213 | callback_, |
[email protected] | 9a88ea99 | 2013-07-10 21:21:57 | [diff] [blame] | 214 | content::QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_CANCELLED); |
[email protected] | 49c71ac | 2013-05-03 01:36:22 | [diff] [blame] | 215 | } |
| 216 | } |
| 217 | |
[email protected] | 6a72a63 | 2013-12-12 22:22:00 | [diff] [blame] | 218 | base::string16 RequestQuotaInfoBarDelegate::GetMessageText() const { |
[email protected] | 9a88ea99 | 2013-07-10 21:21:57 | [diff] [blame] | 219 | // If the site requested larger quota than this threshold, show a different |
| 220 | // message to the user. |
[email protected] | 317f96c9 | 2011-05-31 06:53:41 | [diff] [blame] | 221 | return l10n_util::GetStringFUTF16( |
rsleevi | 24f64dc2 | 2015-08-07 21:39:21 | [diff] [blame^] | 222 | (requested_quota_ > kRequestLargeQuotaThreshold |
| 223 | ? IDS_REQUEST_LARGE_QUOTA_INFOBAR_QUESTION |
| 224 | : IDS_REQUEST_QUOTA_INFOBAR_QUESTION), |
| 225 | url_formatter::FormatUrl( |
| 226 | origin_url_, display_languages_, |
| 227 | url_formatter::kFormatUrlOmitUsernamePassword | |
| 228 | url_formatter::kFormatUrlOmitTrailingSlashOnBareHostname, |
| 229 | net::UnescapeRule::SPACES, nullptr, nullptr, nullptr)); |
[email protected] | 317f96c9 | 2011-05-31 06:53:41 | [diff] [blame] | 230 | } |
| 231 | |
| 232 | bool RequestQuotaInfoBarDelegate::Accept() { |
| 233 | context_->DispatchCallbackOnIOThread( |
[email protected] | 9f9749a | 2012-03-02 19:37:00 | [diff] [blame] | 234 | callback_, |
[email protected] | 9a88ea99 | 2013-07-10 21:21:57 | [diff] [blame] | 235 | content::QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_ALLOW); |
[email protected] | 317f96c9 | 2011-05-31 06:53:41 | [diff] [blame] | 236 | return true; |
| 237 | } |
| 238 | |
| 239 | bool RequestQuotaInfoBarDelegate::Cancel() { |
| 240 | context_->DispatchCallbackOnIOThread( |
[email protected] | 9f9749a | 2012-03-02 19:37:00 | [diff] [blame] | 241 | callback_, |
[email protected] | 9a88ea99 | 2013-07-10 21:21:57 | [diff] [blame] | 242 | content::QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_CANCELLED); |
[email protected] | 317f96c9 | 2011-05-31 06:53:41 | [diff] [blame] | 243 | return true; |
| 244 | } |
| 245 | |
[email protected] | 49c71ac | 2013-05-03 01:36:22 | [diff] [blame] | 246 | } // namespace |
| 247 | |
| 248 | |
| 249 | // ChromeQuotaPermissionContext ----------------------------------------------- |
[email protected] | 317f96c9 | 2011-05-31 06:53:41 | [diff] [blame] | 250 | |
[email protected] | 9a88ea99 | 2013-07-10 21:21:57 | [diff] [blame] | 251 | ChromeQuotaPermissionContext::ChromeQuotaPermissionContext() { |
| 252 | } |
[email protected] | 317f96c9 | 2011-05-31 06:53:41 | [diff] [blame] | 253 | |
| 254 | void ChromeQuotaPermissionContext::RequestQuotaPermission( |
[email protected] | f78aa772 | 2014-04-04 00:04:25 | [diff] [blame] | 255 | const content::StorageQuotaParams& params, |
[email protected] | 317f96c9 | 2011-05-31 06:53:41 | [diff] [blame] | 256 | int render_process_id, |
[email protected] | c8d98dd | 2011-10-18 23:12:08 | [diff] [blame] | 257 | const PermissionCallback& callback) { |
[email protected] | cd501a7 | 2014-08-22 19:58:31 | [diff] [blame] | 258 | if (params.storage_type != storage::kStorageTypePersistent) { |
[email protected] | 317f96c9 | 2011-05-31 06:53:41 | [diff] [blame] | 259 | // For now we only support requesting quota with this interface |
| 260 | // for Persistent storage type. |
[email protected] | 9f9749a | 2012-03-02 19:37:00 | [diff] [blame] | 261 | callback.Run(QUOTA_PERMISSION_RESPONSE_DISALLOW); |
[email protected] | 317f96c9 | 2011-05-31 06:53:41 | [diff] [blame] | 262 | return; |
| 263 | } |
| 264 | |
[email protected] | 9a88ea99 | 2013-07-10 21:21:57 | [diff] [blame] | 265 | if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) { |
| 266 | content::BrowserThread::PostTask( |
| 267 | content::BrowserThread::UI, FROM_HERE, |
[email protected] | 1c6bfbb | 2011-11-30 04:36:14 | [diff] [blame] | 268 | base::Bind(&ChromeQuotaPermissionContext::RequestQuotaPermission, this, |
[email protected] | f78aa772 | 2014-04-04 00:04:25 | [diff] [blame] | 269 | params, render_process_id, callback)); |
[email protected] | 317f96c9 | 2011-05-31 06:53:41 | [diff] [blame] | 270 | return; |
| 271 | } |
| 272 | |
[email protected] | 9a88ea99 | 2013-07-10 21:21:57 | [diff] [blame] | 273 | content::WebContents* web_contents = |
[email protected] | f78aa772 | 2014-04-04 00:04:25 | [diff] [blame] | 274 | tab_util::GetWebContentsByID(render_process_id, |
| 275 | params.render_view_id); |
[email protected] | 83ff91c | 2012-01-05 20:54:13 | [diff] [blame] | 276 | if (!web_contents) { |
[email protected] | 317f96c9 | 2011-05-31 06:53:41 | [diff] [blame] | 277 | // The tab may have gone away or the request may not be from a tab. |
| 278 | LOG(WARNING) << "Attempt to request quota tabless renderer: " |
[email protected] | f78aa772 | 2014-04-04 00:04:25 | [diff] [blame] | 279 | << render_process_id << "," << params.render_view_id; |
[email protected] | 9f9749a | 2012-03-02 19:37:00 | [diff] [blame] | 280 | DispatchCallbackOnIOThread(callback, QUOTA_PERMISSION_RESPONSE_CANCELLED); |
[email protected] | 317f96c9 | 2011-05-31 06:53:41 | [diff] [blame] | 281 | return; |
| 282 | } |
| 283 | |
felt | 51f26d1f | 2015-03-10 04:09:37 | [diff] [blame] | 284 | InfoBarService* infobar_service = |
| 285 | InfoBarService::FromWebContents(web_contents); |
| 286 | if (!infobar_service) { |
| 287 | // The tab has no infobar service. |
| 288 | LOG(WARNING) << "Attempt to request quota from a background page: " |
| 289 | << render_process_id << "," << params.render_view_id; |
| 290 | DispatchCallbackOnIOThread(callback, QUOTA_PERMISSION_RESPONSE_CANCELLED); |
| 291 | return; |
| 292 | } |
| 293 | |
[email protected] | c032489d | 2014-02-11 19:07:24 | [diff] [blame] | 294 | if (PermissionBubbleManager::Enabled()) { |
| 295 | PermissionBubbleManager* bubble_manager = |
| 296 | PermissionBubbleManager::FromWebContents(web_contents); |
[email protected] | f2d77086 | 2014-05-13 03:26:14 | [diff] [blame] | 297 | if (bubble_manager) { |
| 298 | bubble_manager->AddRequest(new QuotaPermissionRequest(this, |
| 299 | params.origin_url, params.requested_size, params.user_gesture, |
| 300 | Profile::FromBrowserContext(web_contents->GetBrowserContext())-> |
| 301 | GetPrefs()->GetString(prefs::kAcceptLanguages), |
| 302 | callback)); |
| 303 | } |
[email protected] | c032489d | 2014-02-11 19:07:24 | [diff] [blame] | 304 | return; |
| 305 | } |
| 306 | |
[email protected] | 0be0993 | 2013-01-08 02:03:50 | [diff] [blame] | 307 | RequestQuotaInfoBarDelegate::Create( |
[email protected] | f78aa772 | 2014-04-04 00:04:25 | [diff] [blame] | 308 | infobar_service, this, params.origin_url, params.requested_size, |
[email protected] | 9a88ea99 | 2013-07-10 21:21:57 | [diff] [blame] | 309 | Profile::FromBrowserContext(web_contents->GetBrowserContext())-> |
| 310 | GetPrefs()->GetString(prefs::kAcceptLanguages), |
[email protected] | 0be0993 | 2013-01-08 02:03:50 | [diff] [blame] | 311 | callback); |
[email protected] | 317f96c9 | 2011-05-31 06:53:41 | [diff] [blame] | 312 | } |
| 313 | |
| 314 | void ChromeQuotaPermissionContext::DispatchCallbackOnIOThread( |
[email protected] | c8d98dd | 2011-10-18 23:12:08 | [diff] [blame] | 315 | const PermissionCallback& callback, |
[email protected] | 9f9749a | 2012-03-02 19:37:00 | [diff] [blame] | 316 | QuotaPermissionResponse response) { |
[email protected] | c8d98dd | 2011-10-18 23:12:08 | [diff] [blame] | 317 | DCHECK_EQ(false, callback.is_null()); |
| 318 | |
[email protected] | 9a88ea99 | 2013-07-10 21:21:57 | [diff] [blame] | 319 | if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)) { |
| 320 | content::BrowserThread::PostTask( |
| 321 | content::BrowserThread::IO, FROM_HERE, |
[email protected] | c8d98dd | 2011-10-18 23:12:08 | [diff] [blame] | 322 | base::Bind(&ChromeQuotaPermissionContext::DispatchCallbackOnIOThread, |
| 323 | this, callback, response)); |
[email protected] | 317f96c9 | 2011-05-31 06:53:41 | [diff] [blame] | 324 | return; |
| 325 | } |
[email protected] | c8d98dd | 2011-10-18 23:12:08 | [diff] [blame] | 326 | |
| 327 | callback.Run(response); |
[email protected] | 317f96c9 | 2011-05-31 06:53:41 | [diff] [blame] | 328 | } |
[email protected] | 649d1c0 | 2012-04-27 02:56:21 | [diff] [blame] | 329 | |
| 330 | ChromeQuotaPermissionContext::~ChromeQuotaPermissionContext() {} |