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

Commit

Permalink
chromium_src cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bridiver committed May 5, 2017
1 parent 2e58d2b commit d534ffd
Show file tree
Hide file tree
Showing 103 changed files with 2,076 additions and 6,125 deletions.
10 changes: 10 additions & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ source_set("utility") {
]

deps = [
"chromium_src:importer",
"//chrome/common",
"//chrome/utility",
"//third_party/protobuf:protobuf_lite",
]
Expand All @@ -243,6 +245,14 @@ source_set("utility") {
"atom/utility/atom_content_utility_client.h",
"brave/utility/importer/chrome_importer.cc",
"brave/utility/importer/chrome_importer.h",
"brave/utility/importer/brave_external_process_importer_bridge.cc",
"brave/utility/importer/brave_external_process_importer_bridge.h",
"brave/utility/importer/firefox_importer.cc",
"brave/utility/importer/firefox_importer.h",
"brave/utility/importer/importer_creator.cc",
"brave/utility/importer/importer_creator.h",
"brave/utility/brave_profile_import_handler.cc",
"brave/utility/brave_profile_import_handler.h",
]
}

Expand Down
29 changes: 22 additions & 7 deletions atom/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ source_set("browser") {
"//electron:common",
"//storage/browser",
"//storage/common",
"//components/prefs",
":importer",
]

