-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from brave/geolocations-master
Add Brave geolocations and system network redirect
- Loading branch information
Showing
15 changed files
with
201 additions
and
38 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
File renamed without changes.
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,20 @@ | ||
/* 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/brave_profile_network_delegate.h" | ||
|
||
#include "brave/browser/net/brave_httpse_network_delegate_helper.h" | ||
|
||
BraveProfileNetworkDelegate::BraveProfileNetworkDelegate( | ||
extensions::EventRouterForwarder* event_router, | ||
BooleanPrefMember* enable_referrers) : | ||
BraveNetworkDelegateBase(event_router, enable_referrers) { | ||
brave::OnBeforeURLRequestCallback callback = | ||
base::Bind( | ||
brave::OnBeforeURLRequest_HttpsePreFileWork); | ||
before_url_request_callbacks_.push_back(callback); | ||
} | ||
|
||
BraveProfileNetworkDelegate::~BraveProfileNetworkDelegate() { | ||
} |
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,19 @@ | ||
/* 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_BRAVE_PROFILE_NETWORK_DELEGATE_H_ | ||
#define BRAVE_BROWSER_NET_BRAVE_PROFILE_NETWORK_DELEGATE_H_ | ||
|
||
#include "brave/browser/net/brave_network_delegate_base.h" | ||
|
||
class BraveProfileNetworkDelegate : public BraveNetworkDelegateBase { | ||
public: | ||
BraveProfileNetworkDelegate(extensions::EventRouterForwarder* event_router, | ||
BooleanPrefMember* enable_referrers); | ||
~BraveProfileNetworkDelegate() override; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(BraveProfileNetworkDelegate); | ||
}; | ||
|
||
#endif // BRAVE_BROWSER_NET_BRAVE_PROFILE_NETWORK_DELEGATE_H_ |
26 changes: 26 additions & 0 deletions
26
browser/net/brave_static_redirect_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,26 @@ | ||
/* 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/brave_static_redirect_network_delegate_helper.h" | ||
|
||
#include "extensions/common/url_pattern.h" | ||
#include "net/url_request/url_request.h" | ||
|
||
|
||
namespace brave { | ||
|
||
int OnBeforeURLRequest_StaticRedirectWork( | ||
net::URLRequest* request, | ||
GURL* new_url, | ||
const ResponseCallback& next_callback, | ||
std::shared_ptr<OnBeforeURLRequestContext> ctx) { | ||
URLPattern geoPattern(URLPattern::SCHEME_HTTPS, | ||
"https://www.googleapis.com/geolocation/v1/geolocate?key=*"); | ||
if (geoPattern.MatchesURL(request->url())) { | ||
*new_url = GURL(GOOGLEAPIS_ENDPOINT GOOGLEAPIS_API_KEY); | ||
} | ||
return net::OK; | ||
} | ||
|
||
} // namespace brave |
27 changes: 27 additions & 0 deletions
27
browser/net/brave_static_redirect_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,27 @@ | ||
/* 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_BRAVE_STATIC_REDIRECT_NETWORK_DELEGATE_H_ | ||
#define BRAVE_BROWSER_NET_BRAVE_STATIC_REDIRECT_NETWORK_DELEGATE_H_ | ||
|
||
#include "chrome/browser/net/chrome_network_delegate.h" | ||
#include "brave/browser/net/url_context.h" | ||
|
||
struct OnBeforeURLRequestContext; | ||
|
||
namespace net { | ||
class URLRequest; | ||
} | ||
|
||
namespace brave { | ||
|
||
int OnBeforeURLRequest_StaticRedirectWork( | ||
net::URLRequest* request, | ||
GURL* new_url, | ||
const ResponseCallback& next_callback, | ||
std::shared_ptr<OnBeforeURLRequestContext> ctx); | ||
|
||
} // namespace brave | ||
|
||
#endif // BRAVE_BROWSER_NET_BRAVE_STATIC_REDIRECT_NETWORK_DELEGATE_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,21 @@ | ||
/* 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/brave_system_network_delegate.h" | ||
|
||
#include "brave/browser/net/brave_static_redirect_network_delegate_helper.h" | ||
|
||
|
||
BraveSystemNetworkDelegate::BraveSystemNetworkDelegate( | ||
extensions::EventRouterForwarder* event_router, | ||
BooleanPrefMember* enable_referrers) : | ||
BraveNetworkDelegateBase(event_router, enable_referrers) { | ||
brave::OnBeforeURLRequestCallback callback = | ||
base::Bind( | ||
brave::OnBeforeURLRequest_StaticRedirectWork); | ||
before_url_request_callbacks_.push_back(callback); | ||
} | ||
|
||
BraveSystemNetworkDelegate::~BraveSystemNetworkDelegate() { | ||
} |
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,20 @@ | ||
/* 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_BRAVE_SYSTEM_NETWORK_DELEGATE_H_ | ||
#define BRAVE_BROWSER_NET_BRAVE_SYSTEM_NETWORK_DELEGATE_H_ | ||
|
||
#include "brave/browser/net/brave_network_delegate_base.h" | ||
|
||
|
||
class BraveSystemNetworkDelegate : public BraveNetworkDelegateBase { | ||
public: | ||
BraveSystemNetworkDelegate(extensions::EventRouterForwarder* event_router, | ||
BooleanPrefMember* enable_referrers); | ||
~BraveSystemNetworkDelegate() override; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(BraveSystemNetworkDelegate); | ||
}; | ||
|
||
#endif // BRAVE_BROWSER_NET_BRAVE_SYSTEM_NETWORK_DELEGATE_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,11 @@ | ||
declare_args() { | ||
antimuon_google_api_key = "" | ||
antimuon_google_api_endpoint = "" | ||
} | ||
|
||
config("geolocation") { | ||
defines = [ | ||
"GOOGLEAPIS_API_KEY=\"$antimuon_google_api_key\"", | ||
"GOOGLEAPIS_ENDPOINT=\"$antimuon_google_api_endpoint\"" | ||
] | ||
} |
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,21 @@ | ||
diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc | ||
index 7e840669571cb041bd20aa33b2801dc255a9f19f..d5c6e35efcb062ac14b849452548f873d68798ee 100644 | ||
--- a/chrome/browser/io_thread.cc | ||
+++ b/chrome/browser/io_thread.cc | ||
@@ -30,6 +30,7 @@ | ||
#include "base/threading/thread.h" | ||
#include "base/time/time.h" | ||
#include "base/trace_event/trace_event.h" | ||
+#include "brave/browser/net/brave_system_network_delegate.h" | ||
#include "build/build_config.h" | ||
#include "chrome/browser/browser_process.h" | ||
#include "chrome/browser/data_usage/tab_id_annotator.h" | ||
@@ -755,7 +756,7 @@ void IOThread::ConstructSystemRequestContext() { | ||
|
||
builder->set_user_agent(GetUserAgent()); | ||
std::unique_ptr<ChromeNetworkDelegate> chrome_network_delegate( | ||
- new ChromeNetworkDelegate(extension_event_router_forwarder(), | ||
+ new BraveSystemNetworkDelegate(extension_event_router_forwarder(), | ||
&system_enable_referrers_)); | ||
// By default, data usage is considered off the record. | ||
chrome_network_delegate->set_data_use_aggregator( |
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