Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
jumde committed Apr 17, 2019
1 parent ff9494d commit 8375203
Show file tree
Hide file tree
Showing 21 changed files with 301 additions and 311 deletions.
142 changes: 61 additions & 81 deletions browser/brave_content_browser_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
#include "brave/browser/renderer_host/brave_navigation_ui_data.h"
#include "brave/browser/tor/tor_profile_service_factory.h"
#include "brave/common/brave_cookie_blocking.h"
#include "brave/common/webui_url_constants.h"
#include "brave/common/tor/tor_launcher.mojom.h"
#include "brave/common/tor/switches.h"
#include "brave/common/tor/tor_launcher.mojom.h"
#include "brave/common/webui_url_constants.h"
#include "brave/components/brave_ads/browser/buildflags/buildflags.h"
#include "brave/components/brave_rewards/browser/buildflags/buildflags.h"
#include "brave/components/brave_shields/browser/brave_shields_util.h"
Expand Down Expand Up @@ -50,11 +50,11 @@
#include "services/service_manager/public/cpp/manifest_builder.h"
#include "ui/base/l10n/l10n_util.h"

using brave_shields::BraveShieldsWebContentsObserver;
using content::BrowserThread;
using content::ContentBrowserClient;
using content::RenderFrameHost;
using content::WebContents;
using brave_shields::BraveShieldsWebContentsObserver;

#if BUILDFLAG(BRAVE_ADS_ENABLED)
#include "brave/components/services/bat_ads/public/interfaces/bat_ads.mojom.h"
Expand Down Expand Up @@ -92,15 +92,14 @@ bool HandleURLOverrideRewrite(GURL* url,
}

bool HandleURLReverseOverrideRewrite(GURL* url,
content::BrowserContext* browser_context) {
content::BrowserContext* browser_context) {
if (HandleURLOverrideRewrite(url, browser_context))
return true;

return false;
}

