| 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" |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 private: | 161 private: |
| 162 RequestQuotaInfoBarDelegate( | 162 RequestQuotaInfoBarDelegate( |
| 163 ChromeQuotaPermissionContext* context, | 163 ChromeQuotaPermissionContext* context, |
| 164 const GURL& origin_url, | 164 const GURL& origin_url, |
| 165 int64 requested_quota, | 165 int64 requested_quota, |
| 166 const std::string& display_languages, | 166 const std::string& display_languages, |
| 167 const content::QuotaPermissionContext::PermissionCallback& callback); | 167 const content::QuotaPermissionContext::PermissionCallback& callback); |
| 168 ~RequestQuotaInfoBarDelegate() override; | 168 ~RequestQuotaInfoBarDelegate() override; |
| 169 | 169 |
| 170 // ConfirmInfoBarDelegate: | 170 // ConfirmInfoBarDelegate: |
| 171 std::string GetIdentifier() const override; |
| 171 base::string16 GetMessageText() const override; | 172 base::string16 GetMessageText() const override; |
| 172 bool Accept() override; | 173 bool Accept() override; |
| 173 bool Cancel() override; | 174 bool Cancel() override; |
| 174 | 175 |
| 175 scoped_refptr<ChromeQuotaPermissionContext> context_; | 176 scoped_refptr<ChromeQuotaPermissionContext> context_; |
| 176 GURL origin_url_; | 177 GURL origin_url_; |
| 177 std::string display_languages_; | 178 std::string display_languages_; |
| 178 int64 requested_quota_; | 179 int64 requested_quota_; |
| 179 content::QuotaPermissionContext::PermissionCallback callback_; | 180 content::QuotaPermissionContext::PermissionCallback callback_; |
| 180 | 181 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 209 } | 210 } |
| 210 | 211 |
| 211 RequestQuotaInfoBarDelegate::~RequestQuotaInfoBarDelegate() { | 212 RequestQuotaInfoBarDelegate::~RequestQuotaInfoBarDelegate() { |
| 212 if (!callback_.is_null()) { | 213 if (!callback_.is_null()) { |
| 213 context_->DispatchCallbackOnIOThread( | 214 context_->DispatchCallbackOnIOThread( |
| 214 callback_, | 215 callback_, |
| 215 content::QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_CANCELLED); | 216 content::QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_CANCELLED); |
| 216 } | 217 } |
| 217 } | 218 } |
| 218 | 219 |
| 220 std::string RequestQuotaInfoBarDelegate::GetIdentifier() const { |
| 221 return "RequestQuotaInfoBarDelegate"; |
| 222 } |
| 223 |
| 219 base::string16 RequestQuotaInfoBarDelegate::GetMessageText() const { | 224 base::string16 RequestQuotaInfoBarDelegate::GetMessageText() const { |
| 220 // If the site requested larger quota than this threshold, show a different | 225 // If the site requested larger quota than this threshold, show a different |
| 221 // message to the user. | 226 // message to the user. |
| 222 return l10n_util::GetStringFUTF16( | 227 return l10n_util::GetStringFUTF16( |
| 223 (requested_quota_ > kRequestLargeQuotaThreshold | 228 (requested_quota_ > kRequestLargeQuotaThreshold |
| 224 ? IDS_REQUEST_LARGE_QUOTA_INFOBAR_QUESTION | 229 ? IDS_REQUEST_LARGE_QUOTA_INFOBAR_QUESTION |
| 225 : IDS_REQUEST_QUOTA_INFOBAR_QUESTION), | 230 : IDS_REQUEST_QUOTA_INFOBAR_QUESTION), |
| 226 url_formatter::FormatUrlForSecurityDisplay(origin_url_, | 231 url_formatter::FormatUrlForSecurityDisplay(origin_url_, |
| 227 display_languages_)); | 232 display_languages_)); |
| 228 } | 233 } |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 content::BrowserThread::IO, FROM_HERE, | 326 content::BrowserThread::IO, FROM_HERE, |
| 322 base::Bind(&ChromeQuotaPermissionContext::DispatchCallbackOnIOThread, | 327 base::Bind(&ChromeQuotaPermissionContext::DispatchCallbackOnIOThread, |
| 323 this, callback, response)); | 328 this, callback, response)); |
| 324 return; | 329 return; |
| 325 } | 330 } |
| 326 | 331 |
| 327 callback.Run(response); | 332 callback.Run(response); |
| 328 } | 333 } |
| 329 | 334 |
| 330 ChromeQuotaPermissionContext::~ChromeQuotaPermissionContext() {} | 335 ChromeQuotaPermissionContext::~ChromeQuotaPermissionContext() {} |
| OLD | NEW |