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 - AllowIndexedDB *Includes fixes from review feedback* Fixes brave/browser-laptop#12463 Fixes brave/browser-laptop#14475 Possibly addresses brave/browser-laptop#10685
- Loading branch information
Showing
4 changed files
with
161 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
88 changes: 88 additions & 0 deletions
88
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,88 @@ | ||
// 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/profiles/profile.h" | ||
#include "chrome/common/render_messages.h" | ||
#include "components/content_settings/core/browser/host_content_settings_map.h" | ||
#include "components/content_settings/core/common/content_settings.h" | ||
#include "components/content_settings/core/common/content_settings_types.h" | ||
|
||
using content::BrowserThread; | ||
|
||
namespace { | ||
|
||
const uint32_t kRenderFilteredMessageClasses[] = { | ||
ChromeMsgStart, | ||
}; | ||
|
||
} // namespace | ||
|
||
BraveRenderMessageFilter::BraveRenderMessageFilter(int render_process_id, | ||
Profile* profile) | ||
: BrowserMessageFilter(kRenderFilteredMessageClasses, | ||
arraysize(kRenderFilteredMessageClasses)), | ||
render_process_id_(render_process_id), | ||
profile_(profile) { | ||
host_content_settings_map_ = | ||
HostContentSettingsMapFactory::GetForProfile(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(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) { | ||
ContentSetting setting = host_content_settings_map_->GetContentSetting( | ||
origin_url, top_origin_url, CONTENT_SETTINGS_TYPE_COOKIES, ""); | ||
*allowed = setting == ContentSetting::CONTENT_SETTING_ALLOW; | ||
} | ||
|
||
void BraveRenderMessageFilter::OnAllowDOMStorage(int render_frame_id, | ||
const GURL& origin_url, | ||
const GURL& top_origin_url, | ||
bool local, | ||
bool* allowed) { | ||
ContentSetting setting = host_content_settings_map_->GetContentSetting( | ||
origin_url, top_origin_url, CONTENT_SETTINGS_TYPE_COOKIES, ""); | ||
*allowed = setting == ContentSetting::CONTENT_SETTING_ALLOW; | ||
} | ||
|
||
void BraveRenderMessageFilter::OnAllowIndexedDB(int render_frame_id, | ||
const GURL& origin_url, | ||
const GURL& top_origin_url, | ||
const base::string16& name, | ||
bool* allowed) { | ||
ContentSetting setting = host_content_settings_map_->GetContentSetting( | ||
origin_url, top_origin_url, CONTENT_SETTINGS_TYPE_COOKIES, ""); | ||
*allowed = setting == ContentSetting::CONTENT_SETTING_ALLOW; | ||
} | ||
|
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,69 @@ | ||
// 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" | ||
#include "chrome/browser/content_settings/host_content_settings_map_factory.h" | ||
|
||
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 { | ||
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 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_; | ||
|
||
HostContentSettingsMap* host_content_settings_map_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(BraveRenderMessageFilter); | ||
}; | ||
|
||
#endif // BRAVE_BROWSER_RENDERER_HOST_BRAVE_RENDER_MESSAGE_FILTER_H_ |