diff --git a/brave/browser/renderer_host/brave_render_message_filter.cc b/brave/browser/renderer_host/brave_render_message_filter.cc index bb6244187a..1095d2139e 100644 --- a/brave/browser/renderer_host/brave_render_message_filter.cc +++ b/brave/browser/renderer_host/brave_render_message_filter.cc @@ -13,9 +13,10 @@ #include "base/logging.h" #include "base/macros.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/metrics/chrome_metrics_service_accessor.h" +#include "chrome/browser/content_settings/cookie_settings_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/render_messages.h" +#include "components/content_settings/core/browser/cookie_settings.h" using content::BrowserThread; @@ -32,7 +33,8 @@ BraveRenderMessageFilter::BraveRenderMessageFilter(int render_process_id, : BrowserMessageFilter(kRenderFilteredMessageClasses, arraysize(kRenderFilteredMessageClasses)), render_process_id_(render_process_id), - profile_(profile) { + profile_(profile), + cookie_settings_(CookieSettingsFactory::GetForProfile(profile)) { } BraveRenderMessageFilter::~BraveRenderMessageFilter() { @@ -43,11 +45,6 @@ bool BraveRenderMessageFilter::OnMessageReceived(const IPC::Message& message) { IPC_BEGIN_MESSAGE_MAP(BraveRenderMessageFilter, message) IPC_MESSAGE_HANDLER(ChromeViewHostMsg_AllowDatabase, OnAllowDatabase) IPC_MESSAGE_HANDLER(ChromeViewHostMsg_AllowDOMStorage, OnAllowDOMStorage) - IPC_MESSAGE_HANDLER_DELAY_REPLY( - ChromeViewHostMsg_RequestFileSystemAccessSync, - OnRequestFileSystemAccessSync) - IPC_MESSAGE_HANDLER(ChromeViewHostMsg_RequestFileSystemAccessAsync, - OnRequestFileSystemAccessAsync) IPC_MESSAGE_HANDLER(ChromeViewHostMsg_AllowIndexedDB, OnAllowIndexedDB) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() @@ -62,7 +59,8 @@ void BraveRenderMessageFilter::OnAllowDatabase( const base::string16& name, const base::string16& display_name, bool* allowed) { - *allowed = true; + *allowed = + cookie_settings_->IsCookieAccessAllowed(origin_url, top_origin_url); } void BraveRenderMessageFilter::OnAllowDOMStorage(int render_frame_id, @@ -70,31 +68,8 @@ void BraveRenderMessageFilter::OnAllowDOMStorage(int render_frame_id, const GURL& top_origin_url, bool local, bool* allowed) { - *allowed = true; -} - -void BraveRenderMessageFilter::OnRequestFileSystemAccessSync( - int render_frame_id, - const GURL& origin_url, - const GURL& top_origin_url, - IPC::Message* reply_msg) { - DCHECK_CURRENTLY_ON(BrowserThread::IO); - - - ChromeViewHostMsg_RequestFileSystemAccessSync::WriteReplyParams(reply_msg, - true); - Send(reply_msg); -} - -void BraveRenderMessageFilter::OnRequestFileSystemAccessAsync( - int render_frame_id, - int request_id, - const GURL& origin_url, - const GURL& top_origin_url) { - DCHECK_CURRENTLY_ON(BrowserThread::IO); - - Send(new ChromeViewMsg_RequestFileSystemAccessAsyncResponse( - render_frame_id, request_id, true)); + *allowed = + cookie_settings_->IsCookieAccessAllowed(origin_url, top_origin_url); } void BraveRenderMessageFilter::OnAllowIndexedDB(int render_frame_id, @@ -102,6 +77,7 @@ void BraveRenderMessageFilter::OnAllowIndexedDB(int render_frame_id, const GURL& top_origin_url, const base::string16& name, bool* allowed) { - *allowed = true; + *allowed = + cookie_settings_->IsCookieAccessAllowed(origin_url, top_origin_url); } diff --git a/brave/browser/renderer_host/brave_render_message_filter.h b/brave/browser/renderer_host/brave_render_message_filter.h index df5d1d6551..707c7c6254 100644 --- a/brave/browser/renderer_host/brave_render_message_filter.h +++ b/brave/browser/renderer_host/brave_render_message_filter.h @@ -19,6 +19,10 @@ class GURL; class Profile; +namespace content_settings { +class CookieSettings; +} + // This class filters out incoming Chrome-specific IPC messages for the renderer // process on the IPC thread. class BraveRenderMessageFilter : public content::BrowserMessageFilter { @@ -44,14 +48,6 @@ class BraveRenderMessageFilter : public content::BrowserMessageFilter { const GURL& top_origin_url, bool local, bool* allowed); - void OnRequestFileSystemAccessSync(int render_frame_id, - const GURL& origin_url, - const GURL& top_origin_url, - IPC::Message* message); - void OnRequestFileSystemAccessAsync(int render_frame_id, - int request_id, - const GURL& origin_url, - const GURL& top_origin_url); void OnAllowIndexedDB(int render_frame_id, const GURL& origin_url, const GURL& top_origin_url, @@ -64,6 +60,9 @@ class BraveRenderMessageFilter : public content::BrowserMessageFilter { // accessed on the UI thread! Profile* profile_; + // Used to look up permissions at database creation time. + scoped_refptr cookie_settings_; + DISALLOW_COPY_AND_ASSIGN(BraveRenderMessageFilter); };