refactor: convert C++ enums to C++11 enum classes (#18087)

This commit is contained in:
Milan Burda 2019-05-03 20:11:41 +02:00 committed by Alexey Kuzmin
parent a59dc56fa6
commit c25c31e018
36 changed files with 199 additions and 204 deletions

View file

@ -1291,9 +1291,9 @@ bool App::IsInApplicationsFolder() {
int DockBounce(const std::string& type) { int DockBounce(const std::string& type) {
int request_id = -1; int request_id = -1;
if (type == "critical") if (type == "critical")
request_id = Browser::Get()->DockBounce(Browser::BOUNCE_CRITICAL); request_id = Browser::Get()->DockBounce(Browser::BounceType::CRITICAL);
else if (type == "informational") else if (type == "informational")
request_id = Browser::Get()->DockBounce(Browser::BOUNCE_INFORMATIONAL); request_id = Browser::Get()->DockBounce(Browser::BounceType::INFORMATIONAL);
return request_id; return request_id;
} }

View file

@ -30,17 +30,6 @@ using content::BrowserThread;
namespace gin { namespace gin {
template <>
struct Converter<atom::api::Cookies::Error> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
atom::api::Cookies::Error val) {
if (val == atom::api::Cookies::SUCCESS)
return v8::Null(isolate);
else
return v8::Exception::Error(StringToV8(isolate, "Setting cookie failed"));
}
};
template <> template <>
struct Converter<net::CanonicalCookie> { struct Converter<net::CanonicalCookie> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate, static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,

View file

@ -31,11 +31,6 @@ namespace api {
class Cookies : public mate::TrackableObject<Cookies> { class Cookies : public mate::TrackableObject<Cookies> {
public: public:
enum Error {
SUCCESS,
FAILED,
};
static gin::Handle<Cookies> Create(v8::Isolate* isolate, static gin::Handle<Cookies> Create(v8::Isolate* isolate,
AtomBrowserContext* browser_context); AtomBrowserContext* browser_context);

View file

@ -164,9 +164,9 @@ Protocol::ProtocolError Protocol::UnregisterProtocolInIO(
const std::string& scheme) { const std::string& scheme) {
auto* job_factory = request_context_getter->job_factory(); auto* job_factory = request_context_getter->job_factory();
if (!job_factory->HasProtocolHandler(scheme)) if (!job_factory->HasProtocolHandler(scheme))
return PROTOCOL_NOT_REGISTERED; return ProtocolError::NOT_REGISTERED;
job_factory->SetProtocolHandler(scheme, nullptr); job_factory->SetProtocolHandler(scheme, nullptr);
return PROTOCOL_OK; return ProtocolError::OK;
} }
bool IsProtocolHandledInIO( bool IsProtocolHandledInIO(
@ -209,8 +209,8 @@ Protocol::ProtocolError Protocol::UninterceptProtocolInIO(
scoped_refptr<URLRequestContextGetter> request_context_getter, scoped_refptr<URLRequestContextGetter> request_context_getter,
const std::string& scheme) { const std::string& scheme) {
return request_context_getter->job_factory()->UninterceptProtocol(scheme) return request_context_getter->job_factory()->UninterceptProtocol(scheme)
? PROTOCOL_OK ? ProtocolError::OK
: PROTOCOL_NOT_INTERCEPTED; : ProtocolError::NOT_INTERCEPTED;
} }
void Protocol::OnIOCompleted(const CompletionCallback& callback, void Protocol::OnIOCompleted(const CompletionCallback& callback,
@ -222,7 +222,7 @@ void Protocol::OnIOCompleted(const CompletionCallback& callback,
v8::Locker locker(isolate()); v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate()); v8::HandleScope handle_scope(isolate());
if (error == PROTOCOL_OK) { if (error == ProtocolError::OK) {
callback.Run(v8::Null(isolate())); callback.Run(v8::Null(isolate()));
} else { } else {
std::string str = ErrorCodeToString(error); std::string str = ErrorCodeToString(error);
@ -232,15 +232,15 @@ void Protocol::OnIOCompleted(const CompletionCallback& callback,
std::string Protocol::ErrorCodeToString(ProtocolError error) { std::string Protocol::ErrorCodeToString(ProtocolError error) {
switch (error) { switch (error) {
case PROTOCOL_FAIL: case ProtocolError::FAIL:
return "Failed to manipulate protocol factory"; return "Failed to manipulate protocol factory";
case PROTOCOL_REGISTERED: case ProtocolError::REGISTERED:
return "The scheme has been registered"; return "The scheme has been registered";
case PROTOCOL_NOT_REGISTERED: case ProtocolError::NOT_REGISTERED:
return "The scheme has not been registered"; return "The scheme has not been registered";
case PROTOCOL_INTERCEPTED: case ProtocolError::INTERCEPTED:
return "The scheme has been intercepted"; return "The scheme has been intercepted";
case PROTOCOL_NOT_INTERCEPTED: case ProtocolError::NOT_INTERCEPTED:
return "The scheme has not been intercepted"; return "The scheme has not been intercepted";
default: default:
return "Unexpected error"; return "Unexpected error";

View file

@ -56,13 +56,13 @@ class Protocol : public mate::TrackableObject<Protocol> {
private: private:
// Possible errors. // Possible errors.
enum ProtocolError { enum class ProtocolError {
PROTOCOL_OK, // no error OK, // no error
PROTOCOL_FAIL, // operation failed, should never occur FAIL, // operation failed, should never occur
PROTOCOL_REGISTERED, REGISTERED,
PROTOCOL_NOT_REGISTERED, NOT_REGISTERED,
PROTOCOL_INTERCEPTED, INTERCEPTED,
PROTOCOL_NOT_INTERCEPTED, NOT_INTERCEPTED,
}; };
// The protocol handler that will create a protocol handler for certain // The protocol handler that will create a protocol handler for certain
@ -118,13 +118,13 @@ class Protocol : public mate::TrackableObject<Protocol> {
const Handler& handler) { const Handler& handler) {
auto* job_factory = request_context_getter->job_factory(); auto* job_factory = request_context_getter->job_factory();
if (job_factory->IsHandledProtocol(scheme)) if (job_factory->IsHandledProtocol(scheme))
return PROTOCOL_REGISTERED; return ProtocolError::REGISTERED;
auto protocol_handler = std::make_unique<CustomProtocolHandler<RequestJob>>( auto protocol_handler = std::make_unique<CustomProtocolHandler<RequestJob>>(
isolate, request_context_getter.get(), handler); isolate, request_context_getter.get(), handler);
if (job_factory->SetProtocolHandler(scheme, std::move(protocol_handler))) if (job_factory->SetProtocolHandler(scheme, std::move(protocol_handler)))
return PROTOCOL_OK; return ProtocolError::OK;
else else
return PROTOCOL_FAIL; return ProtocolError::FAIL;
} }
// Unregister the protocol handler that handles |scheme|. // Unregister the protocol handler that handles |scheme|.
@ -159,15 +159,15 @@ class Protocol : public mate::TrackableObject<Protocol> {
const Handler& handler) { const Handler& handler) {
auto* job_factory = request_context_getter->job_factory(); auto* job_factory = request_context_getter->job_factory();
if (!job_factory->IsHandledProtocol(scheme)) if (!job_factory->IsHandledProtocol(scheme))
return PROTOCOL_NOT_REGISTERED; return ProtocolError::NOT_REGISTERED;
// It is possible a protocol is handled but can not be intercepted. // It is possible a protocol is handled but can not be intercepted.
if (!job_factory->HasProtocolHandler(scheme)) if (!job_factory->HasProtocolHandler(scheme))
return PROTOCOL_FAIL; return ProtocolError::FAIL;
auto protocol_handler = std::make_unique<CustomProtocolHandler<RequestJob>>( auto protocol_handler = std::make_unique<CustomProtocolHandler<RequestJob>>(
isolate, request_context_getter.get(), handler); isolate, request_context_getter.get(), handler);
if (!job_factory->InterceptProtocol(scheme, std::move(protocol_handler))) if (!job_factory->InterceptProtocol(scheme, std::move(protocol_handler)))
return PROTOCOL_INTERCEPTED; return ProtocolError::INTERCEPTED;
return PROTOCOL_OK; return ProtocolError::OK;
} }
// Restore the |scheme| to its original protocol handler. // Restore the |scheme| to its original protocol handler.

View file

@ -20,13 +20,13 @@ namespace {
// Convert error code to string. // Convert error code to string.
std::string ErrorCodeToString(ProtocolError error) { std::string ErrorCodeToString(ProtocolError error) {
switch (error) { switch (error) {
case PROTOCOL_REGISTERED: case ProtocolError::REGISTERED:
return "The scheme has been registered"; return "The scheme has been registered";
case PROTOCOL_NOT_REGISTERED: case ProtocolError::NOT_REGISTERED:
return "The scheme has not been registered"; return "The scheme has not been registered";
case PROTOCOL_INTERCEPTED: case ProtocolError::INTERCEPTED:
return "The scheme has been intercepted"; return "The scheme has been intercepted";
case PROTOCOL_NOT_INTERCEPTED: case ProtocolError::NOT_INTERCEPTED:
return "The scheme has not been intercepted"; return "The scheme has not been intercepted";
default: default:
return "Unexpected error"; return "Unexpected error";
@ -56,21 +56,21 @@ void ProtocolNS::RegisterURLLoaderFactories(
ProtocolError ProtocolNS::RegisterProtocol(ProtocolType type, ProtocolError ProtocolNS::RegisterProtocol(ProtocolType type,
const std::string& scheme, const std::string& scheme,
const ProtocolHandler& handler) { const ProtocolHandler& handler) {
ProtocolError error = PROTOCOL_OK; ProtocolError error = ProtocolError::OK;
if (!base::ContainsKey(handlers_, scheme)) if (!base::ContainsKey(handlers_, scheme))
handlers_[scheme] = std::make_pair(type, handler); handlers_[scheme] = std::make_pair(type, handler);
else else
error = PROTOCOL_REGISTERED; error = ProtocolError::REGISTERED;
return error; return error;
} }
void ProtocolNS::UnregisterProtocol(const std::string& scheme, void ProtocolNS::UnregisterProtocol(const std::string& scheme,
mate::Arguments* args) { mate::Arguments* args) {
ProtocolError error = PROTOCOL_OK; ProtocolError error = ProtocolError::OK;
if (base::ContainsKey(handlers_, scheme)) if (base::ContainsKey(handlers_, scheme))
handlers_.erase(scheme); handlers_.erase(scheme);
else else
error = PROTOCOL_NOT_REGISTERED; error = ProtocolError::NOT_REGISTERED;
HandleOptionalCallback(args, error); HandleOptionalCallback(args, error);
} }
@ -89,7 +89,7 @@ void ProtocolNS::HandleOptionalCallback(mate::Arguments* args,
ProtocolError error) { ProtocolError error) {
CompletionCallback callback; CompletionCallback callback;
if (args->GetNext(&callback)) { if (args->GetNext(&callback)) {
if (error == PROTOCOL_OK) if (error == ProtocolError::OK)
callback.Run(v8::Null(args->isolate())); callback.Run(v8::Null(args->isolate()));
else else
callback.Run(v8::Exception::Error( callback.Run(v8::Exception::Error(

View file

@ -22,12 +22,12 @@ class AtomBrowserContext;
namespace api { namespace api {
// Possible errors. // Possible errors.
enum ProtocolError { enum class ProtocolError {
PROTOCOL_OK, // no error OK, // no error
PROTOCOL_REGISTERED, REGISTERED,
PROTOCOL_NOT_REGISTERED, NOT_REGISTERED,
PROTOCOL_INTERCEPTED, INTERCEPTED,
PROTOCOL_NOT_INTERCEPTED, NOT_INTERCEPTED,
}; };
// Protocol implementation based on network services. // Protocol implementation based on network services.

View file

@ -737,15 +737,15 @@ void TopLevelWindow::SetProgressBar(double progress, mate::Arguments* args) {
std::string mode; std::string mode;
args->GetNext(&options) && options.Get("mode", &mode); args->GetNext(&options) && options.Get("mode", &mode);
NativeWindow::ProgressState state = NativeWindow::PROGRESS_NORMAL; NativeWindow::ProgressState state = NativeWindow::ProgressState::kNormal;
if (mode == "error") if (mode == "error")
state = NativeWindow::PROGRESS_ERROR; state = NativeWindow::ProgressState::kError;
else if (mode == "paused") else if (mode == "paused")
state = NativeWindow::PROGRESS_PAUSED; state = NativeWindow::ProgressState::kPaused;
else if (mode == "indeterminate") else if (mode == "indeterminate")
state = NativeWindow::PROGRESS_INDETERMINATE; state = NativeWindow::ProgressState::kIndeterminate;
else if (mode == "none") else if (mode == "none")
state = NativeWindow::PROGRESS_NONE; state = NativeWindow::ProgressState::kNone;
window_->SetProgressBar(progress, state); window_->SetProgressBar(progress, state);
} }

View file

@ -25,18 +25,19 @@ struct Converter<atom::TrayIcon::HighlightMode> {
static bool FromV8(v8::Isolate* isolate, static bool FromV8(v8::Isolate* isolate,
v8::Local<v8::Value> val, v8::Local<v8::Value> val,
atom::TrayIcon::HighlightMode* out) { atom::TrayIcon::HighlightMode* out) {
using HighlightMode = atom::TrayIcon::HighlightMode;
std::string mode; std::string mode;
if (ConvertFromV8(isolate, val, &mode)) { if (ConvertFromV8(isolate, val, &mode)) {
if (mode == "always") { if (mode == "always") {
*out = atom::TrayIcon::HighlightMode::ALWAYS; *out = HighlightMode::ALWAYS;
return true; return true;
} }
if (mode == "selection") { if (mode == "selection") {
*out = atom::TrayIcon::HighlightMode::SELECTION; *out = HighlightMode::SELECTION;
return true; return true;
} }
if (mode == "never") { if (mode == "never") {
*out = atom::TrayIcon::HighlightMode::NEVER; *out = HighlightMode::NEVER;
return true; return true;
} }
} }

View file

@ -268,7 +268,7 @@ struct WebContents::FrameDispatchHelper {
WebContents::WebContents(v8::Isolate* isolate, WebContents::WebContents(v8::Isolate* isolate,
content::WebContents* web_contents) content::WebContents* web_contents)
: content::WebContentsObserver(web_contents), type_(REMOTE) { : content::WebContentsObserver(web_contents), type_(Type::REMOTE) {
web_contents->SetUserAgentOverride(GetBrowserContext()->GetUserAgent(), web_contents->SetUserAgentOverride(GetBrowserContext()->GetUserAgent(),
false); false);
Init(isolate); Init(isolate);
@ -284,7 +284,8 @@ WebContents::WebContents(v8::Isolate* isolate,
std::unique_ptr<content::WebContents> web_contents, std::unique_ptr<content::WebContents> web_contents,
Type type) Type type)
: content::WebContentsObserver(web_contents.get()), type_(type) { : content::WebContentsObserver(web_contents.get()), type_(type) {
DCHECK(type != REMOTE) << "Can't take ownership of a remote WebContents"; DCHECK(type != Type::REMOTE)
<< "Can't take ownership of a remote WebContents";
auto session = Session::CreateFrom(isolate, GetBrowserContext()); auto session = Session::CreateFrom(isolate, GetBrowserContext());
session_.Reset(isolate, session.ToV8()); session_.Reset(isolate, session.ToV8());
InitWithSessionAndOptions(isolate, std::move(web_contents), session, InitWithSessionAndOptions(isolate, std::move(web_contents), session,
@ -303,14 +304,14 @@ WebContents::WebContents(v8::Isolate* isolate,
// Remvoe this after we upgraded to use VS 2015 Update 3. // Remvoe this after we upgraded to use VS 2015 Update 3.
bool b = false; bool b = false;
if (options.Get("isGuest", &b) && b) if (options.Get("isGuest", &b) && b)
type_ = WEB_VIEW; type_ = Type::WEB_VIEW;
else if (options.Get("isBackgroundPage", &b) && b) else if (options.Get("isBackgroundPage", &b) && b)
type_ = BACKGROUND_PAGE; type_ = Type::BACKGROUND_PAGE;
else if (options.Get("isBrowserView", &b) && b) else if (options.Get("isBrowserView", &b) && b)
type_ = BROWSER_VIEW; type_ = Type::BROWSER_VIEW;
#if BUILDFLAG(ENABLE_OSR) #if BUILDFLAG(ENABLE_OSR)
else if (options.Get(options::kOffscreen, &b) && b) else if (options.Get(options::kOffscreen, &b) && b)
type_ = OFF_SCREEN; type_ = Type::OFF_SCREEN;
#endif #endif
// Init embedder earlier // Init embedder earlier
@ -457,12 +458,12 @@ WebContents::~WebContents() {
RenderViewDeleted(web_contents()->GetRenderViewHost()); RenderViewDeleted(web_contents()->GetRenderViewHost());
if (type_ == WEB_VIEW) { if (type_ == Type::WEB_VIEW) {
DCHECK(!web_contents()->GetOuterWebContents()) DCHECK(!web_contents()->GetOuterWebContents())
<< "Should never manually destroy an attached webview"; << "Should never manually destroy an attached webview";
// For webview simply destroy the WebContents immediately. // For webview simply destroy the WebContents immediately.
DestroyWebContents(false /* async */); DestroyWebContents(false /* async */);
} else if (type_ == BROWSER_WINDOW && owner_window()) { } else if (type_ == Type::BROWSER_WINDOW && owner_window()) {
// For BrowserWindow we should close the window and clean up everything // For BrowserWindow we should close the window and clean up everything
// before WebContents is destroyed. // before WebContents is destroyed.
for (ExtendedWebContentsObserver& observer : observers_) for (ExtendedWebContentsObserver& observer : observers_)
@ -509,7 +510,7 @@ void WebContents::OnCreateWindow(
WindowOpenDisposition disposition, WindowOpenDisposition disposition,
const std::vector<std::string>& features, const std::vector<std::string>& features,
const scoped_refptr<network::ResourceRequestBody>& body) { const scoped_refptr<network::ResourceRequestBody>& body) {
if (type_ == BROWSER_WINDOW || type_ == OFF_SCREEN) if (type_ == Type::BROWSER_WINDOW || type_ == Type::OFF_SCREEN)
Emit("-new-window", target_url, frame_name, disposition, features, body, Emit("-new-window", target_url, frame_name, disposition, features, body,
referrer); referrer);
else else
@ -541,7 +542,7 @@ void WebContents::AddNewContents(
v8::Locker locker(isolate()); v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate()); v8::HandleScope handle_scope(isolate());
auto api_web_contents = auto api_web_contents =
CreateAndTake(isolate(), std::move(new_contents), BROWSER_WINDOW); CreateAndTake(isolate(), std::move(new_contents), Type::BROWSER_WINDOW);
if (Emit("-add-new-contents", api_web_contents, disposition, user_gesture, if (Emit("-add-new-contents", api_web_contents, disposition, user_gesture,
initial_rect.x(), initial_rect.y(), initial_rect.width(), initial_rect.x(), initial_rect.y(), initial_rect.width(),
initial_rect.height(), tracker->url, tracker->frame_name)) { initial_rect.height(), tracker->url, tracker->frame_name)) {
@ -554,7 +555,7 @@ content::WebContents* WebContents::OpenURLFromTab(
content::WebContents* source, content::WebContents* source,
const content::OpenURLParams& params) { const content::OpenURLParams& params) {
if (params.disposition != WindowOpenDisposition::CURRENT_TAB) { if (params.disposition != WindowOpenDisposition::CURRENT_TAB) {
if (type_ == BROWSER_WINDOW || type_ == OFF_SCREEN) if (type_ == Type::BROWSER_WINDOW || type_ == Type::OFF_SCREEN)
Emit("-new-window", params.url, "", params.disposition); Emit("-new-window", params.url, "", params.disposition);
else else
Emit("new-window", params.url, "", params.disposition); Emit("new-window", params.url, "", params.disposition);
@ -576,7 +577,7 @@ content::WebContents* WebContents::OpenURLFromTab(
void WebContents::BeforeUnloadFired(content::WebContents* tab, void WebContents::BeforeUnloadFired(content::WebContents* tab,
bool proceed, bool proceed,
bool* proceed_to_fire_unload) { bool* proceed_to_fire_unload) {
if (type_ == BROWSER_WINDOW || type_ == OFF_SCREEN) if (type_ == Type::BROWSER_WINDOW || type_ == Type::OFF_SCREEN)
*proceed_to_fire_unload = proceed; *proceed_to_fire_unload = proceed;
else else
*proceed_to_fire_unload = true; *proceed_to_fire_unload = true;
@ -610,7 +611,7 @@ void WebContents::UpdateTargetURL(content::WebContents* source,
bool WebContents::HandleKeyboardEvent( bool WebContents::HandleKeyboardEvent(
content::WebContents* source, content::WebContents* source,
const content::NativeWebKeyboardEvent& event) { const content::NativeWebKeyboardEvent& event) {
if (type_ == WEB_VIEW && embedder_) { if (type_ == Type::WEB_VIEW && embedder_) {
// Send the unhandled keyboard events back to the embedder. // Send the unhandled keyboard events back to the embedder.
return embedder_->HandleKeyboardEvent(source, event); return embedder_->HandleKeyboardEvent(source, event);
} else { } else {
@ -1390,14 +1391,14 @@ v8::Local<v8::Promise> WebContents::SavePage(
} }
void WebContents::OpenDevTools(mate::Arguments* args) { void WebContents::OpenDevTools(mate::Arguments* args) {
if (type_ == REMOTE) if (type_ == Type::REMOTE)
return; return;
if (!enable_devtools_) if (!enable_devtools_)
return; return;
std::string state; std::string state;
if (type_ == WEB_VIEW || !owner_window()) { if (type_ == Type::WEB_VIEW || !owner_window()) {
state = "detach"; state = "detach";
} }
bool activate = true; bool activate = true;
@ -1413,21 +1414,21 @@ void WebContents::OpenDevTools(mate::Arguments* args) {
} }
void WebContents::CloseDevTools() { void WebContents::CloseDevTools() {
if (type_ == REMOTE) if (type_ == Type::REMOTE)
return; return;
managed_web_contents()->CloseDevTools(); managed_web_contents()->CloseDevTools();
} }
bool WebContents::IsDevToolsOpened() { bool WebContents::IsDevToolsOpened() {
if (type_ == REMOTE) if (type_ == Type::REMOTE)
return false; return false;
return managed_web_contents()->IsDevToolsViewShowing(); return managed_web_contents()->IsDevToolsViewShowing();
} }
bool WebContents::IsDevToolsFocused() { bool WebContents::IsDevToolsFocused() {
if (type_ == REMOTE) if (type_ == Type::REMOTE)
return false; return false;
return managed_web_contents()->GetView()->IsDevToolsViewFocused(); return managed_web_contents()->GetView()->IsDevToolsViewFocused();
@ -1435,7 +1436,7 @@ bool WebContents::IsDevToolsFocused() {
void WebContents::EnableDeviceEmulation( void WebContents::EnableDeviceEmulation(
const blink::WebDeviceEmulationParams& params) { const blink::WebDeviceEmulationParams& params) {
if (type_ == REMOTE) if (type_ == Type::REMOTE)
return; return;
auto* frame_host = web_contents()->GetMainFrame(); auto* frame_host = web_contents()->GetMainFrame();
@ -1450,7 +1451,7 @@ void WebContents::EnableDeviceEmulation(
} }
void WebContents::DisableDeviceEmulation() { void WebContents::DisableDeviceEmulation() {
if (type_ == REMOTE) if (type_ == Type::REMOTE)
return; return;
auto* frame_host = web_contents()->GetMainFrame(); auto* frame_host = web_contents()->GetMainFrame();
@ -1472,7 +1473,7 @@ void WebContents::ToggleDevTools() {
} }
void WebContents::InspectElement(int x, int y) { void WebContents::InspectElement(int x, int y) {
if (type_ == REMOTE) if (type_ == Type::REMOTE)
return; return;
if (!enable_devtools_) if (!enable_devtools_)
@ -1484,7 +1485,7 @@ void WebContents::InspectElement(int x, int y) {
} }
void WebContents::InspectSharedWorker() { void WebContents::InspectSharedWorker() {
if (type_ == REMOTE) if (type_ == Type::REMOTE)
return; return;
if (!enable_devtools_) if (!enable_devtools_)
@ -1501,7 +1502,7 @@ void WebContents::InspectSharedWorker() {
} }
void WebContents::InspectServiceWorker() { void WebContents::InspectServiceWorker() {
if (type_ == REMOTE) if (type_ == Type::REMOTE)
return; return;
if (!enable_devtools_) if (!enable_devtools_)
@ -1701,7 +1702,7 @@ bool WebContents::IsFocused() const {
if (!view) if (!view)
return false; return false;
if (GetType() != BACKGROUND_PAGE) { if (GetType() != Type::BACKGROUND_PAGE) {
auto* window = web_contents()->GetNativeView()->GetToplevelWindow(); auto* window = web_contents()->GetNativeView()->GetToplevelWindow();
if (window && !window->IsVisible()) if (window && !window->IsVisible())
return false; return false;
@ -1933,7 +1934,7 @@ void WebContents::OnCursorChange(const content::WebCursor& cursor) {
} }
bool WebContents::IsGuest() const { bool WebContents::IsGuest() const {
return type_ == WEB_VIEW; return type_ == Type::WEB_VIEW;
} }
void WebContents::AttachToIframe(content::WebContents* embedder_web_contents, void WebContents::AttachToIframe(content::WebContents* embedder_web_contents,
@ -1944,7 +1945,7 @@ void WebContents::AttachToIframe(content::WebContents* embedder_web_contents,
bool WebContents::IsOffScreen() const { bool WebContents::IsOffScreen() const {
#if BUILDFLAG(ENABLE_OSR) #if BUILDFLAG(ENABLE_OSR)
return type_ == OFF_SCREEN; return type_ == Type::OFF_SCREEN;
#else #else
return false; return false;
#endif #endif

View file

@ -80,7 +80,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
public content::WebContentsObserver, public content::WebContentsObserver,
public mojom::ElectronBrowser { public mojom::ElectronBrowser {
public: public:
enum Type { enum class Type {
BACKGROUND_PAGE, // A DevTools extension background page. BACKGROUND_PAGE, // A DevTools extension background page.
BROWSER_WINDOW, // Used by BrowserWindow. BROWSER_WINDOW, // Used by BrowserWindow.
BROWSER_VIEW, // Used by BrowserView. BROWSER_VIEW, // Used by BrowserView.
@ -534,7 +534,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
WebContentsZoomController* zoom_controller_ = nullptr; WebContentsZoomController* zoom_controller_ = nullptr;
// The type of current WebContents. // The type of current WebContents.
Type type_ = BROWSER_WINDOW; Type type_ = Type::BROWSER_WINDOW;
// Request id used for findInPage request. // Request id used for findInPage request.
uint32_t request_id_ = 0; uint32_t request_id_ = 0;

View file

@ -16,7 +16,7 @@ bool WebContents::IsFocused() const {
if (!view) if (!view)
return false; return false;
if (GetType() != BACKGROUND_PAGE) { if (GetType() != Type::BACKGROUND_PAGE) {
auto window = [web_contents()->GetNativeView().GetNativeNSView() window]; auto window = [web_contents()->GetNativeView().GetNativeNSView() window];
// On Mac the render widget host view does not lose focus when the window // On Mac the render widget host view does not lose focus when the window
// loses focus so check if the top level window is the key window. // loses focus so check if the top level window is the key window.

View file

@ -205,7 +205,8 @@ AtomBrowserMainParts::AtomBrowserMainParts(
const content::MainFunctionParams& params) const content::MainFunctionParams& params)
: fake_browser_process_(new BrowserProcessImpl), : fake_browser_process_(new BrowserProcessImpl),
browser_(new Browser), browser_(new Browser),
node_bindings_(NodeBindings::Create(NodeBindings::BROWSER)), node_bindings_(
NodeBindings::Create(NodeBindings::BrowserEnvironment::BROWSER)),
electron_bindings_(new ElectronBindings(uv_default_loop())), electron_bindings_(new ElectronBindings(uv_default_loop())),
main_function_params_(params) { main_function_params_(params) {
DCHECK(!self_) << "Cannot have two AtomBrowserMainParts"; DCHECK(!self_) << "Cannot have two AtomBrowserMainParts";

View file

@ -92,8 +92,8 @@ void AtomJavaScriptDialogManager::RunJavaScriptDialog(
} }
atom::ShowMessageBox( atom::ShowMessageBox(
window, atom::MessageBoxType::MESSAGE_BOX_TYPE_NONE, buttons, default_id, window, atom::MessageBoxType::kNone, buttons, default_id, cancel_id,
cancel_id, atom::MessageBoxOptions::MESSAGE_BOX_NONE, "", atom::MessageBoxOptions::MESSAGE_BOX_NONE, "",
base::UTF16ToUTF8(message_text), "", checkbox, false, gfx::ImageSkia(), base::UTF16ToUTF8(message_text), "", checkbox, false, gfx::ImageSkia(),
base::Bind(&AtomJavaScriptDialogManager::OnMessageBoxCallback, base::Bind(&AtomJavaScriptDialogManager::OnMessageBoxCallback,
base::Unretained(this), base::Passed(std::move(callback)), base::Unretained(this), base::Passed(std::move(callback)),

View file

@ -155,9 +155,9 @@ class Browser : public WindowListObserver {
const base::DictionaryValue& user_info); const base::DictionaryValue& user_info);
// Bounce the dock icon. // Bounce the dock icon.
enum BounceType { enum class BounceType {
BOUNCE_CRITICAL = 0, CRITICAL = 0, // NSCriticalRequest
BOUNCE_INFORMATIONAL = 10, INFORMATIONAL = 10, // NSInformationalRequest
}; };
int DockBounce(BounceType type); int DockBounce(BounceType type);
void DockCancelBounce(int request_id); void DockCancelBounce(int request_id);

View file

@ -164,12 +164,12 @@ class NativeWindow : public base::SupportsUserData,
virtual NativeWindowHandle GetNativeWindowHandle() const = 0; virtual NativeWindowHandle GetNativeWindowHandle() const = 0;
// Taskbar/Dock APIs. // Taskbar/Dock APIs.
enum ProgressState { enum class ProgressState {
PROGRESS_NONE, // no progress, no marking kNone, // no progress, no marking
PROGRESS_INDETERMINATE, // progress, indeterminate kIndeterminate, // progress, indeterminate
PROGRESS_ERROR, // progress, errored (red) kError, // progress, errored (red)
PROGRESS_PAUSED, // progress, paused (yellow) kPaused, // progress, paused (yellow)
PROGRESS_NORMAL, // progress, not marked (green) kNormal, // progress, not marked (green)
}; };
virtual void SetProgressBar(double progress, const ProgressState state) = 0; virtual void SetProgressBar(double progress, const ProgressState state) = 0;

View file

@ -146,7 +146,7 @@ class NativeWindowMac : public NativeWindow {
void SetStyleMask(bool on, NSUInteger flag); void SetStyleMask(bool on, NSUInteger flag);
void SetCollectionBehavior(bool on, NSUInteger flag); void SetCollectionBehavior(bool on, NSUInteger flag);
enum TitleBarStyle { enum class TitleBarStyle {
NORMAL, NORMAL,
HIDDEN, HIDDEN,
HIDDEN_INSET, HIDDEN_INSET,
@ -200,7 +200,7 @@ class NativeWindowMac : public NativeWindow {
NSApplicationPresentationOptions kiosk_options_; NSApplicationPresentationOptions kiosk_options_;
// The "titleBarStyle" option. // The "titleBarStyle" option.
TitleBarStyle title_bar_style_ = NORMAL; TitleBarStyle title_bar_style_ = TitleBarStyle::NORMAL;
// The visibility mode of window button controls when explicitly set through // The visibility mode of window button controls when explicitly set through
// setWindowButtonVisibility(). // setWindowButtonVisibility().

View file

@ -211,15 +211,16 @@ struct Converter<atom::NativeWindowMac::TitleBarStyle> {
static bool FromV8(v8::Isolate* isolate, static bool FromV8(v8::Isolate* isolate,
v8::Handle<v8::Value> val, v8::Handle<v8::Value> val,
atom::NativeWindowMac::TitleBarStyle* out) { atom::NativeWindowMac::TitleBarStyle* out) {
using TitleBarStyle = atom::NativeWindowMac::TitleBarStyle;
std::string title_bar_style; std::string title_bar_style;
if (!ConvertFromV8(isolate, val, &title_bar_style)) if (!ConvertFromV8(isolate, val, &title_bar_style))
return false; return false;
if (title_bar_style == "hidden") { if (title_bar_style == "hidden") {
*out = atom::NativeWindowMac::HIDDEN; *out = TitleBarStyle::HIDDEN;
} else if (title_bar_style == "hiddenInset") { } else if (title_bar_style == "hiddenInset") {
*out = atom::NativeWindowMac::HIDDEN_INSET; *out = TitleBarStyle::HIDDEN_INSET;
} else if (title_bar_style == "customButtonsOnHover") { } else if (title_bar_style == "customButtonsOnHover") {
*out = atom::NativeWindowMac::CUSTOM_BUTTONS_ON_HOVER; *out = TitleBarStyle::CUSTOM_BUTTONS_ON_HOVER;
} else { } else {
return false; return false;
} }
@ -319,7 +320,7 @@ NativeWindowMac::NativeWindowMac(const mate::Dictionary& options,
} }
NSUInteger styleMask = NSWindowStyleMaskTitled; NSUInteger styleMask = NSWindowStyleMaskTitled;
if (title_bar_style_ == CUSTOM_BUTTONS_ON_HOVER && if (title_bar_style_ == TitleBarStyle::CUSTOM_BUTTONS_ON_HOVER &&
(!useStandardWindow || transparent() || !has_frame())) { (!useStandardWindow || transparent() || !has_frame())) {
styleMask = NSWindowStyleMaskFullSizeContentView; styleMask = NSWindowStyleMaskFullSizeContentView;
} }
@ -329,7 +330,7 @@ NativeWindowMac::NativeWindowMac(const mate::Dictionary& options,
if (closable) { if (closable) {
styleMask |= NSWindowStyleMaskClosable; styleMask |= NSWindowStyleMaskClosable;
} }
if (title_bar_style_ != NORMAL) { if (title_bar_style_ != TitleBarStyle::NORMAL) {
// The window without titlebar is treated the same with frameless window. // The window without titlebar is treated the same with frameless window.
set_has_frame(false); set_has_frame(false);
} }
@ -400,12 +401,12 @@ NativeWindowMac::NativeWindowMac(const mate::Dictionary& options,
} }
// Hide the title bar background // Hide the title bar background
if (title_bar_style_ != NORMAL) { if (title_bar_style_ != TitleBarStyle::NORMAL) {
[window_ setTitlebarAppearsTransparent:YES]; [window_ setTitlebarAppearsTransparent:YES];
} }
// Hide the title bar. // Hide the title bar.
if (title_bar_style_ == HIDDEN_INSET) { if (title_bar_style_ == TitleBarStyle::HIDDEN_INSET) {
base::scoped_nsobject<NSToolbar> toolbar( base::scoped_nsobject<NSToolbar> toolbar(
[[NSToolbar alloc] initWithIdentifier:@"titlebarStylingToolbar"]); [[NSToolbar alloc] initWithIdentifier:@"titlebarStylingToolbar"]);
[toolbar setShowsBaselineSeparator:NO]; [toolbar setShowsBaselineSeparator:NO];
@ -1235,7 +1236,7 @@ bool NativeWindowMac::AddTabbedWindow(NativeWindow* window) {
} }
bool NativeWindowMac::SetWindowButtonVisibility(bool visible) { bool NativeWindowMac::SetWindowButtonVisibility(bool visible) {
if (title_bar_style_ == CUSTOM_BUTTONS_ON_HOVER) { if (title_bar_style_ == TitleBarStyle::CUSTOM_BUTTONS_ON_HOVER) {
return false; return false;
} }
@ -1267,7 +1268,7 @@ void NativeWindowMac::SetVibrancy(const std::string& type) {
background_color_before_vibrancy_.reset([[window_ backgroundColor] retain]); background_color_before_vibrancy_.reset([[window_ backgroundColor] retain]);
transparency_before_vibrancy_ = [window_ titlebarAppearsTransparent]; transparency_before_vibrancy_ = [window_ titlebarAppearsTransparent];
if (title_bar_style_ != NORMAL) { if (title_bar_style_ != TitleBarStyle::NORMAL) {
[window_ setTitlebarAppearsTransparent:YES]; [window_ setTitlebarAppearsTransparent:YES];
[window_ setBackgroundColor:[NSColor clearColor]]; [window_ setBackgroundColor:[NSColor clearColor]];
} }
@ -1420,14 +1421,14 @@ void NativeWindowMac::AddContentViewLayers() {
// The fullscreen button should always be hidden for frameless window. // The fullscreen button should always be hidden for frameless window.
[[window_ standardWindowButton:NSWindowFullScreenButton] setHidden:YES]; [[window_ standardWindowButton:NSWindowFullScreenButton] setHidden:YES];
if (title_bar_style_ == CUSTOM_BUTTONS_ON_HOVER) { if (title_bar_style_ == TitleBarStyle::CUSTOM_BUTTONS_ON_HOVER) {
buttons_view_.reset( buttons_view_.reset(
[[CustomWindowButtonView alloc] initWithFrame:NSZeroRect]); [[CustomWindowButtonView alloc] initWithFrame:NSZeroRect]);
// NSWindowStyleMaskFullSizeContentView does not work with zoom button // NSWindowStyleMaskFullSizeContentView does not work with zoom button
SetFullScreenable(false); SetFullScreenable(false);
[[window_ contentView] addSubview:buttons_view_]; [[window_ contentView] addSubview:buttons_view_];
} else { } else {
if (title_bar_style_ != NORMAL) if (title_bar_style_ != TitleBarStyle::NORMAL)
return; return;
// Hide the window buttons. // Hide the window buttons.

View file

@ -54,7 +54,7 @@ void URLRequestAsarJob::Initialize(
std::shared_ptr<Archive> archive = GetOrCreateAsarArchive(asar_path); std::shared_ptr<Archive> archive = GetOrCreateAsarArchive(asar_path);
Archive::FileInfo file_info; Archive::FileInfo file_info;
if (!archive || !archive->GetFileInfo(relative_path, &file_info)) { if (!archive || !archive->GetFileInfo(relative_path, &file_info)) {
type_ = TYPE_ERROR; type_ = JobType::kError;
return; return;
} }
@ -73,7 +73,7 @@ void URLRequestAsarJob::InitializeAsarJob(
std::shared_ptr<Archive> archive, std::shared_ptr<Archive> archive,
const base::FilePath& file_path, const base::FilePath& file_path,
const Archive::FileInfo& file_info) { const Archive::FileInfo& file_info) {
type_ = TYPE_ASAR; type_ = JobType::kAsar;
file_task_runner_ = file_task_runner; file_task_runner_ = file_task_runner;
stream_.reset(new net::FileStream(file_task_runner_)); stream_.reset(new net::FileStream(file_task_runner_));
archive_ = archive; archive_ = archive;
@ -84,16 +84,16 @@ void URLRequestAsarJob::InitializeAsarJob(
void URLRequestAsarJob::InitializeFileJob( void URLRequestAsarJob::InitializeFileJob(
const scoped_refptr<base::TaskRunner> file_task_runner, const scoped_refptr<base::TaskRunner> file_task_runner,
const base::FilePath& file_path) { const base::FilePath& file_path) {
type_ = TYPE_FILE; type_ = JobType::kFile;
file_task_runner_ = file_task_runner; file_task_runner_ = file_task_runner;
stream_.reset(new net::FileStream(file_task_runner_)); stream_.reset(new net::FileStream(file_task_runner_));
file_path_ = file_path; file_path_ = file_path;
} }
void URLRequestAsarJob::Start() { void URLRequestAsarJob::Start() {
if (type_ == TYPE_ASAR || type_ == TYPE_FILE) { if (type_ == JobType::kAsar || type_ == JobType::kFile) {
auto* meta_info = new FileMetaInfo(); auto* meta_info = new FileMetaInfo();
if (type_ == TYPE_ASAR) { if (type_ == JobType::kAsar) {
meta_info->file_path = archive_->path(); meta_info->file_path = archive_->path();
meta_info->file_exists = true; meta_info->file_exists = true;
meta_info->is_directory = false; meta_info->is_directory = false;
@ -144,7 +144,7 @@ int URLRequestAsarJob::ReadRawData(net::IOBuffer* dest, int dest_size) {
bool URLRequestAsarJob::IsRedirectResponse(GURL* location, bool URLRequestAsarJob::IsRedirectResponse(GURL* location,
int* http_status_code, int* http_status_code,
bool* insecure_scheme_was_upgraded) { bool* insecure_scheme_was_upgraded) {
if (type_ != TYPE_FILE) if (type_ != JobType::kFile)
return false; return false;
#if defined(OS_WIN) #if defined(OS_WIN)
// Follow a Windows shortcut. // Follow a Windows shortcut.
@ -222,7 +222,7 @@ void URLRequestAsarJob::GetResponseInfo(net::HttpResponseInfo* info) {
void URLRequestAsarJob::FetchMetaInfo(const base::FilePath& file_path, void URLRequestAsarJob::FetchMetaInfo(const base::FilePath& file_path,
JobType type, JobType type,
FileMetaInfo* meta_info) { FileMetaInfo* meta_info) {
if (type == TYPE_FILE) { if (type == JobType::kFile) {
base::File::Info file_info; base::File::Info file_info;
meta_info->file_exists = base::GetFileInfo(file_path, &file_info); meta_info->file_exists = base::GetFileInfo(file_path, &file_info);
if (meta_info->file_exists) { if (meta_info->file_exists) {
@ -278,7 +278,7 @@ void URLRequestAsarJob::DidOpen(int result) {
} }
int64_t file_size, read_offset; int64_t file_size, read_offset;
if (type_ == TYPE_ASAR) { if (type_ == JobType::kAsar) {
file_size = file_info_.size; file_size = file_info_.size;
read_offset = file_info_.offset; read_offset = file_info_.offset;
} else { } else {

View file

@ -66,10 +66,10 @@ class URLRequestAsarJob : public net::URLRequestJob {
private: private:
// The type of this job. // The type of this job.
enum JobType { enum class JobType {
TYPE_ERROR, kError,
TYPE_ASAR, kAsar,
TYPE_FILE, kFile,
}; };
// Meta information about the file. It's used as a member in the // Meta information about the file. It's used as a member in the
@ -111,7 +111,7 @@ class URLRequestAsarJob : public net::URLRequestJob {
// Callback after data is asynchronously read from the file into |buf|. // Callback after data is asynchronously read from the file into |buf|.
void DidRead(scoped_refptr<net::IOBuffer> buf, int result); void DidRead(scoped_refptr<net::IOBuffer> buf, int result);
JobType type_ = TYPE_ERROR; JobType type_ = JobType::kError;
std::shared_ptr<Archive> archive_; std::shared_ptr<Archive> archive_;
base::FilePath file_path_; base::FilePath file_path_;

View file

@ -157,7 +157,7 @@ bool ScopedDisableResize::disable_resize_ = false;
- (void)performClose:(id)sender { - (void)performClose:(id)sender {
if (shell_->title_bar_style() == if (shell_->title_bar_style() ==
atom::NativeWindowMac::CUSTOM_BUTTONS_ON_HOVER) { atom::NativeWindowMac::TitleBarStyle::CUSTOM_BUTTONS_ON_HOVER) {
[[self delegate] windowShouldClose:self]; [[self delegate] windowShouldClose:self];
} else if (shell_->IsSimpleFullScreen()) { } else if (shell_->IsSimpleFullScreen()) {
if ([[self delegate] respondsToSelector:@selector(windowShouldClose:)]) { if ([[self delegate] respondsToSelector:@selector(windowShouldClose:)]) {
@ -182,7 +182,7 @@ bool ScopedDisableResize::disable_resize_ = false;
- (void)performMiniaturize:(id)sender { - (void)performMiniaturize:(id)sender {
if (shell_->title_bar_style() == if (shell_->title_bar_style() ==
atom::NativeWindowMac::CUSTOM_BUTTONS_ON_HOVER) atom::NativeWindowMac::TitleBarStyle::CUSTOM_BUTTONS_ON_HOVER)
[self miniaturize:self]; [self miniaturize:self];
else else
[super performMiniaturize:sender]; [super performMiniaturize:sender];

View file

@ -15,6 +15,8 @@
#include "ui/views/widget/native_widget_mac.h" #include "ui/views/widget/native_widget_mac.h"
#include "ui/views_bridge_mac/bridged_native_widget_impl.h" #include "ui/views_bridge_mac/bridged_native_widget_impl.h"
using TitleBarStyle = atom::NativeWindowMac::TitleBarStyle;
@implementation AtomNSWindowDelegate @implementation AtomNSWindowDelegate
- (id)initWithShell:(atom::NativeWindowMac*)shell { - (id)initWithShell:(atom::NativeWindowMac*)shell {
@ -181,7 +183,7 @@
shell_->SetResizable(true); shell_->SetResizable(true);
// Hide the native toolbar before entering fullscreen, so there is no visual // Hide the native toolbar before entering fullscreen, so there is no visual
// artifacts. // artifacts.
if (shell_->title_bar_style() == atom::NativeWindowMac::HIDDEN_INSET) { if (shell_->title_bar_style() == TitleBarStyle::HIDDEN_INSET) {
NSWindow* window = shell_->GetNativeWindow().GetNativeNSWindow(); NSWindow* window = shell_->GetNativeWindow().GetNativeNSWindow();
[window setToolbar:nil]; [window setToolbar:nil];
} }
@ -198,14 +200,14 @@
// FIXME(zcbenz): Showing titlebar for hiddenInset window is weird under // FIXME(zcbenz): Showing titlebar for hiddenInset window is weird under
// fullscreen mode. // fullscreen mode.
// Show title if fullscreen_window_title flag is set // Show title if fullscreen_window_title flag is set
(shell_->title_bar_style() != atom::NativeWindowMac::HIDDEN_INSET || (shell_->title_bar_style() != TitleBarStyle::HIDDEN_INSET ||
shell_->fullscreen_window_title())) { shell_->fullscreen_window_title())) {
[window setTitleVisibility:NSWindowTitleVisible]; [window setTitleVisibility:NSWindowTitleVisible];
} }
// Restore the native toolbar immediately after entering fullscreen, if we // Restore the native toolbar immediately after entering fullscreen, if we
// do this before leaving fullscreen, traffic light buttons will be jumping. // do this before leaving fullscreen, traffic light buttons will be jumping.
if (shell_->title_bar_style() == atom::NativeWindowMac::HIDDEN_INSET) { if (shell_->title_bar_style() == TitleBarStyle::HIDDEN_INSET) {
base::scoped_nsobject<NSToolbar> toolbar( base::scoped_nsobject<NSToolbar> toolbar(
[[NSToolbar alloc] initWithIdentifier:@"titlebarStylingToolbar"]); [[NSToolbar alloc] initWithIdentifier:@"titlebarStylingToolbar"]);
[toolbar setShowsBaselineSeparator:NO]; [toolbar setShowsBaselineSeparator:NO];
@ -222,13 +224,13 @@
// Restore the titlebar visibility. // Restore the titlebar visibility.
NSWindow* window = shell_->GetNativeWindow().GetNativeNSWindow(); NSWindow* window = shell_->GetNativeWindow().GetNativeNSWindow();
if ((shell_->transparent() || !shell_->has_frame()) && if ((shell_->transparent() || !shell_->has_frame()) &&
(shell_->title_bar_style() != atom::NativeWindowMac::HIDDEN_INSET || (shell_->title_bar_style() != TitleBarStyle::HIDDEN_INSET ||
shell_->fullscreen_window_title())) { shell_->fullscreen_window_title())) {
[window setTitleVisibility:NSWindowTitleHidden]; [window setTitleVisibility:NSWindowTitleHidden];
} }
// Turn off the style for toolbar. // Turn off the style for toolbar.
if (shell_->title_bar_style() == atom::NativeWindowMac::HIDDEN_INSET) { if (shell_->title_bar_style() == TitleBarStyle::HIDDEN_INSET) {
shell_->SetStyleMask(false, NSWindowStyleMaskFullSizeContentView); shell_->SetStyleMask(false, NSWindowStyleMaskFullSizeContentView);
[window setTitlebarAppearsTransparent:YES]; [window setTitlebarAppearsTransparent:YES];
} }

View file

@ -19,12 +19,12 @@ namespace atom {
class NativeWindow; class NativeWindow;
enum MessageBoxType { enum class MessageBoxType {
MESSAGE_BOX_TYPE_NONE = 0, kNone = 0,
MESSAGE_BOX_TYPE_INFORMATION, kInformation,
MESSAGE_BOX_TYPE_WARNING, kWarning,
MESSAGE_BOX_TYPE_ERROR, kError,
MESSAGE_BOX_TYPE_QUESTION, kQuestion,
}; };
enum MessageBoxOptions { enum MessageBoxOptions {

View file

@ -111,13 +111,13 @@ class GtkMessageBox : public NativeWindowObserver {
GtkMessageType GetMessageType(MessageBoxType type) { GtkMessageType GetMessageType(MessageBoxType type) {
switch (type) { switch (type) {
case MESSAGE_BOX_TYPE_INFORMATION: case MessageBoxType::kInformation:
return GTK_MESSAGE_INFO; return GTK_MESSAGE_INFO;
case MESSAGE_BOX_TYPE_WARNING: case MessageBoxType::kWarning:
return GTK_MESSAGE_WARNING; return GTK_MESSAGE_WARNING;
case MESSAGE_BOX_TYPE_QUESTION: case MessageBoxType::kQuestion:
return GTK_MESSAGE_QUESTION; return GTK_MESSAGE_QUESTION;
case MESSAGE_BOX_TYPE_ERROR: case MessageBoxType::kError:
return GTK_MESSAGE_ERROR; return GTK_MESSAGE_ERROR;
default: default:
return GTK_MESSAGE_OTHER; return GTK_MESSAGE_OTHER;
@ -235,7 +235,7 @@ void ShowMessageBox(NativeWindow* parent,
void ShowErrorBox(const base::string16& title, const base::string16& content) { void ShowErrorBox(const base::string16& title, const base::string16& content) {
if (Browser::Get()->is_ready()) { if (Browser::Get()->is_ready()) {
GtkMessageBox(nullptr, MESSAGE_BOX_TYPE_ERROR, {"OK"}, -1, 0, "Error", GtkMessageBox(nullptr, MessageBoxType::kError, {"OK"}, -1, 0, "Error",
base::UTF16ToUTF8(title).c_str(), base::UTF16ToUTF8(title).c_str(),
base::UTF16ToUTF8(content).c_str(), "", false, base::UTF16ToUTF8(content).c_str(), "", false,
gfx::ImageSkia()) gfx::ImageSkia())

View file

@ -38,11 +38,11 @@ NSAlert* CreateNSAlert(NativeWindow* parent_window,
[alert setInformativeText:base::SysUTF8ToNSString(detail)]; [alert setInformativeText:base::SysUTF8ToNSString(detail)];
switch (type) { switch (type) {
case MESSAGE_BOX_TYPE_INFORMATION: case MessageBoxType::kInformation:
alert.alertStyle = NSInformationalAlertStyle; alert.alertStyle = NSInformationalAlertStyle;
break; break;
case MESSAGE_BOX_TYPE_WARNING: case MessageBoxType::kWarning:
case MESSAGE_BOX_TYPE_ERROR: case MessageBoxType::kError:
// NSWarningAlertStyle shows the app icon while NSCriticalAlertStyle // NSWarningAlertStyle shows the app icon while NSCriticalAlertStyle
// shows a warning icon with an app icon badge. Since there is no // shows a warning icon with an app icon badge. Since there is no
// error variant, lets just use NSCriticalAlertStyle. // error variant, lets just use NSCriticalAlertStyle.

View file

@ -119,17 +119,17 @@ int ShowTaskDialogUTF16(NativeWindow* parent,
} else { } else {
// Show icon according to dialog's type. // Show icon according to dialog's type.
switch (type) { switch (type) {
case MESSAGE_BOX_TYPE_INFORMATION: case MessageBoxType::kInformation:
case MESSAGE_BOX_TYPE_QUESTION: case MessageBoxType::kQuestion:
config.pszMainIcon = TD_INFORMATION_ICON; config.pszMainIcon = TD_INFORMATION_ICON;
break; break;
case MESSAGE_BOX_TYPE_WARNING: case MessageBoxType::kWarning:
config.pszMainIcon = TD_WARNING_ICON; config.pszMainIcon = TD_WARNING_ICON;
break; break;
case MESSAGE_BOX_TYPE_ERROR: case MessageBoxType::kError:
config.pszMainIcon = TD_ERROR_ICON; config.pszMainIcon = TD_ERROR_ICON;
break; break;
case MESSAGE_BOX_TYPE_NONE: case MessageBoxType::kNone:
break; break;
} }
} }
@ -279,7 +279,7 @@ void ShowMessageBox(NativeWindow* parent,
void ShowErrorBox(const base::string16& title, const base::string16& content) { void ShowErrorBox(const base::string16& title, const base::string16& content) {
atom::UnresponsiveSuppressor suppressor; atom::UnresponsiveSuppressor suppressor;
ShowTaskDialogUTF16(nullptr, MESSAGE_BOX_TYPE_ERROR, {}, -1, 0, 0, L"Error", ShowTaskDialogUTF16(nullptr, MessageBoxType::kError, {}, -1, 0, 0, L"Error",
title, content, L"", nullptr, gfx::ImageSkia()); title, content, L"", nullptr, gfx::ImageSkia());
} }

View file

@ -40,7 +40,7 @@ class TrayIcon {
virtual void SetToolTip(const std::string& tool_tip) = 0; virtual void SetToolTip(const std::string& tool_tip) = 0;
// Sets the status icon highlight mode. This only works on macOS. // Sets the status icon highlight mode. This only works on macOS.
enum HighlightMode { enum class HighlightMode {
ALWAYS, // Always highlight the tray icon ALWAYS, // Always highlight the tray icon
NEVER, // Never highlight the tray icon NEVER, // Never highlight the tray icon
SELECTION // Highlight the tray icon when clicked or the menu is opened SELECTION // Highlight the tray icon when clicked or the menu is opened

View file

@ -425,12 +425,13 @@ const CGFloat kVerticalTitleMargin = 2;
} }
- (BOOL)shouldHighlight { - (BOOL)shouldHighlight {
using HighlightMode = atom::TrayIcon::HighlightMode;
switch (highlight_mode_) { switch (highlight_mode_) {
case atom::TrayIcon::HighlightMode::ALWAYS: case HighlightMode::ALWAYS:
return true; return true;
case atom::TrayIcon::HighlightMode::NEVER: case HighlightMode::NEVER:
return false; return false;
case atom::TrayIcon::HighlightMode::SELECTION: case HighlightMode::SELECTION:
BOOL isMenuOpen = menuController_ && [menuController_ isMenuOpen]; BOOL isMenuOpen = menuController_ && [menuController_ isMenuOpen];
return forceHighlight_ || inMouseEventSequence_ || isMenuOpen; return forceHighlight_ || inMouseEventSequence_ || isMenuOpen;
} }

View file

@ -122,7 +122,7 @@ void PdfViewerHandler::Initialize(const base::ListValue* args) {
auto zoom_controller = auto zoom_controller =
WebContentsZoomController::FromWebContents(web_ui()->GetWebContents()); WebContentsZoomController::FromWebContents(web_ui()->GetWebContents());
zoom_controller->SetZoomMode(WebContentsZoomController::ZOOM_MODE_MANUAL); zoom_controller->SetZoomMode(WebContentsZoomController::ZoomMode::MANUAL);
zoom_controller->SetZoomLevel(0); zoom_controller->SetZoomLevel(0);
} }

View file

@ -139,18 +139,18 @@ bool TaskbarHost::SetProgressBar(HWND window,
return false; return false;
bool success; bool success;
if (value > 1.0 || state == NativeWindow::PROGRESS_INDETERMINATE) { if (value > 1.0 || state == NativeWindow::ProgressState::kIndeterminate) {
success = SUCCEEDED(taskbar_->SetProgressState(window, TBPF_INDETERMINATE)); success = SUCCEEDED(taskbar_->SetProgressState(window, TBPF_INDETERMINATE));
} else if (value < 0 || state == NativeWindow::PROGRESS_NONE) { } else if (value < 0 || state == NativeWindow::ProgressState::kNone) {
success = SUCCEEDED(taskbar_->SetProgressState(window, TBPF_NOPROGRESS)); success = SUCCEEDED(taskbar_->SetProgressState(window, TBPF_NOPROGRESS));
} else { } else {
// Unless SetProgressState set a blocking state (TBPF_ERROR, TBPF_PAUSED) // Unless SetProgressState set a blocking state (TBPF_ERROR, TBPF_PAUSED)
// for the window, a call to SetProgressValue assumes the TBPF_NORMAL // for the window, a call to SetProgressValue assumes the TBPF_NORMAL
// state even if it is not explicitly set. // state even if it is not explicitly set.
// SetProgressValue overrides and clears the TBPF_INDETERMINATE state. // SetProgressValue overrides and clears the TBPF_INDETERMINATE state.
if (state == NativeWindow::PROGRESS_ERROR) { if (state == NativeWindow::ProgressState::kError) {
success = SUCCEEDED(taskbar_->SetProgressState(window, TBPF_ERROR)); success = SUCCEEDED(taskbar_->SetProgressState(window, TBPF_ERROR));
} else if (state == NativeWindow::PROGRESS_PAUSED) { } else if (state == NativeWindow::ProgressState::kPaused) {
success = SUCCEEDED(taskbar_->SetProgressState(window, TBPF_PAUSED)); success = SUCCEEDED(taskbar_->SetProgressState(window, TBPF_PAUSED));
} else { } else {
success = SUCCEEDED(taskbar_->SetProgressState(window, TBPF_NORMAL)); success = SUCCEEDED(taskbar_->SetProgressState(window, TBPF_NORMAL));

View file

@ -44,14 +44,14 @@ void WebContentsZoomController::SetEmbedderZoomController(
void WebContentsZoomController::SetZoomLevel(double level) { void WebContentsZoomController::SetZoomLevel(double level) {
if (!web_contents()->GetRenderViewHost()->IsRenderViewLive() || if (!web_contents()->GetRenderViewHost()->IsRenderViewLive() ||
content::ZoomValuesEqual(GetZoomLevel(), level) || content::ZoomValuesEqual(GetZoomLevel(), level) ||
zoom_mode_ == ZOOM_MODE_DISABLED) zoom_mode_ == ZoomMode::DISABLED)
return; return;
int render_process_id = int render_process_id =
web_contents()->GetRenderViewHost()->GetProcess()->GetID(); web_contents()->GetRenderViewHost()->GetProcess()->GetID();
int render_view_id = web_contents()->GetRenderViewHost()->GetRoutingID(); int render_view_id = web_contents()->GetRenderViewHost()->GetRoutingID();
if (zoom_mode_ == ZOOM_MODE_MANUAL) { if (zoom_mode_ == ZoomMode::MANUAL) {
zoom_level_ = level; zoom_level_ = level;
for (Observer& observer : observers_) for (Observer& observer : observers_)
@ -62,7 +62,7 @@ void WebContentsZoomController::SetZoomLevel(double level) {
content::HostZoomMap* zoom_map = content::HostZoomMap* zoom_map =
content::HostZoomMap::GetForWebContents(web_contents()); content::HostZoomMap::GetForWebContents(web_contents());
if (zoom_mode_ == ZOOM_MODE_ISOLATED || if (zoom_mode_ == ZoomMode::ISOLATED ||
zoom_map->UsesTemporaryZoomLevel(render_process_id, render_view_id)) { zoom_map->UsesTemporaryZoomLevel(render_process_id, render_view_id)) {
zoom_map->SetTemporaryZoomLevel(render_process_id, render_view_id, level); zoom_map->SetTemporaryZoomLevel(render_process_id, render_view_id, level);
// Notify observers of zoom level changes. // Notify observers of zoom level changes.
@ -78,7 +78,7 @@ void WebContentsZoomController::SetZoomLevel(double level) {
} }
double WebContentsZoomController::GetZoomLevel() { double WebContentsZoomController::GetZoomLevel() {
return zoom_mode_ == ZOOM_MODE_MANUAL return zoom_mode_ == ZoomMode::MANUAL
? zoom_level_ ? zoom_level_
: content::HostZoomMap::GetZoomLevel(web_contents()); : content::HostZoomMap::GetZoomLevel(web_contents());
} }
@ -120,7 +120,7 @@ void WebContentsZoomController::SetZoomMode(ZoomMode new_mode) {
double original_zoom_level = GetZoomLevel(); double original_zoom_level = GetZoomLevel();
switch (new_mode) { switch (new_mode) {
case ZOOM_MODE_DEFAULT: { case ZoomMode::DEFAULT: {
content::NavigationEntry* entry = content::NavigationEntry* entry =
web_contents()->GetController().GetLastCommittedEntry(); web_contents()->GetController().GetLastCommittedEntry();
@ -148,11 +148,11 @@ void WebContentsZoomController::SetZoomMode(ZoomMode new_mode) {
zoom_map->ClearTemporaryZoomLevel(render_process_id, render_view_id); zoom_map->ClearTemporaryZoomLevel(render_process_id, render_view_id);
break; break;
} }
case ZOOM_MODE_ISOLATED: { case ZoomMode::ISOLATED: {
// Unless the zoom mode was |ZOOM_MODE_DISABLED| before this call, the // Unless the zoom mode was |ZoomMode::DISABLED| before this call, the
// page needs an initial isolated zoom back to the same level it was at // page needs an initial isolated zoom back to the same level it was at
// in the other mode. // in the other mode.
if (zoom_mode_ != ZOOM_MODE_DISABLED) { if (zoom_mode_ != ZoomMode::DISABLED) {
zoom_map->SetTemporaryZoomLevel(render_process_id, render_view_id, zoom_map->SetTemporaryZoomLevel(render_process_id, render_view_id,
original_zoom_level); original_zoom_level);
} else { } else {
@ -164,11 +164,11 @@ void WebContentsZoomController::SetZoomMode(ZoomMode new_mode) {
} }
break; break;
} }
case ZOOM_MODE_MANUAL: { case ZoomMode::MANUAL: {
// Unless the zoom mode was |ZOOM_MODE_DISABLED| before this call, the // Unless the zoom mode was |ZoomMode::DISABLED| before this call, the
// page needs to be resized to the default zoom. While in manual mode, // page needs to be resized to the default zoom. While in manual mode,
// the zoom level is handled independently. // the zoom level is handled independently.
if (zoom_mode_ != ZOOM_MODE_DISABLED) { if (zoom_mode_ != ZoomMode::DISABLED) {
zoom_map->SetTemporaryZoomLevel(render_process_id, render_view_id, zoom_map->SetTemporaryZoomLevel(render_process_id, render_view_id,
GetDefaultZoomLevel()); GetDefaultZoomLevel());
zoom_level_ = original_zoom_level; zoom_level_ = original_zoom_level;
@ -181,7 +181,7 @@ void WebContentsZoomController::SetZoomMode(ZoomMode new_mode) {
} }
break; break;
} }
case ZOOM_MODE_DISABLED: { case ZoomMode::DISABLED: {
// The page needs to be zoomed back to default before disabling the zoom // The page needs to be zoomed back to default before disabling the zoom
zoom_map->SetTemporaryZoomLevel(render_process_id, render_view_id, zoom_map->SetTemporaryZoomLevel(render_process_id, render_view_id,
GetDefaultZoomLevel()); GetDefaultZoomLevel());
@ -194,7 +194,7 @@ void WebContentsZoomController::SetZoomMode(ZoomMode new_mode) {
void WebContentsZoomController::ResetZoomModeOnNavigationIfNeeded( void WebContentsZoomController::ResetZoomModeOnNavigationIfNeeded(
const GURL& url) { const GURL& url) {
if (zoom_mode_ != ZOOM_MODE_ISOLATED && zoom_mode_ != ZOOM_MODE_MANUAL) if (zoom_mode_ != ZoomMode::ISOLATED && zoom_mode_ != ZoomMode::MANUAL)
return; return;
int render_process_id = int render_process_id =
@ -208,7 +208,7 @@ void WebContentsZoomController::ResetZoomModeOnNavigationIfNeeded(
for (Observer& observer : observers_) for (Observer& observer : observers_)
observer.OnZoomLevelChanged(web_contents(), new_zoom_level, false); observer.OnZoomLevelChanged(web_contents(), new_zoom_level, false);
zoom_map->ClearTemporaryZoomLevel(render_process_id, render_view_id); zoom_map->ClearTemporaryZoomLevel(render_process_id, render_view_id);
zoom_mode_ = ZOOM_MODE_DEFAULT; zoom_mode_ = ZoomMode::DEFAULT;
} }
void WebContentsZoomController::DidFinishNavigation( void WebContentsZoomController::DidFinishNavigation(

View file

@ -32,23 +32,23 @@ class WebContentsZoomController
}; };
// Defines how zoom changes are handled. // Defines how zoom changes are handled.
enum ZoomMode { enum class ZoomMode {
// Results in default zoom behavior, i.e. zoom changes are handled // Results in default zoom behavior, i.e. zoom changes are handled
// automatically and on a per-origin basis, meaning that other tabs // automatically and on a per-origin basis, meaning that other tabs
// navigated to the same origin will also zoom. // navigated to the same origin will also zoom.
ZOOM_MODE_DEFAULT, DEFAULT,
// Results in zoom changes being handled automatically, but on a per-tab // Results in zoom changes being handled automatically, but on a per-tab
// basis. Tabs in this zoom mode will not be affected by zoom changes in // basis. Tabs in this zoom mode will not be affected by zoom changes in
// other tabs, and vice versa. // other tabs, and vice versa.
ZOOM_MODE_ISOLATED, ISOLATED,
// Overrides the automatic handling of zoom changes. The |onZoomChange| // Overrides the automatic handling of zoom changes. The |onZoomChange|
// event will still be dispatched, but the page will not actually be zoomed. // event will still be dispatched, but the page will not actually be zoomed.
// These zoom changes can be handled manually by listening for the // These zoom changes can be handled manually by listening for the
// |onZoomChange| event. Zooming in this mode is also on a per-tab basis. // |onZoomChange| event. Zooming in this mode is also on a per-tab basis.
ZOOM_MODE_MANUAL, MANUAL,
// Disables all zooming in this tab. The tab will revert to the default // Disables all zooming in this tab. The tab will revert to the default
// zoom level, and all attempted zoom changes will be ignored. // zoom level, and all attempted zoom changes will be ignored.
ZOOM_MODE_DISABLED, DISABLED,
}; };
explicit WebContentsZoomController(content::WebContents* web_contents); explicit WebContentsZoomController(content::WebContents* web_contents);
@ -95,7 +95,7 @@ class WebContentsZoomController
void SetZoomFactorOnNavigationIfNeeded(const GURL& url); void SetZoomFactorOnNavigationIfNeeded(const GURL& url);
// The current zoom mode. // The current zoom mode.
ZoomMode zoom_mode_ = ZOOM_MODE_DEFAULT; ZoomMode zoom_mode_ = ZoomMode::DEFAULT;
// Current zoom level. // Current zoom level.
double zoom_level_ = 1.0; double zoom_level_ = 1.0;

View file

@ -158,7 +158,7 @@ base::FilePath GetResourcesPath(bool is_browser) {
NodeBindings::NodeBindings(BrowserEnvironment browser_env) NodeBindings::NodeBindings(BrowserEnvironment browser_env)
: browser_env_(browser_env), weak_factory_(this) { : browser_env_(browser_env), weak_factory_(this) {
if (browser_env == WORKER) { if (browser_env == BrowserEnvironment::WORKER) {
uv_loop_init(&worker_loop_); uv_loop_init(&worker_loop_);
uv_loop_ = &worker_loop_; uv_loop_ = &worker_loop_;
} else { } else {
@ -207,12 +207,12 @@ base::FilePath::StringType NodeBindings::GetHelperResourcesPath() {
void NodeBindings::Initialize() { void NodeBindings::Initialize() {
TRACE_EVENT0("electron", "NodeBindings::Initialize"); TRACE_EVENT0("electron", "NodeBindings::Initialize");
// Open node's error reporting system for browser process. // Open node's error reporting system for browser process.
node::g_standalone_mode = browser_env_ == BROWSER; node::g_standalone_mode = browser_env_ == BrowserEnvironment::BROWSER;
node::g_upstream_node_mode = false; node::g_upstream_node_mode = false;
#if defined(OS_LINUX) #if defined(OS_LINUX)
// Get real command line in renderer process forked by zygote. // Get real command line in renderer process forked by zygote.
if (browser_env_ != BROWSER) if (browser_env_ != BrowserEnvironment::BROWSER)
AtomCommandLine::InitializeFromCommandLine(); AtomCommandLine::InitializeFromCommandLine();
#endif #endif
@ -286,7 +286,8 @@ void NodeBindings::Initialize() {
#if defined(OS_WIN) #if defined(OS_WIN)
// uv_init overrides error mode to suppress the default crash dialog, bring // uv_init overrides error mode to suppress the default crash dialog, bring
// it back if user wants to show it. // it back if user wants to show it.
if (browser_env_ == BROWSER || env->HasVar("ELECTRON_DEFAULT_ERROR_MODE")) if (browser_env_ == BrowserEnvironment::BROWSER ||
env->HasVar("ELECTRON_DEFAULT_ERROR_MODE"))
SetErrorMode(GetErrorMode() & ~SEM_NOGPFAULTERRORBOX); SetErrorMode(GetErrorMode() & ~SEM_NOGPFAULTERRORBOX);
#endif #endif
@ -308,17 +309,18 @@ node::Environment* NodeBindings::CreateEnvironment(
// Feed node the path to initialization script. // Feed node the path to initialization script.
base::FilePath::StringType process_type; base::FilePath::StringType process_type;
switch (browser_env_) { switch (browser_env_) {
case BROWSER: case BrowserEnvironment::BROWSER:
process_type = FILE_PATH_LITERAL("browser"); process_type = FILE_PATH_LITERAL("browser");
break; break;
case RENDERER: case BrowserEnvironment::RENDERER:
process_type = FILE_PATH_LITERAL("renderer"); process_type = FILE_PATH_LITERAL("renderer");
break; break;
case WORKER: case BrowserEnvironment::WORKER:
process_type = FILE_PATH_LITERAL("worker"); process_type = FILE_PATH_LITERAL("worker");
break; break;
} }
base::FilePath resources_path = GetResourcesPath(browser_env_ == BROWSER); base::FilePath resources_path =
GetResourcesPath(browser_env_ == BrowserEnvironment::BROWSER);
base::FilePath script_path = base::FilePath script_path =
resources_path.Append(FILE_PATH_LITERAL("electron.asar")) resources_path.Append(FILE_PATH_LITERAL("electron.asar"))
.Append(process_type) .Append(process_type)
@ -330,7 +332,7 @@ node::Environment* NodeBindings::CreateEnvironment(
node::CreateIsolateData(context->GetIsolate(), uv_loop_, platform), node::CreateIsolateData(context->GetIsolate(), uv_loop_, platform),
context, args.size(), c_argv.get(), 0, nullptr); context, args.size(), c_argv.get(), 0, nullptr);
if (browser_env_ == BROWSER) { if (browser_env_ == BrowserEnvironment::BROWSER) {
// SetAutorunMicrotasks is no longer called in node::CreateEnvironment // SetAutorunMicrotasks is no longer called in node::CreateEnvironment
// so instead call it here to match expected node behavior // so instead call it here to match expected node behavior
context->GetIsolate()->SetMicrotasksPolicy(v8::MicrotasksPolicy::kExplicit); context->GetIsolate()->SetMicrotasksPolicy(v8::MicrotasksPolicy::kExplicit);
@ -344,7 +346,7 @@ node::Environment* NodeBindings::CreateEnvironment(
process.SetReadOnly("type", process_type); process.SetReadOnly("type", process_type);
process.Set("resourcesPath", resources_path); process.Set("resourcesPath", resources_path);
// Do not set DOM globals for renderer process. // Do not set DOM globals for renderer process.
if (browser_env_ != BROWSER) if (browser_env_ != BrowserEnvironment::BROWSER)
process.Set("_noBrowserGlobals", resources_path); process.Set("_noBrowserGlobals", resources_path);
// The path to helper app. // The path to helper app.
base::FilePath helper_exec_path; base::FilePath helper_exec_path;
@ -397,13 +399,13 @@ void NodeBindings::UvRunOnce() {
v8::MicrotasksScope script_scope(env->isolate(), v8::MicrotasksScope script_scope(env->isolate(),
v8::MicrotasksScope::kRunMicrotasks); v8::MicrotasksScope::kRunMicrotasks);
if (browser_env_ != BROWSER) if (browser_env_ != BrowserEnvironment::BROWSER)
TRACE_EVENT_BEGIN0("devtools.timeline", "FunctionCall"); TRACE_EVENT_BEGIN0("devtools.timeline", "FunctionCall");
// Deal with uv events. // Deal with uv events.
int r = uv_run(uv_loop_, UV_RUN_NOWAIT); int r = uv_run(uv_loop_, UV_RUN_NOWAIT);
if (browser_env_ != BROWSER) if (browser_env_ != BrowserEnvironment::BROWSER)
TRACE_EVENT_END0("devtools.timeline", "FunctionCall"); TRACE_EVENT_END0("devtools.timeline", "FunctionCall");
if (r == 0) if (r == 0)

View file

@ -25,7 +25,7 @@ namespace atom {
class NodeBindings { class NodeBindings {
public: public:
enum BrowserEnvironment { enum class BrowserEnvironment {
BROWSER, BROWSER,
RENDERER, RENDERER,
WORKER, WORKER,
@ -77,7 +77,7 @@ class NodeBindings {
void WakeupEmbedThread(); void WakeupEmbedThread();
// Which environment we are running. // Which environment we are running.
BrowserEnvironment browser_env_; const BrowserEnvironment browser_env_;
// Current thread's MessageLoop. // Current thread's MessageLoop.
scoped_refptr<base::SingleThreadTaskRunner> task_runner_; scoped_refptr<base::SingleThreadTaskRunner> task_runner_;

View file

@ -34,7 +34,8 @@ bool IsDevToolsExtension(content::RenderFrame* render_frame) {
} // namespace } // namespace
AtomRendererClient::AtomRendererClient() AtomRendererClient::AtomRendererClient()
: node_bindings_(NodeBindings::Create(NodeBindings::RENDERER)), : node_bindings_(
NodeBindings::Create(NodeBindings::BrowserEnvironment::RENDERER)),
electron_bindings_(new ElectronBindings(uv_default_loop())) {} electron_bindings_(new ElectronBindings(uv_default_loop())) {}
AtomRendererClient::~AtomRendererClient() { AtomRendererClient::~AtomRendererClient() {

View file

@ -29,7 +29,8 @@ WebWorkerObserver* WebWorkerObserver::GetCurrent() {
} }
WebWorkerObserver::WebWorkerObserver() WebWorkerObserver::WebWorkerObserver()
: node_bindings_(NodeBindings::Create(NodeBindings::WORKER)), : node_bindings_(
NodeBindings::Create(NodeBindings::BrowserEnvironment::WORKER)),
electron_bindings_(new ElectronBindings(node_bindings_->uv_loop())) { electron_bindings_(new ElectronBindings(node_bindings_->uv_loop())) {
lazy_tls.Pointer()->Set(this); lazy_tls.Pointer()->Set(this);
} }