refactor: convert C++ enums to C++11 enum classes (#18087)
This commit is contained in:
parent
a59dc56fa6
commit
c25c31e018
36 changed files with 199 additions and 204 deletions
|
@ -1291,9 +1291,9 @@ bool App::IsInApplicationsFolder() {
|
|||
int DockBounce(const std::string& type) {
|
||||
int request_id = -1;
|
||||
if (type == "critical")
|
||||
request_id = Browser::Get()->DockBounce(Browser::BOUNCE_CRITICAL);
|
||||
request_id = Browser::Get()->DockBounce(Browser::BounceType::CRITICAL);
|
||||
else if (type == "informational")
|
||||
request_id = Browser::Get()->DockBounce(Browser::BOUNCE_INFORMATIONAL);
|
||||
request_id = Browser::Get()->DockBounce(Browser::BounceType::INFORMATIONAL);
|
||||
return request_id;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,17 +30,6 @@ using content::BrowserThread;
|
|||
|
||||
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 <>
|
||||
struct Converter<net::CanonicalCookie> {
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
|
|
|
@ -31,11 +31,6 @@ namespace api {
|
|||
|
||||
class Cookies : public mate::TrackableObject<Cookies> {
|
||||
public:
|
||||
enum Error {
|
||||
SUCCESS,
|
||||
FAILED,
|
||||
};
|
||||
|
||||
static gin::Handle<Cookies> Create(v8::Isolate* isolate,
|
||||
AtomBrowserContext* browser_context);
|
||||
|
||||
|
|
|
@ -164,9 +164,9 @@ Protocol::ProtocolError Protocol::UnregisterProtocolInIO(
|
|||
const std::string& scheme) {
|
||||
auto* job_factory = request_context_getter->job_factory();
|
||||
if (!job_factory->HasProtocolHandler(scheme))
|
||||
return PROTOCOL_NOT_REGISTERED;
|
||||
return ProtocolError::NOT_REGISTERED;
|
||||
job_factory->SetProtocolHandler(scheme, nullptr);
|
||||
return PROTOCOL_OK;
|
||||
return ProtocolError::OK;
|
||||
}
|
||||
|
||||
bool IsProtocolHandledInIO(
|
||||
|
@ -209,8 +209,8 @@ Protocol::ProtocolError Protocol::UninterceptProtocolInIO(
|
|||
scoped_refptr<URLRequestContextGetter> request_context_getter,
|
||||
const std::string& scheme) {
|
||||
return request_context_getter->job_factory()->UninterceptProtocol(scheme)
|
||||
? PROTOCOL_OK
|
||||
: PROTOCOL_NOT_INTERCEPTED;
|
||||
? ProtocolError::OK
|
||||
: ProtocolError::NOT_INTERCEPTED;
|
||||
}
|
||||
|
||||
void Protocol::OnIOCompleted(const CompletionCallback& callback,
|
||||
|
@ -222,7 +222,7 @@ void Protocol::OnIOCompleted(const CompletionCallback& callback,
|
|||
v8::Locker locker(isolate());
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
|
||||
if (error == PROTOCOL_OK) {
|
||||
if (error == ProtocolError::OK) {
|
||||
callback.Run(v8::Null(isolate()));
|
||||
} else {
|
||||
std::string str = ErrorCodeToString(error);
|
||||
|
@ -232,15 +232,15 @@ void Protocol::OnIOCompleted(const CompletionCallback& callback,
|
|||
|
||||
std::string Protocol::ErrorCodeToString(ProtocolError error) {
|
||||
switch (error) {
|
||||
case PROTOCOL_FAIL:
|
||||
case ProtocolError::FAIL:
|
||||
return "Failed to manipulate protocol factory";
|
||||
case PROTOCOL_REGISTERED:
|
||||
case ProtocolError::REGISTERED:
|
||||
return "The scheme has been registered";
|
||||
case PROTOCOL_NOT_REGISTERED:
|
||||
case ProtocolError::NOT_REGISTERED:
|
||||
return "The scheme has not been registered";
|
||||
case PROTOCOL_INTERCEPTED:
|
||||
case ProtocolError::INTERCEPTED:
|
||||
return "The scheme has been intercepted";
|
||||
case PROTOCOL_NOT_INTERCEPTED:
|
||||
case ProtocolError::NOT_INTERCEPTED:
|
||||
return "The scheme has not been intercepted";
|
||||
default:
|
||||
return "Unexpected error";
|
||||
|
|
|
@ -56,13 +56,13 @@ class Protocol : public mate::TrackableObject<Protocol> {
|
|||
|
||||
private:
|
||||
// Possible errors.
|
||||
enum ProtocolError {
|
||||
PROTOCOL_OK, // no error
|
||||
PROTOCOL_FAIL, // operation failed, should never occur
|
||||
PROTOCOL_REGISTERED,
|
||||
PROTOCOL_NOT_REGISTERED,
|
||||
PROTOCOL_INTERCEPTED,
|
||||
PROTOCOL_NOT_INTERCEPTED,
|
||||
enum class ProtocolError {
|
||||
OK, // no error
|
||||
FAIL, // operation failed, should never occur
|
||||
REGISTERED,
|
||||
NOT_REGISTERED,
|
||||
INTERCEPTED,
|
||||
NOT_INTERCEPTED,
|
||||
};
|
||||
|
||||
// The protocol handler that will create a protocol handler for certain
|
||||
|
@ -118,13 +118,13 @@ class Protocol : public mate::TrackableObject<Protocol> {
|
|||
const Handler& handler) {
|
||||
auto* job_factory = request_context_getter->job_factory();
|
||||
if (job_factory->IsHandledProtocol(scheme))
|
||||
return PROTOCOL_REGISTERED;
|
||||
return ProtocolError::REGISTERED;
|
||||
auto protocol_handler = std::make_unique<CustomProtocolHandler<RequestJob>>(
|
||||
isolate, request_context_getter.get(), handler);
|
||||
if (job_factory->SetProtocolHandler(scheme, std::move(protocol_handler)))
|
||||
return PROTOCOL_OK;
|
||||
return ProtocolError::OK;
|
||||
else
|
||||
return PROTOCOL_FAIL;
|
||||
return ProtocolError::FAIL;
|
||||
}
|
||||
|
||||
// Unregister the protocol handler that handles |scheme|.
|
||||
|
@ -159,15 +159,15 @@ class Protocol : public mate::TrackableObject<Protocol> {
|
|||
const Handler& handler) {
|
||||
auto* job_factory = request_context_getter->job_factory();
|
||||
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.
|
||||
if (!job_factory->HasProtocolHandler(scheme))
|
||||
return PROTOCOL_FAIL;
|
||||
return ProtocolError::FAIL;
|
||||
auto protocol_handler = std::make_unique<CustomProtocolHandler<RequestJob>>(
|
||||
isolate, request_context_getter.get(), handler);
|
||||
if (!job_factory->InterceptProtocol(scheme, std::move(protocol_handler)))
|
||||
return PROTOCOL_INTERCEPTED;
|
||||
return PROTOCOL_OK;
|
||||
return ProtocolError::INTERCEPTED;
|
||||
return ProtocolError::OK;
|
||||
}
|
||||
|
||||
// Restore the |scheme| to its original protocol handler.
|
||||
|
|
|
@ -20,13 +20,13 @@ namespace {
|
|||
// Convert error code to string.
|
||||
std::string ErrorCodeToString(ProtocolError error) {
|
||||
switch (error) {
|
||||
case PROTOCOL_REGISTERED:
|
||||
case ProtocolError::REGISTERED:
|
||||
return "The scheme has been registered";
|
||||
case PROTOCOL_NOT_REGISTERED:
|
||||
case ProtocolError::NOT_REGISTERED:
|
||||
return "The scheme has not been registered";
|
||||
case PROTOCOL_INTERCEPTED:
|
||||
case ProtocolError::INTERCEPTED:
|
||||
return "The scheme has been intercepted";
|
||||
case PROTOCOL_NOT_INTERCEPTED:
|
||||
case ProtocolError::NOT_INTERCEPTED:
|
||||
return "The scheme has not been intercepted";
|
||||
default:
|
||||
return "Unexpected error";
|
||||
|
@ -56,21 +56,21 @@ void ProtocolNS::RegisterURLLoaderFactories(
|
|||
ProtocolError ProtocolNS::RegisterProtocol(ProtocolType type,
|
||||
const std::string& scheme,
|
||||
const ProtocolHandler& handler) {
|
||||
ProtocolError error = PROTOCOL_OK;
|
||||
ProtocolError error = ProtocolError::OK;
|
||||
if (!base::ContainsKey(handlers_, scheme))
|
||||
handlers_[scheme] = std::make_pair(type, handler);
|
||||
else
|
||||
error = PROTOCOL_REGISTERED;
|
||||
error = ProtocolError::REGISTERED;
|
||||
return error;
|
||||
}
|
||||
|
||||
void ProtocolNS::UnregisterProtocol(const std::string& scheme,
|
||||
mate::Arguments* args) {
|
||||
ProtocolError error = PROTOCOL_OK;
|
||||
ProtocolError error = ProtocolError::OK;
|
||||
if (base::ContainsKey(handlers_, scheme))
|
||||
handlers_.erase(scheme);
|
||||
else
|
||||
error = PROTOCOL_NOT_REGISTERED;
|
||||
error = ProtocolError::NOT_REGISTERED;
|
||||
HandleOptionalCallback(args, error);
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ void ProtocolNS::HandleOptionalCallback(mate::Arguments* args,
|
|||
ProtocolError error) {
|
||||
CompletionCallback callback;
|
||||
if (args->GetNext(&callback)) {
|
||||
if (error == PROTOCOL_OK)
|
||||
if (error == ProtocolError::OK)
|
||||
callback.Run(v8::Null(args->isolate()));
|
||||
else
|
||||
callback.Run(v8::Exception::Error(
|
||||
|
|
|
@ -22,12 +22,12 @@ class AtomBrowserContext;
|
|||
namespace api {
|
||||
|
||||
// Possible errors.
|
||||
enum ProtocolError {
|
||||
PROTOCOL_OK, // no error
|
||||
PROTOCOL_REGISTERED,
|
||||
PROTOCOL_NOT_REGISTERED,
|
||||
PROTOCOL_INTERCEPTED,
|
||||
PROTOCOL_NOT_INTERCEPTED,
|
||||
enum class ProtocolError {
|
||||
OK, // no error
|
||||
REGISTERED,
|
||||
NOT_REGISTERED,
|
||||
INTERCEPTED,
|
||||
NOT_INTERCEPTED,
|
||||
};
|
||||
|
||||
// Protocol implementation based on network services.
|
||||
|
|
|
@ -737,15 +737,15 @@ void TopLevelWindow::SetProgressBar(double progress, mate::Arguments* args) {
|
|||
std::string mode;
|
||||
args->GetNext(&options) && options.Get("mode", &mode);
|
||||
|
||||
NativeWindow::ProgressState state = NativeWindow::PROGRESS_NORMAL;
|
||||
NativeWindow::ProgressState state = NativeWindow::ProgressState::kNormal;
|
||||
if (mode == "error")
|
||||
state = NativeWindow::PROGRESS_ERROR;
|
||||
state = NativeWindow::ProgressState::kError;
|
||||
else if (mode == "paused")
|
||||
state = NativeWindow::PROGRESS_PAUSED;
|
||||
state = NativeWindow::ProgressState::kPaused;
|
||||
else if (mode == "indeterminate")
|
||||
state = NativeWindow::PROGRESS_INDETERMINATE;
|
||||
state = NativeWindow::ProgressState::kIndeterminate;
|
||||
else if (mode == "none")
|
||||
state = NativeWindow::PROGRESS_NONE;
|
||||
state = NativeWindow::ProgressState::kNone;
|
||||
|
||||
window_->SetProgressBar(progress, state);
|
||||
}
|
||||
|
|
|
@ -25,18 +25,19 @@ struct Converter<atom::TrayIcon::HighlightMode> {
|
|||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
atom::TrayIcon::HighlightMode* out) {
|
||||
using HighlightMode = atom::TrayIcon::HighlightMode;
|
||||
std::string mode;
|
||||
if (ConvertFromV8(isolate, val, &mode)) {
|
||||
if (mode == "always") {
|
||||
*out = atom::TrayIcon::HighlightMode::ALWAYS;
|
||||
*out = HighlightMode::ALWAYS;
|
||||
return true;
|
||||
}
|
||||
if (mode == "selection") {
|
||||
*out = atom::TrayIcon::HighlightMode::SELECTION;
|
||||
*out = HighlightMode::SELECTION;
|
||||
return true;
|
||||
}
|
||||
if (mode == "never") {
|
||||
*out = atom::TrayIcon::HighlightMode::NEVER;
|
||||
*out = HighlightMode::NEVER;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -268,7 +268,7 @@ struct WebContents::FrameDispatchHelper {
|
|||
|
||||
WebContents::WebContents(v8::Isolate* isolate,
|
||||
content::WebContents* web_contents)
|
||||
: content::WebContentsObserver(web_contents), type_(REMOTE) {
|
||||
: content::WebContentsObserver(web_contents), type_(Type::REMOTE) {
|
||||
web_contents->SetUserAgentOverride(GetBrowserContext()->GetUserAgent(),
|
||||
false);
|
||||
Init(isolate);
|
||||
|
@ -284,7 +284,8 @@ WebContents::WebContents(v8::Isolate* isolate,
|
|||
std::unique_ptr<content::WebContents> web_contents,
|
||||
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());
|
||||
session_.Reset(isolate, session.ToV8());
|
||||
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.
|
||||
bool b = false;
|
||||
if (options.Get("isGuest", &b) && b)
|
||||
type_ = WEB_VIEW;
|
||||
type_ = Type::WEB_VIEW;
|
||||
else if (options.Get("isBackgroundPage", &b) && b)
|
||||
type_ = BACKGROUND_PAGE;
|
||||
type_ = Type::BACKGROUND_PAGE;
|
||||
else if (options.Get("isBrowserView", &b) && b)
|
||||
type_ = BROWSER_VIEW;
|
||||
type_ = Type::BROWSER_VIEW;
|
||||
#if BUILDFLAG(ENABLE_OSR)
|
||||
else if (options.Get(options::kOffscreen, &b) && b)
|
||||
type_ = OFF_SCREEN;
|
||||
type_ = Type::OFF_SCREEN;
|
||||
#endif
|
||||
|
||||
// Init embedder earlier
|
||||
|
@ -457,12 +458,12 @@ WebContents::~WebContents() {
|
|||
|
||||
RenderViewDeleted(web_contents()->GetRenderViewHost());
|
||||
|
||||
if (type_ == WEB_VIEW) {
|
||||
if (type_ == Type::WEB_VIEW) {
|
||||
DCHECK(!web_contents()->GetOuterWebContents())
|
||||
<< "Should never manually destroy an attached webview";
|
||||
// For webview simply destroy the WebContents immediately.
|
||||
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
|
||||
// before WebContents is destroyed.
|
||||
for (ExtendedWebContentsObserver& observer : observers_)
|
||||
|
@ -509,7 +510,7 @@ void WebContents::OnCreateWindow(
|
|||
WindowOpenDisposition disposition,
|
||||
const std::vector<std::string>& features,
|
||||
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,
|
||||
referrer);
|
||||
else
|
||||
|
@ -541,7 +542,7 @@ void WebContents::AddNewContents(
|
|||
v8::Locker locker(isolate());
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
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,
|
||||
initial_rect.x(), initial_rect.y(), initial_rect.width(),
|
||||
initial_rect.height(), tracker->url, tracker->frame_name)) {
|
||||
|
@ -554,7 +555,7 @@ content::WebContents* WebContents::OpenURLFromTab(
|
|||
content::WebContents* source,
|
||||
const content::OpenURLParams& params) {
|
||||
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);
|
||||
else
|
||||
Emit("new-window", params.url, "", params.disposition);
|
||||
|
@ -576,7 +577,7 @@ content::WebContents* WebContents::OpenURLFromTab(
|
|||
void WebContents::BeforeUnloadFired(content::WebContents* tab,
|
||||
bool proceed,
|
||||
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;
|
||||
else
|
||||
*proceed_to_fire_unload = true;
|
||||
|
@ -610,7 +611,7 @@ void WebContents::UpdateTargetURL(content::WebContents* source,
|
|||
bool WebContents::HandleKeyboardEvent(
|
||||
content::WebContents* source,
|
||||
const content::NativeWebKeyboardEvent& event) {
|
||||
if (type_ == WEB_VIEW && embedder_) {
|
||||
if (type_ == Type::WEB_VIEW && embedder_) {
|
||||
// Send the unhandled keyboard events back to the embedder.
|
||||
return embedder_->HandleKeyboardEvent(source, event);
|
||||
} else {
|
||||
|
@ -1390,14 +1391,14 @@ v8::Local<v8::Promise> WebContents::SavePage(
|
|||
}
|
||||
|
||||
void WebContents::OpenDevTools(mate::Arguments* args) {
|
||||
if (type_ == REMOTE)
|
||||
if (type_ == Type::REMOTE)
|
||||
return;
|
||||
|
||||
if (!enable_devtools_)
|
||||
return;
|
||||
|
||||
std::string state;
|
||||
if (type_ == WEB_VIEW || !owner_window()) {
|
||||
if (type_ == Type::WEB_VIEW || !owner_window()) {
|
||||
state = "detach";
|
||||
}
|
||||
bool activate = true;
|
||||
|
@ -1413,21 +1414,21 @@ void WebContents::OpenDevTools(mate::Arguments* args) {
|
|||
}
|
||||
|
||||
void WebContents::CloseDevTools() {
|
||||
if (type_ == REMOTE)
|
||||
if (type_ == Type::REMOTE)
|
||||
return;
|
||||
|
||||
managed_web_contents()->CloseDevTools();
|
||||
}
|
||||
|
||||
bool WebContents::IsDevToolsOpened() {
|
||||
if (type_ == REMOTE)
|
||||
if (type_ == Type::REMOTE)
|
||||
return false;
|
||||
|
||||
return managed_web_contents()->IsDevToolsViewShowing();
|
||||
}
|
||||
|
||||
bool WebContents::IsDevToolsFocused() {
|
||||
if (type_ == REMOTE)
|
||||
if (type_ == Type::REMOTE)
|
||||
return false;
|
||||
|
||||
return managed_web_contents()->GetView()->IsDevToolsViewFocused();
|
||||
|
@ -1435,7 +1436,7 @@ bool WebContents::IsDevToolsFocused() {
|
|||
|
||||
void WebContents::EnableDeviceEmulation(
|
||||
const blink::WebDeviceEmulationParams& params) {
|
||||
if (type_ == REMOTE)
|
||||
if (type_ == Type::REMOTE)
|
||||
return;
|
||||
|
||||
auto* frame_host = web_contents()->GetMainFrame();
|
||||
|
@ -1450,7 +1451,7 @@ void WebContents::EnableDeviceEmulation(
|
|||
}
|
||||
|
||||
void WebContents::DisableDeviceEmulation() {
|
||||
if (type_ == REMOTE)
|
||||
if (type_ == Type::REMOTE)
|
||||
return;
|
||||
|
||||
auto* frame_host = web_contents()->GetMainFrame();
|
||||
|
@ -1472,7 +1473,7 @@ void WebContents::ToggleDevTools() {
|
|||
}
|
||||
|
||||
void WebContents::InspectElement(int x, int y) {
|
||||
if (type_ == REMOTE)
|
||||
if (type_ == Type::REMOTE)
|
||||
return;
|
||||
|
||||
if (!enable_devtools_)
|
||||
|
@ -1484,7 +1485,7 @@ void WebContents::InspectElement(int x, int y) {
|
|||
}
|
||||
|
||||
void WebContents::InspectSharedWorker() {
|
||||
if (type_ == REMOTE)
|
||||
if (type_ == Type::REMOTE)
|
||||
return;
|
||||
|
||||
if (!enable_devtools_)
|
||||
|
@ -1501,7 +1502,7 @@ void WebContents::InspectSharedWorker() {
|
|||
}
|
||||
|
||||
void WebContents::InspectServiceWorker() {
|
||||
if (type_ == REMOTE)
|
||||
if (type_ == Type::REMOTE)
|
||||
return;
|
||||
|
||||
if (!enable_devtools_)
|
||||
|
@ -1701,7 +1702,7 @@ bool WebContents::IsFocused() const {
|
|||
if (!view)
|
||||
return false;
|
||||
|
||||
if (GetType() != BACKGROUND_PAGE) {
|
||||
if (GetType() != Type::BACKGROUND_PAGE) {
|
||||
auto* window = web_contents()->GetNativeView()->GetToplevelWindow();
|
||||
if (window && !window->IsVisible())
|
||||
return false;
|
||||
|
@ -1933,7 +1934,7 @@ void WebContents::OnCursorChange(const content::WebCursor& cursor) {
|
|||
}
|
||||
|
||||
bool WebContents::IsGuest() const {
|
||||
return type_ == WEB_VIEW;
|
||||
return type_ == Type::WEB_VIEW;
|
||||
}
|
||||
|
||||
void WebContents::AttachToIframe(content::WebContents* embedder_web_contents,
|
||||
|
@ -1944,7 +1945,7 @@ void WebContents::AttachToIframe(content::WebContents* embedder_web_contents,
|
|||
|
||||
bool WebContents::IsOffScreen() const {
|
||||
#if BUILDFLAG(ENABLE_OSR)
|
||||
return type_ == OFF_SCREEN;
|
||||
return type_ == Type::OFF_SCREEN;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
|
|
|
@ -80,7 +80,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
|||
public content::WebContentsObserver,
|
||||
public mojom::ElectronBrowser {
|
||||
public:
|
||||
enum Type {
|
||||
enum class Type {
|
||||
BACKGROUND_PAGE, // A DevTools extension background page.
|
||||
BROWSER_WINDOW, // Used by BrowserWindow.
|
||||
BROWSER_VIEW, // Used by BrowserView.
|
||||
|
@ -534,7 +534,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
|||
WebContentsZoomController* zoom_controller_ = nullptr;
|
||||
|
||||
// The type of current WebContents.
|
||||
Type type_ = BROWSER_WINDOW;
|
||||
Type type_ = Type::BROWSER_WINDOW;
|
||||
|
||||
// Request id used for findInPage request.
|
||||
uint32_t request_id_ = 0;
|
||||
|
|
|
@ -16,7 +16,7 @@ bool WebContents::IsFocused() const {
|
|||
if (!view)
|
||||
return false;
|
||||
|
||||
if (GetType() != BACKGROUND_PAGE) {
|
||||
if (GetType() != Type::BACKGROUND_PAGE) {
|
||||
auto window = [web_contents()->GetNativeView().GetNativeNSView() 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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue