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

Commit

Permalink
Enable safe_browsing_api for muon
Browse files Browse the repository at this point in the history
  • Loading branch information
jumde committed Jan 18, 2018
1 parent d2f3f28 commit 03257a7
Show file tree
Hide file tree
Showing 17 changed files with 1,260 additions and 59 deletions.
17 changes: 17 additions & 0 deletions atom/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,39 @@ source_set("browser") {
]

deps = [
"../../chromium_src/chrome/browser/prerender",
"//electron:common",
"//electron/muon/app",
# @todo(bridiver) fix circular dep
# "//electron/muon/browser",
"//base",
"//chrome/browser:resource_prefetch_predictor_proto",
"//chrome/common:constants",
"//storage/browser",
"//storage/common",
"//components/prefs",
"//components/metrics",
"//components/safe_browsing/common:safe_browsing_prefs",
":importer",
"//electron/vendor/ad-block/muon:ad_block",
"//electron/vendor/tracking-protection/muon:tp_node_addon",
]

sources = [
"//chrome/browser/download/download_completion_blocker.cc",
"//chrome/browser/download/download_completion_blocker.h",
"//chrome/browser/loader/safe_browsing_resource_throttle.h",
"//chrome/browser/loader/safe_browsing_resource_throttle.cc",
"//chrome/browser/safe_browsing/url_checker_delegate_impl.cc",
"//chrome/browser/safe_browsing/url_checker_delegate_impl.h",
"//chrome/browser/download/download_item_model.cc",
"//chrome/browser/download/download_item_model.h",
"//chrome/browser/download/download_stats.cc",
"//chrome/browser/download/download_stats.h",
"//chrome/browser/download/download_target_determiner.cc",
"//chrome/browser/download/download_target_determiner.h",
"//chrome/browser/download/download_target_info.cc",
"//chrome/browser/download/download_target_info.h",
"api/atom_api_app.cc",
"api/atom_api_app.h",
"api/atom_api_autofill.cc",
Expand Down
14 changes: 11 additions & 3 deletions atom/browser/api/atom_api_download_item.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@
#include "atom/common/native_mate_converters/gurl_converter.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_task_runner_handle.h"
#include "content/browser/download/download_item_impl.h"
#include "content/public/browser/download_danger_type.h"
#include "native_mate/dictionary.h"
#include "net/base/filename_util.h"


#include "atom/common/node_includes.h"

namespace mate {
Expand Down Expand Up @@ -78,9 +81,10 @@ DownloadItem::~DownloadItem() {
}

void DownloadItem::OnDownloadUpdated(content::DownloadItem* item) {
if (download_item_->IsDone()) {
Emit("done", item->GetState());

if (download_item_->IsDangerous()) {
Emit("done", 4, item->IsDangerous());
} else if (download_item_->IsDone()) {
Emit("done", item->GetState(), false);
// Destroy the item once item is downloaded.
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, GetDestroyClosure());
Expand Down Expand Up @@ -164,6 +168,10 @@ bool DownloadItem::IsDone() const {
return download_item_->IsDone();
}

bool DownloadItem::IsDangerous() const {
return download_item_->IsDangerous();
}

void DownloadItem::SetSavePath(const base::FilePath& path) {
save_path_ = path;
}
Expand Down
1 change: 1 addition & 0 deletions atom/browser/api/atom_api_download_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class DownloadItem : public mate::TrackableObject<DownloadItem>,
std::string GetGuid() const;
void SetPrompt(bool prompt);
bool ShouldPrompt();
bool IsDangerous() const;

protected:
DownloadItem(v8::Isolate* isolate, content::DownloadItem* download_item);
Expand Down
Loading

0 comments on commit 03257a7

Please sign in to comment.