-
Notifications
You must be signed in to change notification settings - Fork 922
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add devtools cookies display support.
- Loading branch information
Showing
6 changed files
with
158 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
include_rules = [ | ||
"+../../../../../../content/browser/devtools/protocol", | ||
"+content/browser/devtools/protocol", | ||
] |
28 changes: 28 additions & 0 deletions
28
chromium_src/content/browser/devtools/protocol/network_handler.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,28 @@ | ||
/* Copyright (c) 2021 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 "content/browser/devtools/protocol/network_handler.h" | ||
|
||
#define BRAVE_COOKIE_RETRIEVER_NETWORK_SERVICE_RETRIEVE_ARGS \ | ||
const url::Origin &top_frame_origin, | ||
|
||
#define BRAVE_COOKIE_RETRIEVER_NETWORK_SERVICE_RETRIEVE_BODY \ | ||
cookie_options.set_top_frame_origin(top_frame_origin); | ||
|
||
#define BRAVE_NETWORK_HANDLER_GET_COOKIES_RETREIVE_CALL_ARGS \ | ||
host_->ComputeTopFrameOrigin(host_->GetLastCommittedOrigin()), | ||
|
||
#define BRAVE_NETWORK_HANDLER_SET_COOKIES_SET_COOKIE_OPTIONS \ | ||
options.set_top_frame_origin( \ | ||
host_ ? base::make_optional<url::Origin>(host_->ComputeTopFrameOrigin( \ | ||
host_->GetLastCommittedOrigin())) \ | ||
: base::nullopt); | ||
|
||
#include "../../../../../../content/browser/devtools/protocol/network_handler.cc" | ||
|
||
#undef BRAVE_NETWORK_HANDLER_SET_COOKIES_SET_COOKIE_OPTIONS | ||
#undef BRAVE_NETWORK_HANDLER_GET_COOKIES_RETREIVE_CALL_ARGS | ||
#undef BRAVE_COOKIE_RETRIEVER_NETWORK_SERVICE_RETRIEVE_BODY | ||
#undef BRAVE_COOKIE_RETRIEVER_NETWORK_SERVICE_RETRIEVE_ARGS |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* Copyright 2021 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_CHROMIUM_SRC_SERVICES_NETWORK_COOKIE_MANAGER_H_ | ||
#define BRAVE_CHROMIUM_SRC_SERVICES_NETWORK_COOKIE_MANAGER_H_ | ||
|
||
#include "services/network/public/mojom/cookie_manager.mojom.h" | ||
|
||
#define GetCookieList \ | ||
GetCookieList_ChromiumImpl(const GURL& url, \ | ||
const net::CookieOptions& cookie_options, \ | ||
GetCookieListCallback callback); \ | ||
void GetCookieList | ||
|
||
#define SetCanonicalCookie \ | ||
SetCanonicalCookie_ChromiumImpl(const net::CanonicalCookie& cookie, \ | ||
const GURL& source_url, \ | ||
const net::CookieOptions& cookie_options, \ | ||
SetCanonicalCookieCallback callback); \ | ||
void SetCanonicalCookie | ||
|
||
#include "../../../../services/network/cookie_manager.h" | ||
|
||
#undef SetCanonicalCookie | ||
#undef GetCookieList | ||
|
||
#endif // BRAVE_CHROMIUM_SRC_SERVICES_NETWORK_COOKIE_MANAGER_H_ |
41 changes: 41 additions & 0 deletions
41
patches/content-browser-devtools-protocol-network_handler.cc.patch
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,41 @@ | ||
diff --git a/content/browser/devtools/protocol/network_handler.cc b/content/browser/devtools/protocol/network_handler.cc | ||
index 33907f5922a626913dc11d0372fba32d10cb10a1..707df85a130f13ca1ebff745125809308fb28d35 100644 | ||
--- a/content/browser/devtools/protocol/network_handler.cc | ||
+++ b/content/browser/devtools/protocol/network_handler.cc | ||
@@ -199,10 +199,12 @@ class CookieRetrieverNetworkService | ||
public: | ||
static void Retrieve(network::mojom::CookieManager* cookie_manager, | ||
const std::vector<GURL> urls, | ||
+ BRAVE_COOKIE_RETRIEVER_NETWORK_SERVICE_RETRIEVE_ARGS | ||
std::unique_ptr<GetCookiesCallback> callback) { | ||
scoped_refptr<CookieRetrieverNetworkService> self = | ||
new CookieRetrieverNetworkService(std::move(callback)); | ||
net::CookieOptions cookie_options = net::CookieOptions::MakeAllInclusive(); | ||
+ BRAVE_COOKIE_RETRIEVER_NETWORK_SERVICE_RETRIEVE_BODY | ||
for (const auto& url : urls) { | ||
cookie_manager->GetCookieList( | ||
url, cookie_options, | ||
@@ -1309,7 +1311,6 @@ void NetworkHandler::ClearBrowserCookies( | ||
callback->sendFailure(Response::InternalError()); | ||
return; | ||
} | ||
- | ||
storage_partition_->GetCookieManagerForBrowserProcess()->DeleteCookies( | ||
network::mojom::CookieDeletionFilter::New(), | ||
base::BindOnce([](std::unique_ptr<ClearBrowserCookiesCallback> callback, | ||
@@ -1327,6 +1328,7 @@ void NetworkHandler::GetCookies(Maybe<Array<String>> protocol_urls, | ||
|
||
CookieRetrieverNetworkService::Retrieve( | ||
storage_partition_->GetCookieManagerForBrowserProcess(), urls, | ||
+ BRAVE_NETWORK_HANDLER_GET_COOKIES_RETREIVE_CALL_ARGS | ||
std::move(callback)); | ||
} | ||
|
||
@@ -1383,6 +1385,7 @@ void NetworkHandler::SetCookie(const std::string& name, | ||
options.set_same_site_cookie_context( | ||
net::CookieOptions::SameSiteCookieContext::MakeInclusive()); | ||
options.set_include_httponly(); | ||
+ BRAVE_NETWORK_HANDLER_SET_COOKIES_SET_COOKIE_OPTIONS | ||
storage_partition_->GetCookieManagerForBrowserProcess()->SetCanonicalCookie( | ||
*cookie, net::cookie_util::SimulatedCookieSource(*cookie, "https"), | ||
options, |