Skip to content
This repository has been archived by the owner on Jan 4, 2019. It is now read-only.

Enable safe_browsing_api for muon #409

Merged
merged 1 commit into from
Mar 30, 2018
Merged

Enable safe_browsing_api for muon #409

merged 1 commit into from
Mar 30, 2018

Conversation

jumde
Copy link
Contributor

@jumde jumde commented Dec 20, 2017

No description provided.

@@ -156,6 +156,8 @@ void Browser::WillFinishLaunching() {

void Browser::DidFinishLaunching(const base::DictionaryValue& launch_info) {
is_ready_ = true;
sb_service = safe_browsing::SafeBrowsingService::CreateSafeBrowsingService();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should go in chromium_src/chrome/browser/browser_process_impl.cc to match the implementation in src/chrome/browser/browser_process_impl.cc

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am working on the changes, I realized this yesterday. This is still in progress. Should've added the WIP tag to the header.

@@ -290,6 +295,113 @@ source_set("browser") {
"chrome/browser/content_settings/host_content_settings_map_factory.cc",
"chrome/browser/content_settings/host_content_settings_map_factory.h",

"//chrome/browser/renderer_preferences_util.cc",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add //chrome/browser/safe_browsing as a dep instead?

@@ -0,0 +1,60 @@
// Copyright 2014 The Chromium Authors. All rights reserved.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are these copied instead of using chrome src? Are there differences?

Copy link
Collaborator

@bridiver bridiver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comments

@jumde jumde changed the title Enable safe_browsing_api for muon [WIP] Enable safe_browsing_api for muon Dec 21, 2017
@bridiver
Copy link
Collaborator

I added the wip label, so just remove that when you're ready to review again

@jumde jumde force-pushed the safe_browsing_api branch 5 times, most recently from 7671fc4 to e3896f2 Compare December 27, 2017 20:42
@jumde jumde force-pushed the safe_browsing_api branch 4 times, most recently from aac0a4d to 5046ff0 Compare January 2, 2018 17:50
":importer",
"//electron/vendor/ad-block/muon:ad_block",
"//electron/vendor/tracking-protection/muon:tp_node_addon",
]

sources = [
"//chrome/browser/loader/safe_browsing_resource_throttle.h",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these should go in chromium_src/BUILD.gn prerender target

"//electron:common",
"//electron/muon/app",
# @todo(bridiver) fix circular dep
# "//electron/muon/browser",
"//base",
"//chrome/browser:resource_prefetch_predictor_proto",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these should be deps of the the chromium_src prerender target

@@ -21,22 +21,29 @@ source_set("browser") {
]

deps = [
"../../chromium_src/chrome/browser/prerender",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deps should always absolute paths //electron/chromium_src...

"//chrome/browser/renderer_preferences_util.cc",
"//chrome/browser/renderer_preferences_util.h",

"//chrome/browser/safe_browsing/chunk_range.cc",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would put these in a separate safe_browsing target and make that a dep of browser

@jumde jumde force-pushed the safe_browsing_api branch from f3d07e6 to 2e34198 Compare January 5, 2018 03:29
@jumde jumde force-pushed the safe_browsing_api branch 2 times, most recently from 03257a7 to c6d2aa0 Compare January 18, 2018 22:13

SafeBrowsingState::~SafeBrowsingState() {}

void CheckDownloadUrlDone(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like we're copying a lot of code from src/chrome here which we really try to avoid. Can we subclass or use some other method to reuse the existing code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of the code is similar to chrome_download_manager_delegate.cc. I optimized some of it, let me know if you think we can optimize more.


next_state_ = STATE_RESERVE_VIRTUAL_PATH;
-
- if (!should_notify_extensions_ ||
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you provide some explanation for these? This is adding a lot of patches and it doesn't seem like they should all be necessary

@@ -58,9 +93,20 @@ MuonBrowserProcessImpl::component_updater() {
return component_updater(component_updater_, false);
}

void MuonBrowserProcessImpl::ApplyAllowCrossOriginAuthPromptPolicy() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this part of safe browsing?

@@ -599,6 +612,144 @@ source_set("browser") {
}
}

source_set("safe_browsing") {
sources = [
"//chrome/browser/download/download_completion_blocker.cc",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

safe browsing has an existing target in chrome so I don't think we should have to add all these files individually

@@ -658,7 +658,9 @@ void BraveContentBrowserClient::OverrideWebkitPrefs(
prefs->hyperlink_auditing_enabled = false;
// Custom preferences of guest page.
auto web_contents = content::WebContents::FromRenderViewHost(host);
atom::WebContentsPreferences::OverrideWebkitPrefs(web_contents, prefs);
if (web_contents) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when is this null?

@@ -395,8 +395,11 @@ void BravePasswordManagerClient::CheckSafeBrowsingReputation(
const GURL& form_action,
const GURL& frame_url) {}

void BravePasswordManagerClient::LogPasswordReuseDetectedEvent() {}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

? cc @darkdh

#include "native_mate/dictionary.h"
#include "net/base/filename_util.h"

#include "atom/common/node_includes.h"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is intentionally added at the end of the list

@@ -67,12 +67,10 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "chrome/browser/extensions/api/cryptotoken_private/cryptotoken_private_api.h"
#include "extensions/common/file_util.h"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are also here intentionally to group them with other URLResourceRequestBundleJob headers

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's best not to mix in unrelated changes because it just confuses the purpose of the PR. Unrelated changes should be put in a separate PR

#define DUMMY_API_TOKEN "dummytoken"

#if !defined(GOOGLE_API_KEY)
-#define GOOGLE_API_KEY DUMMY_API_TOKEN
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't want to hard code keys like this, what is the purpose of this change?

@@ -1,19 +1,44 @@
source_set("install_verification") {
sources = [
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same thing with source set configs here

danger_level_ = GetDangerLevel(
visited_referrer_before ? VISITED_REFERRER : NO_VISITS_TO_REFERRER);
if (danger_level_ != DownloadFileType::NOT_DANGEROUS &&
+ danger_level_ != DownloadFileType::ALLOW_ON_USER_GESTURE &&
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you explain this change? We can set the user gesture just like chrome does

return false;
}
// This check should be last, so we know the earlier checks passed.
+#if defined(MUON_CHROMIUM_BUILD)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also why this change?

@jumde jumde force-pushed the safe_browsing_api branch from 115f4ec to 7198582 Compare March 20, 2018 18:06
@@ -11,6 +11,7 @@
#include "chrome/browser/io_thread.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/safe_browsing/safe_browsing_service.h"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

@brave brave deleted a comment from jumde Mar 20, 2018
@@ -52,6 +52,10 @@ Browser::CreateParams::CreateParams(Type type, Profile* profile)

Browser::CreateParams::CreateParams(const CreateParams& other) = default;

content::WebContents* Browser::OpenURL(const content::OpenURLParams& params) {
return NULL;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little worried about this one causing a crash. Where does it get called from? Is it just windows doing its usual terrible job of dead code elimination or is there an actual legit code path that leads here?

resource_context,
resource_type,
throttles);
#if BUILDFLAG(ENABLE_NACL)
Copy link
Collaborator

@bridiver bridiver Mar 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this block should be here

@jumde jumde force-pushed the safe_browsing_api branch 2 times, most recently from c61e04d to 8e83a50 Compare March 29, 2018 03:42
bridiver
bridiver previously approved these changes Mar 30, 2018
Copy link
Collaborator

@bridiver bridiver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++

@bridiver bridiver merged commit 213d1cf into master Mar 30, 2018
@bsclifton bsclifton deleted the safe_browsing_api branch June 18, 2018 17:52
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants