| 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 defined(OS_ANDROID) | 39 #if defined(OS_ANDROID) |
| 40 // If the site requested larger quota than this threshold, show a different | 40 // If the site requested larger quota than this threshold, show a different |
| 41 // message to the user. | 41 // message to the user. |
| 42 const int64_t kRequestLargeQuotaThreshold = 5 * 1024 * 1024; | 42 const int64_t kRequestLargeQuotaThreshold = 5 * 1024 * 1024; |
| 43 #endif | 43 #endif |
| 44 | 44 |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 #if defined(OS_ANDROID) | 263 #if defined(OS_ANDROID) |
| 264 InfoBarService* infobar_service = | 264 InfoBarService* infobar_service = |
| 265 InfoBarService::FromWebContents(web_contents); | 265 InfoBarService::FromWebContents(web_contents); |
| 266 if (infobar_service) { | 266 if (infobar_service) { |
| 267 RequestQuotaInfoBarDelegate::Create( | 267 RequestQuotaInfoBarDelegate::Create( |
| 268 infobar_service, this, params.origin_url, params.requested_size, | 268 infobar_service, this, params.origin_url, params.requested_size, |
| 269 callback); | 269 callback); |
| 270 return; | 270 return; |
| 271 } | 271 } |
| 272 #else | 272 #else |
| 273 PermissionBubbleManager* bubble_manager = | 273 PermissionRequestManager* permission_request_manager = |
| 274 PermissionBubbleManager::FromWebContents(web_contents); | 274 PermissionRequestManager::FromWebContents(web_contents); |
| 275 if (bubble_manager) { | 275 if (permission_request_manager) { |
| 276 bubble_manager->AddRequest( | 276 permission_request_manager->AddRequest( |
| 277 new QuotaPermissionRequest(this, params.origin_url, callback)); | 277 new QuotaPermissionRequest(this, params.origin_url, callback)); |
| 278 return; | 278 return; |
| 279 } | 279 } |
| 280 #endif | 280 #endif |
| 281 | 281 |
| 282 // The tab has no UI service for presenting the permissions request. | 282 // The tab has no UI service for presenting the permissions request. |
| 283 LOG(WARNING) << "Attempt to request quota from a background page: " | 283 LOG(WARNING) << "Attempt to request quota from a background page: " |
| 284 << render_process_id << "," << params.render_view_id; | 284 << render_process_id << "," << params.render_view_id; |
| 285 DispatchCallbackOnIOThread(callback, QUOTA_PERMISSION_RESPONSE_CANCELLED); | 285 DispatchCallbackOnIOThread(callback, QUOTA_PERMISSION_RESPONSE_CANCELLED); |
| 286 } | 286 } |
| 287 | 287 |
| 288 void ChromeQuotaPermissionContext::DispatchCallbackOnIOThread( | 288 void ChromeQuotaPermissionContext::DispatchCallbackOnIOThread( |
| 289 const PermissionCallback& callback, | 289 const PermissionCallback& callback, |
| 290 QuotaPermissionResponse response) { | 290 QuotaPermissionResponse response) { |
| 291 DCHECK_EQ(false, callback.is_null()); | 291 DCHECK_EQ(false, callback.is_null()); |
| 292 | 292 |
| 293 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)) { | 293 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)) { |
| 294 content::BrowserThread::PostTask( | 294 content::BrowserThread::PostTask( |
| 295 content::BrowserThread::IO, FROM_HERE, | 295 content::BrowserThread::IO, FROM_HERE, |
| 296 base::Bind(&ChromeQuotaPermissionContext::DispatchCallbackOnIOThread, | 296 base::Bind(&ChromeQuotaPermissionContext::DispatchCallbackOnIOThread, |
| 297 this, callback, response)); | 297 this, callback, response)); |
| 298 return; | 298 return; |
| 299 } | 299 } |
| 300 | 300 |
| 301 callback.Run(response); | 301 callback.Run(response); |
| 302 } | 302 } |
| 303 | 303 |
| 304 ChromeQuotaPermissionContext::~ChromeQuotaPermissionContext() {} | 304 ChromeQuotaPermissionContext::~ChromeQuotaPermissionContext() {} |
| OLD | NEW |