This repository has been archived by the owner on Jan 4, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- AllowDatabase - AllowDOMStorage - RequestFileSystemAccess - AllowIndexedDB Fixes brave/browser-laptop#12463 Fixes brave/browser-laptop#14475 Possibly addresses brave/browser-laptop#10685 Auditors: @darkdh, @bridiver
- Loading branch information
Showing
4 changed files
with
181 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
brave/browser/renderer_host/brave_render_message_filter.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
// 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. | ||
|
||
#include "brave/browser/renderer_host/brave_render_message_filter.h" | ||
|
||
#include <stdint.h> | ||
|
||
#include <string> | ||
|
||
#include "base/bind.h" | ||
#include "base/bind_helpers.h" | ||
#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/profiles/profile.h" | ||
#include "chrome/common/render_messages.h" | ||
|
||
using content::BrowserThread; | ||
|
||
namespace { | ||
|
||
const uint32_t kRenderFilteredMessageClasses[] = { | ||
ChromeMsgStart, NetworkHintsMsgStart, | ||
}; | ||
|
||
} // namespace | ||
|
||
BraveRenderMessageFilter::BraveRenderMessageFilter(int render_process_id, | ||
Profile* profile) | ||
: BrowserMessageFilter(kRenderFilteredMessageClasses, | ||
arraysize(kRenderFilteredMessageClasses)), | ||
render_process_id_(render_process_id), | ||
profile_(profile) { | ||
} | ||
|
||
BraveRenderMessageFilter::~BraveRenderMessageFilter() { | ||
} | ||
|
||
bool BraveRenderMessageFilter::OnMessageReceived(const IPC::Message& message) { | ||
bool handled = true; | ||
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() | ||
|
||
return handled; | ||
} | ||
|
||
void BraveRenderMessageFilter::OnAllowDatabase( | ||
int render_frame_id, | ||
const GURL& origin_url, | ||
const GURL& top_origin_url, | ||
const base::string16& name, | ||
const base::string16& display_name, | ||
bool* allowed) { | ||
*allowed = true; | ||
} | ||
|
||
void BraveRenderMessageFilter::OnAllowDOMStorage(int render_frame_id, | ||
const GURL& origin_url, | ||
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)); | ||
} | ||
|
||
void BraveRenderMessageFilter::OnAllowIndexedDB(int render_frame_id, | ||
const GURL& origin_url, | ||
const GURL& top_origin_url, | ||
const base::string16& name, | ||
bool* allowed) { | ||
*allowed = true; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// 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 BRAVE_BROWSER_RENDERER_HOST_BRAVE_RENDER_MESSAGE_FILTER_H_ | ||
#define BRAVE_BROWSER_RENDERER_HOST_BRAVE_RENDER_MESSAGE_FILTER_H_ | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
#include "base/callback.h" | ||
#include "base/macros.h" | ||
#include "base/sequenced_task_runner_helpers.h" | ||
#include "content/public/browser/browser_message_filter.h" | ||
#include "content/public/browser/browser_thread.h" | ||
#include "extensions/buildflags/buildflags.h" | ||
#include "ppapi/buildflags/buildflags.h" | ||
|
||
class GURL; | ||
class Profile; | ||
|
||
// This class filters out incoming Chrome-specific IPC messages for the renderer | ||
// process on the IPC thread. | ||
class BraveRenderMessageFilter : public content::BrowserMessageFilter { | ||
public: | ||
BraveRenderMessageFilter(int render_process_id, Profile* profile); | ||
|
||
bool OnMessageReceived(const IPC::Message& message) override; | ||
|
||
private: | ||
friend class content::BrowserThread; | ||
friend class base::DeleteHelper<BraveRenderMessageFilter>; | ||
|
||
~BraveRenderMessageFilter() override; | ||
|
||
void OnAllowDatabase(int render_frame_id, | ||
const GURL& origin_url, | ||
const GURL& top_origin_url, | ||
const base::string16& name, | ||
const base::string16& display_name, | ||
bool* allowed); | ||
void OnAllowDOMStorage(int render_frame_id, | ||
const GURL& origin_url, | ||
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, | ||
const base::string16& name, | ||
bool* allowed); | ||
|
||
const int render_process_id_; | ||
|
||
// The Profile associated with our renderer process. This should only be | ||
// accessed on the UI thread! | ||
Profile* profile_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(BraveRenderMessageFilter); | ||
}; | ||
|
||
#endif // BRAVE_BROWSER_RENDERER_HOST_BRAVE_RENDER_MESSAGE_FILTER_H_ |