| 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 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "chrome/browser/permissions/permission_request.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/tab_contents/tab_util.h" | 17 #include "chrome/browser/tab_contents/tab_util.h" |
| 17 #include "chrome/browser/ui/website_settings/permission_bubble_request.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/url_formatter/elide_url.h" | 20 #include "components/url_formatter/elide_url.h" |
| 21 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
| 22 #include "content/public/browser/navigation_details.h" | 22 #include "content/public/browser/navigation_details.h" |
| 23 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
| 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/permissions/permission_request_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 |
| 45 class QuotaPermissionRequest : public PermissionBubbleRequest { | 45 class QuotaPermissionRequest : public PermissionRequest { |
| 46 public: | 46 public: |
| 47 QuotaPermissionRequest( | 47 QuotaPermissionRequest( |
| 48 ChromeQuotaPermissionContext* context, | 48 ChromeQuotaPermissionContext* context, |
| 49 const GURL& origin_url, | 49 const GURL& origin_url, |
| 50 int64_t requested_quota, | 50 int64_t requested_quota, |
| 51 const content::QuotaPermissionContext::PermissionCallback& callback); | 51 const content::QuotaPermissionContext::PermissionCallback& callback); |
| 52 | 52 |
| 53 ~QuotaPermissionRequest() override; | 53 ~QuotaPermissionRequest() override; |
| 54 | 54 |
| 55 private: | 55 private: |
| 56 // PermissionBubbleRequest: | 56 // PermissionRequest: |
| 57 int GetIconId() const override; | 57 int GetIconId() const override; |
| 58 base::string16 GetMessageText() const override; | 58 base::string16 GetMessageText() const override; |
| 59 base::string16 GetMessageTextFragment() const override; | 59 base::string16 GetMessageTextFragment() const override; |
| 60 GURL GetOrigin() const override; | 60 GURL GetOrigin() const override; |
| 61 void PermissionGranted() override; | 61 void PermissionGranted() override; |
| 62 void PermissionDenied() override; | 62 void PermissionDenied() override; |
| 63 void Cancelled() override; | 63 void Cancelled() override; |
| 64 void RequestFinished() override; | 64 void RequestFinished() override; |
| 65 PermissionBubbleType GetPermissionBubbleType() const override; | 65 PermissionBubbleType GetPermissionBubbleType() const override; |
| 66 | 66 |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |