Move global preload implementation to be session based

This commit is contained in:
Samuel Attard 2017-09-17 01:05:49 +10:00 committed by Cheng Zhao
parent 448ccc261d
commit 3b80ee0655
9 changed files with 58 additions and 61 deletions

View file

@ -4,8 +4,6 @@
#include "atom/browser/api/atom_api_window.h"
#include <algorithm>
#include "atom/browser/api/atom_api_browser_view.h"
#include "atom/browser/api/atom_api_menu.h"
#include "atom/browser/api/atom_api_web_contents.h"
@ -18,7 +16,6 @@
#include "atom/common/native_mate_converters/gurl_converter.h"
#include "atom/common/native_mate_converters/image_converter.h"
#include "atom/common/native_mate_converters/string16_converter.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/options_switches.h"
#include "base/command_line.h"
#include "base/threading/thread_task_runner_handle.h"
@ -176,19 +173,6 @@ Window::~Window() {
base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, window_.release());
}
std::vector<base::FilePath::StringType> g_preloads;
void Window::AddGlobalPreload(const base::FilePath::StringType& preloadPath) {
g_preloads.push_back(preloadPath);
}
void Window::RemoveGlobalPreload(const base::FilePath::StringType& preloadPath) {
g_preloads.erase(
std::remove(g_preloads.begin(), g_preloads.end(), preloadPath),
g_preloads.end());
}
std::vector<base::FilePath::StringType> Window::GetGlobalPreloads() {
return g_preloads;
}
void Window::WillCloseWindow(bool* prevent_default) {
*prevent_default = Emit("close");
}
@ -1167,12 +1151,6 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
&mate::TrackableObject<Window>::FromWeakMapID);
browser_window.SetMethod("getAllWindows",
&mate::TrackableObject<Window>::GetAll);
browser_window.SetMethod("addGlobalPreload",
&Window::AddGlobalPreload);
browser_window.SetMethod("removeGlobalPreload",
&Window::RemoveGlobalPreload);
browser_window.SetMethod("getGlobalPreloads",
&Window::GetGlobalPreloads);
mate::Dictionary dict(isolate, exports);
dict.Set("BrowserWindow", browser_window);