bool HandleURLRewrite(GURL* url,
content::BrowserContext* browser_context) {
bool HandleURLRewrite(GURL* url, content::BrowserContext* browser_context) {
if (HandleURLOverrideRewrite(url, browser_context))
return true;

Expand All @@ -111,13 +110,12 @@ bool HandleURLRewrite(GURL* url,

BraveContentBrowserClient::BraveContentBrowserClient(
ChromeFeatureListCreator* chrome_feature_list_creator)
: ChromeContentBrowserClient(chrome_feature_list_creator) {
}
: ChromeContentBrowserClient(chrome_feature_list_creator) {}

BraveContentBrowserClient::~BraveContentBrowserClient() {}

content::BrowserMainParts* BraveContentBrowserClient::CreateBrowserMainParts(
const content::MainFunctionParams& parameters) {
const content::MainFunctionParams& parameters) {
ChromeBrowserMainParts* main_parts = static_cast<ChromeBrowserMainParts*>(
ChromeContentBrowserClient::CreateBrowserMainParts(parameters));
main_parts->AddParts(new BraveBrowserMainExtraParts());
Expand All @@ -130,8 +128,7 @@ void BraveContentBrowserClient::BrowserURLHandlerCreated(
content::BrowserURLHandler::null_handler());
handler->AddHandlerPair(&webtorrent::HandleTorrentURLRewrite,
&webtorrent::HandleTorrentURLReverseRewrite);
handler->AddHandlerPair(&HandleURLRewrite,
&HandleURLReverseOverrideRewrite);
handler->AddHandlerPair(&HandleURLRewrite, &HandleURLReverseOverrideRewrite);
ChromeContentBrowserClient::BrowserURLHandlerCreated(handler);
}

Expand All @@ -143,9 +140,9 @@ bool BraveContentBrowserClient::AllowAccessCookie(
int render_frame_id) {
GURL tab_origin =
BraveShieldsWebContentsObserver::GetTabURLFromRenderFrameInfo(
render_process_id, render_frame_id, -1).GetOrigin();
render_process_id, render_frame_id, -1)
.GetOrigin();
ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);

bool allow_brave_shields =
brave_shields::IsAllowContentSettingWithIOData(
io_data, tab_origin, tab_origin, CONTENT_SETTINGS_TYPE_PLUGINS,
Expand All @@ -159,21 +156,22 @@ bool BraveContentBrowserClient::AllowAccessCookie(
brave_shields::kCookies);
content_settings::BraveCookieSettings* cookie_settings =
(content_settings::BraveCookieSettings*)io_data->GetCookieSettings();
bool allow = !ShouldBlockCookie(allow_brave_shields,
allow_1p_cookies,
allow_3p_cookies,
first_party,
url,
cookie_settings->GetAllowGoogleAuth()) &&
g_brave_browser_process->tracking_protection_service()->ShouldStoreState(cookie_settings,
io_data->GetHostContentSettingsMap(), render_process_id,
render_frame_id, url, first_party, tab_origin);
bool allow =
!ShouldBlockCookie(allow_brave_shields, allow_1p_cookies,
allow_3p_cookies, first_party, url,
cookie_settings->GetAllowGoogleAuth()) &&
g_brave_browser_process->tracking_protection_service()->ShouldStoreState(
cookie_settings, io_data->GetHostContentSettingsMap(),
render_process_id, render_frame_id, url, first_party, tab_origin);
return allow;
}

bool BraveContentBrowserClient::AllowGetCookie(const GURL& url,
const GURL& first_party, const net::CookieList& cookie_list,
content::ResourceContext* context, int render_process_id,
bool BraveContentBrowserClient::AllowGetCookie(
const GURL& url,
const GURL& first_party,
const net::CookieList& cookie_list,
content::ResourceContext* context,
int render_process_id,
int render_frame_id) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
bool allow = AllowAccessCookie(url, first_party, context, render_process_id,
Expand All @@ -184,9 +182,12 @@ bool BraveContentBrowserClient::AllowGetCookie(const GURL& url,
return allow;
}

bool BraveContentBrowserClient::AllowSetCookie(const GURL& url,
const GURL& first_party, const net::CanonicalCookie& cookie,
content::ResourceContext* context, int render_process_id,
bool BraveContentBrowserClient::AllowSetCookie(
const GURL& url,
const GURL& first_party,
const net::CanonicalCookie& cookie,
content::ResourceContext* context,
int render_process_id,
int render_frame_id) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
bool allow = AllowAccessCookie(url, first_party, context, render_process_id,
Expand All @@ -205,55 +206,47 @@ BraveContentBrowserClient::AllowWebBluetooth(
}

bool BraveContentBrowserClient::HandleExternalProtocol(
const GURL& url,
content::ResourceRequestInfo::WebContentsGetter web_contents_getter,
int child_id,
content::NavigationUIData* navigation_data,
bool is_main_frame,
ui::PageTransition page_transition,
bool has_user_gesture,
const std::string& method,
const net::HttpRequestHeaders& headers) {
const GURL& url,
content::ResourceRequestInfo::WebContentsGetter web_contents_getter,
int child_id,
content::NavigationUIData* navigation_data,
bool is_main_frame,
ui::PageTransition page_transition,
bool has_user_gesture,
const std::string& method,
const net::HttpRequestHeaders& headers) {
if (webtorrent::HandleMagnetProtocol(url, web_contents_getter,
page_transition, has_user_gesture)) {
page_transition, has_user_gesture)) {
return true;
}

return ChromeContentBrowserClient::HandleExternalProtocol(
url,
web_contents_getter,
child_id,
navigation_data,
is_main_frame,
page_transition,
has_user_gesture,
method,
headers);
url, web_contents_getter, child_id, navigation_data, is_main_frame,
page_transition, has_user_gesture, method, headers);
}

void BraveContentBrowserClient::RegisterOutOfProcessServices(
OutOfProcessServiceMap* services) {
OutOfProcessServiceMap* services) {
ChromeContentBrowserClient::RegisterOutOfProcessServices(services);
(*services)[tor::mojom::kTorLauncherServiceName] = base::BindRepeating(
l10n_util::GetStringUTF16, IDS_UTILITY_PROCESS_TOR_LAUNCHER_NAME);
l10n_util::GetStringUTF16, IDS_UTILITY_PROCESS_TOR_LAUNCHER_NAME);
#if BUILDFLAG(BRAVE_ADS_ENABLED)
(*services)[bat_ads::mojom::kServiceName] = base::BindRepeating(
l10n_util::GetStringUTF16, IDS_SERVICE_BAT_ADS);
(*services)[bat_ads::mojom::kServiceName] =
base::BindRepeating(l10n_util::GetStringUTF16, IDS_SERVICE_BAT_ADS);
#endif
#if BUILDFLAG(BRAVE_REWARDS_ENABLED)
(*services)[bat_ledger::mojom::kServiceName] = base::BindRepeating(
l10n_util::GetStringUTF16, IDS_UTILITY_PROCESS_LEDGER_NAME);
l10n_util::GetStringUTF16, IDS_UTILITY_PROCESS_LEDGER_NAME);
#endif
}

std::unique_ptr<content::NavigationUIData>
BraveContentBrowserClient::GetNavigationUIData(
content::NavigationHandle* navigation_handle) {
content::NavigationHandle* navigation_handle) {
std::unique_ptr<BraveNavigationUIData> navigation_ui_data =
std::make_unique<BraveNavigationUIData>(navigation_handle);
Profile* profile =
Profile::FromBrowserContext(navigation_handle->GetWebContents()
->GetBrowserContext());
std::make_unique<BraveNavigationUIData>(navigation_handle);
Profile* profile = Profile::FromBrowserContext(
navigation_handle->GetWebContents()->GetBrowserContext());
TorProfileServiceFactory::SetTorNavigationUIData(profile,
navigation_ui_data.get());
return std::move(navigation_ui_data);
Expand All @@ -274,11 +267,11 @@ void BraveContentBrowserClient::AdjustUtilityServiceProcessCommandLine(
const service_manager::Identity& identity,
base::CommandLine* command_line) {
ChromeContentBrowserClient::AdjustUtilityServiceProcessCommandLine(
identity, command_line);
identity, command_line);

if (identity.name() == tor::mojom::kTorLauncherServiceName) {
base::FilePath path =
g_brave_browser_process->tor_client_updater()->GetExecutablePath();
g_brave_browser_process->tor_client_updater()->GetExecutablePath();
DCHECK(!path.empty());
command_line->AppendSwitchPath(tor::switches::kTorExecutablePath,
path.BaseName());
Expand All @@ -296,28 +289,15 @@ void BraveContentBrowserClient::MaybeHideReferrer(
}

Profile* profile = Profile::FromBrowserContext(browser_context);
const bool allow_referrers =
brave_shields::IsAllowContentSettingsForProfile(
profile,
document_url,
document_url,
CONTENT_SETTINGS_TYPE_PLUGINS,
brave_shields::kReferrers);
const bool shields_up =
brave_shields::IsAllowContentSettingsForProfile(
profile,
document_url,
GURL(),
CONTENT_SETTINGS_TYPE_PLUGINS,
brave_shields::kBraveShields);
brave_shields::ShouldSetReferrer(allow_referrers,
shields_up,
referrer->url,
document_url,
request_url,
request_url.GetOrigin(),
referrer->policy,
referrer);
const bool allow_referrers = brave_shields::IsAllowContentSettingsForProfile(
profile, document_url, document_url, CONTENT_SETTINGS_TYPE_PLUGINS,
brave_shields::kReferrers);
const bool shields_up = brave_shields::IsAllowContentSettingsForProfile(
profile, document_url, GURL(), CONTENT_SETTINGS_TYPE_PLUGINS,
brave_shields::kBraveShields);
brave_shields::ShouldSetReferrer(
allow_referrers, shields_up, referrer->url, document_url, request_url,
request_url.GetOrigin(), referrer->policy, referrer);
}

GURL BraveContentBrowserClient::GetEffectiveURL(
Expand Down
3 changes: 1 addition & 2 deletions browser/brave_tab_helpers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ void AttachTabHelpers(content::WebContents* web_contents) {
BraveDrmTabHelper::CreateForWebContents(web_contents);
#if BUILDFLAG(BRAVE_STP_ENABLED)
if (TrackingProtectionHelper::IsSmartTrackingProtectionEnabled()) {
brave_shields::TrackingProtectionHelper::CreateForWebContents(
web_contents);
brave_shields::TrackingProtectionHelper::CreateForWebContents(web_contents);
}
#endif
#endif
Expand Down
4 changes: 2 additions & 2 deletions browser/content_settings/brave_cookie_settings_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
scoped_refptr<content_settings::BraveCookieSettings>
BraveCookieSettingsFactory::GetForProfile(Profile* profile) {
return static_cast<content_settings::BraveCookieSettings*>(
CookieSettingsFactory::GetForProfile(profile).get());
}
CookieSettingsFactory::GetForProfile(profile).get());
}
9 changes: 4 additions & 5 deletions browser/content_settings/brave_cookie_settings_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* 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_COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_BRAVE_COOKIE_SETTINGS_FACTORY_H_
#define BRAVE_COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_BRAVE_COOKIE_SETTINGS_FACTORY_H_
#ifndef BRAVE_BROWSER_CONTENT_SETTINGS_BRAVE_COOKIE_SETTINGS_FACTORY_H_
#define BRAVE_BROWSER_CONTENT_SETTINGS_BRAVE_COOKIE_SETTINGS_FACTORY_H_

#include <string>

Expand All @@ -16,8 +16,7 @@ class BraveCookieSettings;

class Profile;

class BraveCookieSettingsFactory
: public CookieSettingsFactory {
class BraveCookieSettingsFactory : public CookieSettingsFactory {
public:
static scoped_refptr<content_settings::BraveCookieSettings> GetForProfile(
Profile* profile);
Expand All @@ -31,4 +30,4 @@ class BraveCookieSettingsFactory
DISALLOW_COPY_AND_ASSIGN(BraveCookieSettingsFactory);
};

#endif // BRAVE_COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_BRAVE_COOKIE_SETTINGS_FACTORY_H_
#endif // BRAVE_BROWSER_CONTENT_SETTINGS_BRAVE_COOKIE_SETTINGS_FACTORY_H_
8 changes: 4 additions & 4 deletions browser/renderer_host/BUILD.gn
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import("//brave/components/brave_shields/browser/buildflags/buildflags.gni")

source_set("renderer_host") {
public_deps = [
"//brave/components/brave_shields/browser/buildflags",
]

sources = [
"brave_navigation_ui_data.cc",
"brave_navigation_ui_data.h",
]

public_deps = [
"//brave/components/brave_shields/browser/buildflags",
]

if (brave_stp_enabled) {
sources += [
"brave_render_message_filter.cc",
Expand Down
Loading

0 comments on commit 8375203

Please sign in to comment.