sources = [
Expand Down Expand Up @@ -117,7 +119,6 @@ source_set("browser") {
"browser_observer.h",
"common_web_contents_delegate.cc",
"common_web_contents_delegate.h",
"importer/profile_writer.cc",
"javascript_environment.cc",
"javascript_environment.h",
"lib/bluetooth_chooser.cc",
Expand Down Expand Up @@ -171,10 +172,6 @@ source_set("browser") {
"window_list_observer.h",
]

deps += [
"//electron/chromium_src:debug",
]

if (is_posix) {
sources += [
"atom_browser_main_parts_posix.cc",
Expand Down Expand Up @@ -314,8 +311,6 @@ source_set("browser") {
"extensions/api/atom_extensions_api_client.h",
"extensions/atom_browser_client_extensions_part.cc",
"extensions/atom_browser_client_extensions_part.h",
"extensions/atom_extension_api_frame_id_map_helper.cc",
"extensions/atom_extension_api_frame_id_map_helper.h",
"extensions/atom_extension_host_delegate.cc",
"extensions/atom_extension_host_delegate.h",
"extensions/atom_extensions_network_delegate.cc",
Expand All @@ -338,6 +333,26 @@ source_set("browser") {
}
}

source_set("importer") {
public_configs = [
"//electron/build:electron_config"
]

sources = [
"importer/external_process_importer_client.cc",
"importer/external_process_importer_client.h",
"importer/in_process_importer_bridge.cc",
"importer/in_process_importer_bridge.h",
"importer/profile_writer.cc",
"importer/profile_writer.h",
]

deps = [
"//electron:utility",
"//third_party/protobuf:protobuf_lite",
]
}

source_set("mac_auto_updater") {
public_configs = [
"//electron/build:electron_config",
Expand Down
68 changes: 1 addition & 67 deletions atom/browser/api/atom_api_app.cc
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ int GetPathConstant(const std::string& name) {

bool NotificationCallbackWrapper(
const ProcessSingleton::NotificationCallback& callback,
const base::CommandLine::StringVector& cmd,
const base::CommandLine& cmd,
const base::FilePath& cwd) {
// Make sure the callback is called after app gets ready.
if (atom::Browser::Get()->is_ready()) {
Expand Down Expand Up @@ -473,38 +473,6 @@ void PassLoginInformation(scoped_refptr<LoginHandler> login_handler,
login_handler->CancelAuth();
}

#if defined(USE_NSS_CERTS)
int ImportIntoCertStore(
CertificateManagerModel* model,
const base::DictionaryValue& options) {
std::string file_data, cert_path;
base::string16 password;
net::CertificateList imported_certs;
int rv = -1;
options.GetString("certificate", &cert_path);
options.GetString("password", &password);

if (!cert_path.empty()) {
if (base::ReadFileToString(base::FilePath(cert_path), &file_data)) {
rv = model->ImportFromPKCS12(model->cert_db()->GetPublicSlot().get(),
file_data,
password,
true,
&imported_certs);
if (imported_certs.size() > 1) {
auto it = imported_certs.begin();
++it; // skip first which would be the client certificate.
for (; it != imported_certs.end(); ++it)
rv &= model->SetCertTrust(it->get(),
net::CA_CERT,
net::NSSCertDatabase::TRUSTED_SSL);
}
}
}
return rv;
}
#endif

} // namespace

App::App(v8::Isolate* isolate) {
Expand Down Expand Up @@ -865,37 +833,6 @@ void App::StartWorker(mate::Arguments* args) {
args->Return(worker_id);
}

#if defined(USE_NSS_CERTS)
void App::ImportCertificate(
const base::DictionaryValue& options,
const net::CompletionCallback& callback) {
auto browser_context = AtomBrowserContext::From("", false);
if (!certificate_manager_model_) {
std::unique_ptr<base::DictionaryValue> copy = options.CreateDeepCopy();
CertificateManagerModel::Create(
browser_context,
base::Bind(&App::OnCertificateManagerModelCreated,
base::Unretained(this),
base::Passed(&copy),
callback));
return;
}

int rv = ImportIntoCertStore(certificate_manager_model_.get(), options);
callback.Run(rv);
}

void App::OnCertificateManagerModelCreated(
std::unique_ptr<base::DictionaryValue> options,
const net::CompletionCallback& callback,
std::unique_ptr<CertificateManagerModel> model) {
certificate_manager_model_ = std::move(model);
int rv = ImportIntoCertStore(certificate_manager_model_.get(),
*(options.get()));
callback.Run(rv);
}
#endif

#if defined(OS_WIN)
v8::Local<v8::Value> App::GetJumpListSettings() {
JumpList jump_list(atom::Browser::Get()->GetAppUserModelID());
Expand Down Expand Up @@ -1015,9 +952,6 @@ void App::BuildPrototype(
.SetMethod("setDesktopName", &App::SetDesktopName)
.SetMethod("getLocale", &App::GetLocale)
.SetMethod("setLocale", &App::SetLocale)
#if defined(USE_NSS_CERTS)
.SetMethod("importCertificate", &App::ImportCertificate)
#endif
.SetMethod("makeSingleInstance", &App::MakeSingleInstance)
.SetMethod("releaseSingleInstance", &App::ReleaseSingleInstance)
.SetMethod("relaunch", &App::Relaunch)
Expand Down
19 changes: 0 additions & 19 deletions atom/browser/api/atom_api_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@
#include "net/base/completion_callback.h"
#include "net/base/network_change_notifier.h"

#if defined(USE_NSS_CERTS)
#include "chrome/browser/certificate_manager_model.h"
#endif

namespace base {
class FilePath;
}
Expand Down Expand Up @@ -59,13 +55,6 @@ class App : public AtomBrowserClient::Delegate,
int render_process_id,
int render_frame_id);

#if defined(USE_NSS_CERTS)
void OnCertificateManagerModelCreated(
std::unique_ptr<base::DictionaryValue> options,
const net::CompletionCallback& callback,
std::unique_ptr<CertificateManagerModel> model);
#endif

protected:
explicit App(v8::Isolate* isolate);
~App() override;
Expand Down Expand Up @@ -140,10 +129,6 @@ class App : public AtomBrowserClient::Delegate,
mate::Arguments* args);
void StartWorker(mate::Arguments* args);
void StopWorker(mate::Arguments* args);
#if defined(USE_NSS_CERTS)
void ImportCertificate(const base::DictionaryValue& options,
const net::CompletionCallback& callback);
#endif

#if defined(OS_WIN)
// Get the current Jump List settings.
Expand All @@ -157,10 +142,6 @@ class App : public AtomBrowserClient::Delegate,

std::unique_ptr<ProcessSingleton> process_singleton_;

#if defined(USE_NSS_CERTS)
std::unique_ptr<CertificateManagerModel> certificate_manager_model_;
#endif

DISALLOW_COPY_AND_ASSIGN(App);
};

Expand Down
9 changes: 1 addition & 8 deletions atom/browser/api/atom_api_importer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <memory>
#include <string>

#include "atom/browser/importer/profile_writer.h"
#include "atom/common/native_mate_converters/callback.h"
#include "atom/common/native_mate_converters/file_path_converter.h"
#include "atom/common/native_mate_converters/string16_converter.h"
Expand All @@ -24,14 +25,6 @@

using content::BrowserThread;

namespace importer {
void ShowImportLockDialog(gfx::NativeWindow parent,
const base::Callback<void(bool)>& callback) {
base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
base::Bind(callback, false));
}
}

namespace atom {

namespace api {
Expand Down
3 changes: 2 additions & 1 deletion atom/browser/api/atom_api_importer.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@

class ExternalProcessImporterHost;
class ImporterList;
class ProfileWriter;

namespace atom {

class ProfileWriter;

namespace api {

class Importer: public mate::EventEmitter<Importer>,
Expand Down
25 changes: 25 additions & 0 deletions atom/browser/api/atom_api_session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,17 @@
#include "base/guid.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/task/cancelable_task_tracker.h"
#include "base/threading/thread_restrictions.h"
#include "base/threading/thread_task_runner_handle.h"
#include "brave/browser/brave_content_browser_client.h"
#include "brave/browser/brave_permission_manager.h"
#include "chrome/browser/devtools/devtools_network_conditions.h"
#include "chrome/browser/devtools/devtools_network_controller_handle.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "components/history/core/browser/history_service.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
Expand Down Expand Up @@ -344,6 +348,8 @@ void OnClearStorageDataDone(const base::Closure& callback) {
callback.Run();
}

void OnClearHistory() {}

} // namespace

Session::Session(v8::Isolate* isolate, AtomBrowserContext* browser_context)
Expand Down Expand Up @@ -414,6 +420,24 @@ void Session::ClearStorageData(mate::Arguments* args) {
base::Bind(&OnClearStorageDataDone, callback));
}

void Session::ClearHistory(mate::Arguments* args) {
base::Closure callback;
if (!args->GetNext(&callback))
callback = base::Bind(&OnClearHistory);

history::HistoryService* history_service =
HistoryServiceFactory::GetForProfile(
Profile::FromBrowserContext(browser_context()),
ServiceAccessType::EXPLICIT_ACCESS);

base::CancelableTaskTracker task_tracker;
history_service->ExpireHistoryBetween(std::set<GURL>(),
base::Time(),
base::Time::Max(),
callback,
&task_tracker);
}

void Session::FlushStorageData() {
auto storage_partition =
content::BrowserContext::GetStoragePartition(browser_context(), nullptr);
Expand Down Expand Up @@ -626,6 +650,7 @@ void Session::BuildPrototype(v8::Isolate* isolate,
.SetMethod("getCacheSize", &Session::DoCacheAction<CacheAction::STATS>)
.SetMethod("clearCache", &Session::DoCacheAction<CacheAction::CLEAR>)
.SetMethod("clearStorageData", &Session::ClearStorageData)
.SetMethod("clearHistory", &Session::ClearHistory)
.SetMethod("flushStorageData", &Session::FlushStorageData)
.SetMethod("setProxy", &Session::SetProxy)
.SetMethod("setDownloadPath", &Session::SetDownloadPath)
Expand Down
1 change: 1 addition & 0 deletions atom/browser/api/atom_api_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class Session: public mate::TrackableObject<Session>,
template<CacheAction action>
void DoCacheAction(const net::CompletionCallback& callback);
void ClearStorageData(mate::Arguments* args);
void ClearHistory(mate::Arguments* args);
void FlushStorageData();
void SetProxy(const net::ProxyConfig& config, const base::Closure& callback);
void SetDownloadPath(const base::FilePath& path);
Expand Down
Loading

0 comments on commit d534ffd

Please sign in to comment.