Commit 9f9749a4 authored by tfarina@chromium.org's avatar tfarina@chromium.org

Move QuotaPermissionContext to content/public/browser and put it in the content namespace.

BUG=98716
R=jam@chromium.org

Review URL: https://chromiumcodereview.appspot.com/9566035

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@124710 0039d316-1c4b-4281-b951-d872f2087c98
parent 53e4d8f6
......@@ -52,7 +52,6 @@ include_rules = [
"+content/browser/net/url_request_slow_download_job.h",
"+content/browser/net/url_request_slow_http_job.h",
"+content/browser/plugin_service_filter.h",
"+content/browser/quota_permission_context.h",
"+content/browser/renderer_host/dummy_resource_handler.h",
"+content/browser/renderer_host/mock_render_process_host.h",
"+content/browser/renderer_host/render_process_host_browsertest.h",
......
......@@ -139,6 +139,7 @@
using content::AccessTokenStore;
using content::BrowserThread;
using content::ChildProcessSecurityPolicy;
using content::QuotaPermissionContext;
using content::SiteInstance;
using content::WebContents;
......
......@@ -12,6 +12,10 @@
#include "base/compiler_specific.h"
#include "content/public/browser/content_browser_client.h"
namespace content {
class QuotaPermissionContext;
}
namespace chrome {
class ChromeContentBrowserClient : public content::ContentBrowserClient {
......@@ -85,7 +89,8 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient {
const std::vector<std::pair<int, int> >& render_views) OVERRIDE;
virtual net::URLRequestContext* OverrideRequestContextForURL(
const GURL& url, content::ResourceContext* context) OVERRIDE;
virtual QuotaPermissionContext* CreateQuotaPermissionContext() OVERRIDE;
virtual content::QuotaPermissionContext*
CreateQuotaPermissionContext() OVERRIDE;
virtual void OpenItem(const FilePath& path) OVERRIDE;
virtual void ShowItemInFolder(const FilePath& path) OVERRIDE;
virtual void AllowCertificateError(
......
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
......@@ -25,6 +25,7 @@
#include "webkit/quota/quota_types.h"
using content::BrowserThread;
using content::QuotaPermissionContext;
using content::WebContents;
namespace {
......@@ -55,7 +56,8 @@ class RequestQuotaInfoBarDelegate : public ConfirmInfoBarDelegate {
virtual ~RequestQuotaInfoBarDelegate() {
if (!callback_.is_null())
context_->DispatchCallbackOnIOThread(
callback_, QuotaPermissionContext::kResponseCancelled);
callback_,
QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_CANCELLED);
}
virtual bool ShouldExpire(
......@@ -79,7 +81,8 @@ class RequestQuotaInfoBarDelegate : public ConfirmInfoBarDelegate {
void RequestQuotaInfoBarDelegate::InfoBarDismissed() {
context_->DispatchCallbackOnIOThread(
callback_, QuotaPermissionContext::kResponseCancelled);
callback_,
QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_CANCELLED);
}
string16 RequestQuotaInfoBarDelegate::GetMessageText() const {
......@@ -92,13 +95,15 @@ string16 RequestQuotaInfoBarDelegate::GetMessageText() const {
bool RequestQuotaInfoBarDelegate::Accept() {
context_->DispatchCallbackOnIOThread(
callback_, QuotaPermissionContext::kResponseAllow);
callback_,
QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_ALLOW);
return true;
}
bool RequestQuotaInfoBarDelegate::Cancel() {
context_->DispatchCallbackOnIOThread(
callback_, QuotaPermissionContext::kResponseCancelled);
callback_,
QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_CANCELLED);
return true;
}
......@@ -120,7 +125,7 @@ void ChromeQuotaPermissionContext::RequestQuotaPermission(
if (type != quota::kStorageTypePersistent) {
// For now we only support requesting quota with this interface
// for Persistent storage type.
callback.Run(kResponseDisallow);
callback.Run(QUOTA_PERMISSION_RESPONSE_DISALLOW);
return;
}
......@@ -139,7 +144,7 @@ void ChromeQuotaPermissionContext::RequestQuotaPermission(
// The tab may have gone away or the request may not be from a tab.
LOG(WARNING) << "Attempt to request quota tabless renderer: "
<< render_process_id << "," << render_view_id;
DispatchCallbackOnIOThread(callback, kResponseCancelled);
DispatchCallbackOnIOThread(callback, QUOTA_PERMISSION_RESPONSE_CANCELLED);
return;
}
......@@ -154,7 +159,7 @@ void ChromeQuotaPermissionContext::RequestQuotaPermission(
void ChromeQuotaPermissionContext::DispatchCallbackOnIOThread(
const PermissionCallback& callback,
Response response) {
QuotaPermissionResponse response) {
DCHECK_EQ(false, callback.is_null());
if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
......
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
......@@ -6,9 +6,9 @@
#define CHROME_BROWSER_CHROME_QUOTA_PERMISSION_CONTEXT_H_
#include "base/compiler_specific.h"
#include "content/browser/quota_permission_context.h"
#include "content/public/browser/quota_permission_context.h"
class ChromeQuotaPermissionContext : public QuotaPermissionContext {
class ChromeQuotaPermissionContext : public content::QuotaPermissionContext {
public:
ChromeQuotaPermissionContext();
virtual ~ChromeQuotaPermissionContext();
......@@ -24,7 +24,7 @@ class ChromeQuotaPermissionContext : public QuotaPermissionContext {
void DispatchCallbackOnIOThread(
const PermissionCallback& callback,
Response response);
QuotaPermissionResponse response);
};
#endif // CHROME_BROWSER_CHROME_QUOTA_PERMISSION_CONTEXT_H_
......@@ -22,7 +22,7 @@ MockContentBrowserClient::~MockContentBrowserClient() {
}
BrowserMainParts* MockContentBrowserClient::CreateBrowserMainParts(
const content::MainFunctionParams& parameters) {
const MainFunctionParams& parameters) {
return NULL;
}
......@@ -43,8 +43,8 @@ WebUIControllerFactory* MockContentBrowserClient::GetWebUIControllerFactory() {
return NULL;
}
GURL MockContentBrowserClient::GetEffectiveURL(
content::BrowserContext* browser_context, const GURL& url) {
GURL MockContentBrowserClient::GetEffectiveURL(BrowserContext* browser_context,
const GURL& url) {
return url;
}
......@@ -95,8 +95,7 @@ std::string MockContentBrowserClient::GetApplicationLocale() {
return std::string();
}
std::string MockContentBrowserClient::GetAcceptLangs(
content::BrowserContext* context) {
std::string MockContentBrowserClient::GetAcceptLangs(BrowserContext* context) {
return std::string();
}
......@@ -105,9 +104,9 @@ SkBitmap* MockContentBrowserClient::GetDefaultFavicon() {
return &empty;
}
bool MockContentBrowserClient::AllowAppCache(
const GURL& manifest_url, const GURL& first_party,
content::ResourceContext* context) {
bool MockContentBrowserClient::AllowAppCache(const GURL& manifest_url,
const GURL& first_party,
ResourceContext* context) {
return true;
}
......@@ -115,25 +114,23 @@ bool MockContentBrowserClient::AllowGetCookie(
const GURL& url,
const GURL& first_party,
const net::CookieList& cookie_list,
content::ResourceContext* context,
ResourceContext* context,
int render_process_id,
int render_view_id) {
return true;
}
bool MockContentBrowserClient::AllowSetCookie(
const GURL& url,
const GURL& first_party,
const std::string& cookie_line,
content::ResourceContext* context,
int render_process_id,
int render_view_id,
net::CookieOptions* options) {
bool MockContentBrowserClient::AllowSetCookie(const GURL& url,
const GURL& first_party,
const std::string& cookie_line,
ResourceContext* context,
int render_process_id,
int render_view_id,
net::CookieOptions* options) {
return true;
}
bool MockContentBrowserClient::AllowSaveLocalState(
content::ResourceContext* context) {
bool MockContentBrowserClient::AllowSaveLocalState(ResourceContext* context) {
return true;
}
......@@ -142,14 +139,14 @@ bool MockContentBrowserClient::AllowWorkerDatabase(
const string16& name,
const string16& display_name,
unsigned long estimated_size,
content::ResourceContext* context,
ResourceContext* context,
const std::vector<std::pair<int, int> >& render_views) {
return true;
}
bool MockContentBrowserClient::AllowWorkerFileSystem(
const GURL& url,
content::ResourceContext* context,
ResourceContext* context,
const std::vector<std::pair<int, int> >& render_views) {
return true;
}
......@@ -168,7 +165,7 @@ QuotaPermissionContext*
}
net::URLRequestContext* MockContentBrowserClient::OverrideRequestContextForURL(
const GURL& url, content::ResourceContext* context) {
const GURL& url, ResourceContext* context) {
return NULL;
}
......@@ -205,8 +202,8 @@ void MockContentBrowserClient::AddNewCertificate(
}
void MockContentBrowserClient::RequestMediaAccessPermission(
const content::MediaStreamRequest* request,
const content::MediaResponseCallback& callback) {
const MediaStreamRequest* request,
const MediaResponseCallback& callback) {
}
void MockContentBrowserClient::RequestDesktopNotificationPermission(
......@@ -219,13 +216,13 @@ void MockContentBrowserClient::RequestDesktopNotificationPermission(
WebKit::WebNotificationPresenter::Permission
MockContentBrowserClient::CheckDesktopNotificationPermission(
const GURL& source_origin,
content::ResourceContext* context,
ResourceContext* context,
int render_process_id) {
return WebKit::WebNotificationPresenter::PermissionAllowed;
}
void MockContentBrowserClient::ShowDesktopNotification(
const content::ShowDesktopNotificationHostMsgParams& params,
const ShowDesktopNotificationHostMsgParams& params,
int render_process_id,
int render_view_id,
bool worker) {
......@@ -240,13 +237,13 @@ void MockContentBrowserClient::CancelDesktopNotification(
bool MockContentBrowserClient::CanCreateWindow(
const GURL& source_origin,
WindowContainerType container_type,
content::ResourceContext* context,
ResourceContext* context,
int render_process_id) {
return true;
}
std::string MockContentBrowserClient::GetWorkerProcessTitle(
const GURL& url, content::ResourceContext* context) {
const GURL& url, ResourceContext* context) {
return std::string();
}
......
......@@ -22,7 +22,7 @@ class MockContentBrowserClient : public ContentBrowserClient {
virtual ~MockContentBrowserClient();
virtual BrowserMainParts* CreateBrowserMainParts(
const content::MainFunctionParams& parameters) OVERRIDE;
const MainFunctionParams& parameters) OVERRIDE;
virtual WebContentsView* CreateWebContentsView(
WebContents* web_contents) OVERRIDE;
virtual void RenderViewHostCreated(
......@@ -30,7 +30,7 @@ class MockContentBrowserClient : public ContentBrowserClient {
virtual void RenderProcessHostCreated(
RenderProcessHost* host) OVERRIDE;
virtual WebUIControllerFactory* GetWebUIControllerFactory() OVERRIDE;
virtual GURL GetEffectiveURL(content::BrowserContext* browser_context,
virtual GURL GetEffectiveURL(BrowserContext* browser_context,
const GURL& url) OVERRIDE;
virtual bool ShouldUseProcessPerSite(BrowserContext* browser_context,
const GURL& effective_url) OVERRIDE;
......@@ -48,37 +48,35 @@ class MockContentBrowserClient : public ContentBrowserClient {
virtual void AppendExtraCommandLineSwitches(CommandLine* command_line,
int child_process_id) OVERRIDE;
virtual std::string GetApplicationLocale() OVERRIDE;
virtual std::string GetAcceptLangs(
content::BrowserContext* context) OVERRIDE;
virtual std::string GetAcceptLangs(BrowserContext* context) OVERRIDE;
virtual SkBitmap* GetDefaultFavicon() OVERRIDE;
virtual bool AllowAppCache(const GURL& manifest_url,
const GURL& first_party,
content::ResourceContext* context) OVERRIDE;
ResourceContext* context) OVERRIDE;
virtual bool AllowGetCookie(const GURL& url,
const GURL& first_party,
const net::CookieList& cookie_list,
content::ResourceContext* context,
ResourceContext* context,
int render_process_id,
int render_view_id) OVERRIDE;
virtual bool AllowSetCookie(const GURL& url,
const GURL& first_party,
const std::string& cookie_line,
content::ResourceContext* context,
ResourceContext* context,
int render_process_id,
int render_view_id,
net::CookieOptions* options) OVERRIDE;
virtual bool AllowSaveLocalState(
content::ResourceContext* context) OVERRIDE;
virtual bool AllowSaveLocalState(ResourceContext* context) OVERRIDE;
virtual bool AllowWorkerDatabase(
const GURL& url,
const string16& name,
const string16& display_name,
unsigned long estimated_size,
content::ResourceContext* context,
ResourceContext* context,
const std::vector<std::pair<int, int> >& render_views) OVERRIDE;
virtual bool AllowWorkerFileSystem(
const GURL& url,
content::ResourceContext* context,
ResourceContext* context,
const std::vector<std::pair<int, int> >& render_views) OVERRIDE;
virtual bool AllowWorkerIndexedDB(
const GURL& url,
......@@ -86,7 +84,7 @@ class MockContentBrowserClient : public ContentBrowserClient {
content::ResourceContext* context,
const std::vector<std::pair<int, int> >& render_views) OVERRIDE;
virtual net::URLRequestContext* OverrideRequestContextForURL(
const GURL& url, content::ResourceContext* context) OVERRIDE;
const GURL& url, ResourceContext* context) OVERRIDE;
virtual QuotaPermissionContext* CreateQuotaPermissionContext() OVERRIDE;
virtual void OpenItem(const FilePath& path) OVERRIDE;
virtual void ShowItemInFolder(const FilePath& path) OVERRIDE;
......@@ -111,8 +109,8 @@ class MockContentBrowserClient : public ContentBrowserClient {
int render_process_id,
int render_view_id) OVERRIDE;
virtual void RequestMediaAccessPermission(
const content::MediaStreamRequest* request,
const content::MediaResponseCallback& callback) OVERRIDE;
const MediaStreamRequest* request,
const MediaResponseCallback& callback) OVERRIDE;
virtual void RequestDesktopNotificationPermission(
const GURL& source_origin,
int callback_context,
......@@ -121,7 +119,7 @@ class MockContentBrowserClient : public ContentBrowserClient {
virtual WebKit::WebNotificationPresenter::Permission
CheckDesktopNotificationPermission(
const GURL& source_origin,
content::ResourceContext* context,
ResourceContext* context,
int render_process_id) OVERRIDE;
virtual void ShowDesktopNotification(
const content::ShowDesktopNotificationHostMsgParams& params,
......@@ -135,10 +133,10 @@ class MockContentBrowserClient : public ContentBrowserClient {
virtual bool CanCreateWindow(
const GURL& source_origin,
WindowContainerType container_type,
content::ResourceContext* context,
ResourceContext* context,
int render_process_id) OVERRIDE;
virtual std::string GetWorkerProcessTitle(
const GURL& url, content::ResourceContext* context) OVERRIDE;
virtual std::string GetWorkerProcessTitle(const GURL& url,
ResourceContext* context) OVERRIDE;
virtual void ResourceDispatcherHostCreated() OVERRIDE;
virtual SpeechInputManagerDelegate* GetSpeechInputManagerDelegate() OVERRIDE;
virtual ui::Clipboard* GetClipboard() OVERRIDE;
......
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
......@@ -6,12 +6,13 @@
#include "base/bind.h"
#include "base/memory/weak_ptr.h"
#include "content/browser/quota_permission_context.h"
#include "content/common/quota_messages.h"
#include "content/public/browser/quota_permission_context.h"
#include "googleurl/src/gurl.h"
#include "net/base/net_util.h"
#include "webkit/quota/quota_manager.h"
using content::QuotaPermissionContext;
using quota::QuotaClient;
using quota::QuotaManager;
using quota::QuotaStatusCode;
......@@ -153,8 +154,9 @@ class QuotaDispatcherHost::RequestQuotaDispatcher
DidFinish(status, std::min(requested_quota_, quota));
}
void DidGetPermissionResponse(QuotaPermissionContext::Response response) {
if (response != QuotaPermissionContext::kResponseAllow) {
void DidGetPermissionResponse(
QuotaPermissionContext::QuotaPermissionResponse response) {
if (response != QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_ALLOW) {
// User didn't allow the new quota. Just returning the current quota.
DidFinish(quota::kQuotaStatusOk, current_quota_);
return;
......
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
......@@ -12,6 +12,10 @@
class GURL;
namespace content {
class QuotaPermissionContext;
}
namespace IPC {
class Message;
}
......@@ -20,13 +24,11 @@ namespace quota {
class QuotaManager;
}
class QuotaPermissionContext;
class QuotaDispatcherHost : public content::BrowserMessageFilter {
public:
QuotaDispatcherHost(int process_id,
quota::QuotaManager* quota_manager,
QuotaPermissionContext* permission_context);
content::QuotaPermissionContext* permission_context);
virtual ~QuotaDispatcherHost();
virtual bool OnMessageReceived(const IPC::Message& message,
bool* message_was_ok) OVERRIDE;
......@@ -51,7 +53,7 @@ class QuotaDispatcherHost : public content::BrowserMessageFilter {
int process_id_;
quota::QuotaManager* quota_manager_;
scoped_refptr<QuotaPermissionContext> permission_context_;
scoped_refptr<content::QuotaPermissionContext> permission_context_;
IDMap<RequestDispatcher, IDMapOwnPointer> outstanding_requests_;
......
......@@ -91,6 +91,7 @@
'public/browser/plugin_service.h',
'public/browser/profiler_controller.h',
'public/browser/profiler_subscriber.h',
'public/browser/quota_permission_context.h',
'public/browser/render_process_host.h',
'public/browser/render_process_host_factory.h',
'public/browser/render_view_host_delegate.cc',
......@@ -415,7 +416,6 @@
'browser/profiler_controller_impl.h',
'browser/profiler_message_filter.cc',
'browser/profiler_message_filter.h',
'browser/quota_permission_context.h',
'browser/renderer_host/accelerated_plugin_view_mac.h',
'browser/renderer_host/accelerated_plugin_view_mac.mm',
'browser/renderer_host/accelerated_surface_container_mac.cc',
......
......@@ -21,24 +21,11 @@ class CommandLine;
class FilePath;
class GURL;
class PluginProcessHost;
class QuotaPermissionContext;
class RenderViewHost;
class ResourceDispatcherHost;
class SkBitmap;
struct WebPreferences;
namespace content {
class AccessTokenStore;
class BrowserMainParts;
class RenderProcessHost;
class SiteInstance;
class SpeechInputManagerDelegate;
class WebContents;
class WebContentsView;
struct MainFunctionParams;
struct ShowDesktopNotificationHostMsgParams;
}
namespace crypto {
class CryptoModuleBlockingPasswordDelegate;
}
......@@ -61,9 +48,19 @@ class Clipboard;
namespace content {
class AccessTokenStore;
class BrowserContext;
class BrowserMainParts;
class RenderProcessHost;
class QuotaPermissionContext;
class ResourceContext;
class SiteInstance;
class SpeechInputManagerDelegate;
class WebContents;
class WebContentsView;
class WebUIControllerFactory;
struct MainFunctionParams;
struct ShowDesktopNotificationHostMsgParams;
typedef base::Callback< void(const content::MediaStreamDevices&) >
MediaResponseCallback;
......
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_QUOTA_PERMISSION_CONTEXT_H_
#define CONTENT_BROWSER_QUOTA_PERMISSION_CONTEXT_H_
#ifndef CONTENT_PUBLIC_BROWSER_QUOTA_PERMISSION_CONTEXT_H_
#define CONTENT_PUBLIC_BROWSER_QUOTA_PERMISSION_CONTEXT_H_
#pragma once
#include "base/callback.h"
#include "base/memory/ref_counted.h"
......@@ -11,17 +12,19 @@
class GURL;
namespace content {
class QuotaPermissionContext
: public base::RefCountedThreadSafe<QuotaPermissionContext> {
public:
enum Response {
kResponseUnknown,
kResponseAllow,
kResponseDisallow,
kResponseCancelled,
enum QuotaPermissionResponse {
QUOTA_PERMISSION_RESPONSE_UNKNOWN,
QUOTA_PERMISSION_RESPONSE_ALLOW,
QUOTA_PERMISSION_RESPONSE_DISALLOW,
QUOTA_PERMISSION_RESPONSE_CANCELLED,
};
typedef base::Callback<void(Response)> PermissionCallback;
typedef base::Callback<void(QuotaPermissionResponse)> PermissionCallback;
virtual void RequestQuotaPermission(
const GURL& origin_url,
......@@ -36,4 +39,6 @@ class QuotaPermissionContext
virtual ~QuotaPermissionContext() {}
};
#endif // CONTENT_BROWSER_QUOTA_PERMISSION_CONTEXT_H_
} // namespace content
#endif // CONTENT_PUBLIC_BROWSER_QUOTA_PERMISSION_CONTEXT_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment