-
Notifications
You must be signed in to change notification settings - Fork 896
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement Sec-GPC header and globalPrivacyControl JS API
- Loading branch information
1 parent
f4e20a3
commit ec4ccbb
Showing
12 changed files
with
170 additions
and
2 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
24 changes: 24 additions & 0 deletions
24
browser/net/global_privacy_control_network_delegate_helper.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,24 @@ | ||
/* Copyright (c) 2020 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "brave/browser/net/global_privacy_control_network_delegate_helper.h" | ||
|
||
#include <memory> | ||
|
||
#include "brave/common/network_constants.h" | ||
#include "net/base/net_errors.h" | ||
#include "net/http/http_request_headers.h" | ||
|
||
namespace brave { | ||
|
||
int OnBeforeStartTransaction_GlobalPrivacyControlWork( | ||
net::HttpRequestHeaders* headers, | ||
const ResponseCallback& next_callback, | ||
std::shared_ptr<BraveRequestInfo> ctx) { | ||
headers->SetHeader(kSecGpcHeader, "1"); | ||
return net::OK; | ||
} | ||
|
||
} // namespace brave |
22 changes: 22 additions & 0 deletions
22
browser/net/global_privacy_control_network_delegate_helper.h
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,22 @@ | ||
/* Copyright (c) 2020 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#ifndef BRAVE_BROWSER_NET_GLOBAL_PRIVACY_CONTROL_NETWORK_DELEGATE_HELPER_H_ | ||
#define BRAVE_BROWSER_NET_GLOBAL_PRIVACY_CONTROL_NETWORK_DELEGATE_HELPER_H_ | ||
|
||
#include <memory> | ||
|
||
#include "brave/browser/net/url_context.h" | ||
|
||
namespace brave { | ||
|
||
int OnBeforeStartTransaction_GlobalPrivacyControlWork( | ||
net::HttpRequestHeaders* headers, | ||
const ResponseCallback& next_callback, | ||
std::shared_ptr<BraveRequestInfo> ctx); | ||
|
||
} // namespace brave | ||
|
||
#endif // BRAVE_BROWSER_NET_GLOBAL_PRIVACY_CONTROL_NETWORK_DELEGATE_HELPER_H_ |
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
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
13 changes: 13 additions & 0 deletions
13
third_party/blink/renderer/modules/global_privacy_control/BUILD.gn
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,13 @@ | ||
# Copyright (c) 2020 The Brave Authors. All rights reserved. | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
# You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
import("//third_party/blink/renderer/modules/modules.gni") | ||
|
||
blink_modules_sources("global_privacy_control") { | ||
sources = [ | ||
"navigator_global_privacy_control.cc", | ||
"navigator_global_privacy_control.h", | ||
] | ||
} |
6 changes: 6 additions & 0 deletions
6
third_party/blink/renderer/modules/global_privacy_control/idls.gni
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,6 @@ | ||
# Copyright (c) 2020 The Brave Authors. All rights reserved. | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
# You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
modules_dependency_idl_files = [ "navigator_global_privacy_control.idl" ] |
40 changes: 40 additions & 0 deletions
40
...d_party/blink/renderer/modules/global_privacy_control/navigator_global_privacy_control.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,40 @@ | ||
/* Copyright (c) 2020 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "brave/third_party/blink/renderer/modules/global_privacy_control/navigator_global_privacy_control.h" | ||
|
||
#include "third_party/blink/renderer/core/frame/navigator.h" | ||
|
||
namespace blink { | ||
|
||
NavigatorGlobalPrivacyControl:: | ||
NavigatorGlobalPrivacyControl(Navigator& navigator) // NOLINT | ||
: Supplement<Navigator>(navigator) {} | ||
|
||
// static | ||
const char NavigatorGlobalPrivacyControl::kSupplementName[] = | ||
"NavigatorGlobalPrivacyControl"; | ||
|
||
NavigatorGlobalPrivacyControl& | ||
NavigatorGlobalPrivacyControl::From(Navigator& navigator) { | ||
NavigatorGlobalPrivacyControl* supplement = | ||
Supplement<Navigator>::From<NavigatorGlobalPrivacyControl>(navigator); | ||
if (!supplement) { | ||
supplement = MakeGarbageCollected<NavigatorGlobalPrivacyControl>(navigator); | ||
ProvideTo(navigator, supplement); | ||
} | ||
return *supplement; | ||
} | ||
|
||
bool NavigatorGlobalPrivacyControl:: | ||
globalPrivacyControl(blink::Navigator& navigator) { // NOLINT | ||
return true; | ||
} | ||
|
||
void NavigatorGlobalPrivacyControl::Trace(blink::Visitor* visitor) const { | ||
Supplement<Navigator>::Trace(visitor); | ||
} | ||
|
||
} // namespace blink |
39 changes: 39 additions & 0 deletions
39
third_party/blink/renderer/modules/global_privacy_control/navigator_global_privacy_control.h
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,39 @@ | ||
// Copyright (c) 2020 The Brave Authors. All rights reserved. | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
// you can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
#ifndef BRAVE_THIRD_PARTY_BLINK_RENDERER_MODULES_GLOBAL_PRIVACY_CONTROL_NAVIGATOR_GLOBAL_PRIVACY_CONTROL_H_ | ||
#define BRAVE_THIRD_PARTY_BLINK_RENDERER_MODULES_GLOBAL_PRIVACY_CONTROL_NAVIGATOR_GLOBAL_PRIVACY_CONTROL_H_ | ||
|
||
#include "third_party/blink/renderer/core/frame/navigator.h" | ||
#include "third_party/blink/renderer/platform/bindings/name_client.h" | ||
#include "third_party/blink/renderer/platform/heap/handle.h" | ||
#include "third_party/blink/renderer/platform/supplementable.h" | ||
|
||
namespace blink { | ||
|
||
class Navigator; | ||
|
||
class NavigatorGlobalPrivacyControl final | ||
: public GarbageCollected<NavigatorGlobalPrivacyControl>, | ||
public Supplement<Navigator>, | ||
public NameClient { | ||
|
||
public: | ||
static const char kSupplementName[]; | ||
|
||
static NavigatorGlobalPrivacyControl& From(Navigator&); | ||
static bool globalPrivacyControl(blink::Navigator&); | ||
|
||
explicit NavigatorGlobalPrivacyControl(Navigator&); | ||
|
||
void Trace(blink::Visitor*) const override; | ||
const char* NameInHeapSnapshot() const override { | ||
return "NavigatorGlobalPrivacyControl"; | ||
} | ||
}; | ||
|
||
} // namespace blink | ||
|
||
#endif // BRAVE_THIRD_PARTY_BLINK_RENDERER_MODULES_GLOBAL_PRIVACY_CONTROL_NAVIGATOR_GLOBAL_PRIVACY_CONTROL_H_ |
9 changes: 9 additions & 0 deletions
9
..._party/blink/renderer/modules/global_privacy_control/navigator_global_privacy_control.idl
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,9 @@ | ||
/* Copyright (c) 2020 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
[ | ||
ImplementedAs=NavigatorGlobalPrivacyControl | ||
] partial interface Navigator { | ||
readonly attribute boolean globalPrivacyControl; | ||
}; |