| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "grit/theme_resources.h" | 24 #include "grit/theme_resources.h" |
| 25 #include "storage/common/quota/quota_types.h" | 25 #include "storage/common/quota/quota_types.h" |
| 26 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
| 27 #include "url/gurl.h" | 27 #include "url/gurl.h" |
| 28 | 28 |
| 29 #if defined(OS_ANDROID) | 29 #if defined(OS_ANDROID) |
| 30 #include "chrome/browser/infobars/infobar_service.h" | 30 #include "chrome/browser/infobars/infobar_service.h" |
| 31 #include "components/infobars/core/confirm_infobar_delegate.h" | 31 #include "components/infobars/core/confirm_infobar_delegate.h" |
| 32 #include "components/infobars/core/infobar.h" | 32 #include "components/infobars/core/infobar.h" |
| 33 #else | 33 #else |
| 34 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" | 34 #include "chrome/browser/permissions/permission_request_manager.h" |
| 35 #endif | 35 #endif |
| 36 | 36 |
| 37 namespace { | 37 namespace { |
| 38 | 38 |
| 39 // If the site requested larger quota than this threshold, show a different | 39 // If the site requested larger quota than this threshold, show a different |
| 40 // message to the user. | 40 // message to the user. |
| 41 const int64_t kRequestLargeQuotaThreshold = 5 * 1024 * 1024; | 41 const int64_t kRequestLargeQuotaThreshold = 5 * 1024 * 1024; |
| 42 | 42 |
| 43 // QuotaPermissionRequest --------------------------------------------- | 43 // QuotaPermissionRequest --------------------------------------------- |
| 44 | 44 |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 #if defined(OS_ANDROID) | 274 #if defined(OS_ANDROID) |
| 275 InfoBarService* infobar_service = | 275 InfoBarService* infobar_service = |
| 276 InfoBarService::FromWebContents(web_contents); | 276 InfoBarService::FromWebContents(web_contents); |
| 277 if (infobar_service) { | 277 if (infobar_service) { |
| 278 RequestQuotaInfoBarDelegate::Create( | 278 RequestQuotaInfoBarDelegate::Create( |
| 279 infobar_service, this, params.origin_url, params.requested_size, | 279 infobar_service, this, params.origin_url, params.requested_size, |
| 280 callback); | 280 callback); |
| 281 return; | 281 return; |
| 282 } | 282 } |
| 283 #else | 283 #else |
| 284 PermissionBubbleManager* bubble_manager = | 284 PermissionRequestManager* permission_request_manager = |
| 285 PermissionBubbleManager::FromWebContents(web_contents); | 285 PermissionRequestManager::FromWebContents(web_contents); |
| 286 if (bubble_manager) { | 286 if (permission_request_manager) { |
| 287 bubble_manager->AddRequest(new QuotaPermissionRequest( | 287 permission_request_manager->AddRequest(new QuotaPermissionRequest( |
| 288 this, params.origin_url, params.requested_size, callback)); | 288 this, params.origin_url, params.requested_size, callback)); |
| 289 return; | 289 return; |
| 290 } | 290 } |
| 291 #endif | 291 #endif |
| 292 | 292 |
| 293 // The tab has no UI service for presenting the permissions request. | 293 // The tab has no UI service for presenting the permissions request. |
| 294 LOG(WARNING) << "Attempt to request quota from a background page: " | 294 LOG(WARNING) << "Attempt to request quota from a background page: " |
| 295 << render_process_id << "," << params.render_view_id; | 295 << render_process_id << "," << params.render_view_id; |
| 296 DispatchCallbackOnIOThread(callback, QUOTA_PERMISSION_RESPONSE_CANCELLED); | 296 DispatchCallbackOnIOThread(callback, QUOTA_PERMISSION_RESPONSE_CANCELLED); |
| 297 } | 297 } |
| 298 | 298 |
| 299 void ChromeQuotaPermissionContext::DispatchCallbackOnIOThread( | 299 void ChromeQuotaPermissionContext::DispatchCallbackOnIOThread( |
| 300 const PermissionCallback& callback, | 300 const PermissionCallback& callback, |
| 301 QuotaPermissionResponse response) { | 301 QuotaPermissionResponse response) { |
| 302 DCHECK_EQ(false, callback.is_null()); | 302 DCHECK_EQ(false, callback.is_null()); |
| 303 | 303 |
| 304 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)) { | 304 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)) { |
| 305 content::BrowserThread::PostTask( | 305 content::BrowserThread::PostTask( |
| 306 content::BrowserThread::IO, FROM_HERE, | 306 content::BrowserThread::IO, FROM_HERE, |
| 307 base::Bind(&ChromeQuotaPermissionContext::DispatchCallbackOnIOThread, | 307 base::Bind(&ChromeQuotaPermissionContext::DispatchCallbackOnIOThread, |
| 308 this, callback, response)); | 308 this, callback, response)); |
| 309 return; | 309 return; |
| 310 } | 310 } |
| 311 | 311 |
| 312 callback.Run(response); | 312 callback.Run(response); |
| 313 } | 313 } |
| 314 | 314 |
| 315 ChromeQuotaPermissionContext::~ChromeQuotaPermissionContext() {} | 315 ChromeQuotaPermissionContext::~ChromeQuotaPermissionContext() {} |
| OLD | NEW |