mirror of
https://github.com/electron/electron.git
synced 2026-02-19 03:14:51 -05:00
Compare commits
143 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6d20d37101 | ||
|
|
df12f181a4 | ||
|
|
be5f1b09f4 | ||
|
|
c71efc8ca5 | ||
|
|
8278ee533d | ||
|
|
1896deb10e | ||
|
|
095b2e6047 | ||
|
|
e682dc7544 | ||
|
|
8127bbc992 | ||
|
|
9fd46ac4db | ||
|
|
1e13159157 | ||
|
|
215ca78c7f | ||
|
|
0404cc850b | ||
|
|
fb5260eb30 | ||
|
|
28b3678159 | ||
|
|
965471d9f8 | ||
|
|
d7c67d795b | ||
|
|
841407a619 | ||
|
|
1759a71814 | ||
|
|
d61bec0fb8 | ||
|
|
442db4c5ba | ||
|
|
922fce1892 | ||
|
|
38b27bbd66 | ||
|
|
6bc59cf2d7 | ||
|
|
957de56343 | ||
|
|
1a2b5834ed | ||
|
|
59b43a6571 | ||
|
|
1a55cd3efe | ||
|
|
c8122392de | ||
|
|
8b7d2b5ce3 | ||
|
|
d9c6cf7b75 | ||
|
|
e1318ffb34 | ||
|
|
7756bb6762 | ||
|
|
d9cf9a7cbc | ||
|
|
87faae1b13 | ||
|
|
051548aa69 | ||
|
|
9dd714f056 | ||
|
|
fe4d86925b | ||
|
|
617892400f | ||
|
|
73ab6d409b | ||
|
|
55715bec23 | ||
|
|
115526424a | ||
|
|
aebc1d0650 | ||
|
|
c7dc901607 | ||
|
|
b1ae60a639 | ||
|
|
7e7b6df72b | ||
|
|
05f0b5a8a4 | ||
|
|
2978beaeb7 | ||
|
|
6f61832a34 | ||
|
|
63c1fdd22a | ||
|
|
3966441d21 | ||
|
|
579f253340 | ||
|
|
821005e6b4 | ||
|
|
871571c65e | ||
|
|
326af3cbe3 | ||
|
|
4c3fd38774 | ||
|
|
74be1d5b25 | ||
|
|
cab466f999 | ||
|
|
4cb3e2ecb5 | ||
|
|
cb22b88e6a | ||
|
|
5bdc077b48 | ||
|
|
927c3f34c3 | ||
|
|
c916baa939 | ||
|
|
3a97439fe9 | ||
|
|
c6d5a92d34 | ||
|
|
2d802d6f1e | ||
|
|
fa59ea3bc5 | ||
|
|
804cf5e8ba | ||
|
|
fc0153f0bc | ||
|
|
c823e31904 | ||
|
|
2ef66cb660 | ||
|
|
f607e81fac | ||
|
|
e06778178a | ||
|
|
f6327de7f7 | ||
|
|
8e40947938 | ||
|
|
898db4d6bd | ||
|
|
6fea6cf58a | ||
|
|
428c5b6d01 | ||
|
|
3f37439da3 | ||
|
|
db46c1b925 | ||
|
|
c3cd438d34 | ||
|
|
ccf4ed907a | ||
|
|
b70e7c6a4c | ||
|
|
4d302956d3 | ||
|
|
c8723238f8 | ||
|
|
60fb406c61 | ||
|
|
bb49515145 | ||
|
|
87e0c812e9 | ||
|
|
ea3e84e7ff | ||
|
|
239b97cde1 | ||
|
|
c22ffd863b | ||
|
|
857acd2574 | ||
|
|
3b1ee994e2 | ||
|
|
e675407552 | ||
|
|
d19ead1907 | ||
|
|
a9b0111c3e | ||
|
|
279407f7a3 | ||
|
|
a76ea00249 | ||
|
|
8577f2b52f | ||
|
|
526cee7ec3 | ||
|
|
2d676770b1 | ||
|
|
7de3aa3cc1 | ||
|
|
2b9b4c6789 | ||
|
|
de24ed7cea | ||
|
|
ec0a8a1321 | ||
|
|
ad8e727ba2 | ||
|
|
46c69cc3e5 | ||
|
|
69140af083 | ||
|
|
c34c123b33 | ||
|
|
4d02fc58fa | ||
|
|
ca6f688013 | ||
|
|
3d4318e15e | ||
|
|
367a61d234 | ||
|
|
d4bfeff6ad | ||
|
|
a2a4970f5f | ||
|
|
0e131f760b | ||
|
|
bdd2f91913 | ||
|
|
eb7ed5b456 | ||
|
|
74b76102a8 | ||
|
|
add9c38023 | ||
|
|
791f988aba | ||
|
|
5d7cfa1b3a | ||
|
|
9e880f8d8f | ||
|
|
aea1f8aebb | ||
|
|
b4ec7c5aaf | ||
|
|
bb938b02d8 | ||
|
|
9a2e2b365d | ||
|
|
01d2765e4b | ||
|
|
12f46ab533 | ||
|
|
9fe326ebeb | ||
|
|
021ee20400 | ||
|
|
b78bb84424 | ||
|
|
77fa02e93e | ||
|
|
3ca4678705 | ||
|
|
55acdcb1ad | ||
|
|
3503b62ff2 | ||
|
|
0f9f8e62fc | ||
|
|
651009a1dc | ||
|
|
64640afc20 | ||
|
|
8c31c7fb59 | ||
|
|
24518d13d5 | ||
|
|
0ecf077590 | ||
|
|
2365ffe143 |
@@ -10,6 +10,7 @@ os:
|
||||
- osx
|
||||
env:
|
||||
- TARGET_ARCH=x64
|
||||
osx_image: xcode7
|
||||
|
||||
matrix:
|
||||
include:
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
:zap: *프레임워크 이름이 Atom Shell에서 Electron으로 변경되었습니다* :zap:
|
||||
|
||||
Electron 프레임워크는 JavaScript, HTML 그리고 CSS를 사용하여 Cross-Platform 데스크톱 어플리케이션을 개발할 수 있도록 해주는 프레임워크입니다. 이 프레임워크는 [io.js](http://iojs.org) 와
|
||||
Electron 프레임워크는 JavaScript, HTML 그리고 CSS를 사용하여 Cross-Platform 데스크톱 어플리케이션을 개발할 수 있도록 해주는 프레임워크입니다. 이 프레임워크는 [Node.js](https://nodejs.org) 와
|
||||
[Chromium](http://www.chromium.org)을 기반으로 만들어 졌으며 [Atom Editor](https://github.com/atom/atom)에 사용되고 있습니다.
|
||||
|
||||
Electron에 대한 중요한 알림을 받고 싶다면 Twitter에서 [@ElectronJS](https://twitter.com/electronjs)를 팔로우 하세요.
|
||||
|
||||
10
README.md
10
README.md
@@ -7,7 +7,7 @@
|
||||
:zap: *Formerly known as Atom Shell* :zap:
|
||||
|
||||
The Electron framework lets you write cross-platform desktop applications
|
||||
using JavaScript, HTML and CSS. It is based on [io.js](http://iojs.org) and
|
||||
using JavaScript, HTML and CSS. It is based on [Node.js](https://nodejs.org) and
|
||||
[Chromium](http://www.chromium.org) and is used in the [Atom
|
||||
editor](https://github.com/atom/atom).
|
||||
|
||||
@@ -15,7 +15,7 @@ Follow [@ElectronJS](https://twitter.com/electronjs) on Twitter for important
|
||||
announcements.
|
||||
|
||||
This project adheres to the [Contributor Covenant 1.2](http://contributor-covenant.org/version/1/2/0).
|
||||
By participating, you are expected to uphold this code. Please report
|
||||
By participating, you are expected to uphold this code. Please report
|
||||
unacceptable behavior to atom@github.com.
|
||||
|
||||
## Downloads
|
||||
@@ -55,12 +55,12 @@ contains documents describing how to build and contribute to Electron.
|
||||
|
||||
## Community
|
||||
|
||||
You can ask questions and interact with the community in the following
|
||||
You can ask questions and interact with the community in the following
|
||||
locations:
|
||||
- [`electron`](http://discuss.atom.io/category/electron) category on the Atom
|
||||
- [`electron`](http://discuss.atom.io/category/electron) category on the Atom
|
||||
forums
|
||||
- `#atom-shell` channel on Freenode
|
||||
- [`Atom`](http://atom-slack.herokuapp.com/) channel on Slack
|
||||
|
||||
Check out [awesome-electron](https://github.com/sindresorhus/awesome-electron)
|
||||
Check out [awesome-electron](https://github.com/sindresorhus/awesome-electron)
|
||||
for a community maintained list of useful example apps, tools and resources.
|
||||
|
||||
2
atom.gyp
2
atom.gyp
@@ -4,7 +4,7 @@
|
||||
'product_name%': 'Electron',
|
||||
'company_name%': 'GitHub, Inc',
|
||||
'company_abbr%': 'github',
|
||||
'version%': '0.33.4',
|
||||
'version%': '0.33.7',
|
||||
},
|
||||
'includes': [
|
||||
'filenames.gypi',
|
||||
|
||||
@@ -99,7 +99,7 @@ void AtomContentClient::AddAdditionalSchemes(
|
||||
void AtomContentClient::AddPepperPlugins(
|
||||
std::vector<content::PepperPluginInfo>* plugins) {
|
||||
auto command_line = base::CommandLine::ForCurrentProcess();
|
||||
auto flash_path = command_line->GetSwitchValueNative(
|
||||
auto flash_path = command_line->GetSwitchValuePath(
|
||||
switches::kPpapiFlashPath);
|
||||
if (flash_path.empty())
|
||||
return;
|
||||
@@ -108,7 +108,7 @@ void AtomContentClient::AddPepperPlugins(
|
||||
switches::kPpapiFlashVersion);
|
||||
|
||||
plugins->push_back(
|
||||
CreatePepperFlashInfo(base::FilePath(flash_path), flash_version));
|
||||
CreatePepperFlashInfo(flash_path, flash_version));
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "atom/app/atom_main_delegate.h"
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
#include "atom/app/atom_content_client.h"
|
||||
#include "atom/browser/atom_browser_client.h"
|
||||
@@ -27,10 +28,13 @@ AtomMainDelegate::~AtomMainDelegate() {
|
||||
}
|
||||
|
||||
bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
|
||||
// Disable logging out to debug.log on Windows
|
||||
logging::LoggingSettings settings;
|
||||
#if defined(OS_WIN)
|
||||
// On Windows the terminal returns immediately, so we add a new line to
|
||||
// prevent output in the same line as the prompt.
|
||||
std::wcout << std::endl;
|
||||
#if defined(DEBUG)
|
||||
// Print logging to debug.log on Windows
|
||||
settings.logging_dest = logging::LOG_TO_ALL;
|
||||
settings.log_file = L"debug.log";
|
||||
settings.lock_log = logging::LOCK_LOG_FILE;
|
||||
@@ -41,6 +45,12 @@ bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
|
||||
#else // defined(OS_WIN)
|
||||
settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
|
||||
#endif // !defined(OS_WIN)
|
||||
|
||||
// Only enable logging when --enable-logging is specified.
|
||||
auto command_line = base::CommandLine::ForCurrentProcess();
|
||||
if (!command_line->HasSwitch(switches::kEnableLogging))
|
||||
settings.logging_dest = logging::LOG_NONE;
|
||||
|
||||
logging::InitLogging(settings);
|
||||
|
||||
// Logging with pid and timestamp.
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "atom/common/native_mate_converters/callback.h"
|
||||
#include "atom/common/native_mate_converters/file_path_converter.h"
|
||||
#include "atom/common/node_includes.h"
|
||||
#include "atom/common/options_switches.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/environment.h"
|
||||
#include "base/files/file_path.h"
|
||||
@@ -27,6 +28,7 @@
|
||||
#include "brightray/browser/brightray_paths.h"
|
||||
#include "content/public/browser/client_certificate_delegate.h"
|
||||
#include "content/public/browser/gpu_data_manager.h"
|
||||
#include "content/public/common/content_switches.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "native_mate/object_template_builder.h"
|
||||
#include "net/ssl/ssl_cert_request_info.h"
|
||||
@@ -301,6 +303,16 @@ namespace {
|
||||
|
||||
void AppendSwitch(const std::string& switch_string, mate::Arguments* args) {
|
||||
auto command_line = base::CommandLine::ForCurrentProcess();
|
||||
|
||||
if (switch_string == atom::switches::kPpapiFlashPath ||
|
||||
switch_string == atom::switches::kClientCertificate ||
|
||||
switch_string == switches::kLogNetLog) {
|
||||
base::FilePath path;
|
||||
args->GetNext(&path);
|
||||
command_line->AppendSwitchPath(switch_string, path);
|
||||
return;
|
||||
}
|
||||
|
||||
std::string value;
|
||||
if (args->GetNext(&value))
|
||||
command_line->AppendSwitchASCII(switch_string, value);
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "chrome/browser/printing/print_view_manager_basic.h"
|
||||
#include "chrome/browser/printing/print_preview_message_handler.h"
|
||||
#include "content/common/view_messages.h"
|
||||
#include "content/public/browser/browser_plugin_guest_manager.h"
|
||||
#include "content/public/browser/favicon_status.h"
|
||||
#include "content/public/browser/native_web_keyboard_event.h"
|
||||
#include "content/public/browser/navigation_details.h"
|
||||
@@ -51,6 +52,7 @@
|
||||
#include "net/url_request/static_http_user_agent_settings.h"
|
||||
#include "net/url_request/url_request_context.h"
|
||||
#include "third_party/WebKit/public/web/WebInputEvent.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
|
||||
@@ -62,9 +64,21 @@ struct PrintSettings {
|
||||
};
|
||||
|
||||
void SetUserAgentInIO(scoped_refptr<net::URLRequestContextGetter> getter,
|
||||
std::string accept_lang,
|
||||
std::string user_agent) {
|
||||
getter->GetURLRequestContext()->set_http_user_agent_settings(
|
||||
new net::StaticHttpUserAgentSettings("en-us,en", user_agent));
|
||||
new net::StaticHttpUserAgentSettings(
|
||||
net::HttpUtil::GenerateAcceptLanguageHeader(accept_lang),
|
||||
user_agent));
|
||||
}
|
||||
|
||||
bool NotifyZoomLevelChanged(
|
||||
double level, content::WebContents* guest_web_contents) {
|
||||
guest_web_contents->SendToAllFrames(
|
||||
new AtomViewMsg_SetZoomLevel(MSG_ROUTING_NONE, level));
|
||||
|
||||
// Return false to iterate over all guests.
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -133,7 +147,6 @@ struct Converter<net::HttpResponseHeaders*> {
|
||||
std::string value;
|
||||
while (headers->EnumerateHeaderLines(&iter, &key, &value)) {
|
||||
key = base::StringToLowerASCII(key);
|
||||
value = base::StringToLowerASCII(value);
|
||||
if (response_headers.HasKey(key)) {
|
||||
base::ListValue* values = nullptr;
|
||||
if (response_headers.GetList(key, &values))
|
||||
@@ -528,6 +541,7 @@ bool WebContents::OnMessageReceived(const IPC::Message& message) {
|
||||
IPC_MESSAGE_HANDLER(AtomViewHostMsg_Message, OnRendererMessage)
|
||||
IPC_MESSAGE_HANDLER_DELAY_REPLY(AtomViewHostMsg_Message_Sync,
|
||||
OnRendererMessageSync)
|
||||
IPC_MESSAGE_HANDLER(AtomViewHostMsg_ZoomLevelChanged, OnZoomLevelChanged)
|
||||
IPC_MESSAGE_UNHANDLED(handled = false)
|
||||
IPC_END_MESSAGE_MAP()
|
||||
|
||||
@@ -637,8 +651,10 @@ void WebContents::SetUserAgent(const std::string& user_agent) {
|
||||
web_contents()->SetUserAgentOverride(user_agent);
|
||||
scoped_refptr<net::URLRequestContextGetter> getter =
|
||||
web_contents()->GetBrowserContext()->GetRequestContext();
|
||||
|
||||
auto accept_lang = l10n_util::GetApplicationLocale("");
|
||||
getter->GetNetworkTaskRunner()->PostTask(FROM_HERE,
|
||||
base::Bind(&SetUserAgentInIO, getter, user_agent));
|
||||
base::Bind(&SetUserAgentInIO, getter, accept_lang, user_agent));
|
||||
}
|
||||
|
||||
std::string WebContents::GetUserAgent() {
|
||||
@@ -1033,6 +1049,15 @@ void WebContents::OnRendererMessageSync(const base::string16& channel,
|
||||
EmitWithSender(base::UTF16ToUTF8(channel), web_contents(), message, args);
|
||||
}
|
||||
|
||||
void WebContents::OnZoomLevelChanged(double level) {
|
||||
auto manager = web_contents()->GetBrowserContext()->GetGuestManager();
|
||||
if (!manager)
|
||||
return;
|
||||
manager->ForEachGuest(web_contents(),
|
||||
base::Bind(&NotifyZoomLevelChanged,
|
||||
level));
|
||||
}
|
||||
|
||||
// static
|
||||
mate::Handle<WebContents> WebContents::CreateFrom(
|
||||
v8::Isolate* isolate, content::WebContents* web_contents) {
|
||||
|
||||
@@ -247,6 +247,10 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
const base::ListValue& args,
|
||||
IPC::Message* message);
|
||||
|
||||
// Called when guests need to be notified of
|
||||
// embedders' zoom level change.
|
||||
void OnZoomLevelChanged(double level);
|
||||
|
||||
v8::Global<v8::Value> session_;
|
||||
v8::Global<v8::Value> devtools_web_contents_;
|
||||
|
||||
|
||||
@@ -52,13 +52,16 @@ void AtomBrowserMainParts::RegisterDestructionCallback(
|
||||
destruction_callbacks_.push_back(callback);
|
||||
}
|
||||
|
||||
void AtomBrowserMainParts::PreEarlyInitialization() {
|
||||
brightray::BrowserMainParts::PreEarlyInitialization();
|
||||
#if defined(OS_POSIX)
|
||||
HandleSIGCHLD();
|
||||
#endif
|
||||
}
|
||||
|
||||
void AtomBrowserMainParts::PostEarlyInitialization() {
|
||||
brightray::BrowserMainParts::PostEarlyInitialization();
|
||||
|
||||
#if defined(USE_X11)
|
||||
SetDPIFromGSettings();
|
||||
#endif
|
||||
|
||||
{
|
||||
// Temporary set the bridge_task_runner_ as current thread's task runner,
|
||||
// so we can fool gin::PerIsolateData to use it as its task runner, instead
|
||||
@@ -116,6 +119,13 @@ void AtomBrowserMainParts::PreMainMessageLoopRun() {
|
||||
#endif
|
||||
}
|
||||
|
||||
void AtomBrowserMainParts::PostMainMessageLoopStart() {
|
||||
brightray::BrowserMainParts::PostMainMessageLoopStart();
|
||||
#if defined(OS_POSIX)
|
||||
HandleShutdownSignals();
|
||||
#endif
|
||||
}
|
||||
|
||||
void AtomBrowserMainParts::PostMainMessageLoopRun() {
|
||||
brightray::BrowserMainParts::PostMainMessageLoopRun();
|
||||
|
||||
|
||||
@@ -39,8 +39,10 @@ class AtomBrowserMainParts : public brightray::BrowserMainParts {
|
||||
|
||||
protected:
|
||||
// content::BrowserMainParts:
|
||||
void PreEarlyInitialization() override;
|
||||
void PostEarlyInitialization() override;
|
||||
void PreMainMessageLoopRun() override;
|
||||
void PostMainMessageLoopStart() override;
|
||||
void PostMainMessageLoopRun() override;
|
||||
#if defined(OS_MACOSX)
|
||||
void PreMainMessageLoopStart() override;
|
||||
@@ -48,8 +50,10 @@ class AtomBrowserMainParts : public brightray::BrowserMainParts {
|
||||
#endif
|
||||
|
||||
private:
|
||||
#if defined(USE_X11)
|
||||
void SetDPIFromGSettings();
|
||||
#if defined(OS_POSIX)
|
||||
// Set signal handlers.
|
||||
void HandleSIGCHLD();
|
||||
void HandleShutdownSignals();
|
||||
#endif
|
||||
|
||||
// A fake BrowserProcess object that used to feed the source code from chrome.
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
// Copyright (c) 2014 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/browser/atom_browser_main_parts.h"
|
||||
|
||||
#include <gio/gio.h>
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "ui/gfx/switches.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace {
|
||||
|
||||
const char* kInterfaceSchema = "org.gnome.desktop.interface";
|
||||
const char* kScaleFactor = "scaling-factor";
|
||||
|
||||
bool SchemaExists(const char* schema_name) {
|
||||
const gchar* const* schemas = g_settings_list_schemas();
|
||||
while (*schemas) {
|
||||
if (strcmp(schema_name, static_cast<const char*>(*schemas)) == 0)
|
||||
return true;
|
||||
schemas++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool KeyExists(GSettings* client, const char* key) {
|
||||
gchar** keys = g_settings_list_keys(client);
|
||||
if (!keys)
|
||||
return false;
|
||||
|
||||
gchar** iter = keys;
|
||||
while (*iter) {
|
||||
if (strcmp(*iter, key) == 0)
|
||||
break;
|
||||
iter++;
|
||||
}
|
||||
|
||||
bool exists = *iter != NULL;
|
||||
g_strfreev(keys);
|
||||
return exists;
|
||||
}
|
||||
|
||||
void GetDPIFromGSettings(guint* scale_factor) {
|
||||
GSettings* client = nullptr;
|
||||
if (!SchemaExists(kInterfaceSchema) ||
|
||||
!(client = g_settings_new(kInterfaceSchema))) {
|
||||
VLOG(1) << "Cannot create gsettings client.";
|
||||
return;
|
||||
}
|
||||
|
||||
if (KeyExists(client, kScaleFactor))
|
||||
*scale_factor = g_settings_get_uint(client, kScaleFactor);
|
||||
|
||||
g_object_unref(client);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void AtomBrowserMainParts::SetDPIFromGSettings() {
|
||||
guint scale_factor = 1;
|
||||
GetDPIFromGSettings(&scale_factor);
|
||||
if (scale_factor == 0)
|
||||
scale_factor = 1;
|
||||
|
||||
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
|
||||
switches::kForceDeviceScaleFactor, base::UintToString(scale_factor));
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
225
atom/browser/atom_browser_main_parts_posix.cc
Normal file
225
atom/browser/atom_browser_main_parts_posix.cc
Normal file
@@ -0,0 +1,225 @@
|
||||
// Copyright (c) 2015 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Most code came from: chrome/browser/chrome_browser_main_posix.cc.
|
||||
|
||||
#include "atom/browser/atom_browser_main_parts.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <pthread.h>
|
||||
#include <signal.h>
|
||||
#include <sys/resource.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "atom/browser/browser.h"
|
||||
#include "base/posix/eintr_wrapper.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
|
||||
using content::BrowserThread;
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace {
|
||||
|
||||
// See comment in |PreEarlyInitialization()|, where sigaction is called.
|
||||
void SIGCHLDHandler(int signal) {
|
||||
}
|
||||
|
||||
// The OSX fork() implementation can crash in the child process before
|
||||
// fork() returns. In that case, the shutdown pipe will still be
|
||||
// shared with the parent process. To prevent child crashes from
|
||||
// causing parent shutdowns, |g_pipe_pid| is the pid for the process
|
||||
// which registered |g_shutdown_pipe_write_fd|.
|
||||
// See <http://crbug.com/175341>.
|
||||
pid_t g_pipe_pid = -1;
|
||||
int g_shutdown_pipe_write_fd = -1;
|
||||
int g_shutdown_pipe_read_fd = -1;
|
||||
|
||||
// Common code between SIG{HUP, INT, TERM}Handler.
|
||||
void GracefulShutdownHandler(int signal) {
|
||||
// Reinstall the default handler. We had one shot at graceful shutdown.
|
||||
struct sigaction action;
|
||||
memset(&action, 0, sizeof(action));
|
||||
action.sa_handler = SIG_DFL;
|
||||
RAW_CHECK(sigaction(signal, &action, NULL) == 0);
|
||||
|
||||
RAW_CHECK(g_pipe_pid == getpid());
|
||||
RAW_CHECK(g_shutdown_pipe_write_fd != -1);
|
||||
RAW_CHECK(g_shutdown_pipe_read_fd != -1);
|
||||
size_t bytes_written = 0;
|
||||
do {
|
||||
int rv = HANDLE_EINTR(
|
||||
write(g_shutdown_pipe_write_fd,
|
||||
reinterpret_cast<const char*>(&signal) + bytes_written,
|
||||
sizeof(signal) - bytes_written));
|
||||
RAW_CHECK(rv >= 0);
|
||||
bytes_written += rv;
|
||||
} while (bytes_written < sizeof(signal));
|
||||
}
|
||||
|
||||
// See comment in |PostMainMessageLoopStart()|, where sigaction is called.
|
||||
void SIGHUPHandler(int signal) {
|
||||
RAW_CHECK(signal == SIGHUP);
|
||||
GracefulShutdownHandler(signal);
|
||||
}
|
||||
|
||||
// See comment in |PostMainMessageLoopStart()|, where sigaction is called.
|
||||
void SIGINTHandler(int signal) {
|
||||
RAW_CHECK(signal == SIGINT);
|
||||
GracefulShutdownHandler(signal);
|
||||
}
|
||||
|
||||
// See comment in |PostMainMessageLoopStart()|, where sigaction is called.
|
||||
void SIGTERMHandler(int signal) {
|
||||
RAW_CHECK(signal == SIGTERM);
|
||||
GracefulShutdownHandler(signal);
|
||||
}
|
||||
|
||||
class ShutdownDetector : public base::PlatformThread::Delegate {
|
||||
public:
|
||||
explicit ShutdownDetector(int shutdown_fd);
|
||||
|
||||
void ThreadMain() override;
|
||||
|
||||
private:
|
||||
const int shutdown_fd_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(ShutdownDetector);
|
||||
};
|
||||
|
||||
ShutdownDetector::ShutdownDetector(int shutdown_fd)
|
||||
: shutdown_fd_(shutdown_fd) {
|
||||
CHECK_NE(shutdown_fd_, -1);
|
||||
}
|
||||
|
||||
// These functions are used to help us diagnose crash dumps that happen
|
||||
// during the shutdown process.
|
||||
NOINLINE void ShutdownFDReadError() {
|
||||
// Ensure function isn't optimized away.
|
||||
asm("");
|
||||
sleep(UINT_MAX);
|
||||
}
|
||||
|
||||
NOINLINE void ShutdownFDClosedError() {
|
||||
// Ensure function isn't optimized away.
|
||||
asm("");
|
||||
sleep(UINT_MAX);
|
||||
}
|
||||
|
||||
NOINLINE void ExitPosted() {
|
||||
// Ensure function isn't optimized away.
|
||||
asm("");
|
||||
sleep(UINT_MAX);
|
||||
}
|
||||
|
||||
void ShutdownDetector::ThreadMain() {
|
||||
base::PlatformThread::SetName("CrShutdownDetector");
|
||||
|
||||
int signal;
|
||||
size_t bytes_read = 0;
|
||||
ssize_t ret;
|
||||
do {
|
||||
ret = HANDLE_EINTR(
|
||||
read(shutdown_fd_,
|
||||
reinterpret_cast<char*>(&signal) + bytes_read,
|
||||
sizeof(signal) - bytes_read));
|
||||
if (ret < 0) {
|
||||
NOTREACHED() << "Unexpected error: " << strerror(errno);
|
||||
ShutdownFDReadError();
|
||||
break;
|
||||
} else if (ret == 0) {
|
||||
NOTREACHED() << "Unexpected closure of shutdown pipe.";
|
||||
ShutdownFDClosedError();
|
||||
break;
|
||||
}
|
||||
bytes_read += ret;
|
||||
} while (bytes_read < sizeof(signal));
|
||||
VLOG(1) << "Handling shutdown for signal " << signal << ".";
|
||||
base::Closure task =
|
||||
base::Bind(&Browser::Quit, base::Unretained(Browser::Get()));
|
||||
|
||||
if (!BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, task)) {
|
||||
// Without a UI thread to post the exit task to, there aren't many
|
||||
// options. Raise the signal again. The default handler will pick it up
|
||||
// and cause an ungraceful exit.
|
||||
RAW_LOG(WARNING, "No UI thread, exiting ungracefully.");
|
||||
kill(getpid(), signal);
|
||||
|
||||
// The signal may be handled on another thread. Give that a chance to
|
||||
// happen.
|
||||
sleep(3);
|
||||
|
||||
// We really should be dead by now. For whatever reason, we're not. Exit
|
||||
// immediately, with the exit status set to the signal number with bit 8
|
||||
// set. On the systems that we care about, this exit status is what is
|
||||
// normally used to indicate an exit by this signal's default handler.
|
||||
// This mechanism isn't a de jure standard, but even in the worst case, it
|
||||
// should at least result in an immediate exit.
|
||||
RAW_LOG(WARNING, "Still here, exiting really ungracefully.");
|
||||
_exit(signal | (1 << 7));
|
||||
}
|
||||
ExitPosted();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void AtomBrowserMainParts::HandleSIGCHLD() {
|
||||
// We need to accept SIGCHLD, even though our handler is a no-op because
|
||||
// otherwise we cannot wait on children. (According to POSIX 2001.)
|
||||
struct sigaction action;
|
||||
memset(&action, 0, sizeof(action));
|
||||
action.sa_handler = SIGCHLDHandler;
|
||||
CHECK_EQ(sigaction(SIGCHLD, &action, NULL), 0);
|
||||
}
|
||||
|
||||
void AtomBrowserMainParts::HandleShutdownSignals() {
|
||||
int pipefd[2];
|
||||
int ret = pipe(pipefd);
|
||||
if (ret < 0) {
|
||||
PLOG(DFATAL) << "Failed to create pipe";
|
||||
} else {
|
||||
g_pipe_pid = getpid();
|
||||
g_shutdown_pipe_read_fd = pipefd[0];
|
||||
g_shutdown_pipe_write_fd = pipefd[1];
|
||||
#if !defined(ADDRESS_SANITIZER) && !defined(KEEP_SHADOW_STACKS)
|
||||
const size_t kShutdownDetectorThreadStackSize = PTHREAD_STACK_MIN * 2;
|
||||
#else
|
||||
// ASan instrumentation and -finstrument-functions (used for keeping the
|
||||
// shadow stacks) bloat the stack frames, so we need to increase the stack
|
||||
// size to avoid hitting the guard page.
|
||||
const size_t kShutdownDetectorThreadStackSize = PTHREAD_STACK_MIN * 4;
|
||||
#endif
|
||||
// TODO(viettrungluu,willchan): crbug.com/29675 - This currently leaks, so
|
||||
// if you change this, you'll probably need to change the suppression.
|
||||
if (!base::PlatformThread::CreateNonJoinable(
|
||||
kShutdownDetectorThreadStackSize,
|
||||
new ShutdownDetector(g_shutdown_pipe_read_fd))) {
|
||||
LOG(DFATAL) << "Failed to create shutdown detector task.";
|
||||
}
|
||||
}
|
||||
// Setup signal handlers for shutdown AFTER shutdown pipe is setup because
|
||||
// it may be called right away after handler is set.
|
||||
|
||||
// If adding to this list of signal handlers, note the new signal probably
|
||||
// needs to be reset in child processes. See
|
||||
// base/process_util_posix.cc:LaunchProcess.
|
||||
|
||||
// We need to handle SIGTERM, because that is how many POSIX-based distros ask
|
||||
// processes to quit gracefully at shutdown time.
|
||||
struct sigaction action;
|
||||
memset(&action, 0, sizeof(action));
|
||||
action.sa_handler = SIGTERMHandler;
|
||||
CHECK_EQ(sigaction(SIGTERM, &action, NULL), 0);
|
||||
// Also handle SIGINT - when the user terminates the browser via Ctrl+C. If
|
||||
// the browser process is being debugged, GDB will catch the SIGINT first.
|
||||
action.sa_handler = SIGINTHandler;
|
||||
CHECK_EQ(sigaction(SIGINT, &action, NULL), 0);
|
||||
// And SIGHUP, for when the terminal disappears. On shutdown, many Linux
|
||||
// distros send SIGHUP, SIGTERM, and then SIGKILL.
|
||||
action.sa_handler = SIGHUPHandler;
|
||||
CHECK_EQ(sigaction(SIGHUP, &action, NULL), 0);
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
@@ -16,7 +16,8 @@ namespace atom {
|
||||
|
||||
Browser::Browser()
|
||||
: is_quiting_(false),
|
||||
is_ready_(false) {
|
||||
is_ready_(false),
|
||||
is_shutdown_(false) {
|
||||
WindowList::AddObserver(this);
|
||||
}
|
||||
|
||||
@@ -30,6 +31,9 @@ Browser* Browser::Get() {
|
||||
}
|
||||
|
||||
void Browser::Quit() {
|
||||
if (is_quiting_)
|
||||
return;
|
||||
|
||||
is_quiting_ = HandleBeforeQuit();
|
||||
if (!is_quiting_)
|
||||
return;
|
||||
@@ -42,9 +46,13 @@ void Browser::Quit() {
|
||||
}
|
||||
|
||||
void Browser::Shutdown() {
|
||||
FOR_EACH_OBSERVER(BrowserObserver, observers_, OnQuit());
|
||||
if (is_shutdown_)
|
||||
return;
|
||||
|
||||
is_shutdown_ = true;
|
||||
is_quiting_ = true;
|
||||
|
||||
FOR_EACH_OBSERVER(BrowserObserver, observers_, OnQuit());
|
||||
base::MessageLoop::current()->PostTask(
|
||||
FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
|
||||
}
|
||||
@@ -121,6 +129,9 @@ void Browser::ClientCertificateSelector(
|
||||
}
|
||||
|
||||
void Browser::NotifyAndShutdown() {
|
||||
if (is_shutdown_)
|
||||
return;
|
||||
|
||||
bool prevent_default = false;
|
||||
FOR_EACH_OBSERVER(BrowserObserver, observers_, OnWillQuit(&prevent_default));
|
||||
|
||||
|
||||
@@ -159,6 +159,9 @@ class Browser : public WindowListObserver {
|
||||
// Whether "ready" event has been emitted.
|
||||
bool is_ready_;
|
||||
|
||||
// The browse is being shutdown.
|
||||
bool is_shutdown_;
|
||||
|
||||
std::string version_override_;
|
||||
std::string name_override_;
|
||||
|
||||
|
||||
@@ -18,6 +18,9 @@ for (var i = 0; i < argv.length; i++) {
|
||||
if (argv[i] == '--version' || argv[i] == '-v') {
|
||||
option.version = true;
|
||||
break;
|
||||
} else if (argv[i].match(/^--app=/)) {
|
||||
option.file = argv[i].split('=')[1];
|
||||
break;
|
||||
} else if (argv[i] == '--help' || argv[i] == '-h') {
|
||||
option.help = true;
|
||||
break;
|
||||
@@ -260,7 +263,7 @@ if (option.file && !option.webdriver) {
|
||||
helpMessage += "A path to an Electron application may be specified. The path must be to \n";
|
||||
helpMessage += "an index.js file or to a folder containing a package.json or index.js file.\n\n";
|
||||
helpMessage += "Options:\n";
|
||||
helpMessage += " -r, --require Module to preload (option can be repeated)";
|
||||
helpMessage += " -r, --require Module to preload (option can be repeated)\n";
|
||||
helpMessage += " -h, --help Print this usage message.\n";
|
||||
helpMessage += " -v, --version Print the version.";
|
||||
console.log(helpMessage);
|
||||
|
||||
@@ -67,7 +67,7 @@ ipc.on 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_METHOD', (event, guestId, method,
|
||||
ipc.on 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_POSTMESSAGE', (event, guestId, message, targetOrigin) ->
|
||||
guestContents = BrowserWindow.fromId(guestId)?.webContents
|
||||
if guestContents?.getUrl().indexOf(targetOrigin) is 0 or targetOrigin is '*'
|
||||
guestContents.send 'ATOM_SHELL_GUEST_WINDOW_POSTMESSAGE', message, targetOrigin
|
||||
guestContents.send 'ATOM_SHELL_GUEST_WINDOW_POSTMESSAGE', guestId, message, targetOrigin
|
||||
|
||||
ipc.on 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPENER_POSTMESSAGE', (event, guestId, message, targetOrigin, sourceOrigin) ->
|
||||
embedder = v8Util.getHiddenValue event.sender, 'embedder'
|
||||
|
||||
@@ -7,21 +7,29 @@ Module = require 'module'
|
||||
# we need to restore it here.
|
||||
process.argv.splice 1, 1
|
||||
|
||||
# Clear search paths.
|
||||
require path.resolve(__dirname, '..', '..', 'common', 'lib', 'reset-search-paths')
|
||||
|
||||
# Import common settings.
|
||||
require path.resolve(__dirname, '..', '..', 'common', 'lib', 'init')
|
||||
|
||||
# Add browser/api/lib to module search paths, which contains javascript part of
|
||||
# Electron's built-in libraries.
|
||||
globalPaths = Module.globalPaths
|
||||
globalPaths.push path.resolve(__dirname, '..', 'api', 'lib')
|
||||
|
||||
# Import common settings.
|
||||
require path.resolve(__dirname, '..', '..', 'common', 'lib', 'init')
|
||||
|
||||
if process.platform is 'win32'
|
||||
# Redirect node's console to use our own implementations, since node can not
|
||||
# handle console output when running as GUI program.
|
||||
print = (args...) ->
|
||||
process.log util.format(args...)
|
||||
console.log = console.error = console.warn = print
|
||||
process.stdout.write = process.stderr.write = print
|
||||
consoleLog = (args...) ->
|
||||
process.log util.format(args...) + "\n"
|
||||
streamWrite = (chunk, encoding, callback) ->
|
||||
chunk = chunk.toString(encoding) if Buffer.isBuffer chunk
|
||||
process.log chunk
|
||||
callback() if callback
|
||||
true
|
||||
console.log = console.error = console.warn = consoleLog
|
||||
process.stdout.write = process.stderr.write = streamWrite
|
||||
|
||||
# Always returns EOF for stdin stream.
|
||||
Readable = require('stream').Readable
|
||||
|
||||
@@ -34,6 +34,7 @@ class ObjectsRegistry extends EventEmitter
|
||||
@dereference id, 1
|
||||
# Also reduce the count in owner.
|
||||
pointer = @owners[webContentsId]
|
||||
return unless pointer?
|
||||
--pointer[id]
|
||||
delete pointer[id] if pointer[id] is 0
|
||||
|
||||
@@ -57,6 +58,7 @@ class ObjectsRegistry extends EventEmitter
|
||||
# Private: Dereference the object from store.
|
||||
dereference: (id, count) ->
|
||||
pointer = @storage[id]
|
||||
return unless pointer?
|
||||
pointer.count -= count
|
||||
if pointer.count is 0
|
||||
v8Util.deleteHiddenValue pointer.object, 'atomId'
|
||||
|
||||
@@ -43,11 +43,20 @@
|
||||
atom::Browser::Get()->OpenURL(base::SysNSStringToUTF8(url));
|
||||
}
|
||||
|
||||
- (bool)voiceOverEnabled {
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
[defaults addSuiteNamed:@"com.apple.universalaccess"];
|
||||
[defaults synchronize];
|
||||
|
||||
return [defaults boolForKey:@"voiceOverOnOffKey"];
|
||||
}
|
||||
|
||||
- (void)accessibilitySetValue:(id)value forAttribute:(NSString *)attribute {
|
||||
// Undocumented attribute that VoiceOver happens to set while running.
|
||||
// Chromium uses this too, even though it's not exactly right.
|
||||
if ([attribute isEqualToString:@"AXEnhancedUserInterface"]) {
|
||||
[self updateAccessibilityEnabled:[value boolValue]];
|
||||
bool enableAccessibility = ([self voiceOverEnabled] && [value boolValue]);
|
||||
[self updateAccessibilityEnabled:enableAccessibility];
|
||||
}
|
||||
return [super accessibilitySetValue:value forAttribute:attribute];
|
||||
}
|
||||
|
||||
@@ -112,27 +112,34 @@ void NativeWindow::InitFromOptions(const mate::Dictionary& options) {
|
||||
int x = -1, y = -1;
|
||||
bool center;
|
||||
if (options.Get(switches::kX, &x) && options.Get(switches::kY, &y)) {
|
||||
int width = -1, height = -1;
|
||||
options.Get(switches::kWidth, &width);
|
||||
options.Get(switches::kHeight, &height);
|
||||
SetBounds(gfx::Rect(x, y, width, height));
|
||||
SetPosition(gfx::Point(x, y));
|
||||
} else if (options.Get(switches::kCenter, ¢er) && center) {
|
||||
Center();
|
||||
}
|
||||
extensions::SizeConstraints size_constraints;
|
||||
int min_height = 0, min_width = 0;
|
||||
if (options.Get(switches::kMinHeight, &min_height) |
|
||||
options.Get(switches::kMinWidth, &min_width)) {
|
||||
SetMinimumSize(gfx::Size(min_width, min_height));
|
||||
size_constraints.set_minimum_size(gfx::Size(min_width, min_height));
|
||||
}
|
||||
int max_height = INT_MAX, max_width = INT_MAX;
|
||||
if (options.Get(switches::kMaxHeight, &max_height) |
|
||||
options.Get(switches::kMaxWidth, &max_width)) {
|
||||
SetMaximumSize(gfx::Size(max_width, max_height));
|
||||
size_constraints.set_maximum_size(gfx::Size(max_width, max_height));
|
||||
}
|
||||
bool use_content_size = false;
|
||||
options.Get(switches::kUseContentSize, &use_content_size);
|
||||
if (use_content_size) {
|
||||
SetContentSizeConstraints(size_constraints);
|
||||
} else {
|
||||
SetSizeConstraints(size_constraints);
|
||||
}
|
||||
#if defined(OS_WIN) || defined(USE_X11)
|
||||
bool resizable;
|
||||
if (options.Get(switches::kResizable, &resizable)) {
|
||||
SetResizable(resizable);
|
||||
}
|
||||
#endif
|
||||
bool top;
|
||||
if (options.Get(switches::kAlwaysOnTop, &top) && top) {
|
||||
SetAlwaysOnTop(true);
|
||||
@@ -178,6 +185,67 @@ gfx::Point NativeWindow::GetPosition() {
|
||||
return GetBounds().origin();
|
||||
}
|
||||
|
||||
void NativeWindow::SetContentSize(const gfx::Size& size) {
|
||||
SetSize(ContentSizeToWindowSize(size));
|
||||
}
|
||||
|
||||
gfx::Size NativeWindow::GetContentSize() {
|
||||
return WindowSizeToContentSize(GetSize());
|
||||
}
|
||||
|
||||
void NativeWindow::SetSizeConstraints(
|
||||
const extensions::SizeConstraints& window_constraints) {
|
||||
extensions::SizeConstraints content_constraints;
|
||||
if (window_constraints.HasMaximumSize())
|
||||
content_constraints.set_maximum_size(
|
||||
WindowSizeToContentSize(window_constraints.GetMaximumSize()));
|
||||
if (window_constraints.HasMinimumSize())
|
||||
content_constraints.set_minimum_size(
|
||||
WindowSizeToContentSize(window_constraints.GetMinimumSize()));
|
||||
SetContentSizeConstraints(content_constraints);
|
||||
}
|
||||
|
||||
extensions::SizeConstraints NativeWindow::GetSizeConstraints() {
|
||||
extensions::SizeConstraints content_constraints = GetContentSizeConstraints();
|
||||
extensions::SizeConstraints window_constraints;
|
||||
if (content_constraints.HasMaximumSize())
|
||||
window_constraints.set_maximum_size(
|
||||
ContentSizeToWindowSize(content_constraints.GetMaximumSize()));
|
||||
if (content_constraints.HasMinimumSize())
|
||||
window_constraints.set_minimum_size(
|
||||
ContentSizeToWindowSize(content_constraints.GetMinimumSize()));
|
||||
return window_constraints;
|
||||
}
|
||||
|
||||
void NativeWindow::SetContentSizeConstraints(
|
||||
const extensions::SizeConstraints& size_constraints) {
|
||||
size_constraints_ = size_constraints;
|
||||
}
|
||||
|
||||
extensions::SizeConstraints NativeWindow::GetContentSizeConstraints() {
|
||||
return size_constraints_;
|
||||
}
|
||||
|
||||
void NativeWindow::SetMinimumSize(const gfx::Size& size) {
|
||||
extensions::SizeConstraints size_constraints;
|
||||
size_constraints.set_minimum_size(size);
|
||||
SetSizeConstraints(size_constraints);
|
||||
}
|
||||
|
||||
gfx::Size NativeWindow::GetMinimumSize() {
|
||||
return GetSizeConstraints().GetMinimumSize();
|
||||
}
|
||||
|
||||
void NativeWindow::SetMaximumSize(const gfx::Size& size) {
|
||||
extensions::SizeConstraints size_constraints;
|
||||
size_constraints.set_maximum_size(size);
|
||||
SetSizeConstraints(size_constraints);
|
||||
}
|
||||
|
||||
gfx::Size NativeWindow::GetMaximumSize() {
|
||||
return GetSizeConstraints().GetMaximumSize();
|
||||
}
|
||||
|
||||
void NativeWindow::SetRepresentedFilename(const std::string& filename) {
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "content/public/browser/readback_types.h"
|
||||
#include "content/public/browser/web_contents_observer.h"
|
||||
#include "content/public/browser/web_contents_user_data.h"
|
||||
#include "extensions/browser/app_window/size_constraints.h"
|
||||
#include "ui/gfx/image/image.h"
|
||||
#include "ui/gfx/image/image_skia.h"
|
||||
|
||||
@@ -110,12 +111,18 @@ class NativeWindow : public base::SupportsUserData,
|
||||
virtual gfx::Size GetSize();
|
||||
virtual void SetPosition(const gfx::Point& position);
|
||||
virtual gfx::Point GetPosition();
|
||||
virtual void SetContentSize(const gfx::Size& size) = 0;
|
||||
virtual gfx::Size GetContentSize() = 0;
|
||||
virtual void SetMinimumSize(const gfx::Size& size) = 0;
|
||||
virtual gfx::Size GetMinimumSize() = 0;
|
||||
virtual void SetMaximumSize(const gfx::Size& size) = 0;
|
||||
virtual gfx::Size GetMaximumSize() = 0;
|
||||
virtual void SetContentSize(const gfx::Size& size);
|
||||
virtual gfx::Size GetContentSize();
|
||||
virtual void SetSizeConstraints(
|
||||
const extensions::SizeConstraints& size_constraints);
|
||||
virtual extensions::SizeConstraints GetSizeConstraints();
|
||||
virtual void SetContentSizeConstraints(
|
||||
const extensions::SizeConstraints& size_constraints);
|
||||
virtual extensions::SizeConstraints GetContentSizeConstraints();
|
||||
virtual void SetMinimumSize(const gfx::Size& size);
|
||||
virtual gfx::Size GetMinimumSize();
|
||||
virtual void SetMaximumSize(const gfx::Size& size);
|
||||
virtual gfx::Size GetMaximumSize();
|
||||
virtual void SetResizable(bool resizable) = 0;
|
||||
virtual bool IsResizable() = 0;
|
||||
virtual void SetAlwaysOnTop(bool top) = 0;
|
||||
@@ -234,6 +241,10 @@ class NativeWindow : public base::SupportsUserData,
|
||||
NativeWindow(brightray::InspectableWebContents* inspectable_web_contents,
|
||||
const mate::Dictionary& options);
|
||||
|
||||
// Converts between content size to window size.
|
||||
virtual gfx::Size ContentSizeToWindowSize(const gfx::Size& size) = 0;
|
||||
virtual gfx::Size WindowSizeToContentSize(const gfx::Size& size) = 0;
|
||||
|
||||
// content::WebContentsObserver:
|
||||
void RenderViewCreated(content::RenderViewHost* render_view_host) override;
|
||||
void BeforeUnloadDialogCancelled() override;
|
||||
@@ -269,6 +280,9 @@ class NativeWindow : public base::SupportsUserData,
|
||||
// has to been explicitly provided.
|
||||
scoped_ptr<SkRegion> draggable_region_; // used in custom drag.
|
||||
|
||||
// Minimum and maximum size, stored as content size.
|
||||
extensions::SizeConstraints size_constraints_;
|
||||
|
||||
// Whether window can be resized larger than screen.
|
||||
bool enable_larger_than_screen_;
|
||||
|
||||
|
||||
@@ -44,12 +44,8 @@ class NativeWindowMac : public NativeWindow {
|
||||
bool IsFullscreen() const override;
|
||||
void SetBounds(const gfx::Rect& bounds) override;
|
||||
gfx::Rect GetBounds() override;
|
||||
void SetContentSize(const gfx::Size& size) override;
|
||||
gfx::Size GetContentSize() override;
|
||||
void SetMinimumSize(const gfx::Size& size) override;
|
||||
gfx::Size GetMinimumSize() override;
|
||||
void SetMaximumSize(const gfx::Size& size) override;
|
||||
gfx::Size GetMaximumSize() override;
|
||||
void SetContentSizeConstraints(
|
||||
const extensions::SizeConstraints& size_constraints) override;
|
||||
void SetResizable(bool resizable) override;
|
||||
bool IsResizable() override;
|
||||
void SetAlwaysOnTop(bool top) override;
|
||||
@@ -89,6 +85,10 @@ class NativeWindowMac : public NativeWindow {
|
||||
const content::NativeWebKeyboardEvent&) override;
|
||||
|
||||
private:
|
||||
// NativeWindow:
|
||||
gfx::Size ContentSizeToWindowSize(const gfx::Size& size) override;
|
||||
gfx::Size WindowSizeToContentSize(const gfx::Size& size) override;
|
||||
|
||||
void InstallView();
|
||||
void UninstallView();
|
||||
|
||||
|
||||
@@ -350,6 +350,8 @@ NativeWindowMac::NativeWindowMac(
|
||||
|
||||
bool useStandardWindow = true;
|
||||
options.Get(switches::kStandardWindow, &useStandardWindow);
|
||||
bool resizable = true;
|
||||
options.Get(switches::kResizable, &resizable);
|
||||
|
||||
// New title bar styles are available in Yosemite or newer
|
||||
std::string titleBarStyle;
|
||||
@@ -357,10 +359,13 @@ NativeWindowMac::NativeWindowMac(
|
||||
options.Get(switches::kTitleBarStyle, &titleBarStyle);
|
||||
|
||||
NSUInteger styleMask = NSTitledWindowMask | NSClosableWindowMask |
|
||||
NSMiniaturizableWindowMask | NSResizableWindowMask;
|
||||
NSMiniaturizableWindowMask;
|
||||
if (!useStandardWindow || transparent() || !has_frame()) {
|
||||
styleMask |= NSTexturedBackgroundWindowMask;
|
||||
}
|
||||
if (resizable) {
|
||||
styleMask |= NSResizableWindowMask;
|
||||
}
|
||||
if ((titleBarStyle == "hidden") || (titleBarStyle == "hidden-inset")) {
|
||||
styleMask |= NSFullSizeContentViewWindowMask;
|
||||
styleMask |= NSUnifiedTitleAndToolbarWindowMask;
|
||||
@@ -549,56 +554,30 @@ gfx::Rect NativeWindowMac::GetBounds() {
|
||||
return bounds;
|
||||
}
|
||||
|
||||
void NativeWindowMac::SetContentSize(const gfx::Size& size) {
|
||||
if (!has_frame()) {
|
||||
SetSize(size);
|
||||
return;
|
||||
void NativeWindowMac::SetContentSizeConstraints(
|
||||
const extensions::SizeConstraints& size_constraints) {
|
||||
auto convertSize = [this](const gfx::Size& size) {
|
||||
// Our frameless window still has titlebar attached, so setting contentSize
|
||||
// will result in actual content size being larger.
|
||||
if (!has_frame()) {
|
||||
NSRect frame = NSMakeRect(0, 0, size.width(), size.height());
|
||||
NSRect content = [window_ contentRectForFrameRect:frame];
|
||||
return content.size;
|
||||
} else {
|
||||
return NSMakeSize(size.width(), size.height());
|
||||
}
|
||||
};
|
||||
|
||||
NSView* content = [window_ contentView];
|
||||
if (size_constraints.HasMinimumSize()) {
|
||||
NSSize min_size = convertSize(size_constraints.GetMinimumSize());
|
||||
[window_ setContentMinSize:[content convertSize:min_size toView:nil]];
|
||||
}
|
||||
|
||||
NSRect frame_nsrect = [window_ frame];
|
||||
NSSize frame = frame_nsrect.size;
|
||||
NSSize content = [window_ contentRectForFrameRect:frame_nsrect].size;
|
||||
|
||||
int width = size.width() + frame.width - content.width;
|
||||
int height = size.height() + frame.height - content.height;
|
||||
frame_nsrect.origin.y -= height - frame_nsrect.size.height;
|
||||
frame_nsrect.size.width = width;
|
||||
frame_nsrect.size.height = height;
|
||||
[window_ setFrame:frame_nsrect display:YES];
|
||||
}
|
||||
|
||||
gfx::Size NativeWindowMac::GetContentSize() {
|
||||
if (!has_frame())
|
||||
return GetSize();
|
||||
|
||||
NSRect bounds = [[window_ contentView] bounds];
|
||||
return gfx::Size(bounds.size.width, bounds.size.height);
|
||||
}
|
||||
|
||||
void NativeWindowMac::SetMinimumSize(const gfx::Size& size) {
|
||||
NSSize min_size = NSMakeSize(size.width(), size.height());
|
||||
NSView* content = [window_ contentView];
|
||||
[window_ setContentMinSize:[content convertSize:min_size toView:nil]];
|
||||
}
|
||||
|
||||
gfx::Size NativeWindowMac::GetMinimumSize() {
|
||||
NSView* content = [window_ contentView];
|
||||
NSSize min_size = [content convertSize:[window_ contentMinSize]
|
||||
fromView:nil];
|
||||
return gfx::Size(min_size.width, min_size.height);
|
||||
}
|
||||
|
||||
void NativeWindowMac::SetMaximumSize(const gfx::Size& size) {
|
||||
NSSize max_size = NSMakeSize(size.width(), size.height());
|
||||
NSView* content = [window_ contentView];
|
||||
[window_ setContentMaxSize:[content convertSize:max_size toView:nil]];
|
||||
}
|
||||
|
||||
gfx::Size NativeWindowMac::GetMaximumSize() {
|
||||
NSView* content = [window_ contentView];
|
||||
NSSize max_size = [content convertSize:[window_ contentMaxSize]
|
||||
fromView:nil];
|
||||
return gfx::Size(max_size.width, max_size.height);
|
||||
if (size_constraints.HasMaximumSize()) {
|
||||
NSSize max_size = convertSize(size_constraints.GetMaximumSize());
|
||||
[window_ setContentMaxSize:[content convertSize:max_size toView:nil]];
|
||||
}
|
||||
NativeWindow::SetContentSizeConstraints(size_constraints);
|
||||
}
|
||||
|
||||
void NativeWindowMac::SetResizable(bool resizable) {
|
||||
@@ -821,6 +800,24 @@ void NativeWindowMac::HandleKeyboardEvent(
|
||||
}
|
||||
}
|
||||
|
||||
gfx::Size NativeWindowMac::ContentSizeToWindowSize(const gfx::Size& size) {
|
||||
if (!has_frame())
|
||||
return size;
|
||||
|
||||
NSRect content = NSMakeRect(0, 0, size.width(), size.height());
|
||||
NSRect frame = [window_ frameRectForContentRect:content];
|
||||
return gfx::Size(frame.size);
|
||||
}
|
||||
|
||||
gfx::Size NativeWindowMac::WindowSizeToContentSize(const gfx::Size& size) {
|
||||
if (!has_frame())
|
||||
return size;
|
||||
|
||||
NSRect frame = NSMakeRect(0, 0, size.width(), size.height());
|
||||
NSRect content = [window_ contentRectForFrameRect:frame];
|
||||
return gfx::Size(content.size);
|
||||
}
|
||||
|
||||
void NativeWindowMac::InstallView() {
|
||||
// Make sure the bottom corner is rounded: http://crbug.com/396264.
|
||||
[[window_ contentView] setWantsLayer:YES];
|
||||
|
||||
@@ -77,70 +77,6 @@ bool IsAltModifier(const content::NativeWebKeyboardEvent& event) {
|
||||
(modifiers == (Modifiers::AltKey | Modifiers::IsRight));
|
||||
}
|
||||
|
||||
#if defined(OS_WIN)
|
||||
// Convert Win32 WM_APPCOMMANDS to strings.
|
||||
const char* AppCommandToString(int command_id) {
|
||||
switch (command_id) {
|
||||
case APPCOMMAND_BROWSER_BACKWARD : return "browser-backward";
|
||||
case APPCOMMAND_BROWSER_FORWARD : return "browser-forward";
|
||||
case APPCOMMAND_BROWSER_REFRESH : return "browser-refresh";
|
||||
case APPCOMMAND_BROWSER_STOP : return "browser-stop";
|
||||
case APPCOMMAND_BROWSER_SEARCH : return "browser-search";
|
||||
case APPCOMMAND_BROWSER_FAVORITES : return "browser-favorites";
|
||||
case APPCOMMAND_BROWSER_HOME : return "browser-home";
|
||||
case APPCOMMAND_VOLUME_MUTE : return "volume-mute";
|
||||
case APPCOMMAND_VOLUME_DOWN : return "volume-down";
|
||||
case APPCOMMAND_VOLUME_UP : return "volume-up";
|
||||
case APPCOMMAND_MEDIA_NEXTTRACK : return "media-nexttrack";
|
||||
case APPCOMMAND_MEDIA_PREVIOUSTRACK : return "media-previoustrack";
|
||||
case APPCOMMAND_MEDIA_STOP : return "media-stop";
|
||||
case APPCOMMAND_MEDIA_PLAY_PAUSE : return "media-play_pause";
|
||||
case APPCOMMAND_LAUNCH_MAIL : return "launch-mail";
|
||||
case APPCOMMAND_LAUNCH_MEDIA_SELECT : return "launch-media-select";
|
||||
case APPCOMMAND_LAUNCH_APP1 : return "launch-app1";
|
||||
case APPCOMMAND_LAUNCH_APP2 : return "launch-app2";
|
||||
case APPCOMMAND_BASS_DOWN : return "bass-down";
|
||||
case APPCOMMAND_BASS_BOOST : return "bass-boost";
|
||||
case APPCOMMAND_BASS_UP : return "bass-up";
|
||||
case APPCOMMAND_TREBLE_DOWN : return "treble-down";
|
||||
case APPCOMMAND_TREBLE_UP : return "treble-up";
|
||||
case APPCOMMAND_MICROPHONE_VOLUME_MUTE : return "microphone-volume-mute";
|
||||
case APPCOMMAND_MICROPHONE_VOLUME_DOWN : return "microphone-volume-down";
|
||||
case APPCOMMAND_MICROPHONE_VOLUME_UP : return "microphone-volume-up";
|
||||
case APPCOMMAND_HELP : return "help";
|
||||
case APPCOMMAND_FIND : return "find";
|
||||
case APPCOMMAND_NEW : return "new";
|
||||
case APPCOMMAND_OPEN : return "open";
|
||||
case APPCOMMAND_CLOSE : return "close";
|
||||
case APPCOMMAND_SAVE : return "save";
|
||||
case APPCOMMAND_PRINT : return "print";
|
||||
case APPCOMMAND_UNDO : return "undo";
|
||||
case APPCOMMAND_REDO : return "redo";
|
||||
case APPCOMMAND_COPY : return "copy";
|
||||
case APPCOMMAND_CUT : return "cut";
|
||||
case APPCOMMAND_PASTE : return "paste";
|
||||
case APPCOMMAND_REPLY_TO_MAIL : return "reply-to-mail";
|
||||
case APPCOMMAND_FORWARD_MAIL : return "forward-mail";
|
||||
case APPCOMMAND_SEND_MAIL : return "send-mail";
|
||||
case APPCOMMAND_SPELL_CHECK : return "spell-check";
|
||||
case APPCOMMAND_MIC_ON_OFF_TOGGLE : return "mic-on-off-toggle";
|
||||
case APPCOMMAND_CORRECTION_LIST : return "correction-list";
|
||||
case APPCOMMAND_MEDIA_PLAY : return "media-play";
|
||||
case APPCOMMAND_MEDIA_PAUSE : return "media-pause";
|
||||
case APPCOMMAND_MEDIA_RECORD : return "media-record";
|
||||
case APPCOMMAND_MEDIA_FAST_FORWARD : return "media-fast-forward";
|
||||
case APPCOMMAND_MEDIA_REWIND : return "media-rewind";
|
||||
case APPCOMMAND_MEDIA_CHANNEL_UP : return "media-channel-up";
|
||||
case APPCOMMAND_MEDIA_CHANNEL_DOWN : return "media-channel-down";
|
||||
case APPCOMMAND_DELETE : return "delete";
|
||||
case APPCOMMAND_DICTATE_OR_COMMAND_CONTROL_TOGGLE:
|
||||
return "dictate-or-command-control-toggle";
|
||||
default:
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
class NativeWindowClientView : public views::ClientView {
|
||||
public:
|
||||
NativeWindowClientView(views::Widget* widget,
|
||||
@@ -186,7 +122,8 @@ NativeWindowViews::NativeWindowViews(
|
||||
// will not allow us to resize the window larger than scree.
|
||||
// Setting directly to INT_MAX somehow doesn't work, so we just devide
|
||||
// by 10, which should still be large enough.
|
||||
maximum_size_.SetSize(INT_MAX / 10, INT_MAX / 10);
|
||||
SetContentSizeConstraints(extensions::SizeConstraints(
|
||||
gfx::Size(), gfx::Size(INT_MAX / 10, INT_MAX / 10)));
|
||||
|
||||
int width = 800, height = 600;
|
||||
options.Get(switches::kWidth, &width);
|
||||
@@ -271,11 +208,6 @@ NativeWindowViews::NativeWindowViews(
|
||||
set_background(views::Background::CreateStandardPanelBackground());
|
||||
AddChildView(web_view_);
|
||||
|
||||
if (has_frame() &&
|
||||
options.Get(switches::kUseContentSize, &use_content_size_) &&
|
||||
use_content_size_)
|
||||
bounds = ContentBoundsToWindowBounds(bounds);
|
||||
|
||||
#if defined(OS_WIN)
|
||||
// Save initial window state.
|
||||
if (fullscreen)
|
||||
@@ -283,6 +215,8 @@ NativeWindowViews::NativeWindowViews(
|
||||
else
|
||||
last_window_state_ = ui::SHOW_STATE_NORMAL;
|
||||
|
||||
last_normal_size_ = gfx::Size(widget_size_);
|
||||
|
||||
if (!has_frame()) {
|
||||
// Set Window style so that we get a minimize and maximize animation when
|
||||
// frameless.
|
||||
@@ -314,8 +248,14 @@ NativeWindowViews::NativeWindowViews(
|
||||
if (transparent() && !has_frame())
|
||||
wm::SetShadowType(GetNativeWindow(), wm::SHADOW_TYPE_NONE);
|
||||
|
||||
gfx::Size size = bounds.size();
|
||||
if (has_frame() &&
|
||||
options.Get(switches::kUseContentSize, &use_content_size_) &&
|
||||
use_content_size_)
|
||||
size = ContentSizeToWindowSize(size);
|
||||
|
||||
window_->UpdateWindowIcon();
|
||||
window_->CenterWindow(bounds.size());
|
||||
window_->CenterWindow(size);
|
||||
Layout();
|
||||
}
|
||||
|
||||
@@ -351,7 +291,7 @@ void NativeWindowViews::ShowInactive() {
|
||||
}
|
||||
|
||||
void NativeWindowViews::Hide() {
|
||||
web_contents()->WasHidden();
|
||||
window_->Hide();
|
||||
}
|
||||
|
||||
bool NativeWindowViews::IsVisible() {
|
||||
@@ -438,42 +378,23 @@ gfx::Rect NativeWindowViews::GetBounds() {
|
||||
return window_->GetWindowBoundsInScreen();
|
||||
}
|
||||
|
||||
void NativeWindowViews::SetContentSize(const gfx::Size& size) {
|
||||
if (!has_frame()) {
|
||||
NativeWindow::SetSize(size);
|
||||
return;
|
||||
}
|
||||
|
||||
gfx::Rect bounds = window_->GetWindowBoundsInScreen();
|
||||
bounds.set_size(size);
|
||||
SetBounds(ContentBoundsToWindowBounds(bounds));
|
||||
}
|
||||
|
||||
gfx::Size NativeWindowViews::GetContentSize() {
|
||||
if (!has_frame())
|
||||
return GetSize();
|
||||
#if defined(OS_WIN)
|
||||
if (IsMinimized())
|
||||
return NativeWindow::GetContentSize();
|
||||
#endif
|
||||
|
||||
gfx::Size content_size =
|
||||
window_->non_client_view()->frame_view()->GetBoundsForClientView().size();
|
||||
if (menu_bar_ && menu_bar_visible_)
|
||||
content_size.set_height(content_size.height() - kMenuBarHeight);
|
||||
return content_size;
|
||||
return web_view_->size();
|
||||
}
|
||||
|
||||
void NativeWindowViews::SetMinimumSize(const gfx::Size& size) {
|
||||
minimum_size_ = size;
|
||||
}
|
||||
|
||||
gfx::Size NativeWindowViews::GetMinimumSize() {
|
||||
return minimum_size_;
|
||||
}
|
||||
|
||||
void NativeWindowViews::SetMaximumSize(const gfx::Size& size) {
|
||||
maximum_size_ = size;
|
||||
}
|
||||
|
||||
gfx::Size NativeWindowViews::GetMaximumSize() {
|
||||
return maximum_size_;
|
||||
void NativeWindowViews::SetContentSizeConstraints(
|
||||
const extensions::SizeConstraints& size_constraints) {
|
||||
NativeWindow::SetContentSizeConstraints(size_constraints);
|
||||
window_->OnSizeConstraintsChanged();
|
||||
#if defined(USE_X11)
|
||||
if (resizable_)
|
||||
old_size_constraints_ = size_constraints;
|
||||
#endif
|
||||
}
|
||||
|
||||
void NativeWindowViews::SetResizable(bool resizable) {
|
||||
@@ -492,11 +413,13 @@ void NativeWindowViews::SetResizable(bool resizable) {
|
||||
// On Linux there is no "resizable" property of a window, we have to set
|
||||
// both the minimum and maximum size to the window size to achieve it.
|
||||
if (resizable) {
|
||||
SetMaximumSize(gfx::Size());
|
||||
SetMinimumSize(gfx::Size());
|
||||
SetContentSizeConstraints(old_size_constraints_);
|
||||
} else {
|
||||
SetMaximumSize(GetSize());
|
||||
SetMinimumSize(GetSize());
|
||||
old_size_constraints_ = GetContentSizeConstraints();
|
||||
resizable_ = false;
|
||||
gfx::Size content_size = GetContentSize();
|
||||
SetContentSizeConstraints(
|
||||
extensions::SizeConstraints(content_size, content_size));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -608,8 +531,24 @@ void NativeWindowViews::SetMenu(ui::MenuModel* menu_model) {
|
||||
|
||||
if (!menu_bar_autohide_) {
|
||||
SetMenuBarVisibility(true);
|
||||
if (use_content_size_)
|
||||
if (use_content_size_) {
|
||||
// Enlarge the size constraints for the menu.
|
||||
extensions::SizeConstraints constraints = GetContentSizeConstraints();
|
||||
if (constraints.HasMinimumSize()) {
|
||||
gfx::Size min_size = constraints.GetMinimumSize();
|
||||
min_size.set_height(min_size.height() + kMenuBarHeight);
|
||||
constraints.set_minimum_size(min_size);
|
||||
}
|
||||
if (constraints.HasMaximumSize()) {
|
||||
gfx::Size max_size = constraints.GetMaximumSize();
|
||||
max_size.set_height(max_size.height() + kMenuBarHeight);
|
||||
constraints.set_maximum_size(max_size);
|
||||
}
|
||||
SetContentSizeConstraints(constraints);
|
||||
|
||||
// Resize the window to make sure content size is not changed.
|
||||
SetContentSize(content_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -812,68 +751,47 @@ void NativeWindowViews::OnWidgetMove() {
|
||||
NotifyWindowMove();
|
||||
}
|
||||
|
||||
gfx::Size NativeWindowViews::ContentSizeToWindowSize(const gfx::Size& size) {
|
||||
if (!has_frame())
|
||||
return size;
|
||||
|
||||
gfx::Size window_size(size);
|
||||
#if defined(OS_WIN)
|
||||
bool NativeWindowViews::ExecuteWindowsCommand(int command_id) {
|
||||
std::string command = AppCommandToString(command_id);
|
||||
NotifyWindowExecuteWindowsCommand(command);
|
||||
return false;
|
||||
}
|
||||
gfx::Rect dpi_bounds =
|
||||
gfx::Rect(gfx::Point(), gfx::win::DIPToScreenSize(size));
|
||||
gfx::Rect window_bounds = gfx::win::ScreenToDIPRect(
|
||||
window_->non_client_view()->GetWindowBoundsForClientBounds(dpi_bounds));
|
||||
window_size = window_bounds.size();
|
||||
#endif
|
||||
|
||||
if (menu_bar_ && menu_bar_visible_)
|
||||
window_size.set_height(window_size.height() + kMenuBarHeight);
|
||||
return window_size;
|
||||
}
|
||||
|
||||
gfx::Size NativeWindowViews::WindowSizeToContentSize(const gfx::Size& size) {
|
||||
if (!has_frame())
|
||||
return size;
|
||||
|
||||
gfx::Size content_size(size);
|
||||
#if defined(OS_WIN)
|
||||
bool NativeWindowViews::PreHandleMSG(
|
||||
UINT message, WPARAM w_param, LPARAM l_param, LRESULT* result) {
|
||||
switch (message) {
|
||||
case WM_COMMAND:
|
||||
// Handle thumbar button click message.
|
||||
if (HIWORD(w_param) == THBN_CLICKED)
|
||||
return taskbar_host_.HandleThumbarButtonEvent(LOWORD(w_param));
|
||||
return false;
|
||||
case WM_SIZE:
|
||||
// Handle window state change.
|
||||
HandleSizeEvent(w_param, l_param);
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void NativeWindowViews::HandleSizeEvent(WPARAM w_param, LPARAM l_param) {
|
||||
// Here we handle the WM_SIZE event in order to figure out what is the current
|
||||
// window state and notify the user accordingly.
|
||||
switch (w_param) {
|
||||
case SIZE_MAXIMIZED:
|
||||
last_window_state_ = ui::SHOW_STATE_MAXIMIZED;
|
||||
NotifyWindowMaximize();
|
||||
break;
|
||||
case SIZE_MINIMIZED:
|
||||
last_window_state_ = ui::SHOW_STATE_MINIMIZED;
|
||||
NotifyWindowMinimize();
|
||||
break;
|
||||
case SIZE_RESTORED:
|
||||
if (last_window_state_ == ui::SHOW_STATE_NORMAL)
|
||||
return;
|
||||
|
||||
switch (last_window_state_) {
|
||||
case ui::SHOW_STATE_MAXIMIZED:
|
||||
last_window_state_ = ui::SHOW_STATE_NORMAL;
|
||||
NotifyWindowUnmaximize();
|
||||
break;
|
||||
case ui::SHOW_STATE_MINIMIZED:
|
||||
if (IsFullscreen()) {
|
||||
last_window_state_ = ui::SHOW_STATE_FULLSCREEN;
|
||||
NotifyWindowEnterFullScreen();
|
||||
} else {
|
||||
last_window_state_ = ui::SHOW_STATE_NORMAL;
|
||||
NotifyWindowRestore();
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
content_size = gfx::win::DIPToScreenSize(content_size);
|
||||
RECT rect;
|
||||
SetRectEmpty(&rect);
|
||||
HWND hwnd = GetAcceleratedWidget();
|
||||
DWORD style = ::GetWindowLong(hwnd, GWL_STYLE);
|
||||
DWORD ex_style = ::GetWindowLong(hwnd, GWL_EXSTYLE);
|
||||
AdjustWindowRectEx(&rect, style, FALSE, ex_style);
|
||||
content_size.set_width(content_size.width() - (rect.right - rect.left));
|
||||
content_size.set_height(content_size.height() - (rect.bottom - rect.top));
|
||||
content_size = gfx::win::ScreenToDIPSize(content_size);
|
||||
#endif
|
||||
|
||||
if (menu_bar_ && menu_bar_visible_)
|
||||
content_size.set_height(content_size.height() - kMenuBarHeight);
|
||||
return content_size;
|
||||
}
|
||||
|
||||
void NativeWindowViews::HandleKeyboardEvent(
|
||||
content::WebContents*,
|
||||
const content::NativeWebKeyboardEvent& event) {
|
||||
@@ -905,9 +823,6 @@ void NativeWindowViews::HandleKeyboardEvent(
|
||||
// When a single Alt is pressed:
|
||||
menu_bar_alt_pressed_ = true;
|
||||
} else if (event.type == blink::WebInputEvent::KeyUp && IsAltKey(event) &&
|
||||
#if defined(USE_X11)
|
||||
event.modifiers == 0 &&
|
||||
#endif
|
||||
menu_bar_alt_pressed_) {
|
||||
// When a single Alt is released right after a Alt is pressed:
|
||||
menu_bar_alt_pressed_ = false;
|
||||
@@ -918,6 +833,14 @@ void NativeWindowViews::HandleKeyboardEvent(
|
||||
}
|
||||
}
|
||||
|
||||
gfx::Size NativeWindowViews::GetMinimumSize() {
|
||||
return NativeWindow::GetMinimumSize();
|
||||
}
|
||||
|
||||
gfx::Size NativeWindowViews::GetMaximumSize() {
|
||||
return NativeWindow::GetMaximumSize();
|
||||
}
|
||||
|
||||
bool NativeWindowViews::AcceleratorPressed(const ui::Accelerator& accelerator) {
|
||||
return accelerator_util::TriggerAcceleratorTableCommand(
|
||||
&accelerator_table_, accelerator);
|
||||
@@ -940,26 +863,6 @@ void NativeWindowViews::RegisterAccelerators(ui::MenuModel* menu_model) {
|
||||
}
|
||||
}
|
||||
|
||||
gfx::Rect NativeWindowViews::ContentBoundsToWindowBounds(
|
||||
const gfx::Rect& bounds) {
|
||||
gfx::Point origin = bounds.origin();
|
||||
#if defined(OS_WIN)
|
||||
gfx::Rect dpi_bounds = gfx::win::DIPToScreenRect(bounds);
|
||||
gfx::Rect window_bounds = gfx::win::ScreenToDIPRect(
|
||||
window_->non_client_view()->GetWindowBoundsForClientBounds(dpi_bounds));
|
||||
#else
|
||||
gfx::Rect window_bounds =
|
||||
window_->non_client_view()->GetWindowBoundsForClientBounds(bounds);
|
||||
#endif
|
||||
// The window's position would also be changed, but we only want to change
|
||||
// the size.
|
||||
window_bounds.set_origin(origin);
|
||||
|
||||
if (menu_bar_ && menu_bar_visible_)
|
||||
window_bounds.set_height(window_bounds.height() + kMenuBarHeight);
|
||||
return window_bounds;
|
||||
}
|
||||
|
||||
ui::WindowShowState NativeWindowViews::GetRestoredState() {
|
||||
if (IsMaximized())
|
||||
return ui::SHOW_STATE_MAXIMIZED;
|
||||
|
||||
@@ -63,12 +63,9 @@ class NativeWindowViews : public NativeWindow,
|
||||
bool IsFullscreen() const override;
|
||||
void SetBounds(const gfx::Rect& bounds) override;
|
||||
gfx::Rect GetBounds() override;
|
||||
void SetContentSize(const gfx::Size& size) override;
|
||||
gfx::Size GetContentSize() override;
|
||||
void SetMinimumSize(const gfx::Size& size) override;
|
||||
gfx::Size GetMinimumSize() override;
|
||||
void SetMaximumSize(const gfx::Size& size) override;
|
||||
gfx::Size GetMaximumSize() override;
|
||||
void SetContentSizeConstraints(
|
||||
const extensions::SizeConstraints& size_constraints) override;
|
||||
void SetResizable(bool resizable) override;
|
||||
bool IsResizable() override;
|
||||
void SetAlwaysOnTop(bool top) override;
|
||||
@@ -140,20 +137,20 @@ class NativeWindowViews : public NativeWindow,
|
||||
#endif
|
||||
|
||||
// NativeWindow:
|
||||
gfx::Size ContentSizeToWindowSize(const gfx::Size& size) override;
|
||||
gfx::Size WindowSizeToContentSize(const gfx::Size& size) override;
|
||||
void HandleKeyboardEvent(
|
||||
content::WebContents*,
|
||||
const content::NativeWebKeyboardEvent& event) override;
|
||||
|
||||
// views::View:
|
||||
gfx::Size GetMinimumSize() override;
|
||||
gfx::Size GetMaximumSize() override;
|
||||
bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
|
||||
|
||||
// Register accelerators supported by the menu model.
|
||||
void RegisterAccelerators(ui::MenuModel* menu_model);
|
||||
|
||||
// Converts between client area and window area, since we include the menu bar
|
||||
// in client area we need to substract/add menu bar's height in convertions.
|
||||
gfx::Rect ContentBoundsToWindowBounds(const gfx::Rect& content_bounds);
|
||||
|
||||
// Returns the restore state for the window.
|
||||
ui::WindowShowState GetRestoredState();
|
||||
|
||||
@@ -170,12 +167,23 @@ class NativeWindowViews : public NativeWindow,
|
||||
|
||||
// Handles window state events.
|
||||
scoped_ptr<WindowStateWatcher> window_state_watcher_;
|
||||
|
||||
// The "resizable" flag on Linux is implemented by setting size constraints,
|
||||
// we need to make sure size constraints are restored when window becomes
|
||||
// resizable again.
|
||||
extensions::SizeConstraints old_size_constraints_;
|
||||
#elif defined(OS_WIN)
|
||||
// Weak ref.
|
||||
AtomDesktopWindowTreeHostWin* atom_desktop_window_tree_host_win_;
|
||||
|
||||
ui::WindowShowState last_window_state_;
|
||||
|
||||
// There's an issue with restore on Windows, that sometimes causes the Window
|
||||
// to receive the wrong size (#2498). To circumvent that, we keep tabs on the
|
||||
// size of the window while in the normal state (not maximized, minimized or
|
||||
// fullscreen), so we restore it correctly.
|
||||
gfx::Size last_normal_size_;
|
||||
|
||||
// In charge of running taskbar related APIs.
|
||||
TaskbarHost taskbar_host_;
|
||||
#endif
|
||||
@@ -189,8 +197,6 @@ class NativeWindowViews : public NativeWindow,
|
||||
bool use_content_size_;
|
||||
bool resizable_;
|
||||
std::string title_;
|
||||
gfx::Size minimum_size_;
|
||||
gfx::Size maximum_size_;
|
||||
gfx::Size widget_size_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(NativeWindowViews);
|
||||
|
||||
145
atom/browser/native_window_views_win.cc
Normal file
145
atom/browser/native_window_views_win.cc
Normal file
@@ -0,0 +1,145 @@
|
||||
// Copyright (c) 2015 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/browser/native_window_views.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace {
|
||||
|
||||
// Convert Win32 WM_APPCOMMANDS to strings.
|
||||
const char* AppCommandToString(int command_id) {
|
||||
switch (command_id) {
|
||||
case APPCOMMAND_BROWSER_BACKWARD : return "browser-backward";
|
||||
case APPCOMMAND_BROWSER_FORWARD : return "browser-forward";
|
||||
case APPCOMMAND_BROWSER_REFRESH : return "browser-refresh";
|
||||
case APPCOMMAND_BROWSER_STOP : return "browser-stop";
|
||||
case APPCOMMAND_BROWSER_SEARCH : return "browser-search";
|
||||
case APPCOMMAND_BROWSER_FAVORITES : return "browser-favorites";
|
||||
case APPCOMMAND_BROWSER_HOME : return "browser-home";
|
||||
case APPCOMMAND_VOLUME_MUTE : return "volume-mute";
|
||||
case APPCOMMAND_VOLUME_DOWN : return "volume-down";
|
||||
case APPCOMMAND_VOLUME_UP : return "volume-up";
|
||||
case APPCOMMAND_MEDIA_NEXTTRACK : return "media-nexttrack";
|
||||
case APPCOMMAND_MEDIA_PREVIOUSTRACK : return "media-previoustrack";
|
||||
case APPCOMMAND_MEDIA_STOP : return "media-stop";
|
||||
case APPCOMMAND_MEDIA_PLAY_PAUSE : return "media-play_pause";
|
||||
case APPCOMMAND_LAUNCH_MAIL : return "launch-mail";
|
||||
case APPCOMMAND_LAUNCH_MEDIA_SELECT : return "launch-media-select";
|
||||
case APPCOMMAND_LAUNCH_APP1 : return "launch-app1";
|
||||
case APPCOMMAND_LAUNCH_APP2 : return "launch-app2";
|
||||
case APPCOMMAND_BASS_DOWN : return "bass-down";
|
||||
case APPCOMMAND_BASS_BOOST : return "bass-boost";
|
||||
case APPCOMMAND_BASS_UP : return "bass-up";
|
||||
case APPCOMMAND_TREBLE_DOWN : return "treble-down";
|
||||
case APPCOMMAND_TREBLE_UP : return "treble-up";
|
||||
case APPCOMMAND_MICROPHONE_VOLUME_MUTE : return "microphone-volume-mute";
|
||||
case APPCOMMAND_MICROPHONE_VOLUME_DOWN : return "microphone-volume-down";
|
||||
case APPCOMMAND_MICROPHONE_VOLUME_UP : return "microphone-volume-up";
|
||||
case APPCOMMAND_HELP : return "help";
|
||||
case APPCOMMAND_FIND : return "find";
|
||||
case APPCOMMAND_NEW : return "new";
|
||||
case APPCOMMAND_OPEN : return "open";
|
||||
case APPCOMMAND_CLOSE : return "close";
|
||||
case APPCOMMAND_SAVE : return "save";
|
||||
case APPCOMMAND_PRINT : return "print";
|
||||
case APPCOMMAND_UNDO : return "undo";
|
||||
case APPCOMMAND_REDO : return "redo";
|
||||
case APPCOMMAND_COPY : return "copy";
|
||||
case APPCOMMAND_CUT : return "cut";
|
||||
case APPCOMMAND_PASTE : return "paste";
|
||||
case APPCOMMAND_REPLY_TO_MAIL : return "reply-to-mail";
|
||||
case APPCOMMAND_FORWARD_MAIL : return "forward-mail";
|
||||
case APPCOMMAND_SEND_MAIL : return "send-mail";
|
||||
case APPCOMMAND_SPELL_CHECK : return "spell-check";
|
||||
case APPCOMMAND_MIC_ON_OFF_TOGGLE : return "mic-on-off-toggle";
|
||||
case APPCOMMAND_CORRECTION_LIST : return "correction-list";
|
||||
case APPCOMMAND_MEDIA_PLAY : return "media-play";
|
||||
case APPCOMMAND_MEDIA_PAUSE : return "media-pause";
|
||||
case APPCOMMAND_MEDIA_RECORD : return "media-record";
|
||||
case APPCOMMAND_MEDIA_FAST_FORWARD : return "media-fast-forward";
|
||||
case APPCOMMAND_MEDIA_REWIND : return "media-rewind";
|
||||
case APPCOMMAND_MEDIA_CHANNEL_UP : return "media-channel-up";
|
||||
case APPCOMMAND_MEDIA_CHANNEL_DOWN : return "media-channel-down";
|
||||
case APPCOMMAND_DELETE : return "delete";
|
||||
case APPCOMMAND_DICTATE_OR_COMMAND_CONTROL_TOGGLE:
|
||||
return "dictate-or-command-control-toggle";
|
||||
default:
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
bool NativeWindowViews::ExecuteWindowsCommand(int command_id) {
|
||||
std::string command = AppCommandToString(command_id);
|
||||
NotifyWindowExecuteWindowsCommand(command);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool NativeWindowViews::PreHandleMSG(
|
||||
UINT message, WPARAM w_param, LPARAM l_param, LRESULT* result) {
|
||||
switch (message) {
|
||||
case WM_COMMAND:
|
||||
// Handle thumbar button click message.
|
||||
if (HIWORD(w_param) == THBN_CLICKED)
|
||||
return taskbar_host_.HandleThumbarButtonEvent(LOWORD(w_param));
|
||||
return false;
|
||||
case WM_SIZE:
|
||||
// Handle window state change.
|
||||
HandleSizeEvent(w_param, l_param);
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void NativeWindowViews::HandleSizeEvent(WPARAM w_param, LPARAM l_param) {
|
||||
// Here we handle the WM_SIZE event in order to figure out what is the current
|
||||
// window state and notify the user accordingly.
|
||||
switch (w_param) {
|
||||
case SIZE_MAXIMIZED:
|
||||
last_window_state_ = ui::SHOW_STATE_MAXIMIZED;
|
||||
NotifyWindowMaximize();
|
||||
break;
|
||||
case SIZE_MINIMIZED:
|
||||
last_window_state_ = ui::SHOW_STATE_MINIMIZED;
|
||||
NotifyWindowMinimize();
|
||||
break;
|
||||
case SIZE_RESTORED:
|
||||
if (last_window_state_ == ui::SHOW_STATE_NORMAL) {
|
||||
// Window was resized so we save it's new size.
|
||||
last_normal_size_ = GetSize();
|
||||
} else {
|
||||
switch (last_window_state_) {
|
||||
case ui::SHOW_STATE_MAXIMIZED:
|
||||
last_window_state_ = ui::SHOW_STATE_NORMAL;
|
||||
|
||||
// When the window is restored we resize it to the previous known
|
||||
// normal size.
|
||||
NativeWindow::SetSize(last_normal_size_);
|
||||
|
||||
NotifyWindowUnmaximize();
|
||||
break;
|
||||
case ui::SHOW_STATE_MINIMIZED:
|
||||
if (IsFullscreen()) {
|
||||
last_window_state_ = ui::SHOW_STATE_FULLSCREEN;
|
||||
NotifyWindowEnterFullScreen();
|
||||
} else {
|
||||
last_window_state_ = ui::SHOW_STATE_NORMAL;
|
||||
|
||||
// When the window is restored we resize it to the previous known
|
||||
// normal size.
|
||||
NativeWindow::SetSize(last_normal_size_);
|
||||
|
||||
NotifyWindowRestore();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
@@ -17,7 +17,7 @@
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>atom.icns</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>0.33.4</string>
|
||||
<string>0.33.7</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>10.8.0</string>
|
||||
<key>NSMainNibFile</key>
|
||||
|
||||
@@ -56,8 +56,8 @@ END
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 0,33,4,0
|
||||
PRODUCTVERSION 0,33,4,0
|
||||
FILEVERSION 0,33,7,0
|
||||
PRODUCTVERSION 0,33,7,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
@@ -74,12 +74,12 @@ BEGIN
|
||||
BEGIN
|
||||
VALUE "CompanyName", "GitHub, Inc."
|
||||
VALUE "FileDescription", "Electron"
|
||||
VALUE "FileVersion", "0.33.4"
|
||||
VALUE "FileVersion", "0.33.7"
|
||||
VALUE "InternalName", "electron.exe"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2015 GitHub, Inc. All rights reserved."
|
||||
VALUE "OriginalFilename", "electron.exe"
|
||||
VALUE "ProductName", "Electron"
|
||||
VALUE "ProductVersion", "0.33.4"
|
||||
VALUE "ProductVersion", "0.33.7"
|
||||
VALUE "SquirrelAwareVersion", "1"
|
||||
END
|
||||
END
|
||||
|
||||
@@ -104,11 +104,11 @@ gfx::Size FramelessView::GetPreferredSize() const {
|
||||
}
|
||||
|
||||
gfx::Size FramelessView::GetMinimumSize() const {
|
||||
return window_->GetMinimumSize();
|
||||
return window_->GetContentSizeConstraints().GetMinimumSize();
|
||||
}
|
||||
|
||||
gfx::Size FramelessView::GetMaximumSize() const {
|
||||
return window_->GetMaximumSize();
|
||||
return window_->GetContentSizeConstraints().GetMaximumSize();
|
||||
}
|
||||
|
||||
const char* FramelessView::GetClassName() const {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "atom/browser/ui/views/native_frame_view.h"
|
||||
|
||||
#include "atom/browser/native_window_views.h"
|
||||
#include "atom/browser/native_window.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
@@ -14,8 +14,7 @@ const char kViewClassName[] = "AtomNativeFrameView";
|
||||
|
||||
} // namespace
|
||||
|
||||
NativeFrameView::NativeFrameView(NativeWindowViews* window,
|
||||
views::Widget* widget)
|
||||
NativeFrameView::NativeFrameView(NativeWindow* window, views::Widget* widget)
|
||||
: views::NativeFrameView(widget),
|
||||
window_(window) {
|
||||
}
|
||||
|
||||
@@ -9,13 +9,13 @@
|
||||
|
||||
namespace atom {
|
||||
|
||||
class NativeWindowViews;
|
||||
class NativeWindow;
|
||||
|
||||
// Like the views::NativeFrameView, but returns the min/max size from the
|
||||
// NativeWindowViews.
|
||||
class NativeFrameView : public views::NativeFrameView {
|
||||
public:
|
||||
NativeFrameView(NativeWindowViews* window, views::Widget* widget);
|
||||
NativeFrameView(NativeWindow* window, views::Widget* widget);
|
||||
|
||||
protected:
|
||||
// views::View:
|
||||
@@ -24,7 +24,7 @@ class NativeFrameView : public views::NativeFrameView {
|
||||
const char* GetClassName() const override;
|
||||
|
||||
private:
|
||||
NativeWindowViews* window_; // weak ref.
|
||||
NativeWindow* window_; // weak ref.
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(NativeFrameView);
|
||||
};
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "atom/browser/ui/views/win_frame_view.h"
|
||||
|
||||
#include "atom/browser/native_window_views.h"
|
||||
#include "ui/gfx/win/dpi.h"
|
||||
#include "ui/views/widget/widget.h"
|
||||
#include "ui/views/win/hwnd_util.h"
|
||||
|
||||
@@ -39,16 +38,6 @@ int WinFrameView::NonClientHitTest(const gfx::Point& point) {
|
||||
return FramelessView::NonClientHitTest(point);
|
||||
}
|
||||
|
||||
gfx::Size WinFrameView::GetMinimumSize() const {
|
||||
gfx::Size size = FramelessView::GetMinimumSize();
|
||||
return gfx::win::DIPToScreenSize(size);
|
||||
}
|
||||
|
||||
gfx::Size WinFrameView::GetMaximumSize() const {
|
||||
gfx::Size size = FramelessView::GetMaximumSize();
|
||||
return gfx::win::DIPToScreenSize(size);
|
||||
}
|
||||
|
||||
const char* WinFrameView::GetClassName() const {
|
||||
return kViewClassName;
|
||||
}
|
||||
|
||||
@@ -20,8 +20,6 @@ class WinFrameView : public FramelessView {
|
||||
int NonClientHitTest(const gfx::Point& point) override;
|
||||
|
||||
// views::View:
|
||||
gfx::Size GetMinimumSize() const override;
|
||||
gfx::Size GetMaximumSize() const override;
|
||||
const char* GetClassName() const override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <X11/Xatom.h>
|
||||
|
||||
#include "base/environment.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "dbus/bus.h"
|
||||
#include "dbus/object_proxy.h"
|
||||
@@ -50,6 +51,10 @@ void SetWindowType(::Window xwindow, const std::string& type) {
|
||||
}
|
||||
|
||||
bool ShouldUseGlobalMenuBar() {
|
||||
scoped_ptr<base::Environment> env(base::Environment::Create());
|
||||
if (env->HasVar("ELECTRON_FORCE_WINDOW_MENU_BAR"))
|
||||
return false;
|
||||
|
||||
dbus::Bus::Options options;
|
||||
scoped_refptr<dbus::Bus> bus(new dbus::Bus(options));
|
||||
|
||||
|
||||
@@ -30,6 +30,12 @@ IPC_SYNC_MESSAGE_ROUTED2_1(AtomViewHostMsg_Message_Sync,
|
||||
base::ListValue /* arguments */,
|
||||
base::string16 /* result (in JSON) */)
|
||||
|
||||
IPC_MESSAGE_ROUTED1(AtomViewHostMsg_ZoomLevelChanged,
|
||||
double /* level */)
|
||||
|
||||
IPC_MESSAGE_ROUTED1(AtomViewMsg_SetZoomLevel,
|
||||
double /* level */)
|
||||
|
||||
IPC_MESSAGE_ROUTED2(AtomViewMsg_Message,
|
||||
base::string16 /* channel */,
|
||||
base::ListValue /* arguments */)
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
#include "atom/common/atom_version.h"
|
||||
#include "atom/common/chrome_version.h"
|
||||
@@ -40,7 +41,7 @@ void FatalErrorCallback(const char* location, const char* message) {
|
||||
}
|
||||
|
||||
void Log(const base::string16& message) {
|
||||
logging::LogMessage("CONSOLE", 0, 0).stream() << message;
|
||||
std::cout << message;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#define ATOM_MAJOR_VERSION 0
|
||||
#define ATOM_MINOR_VERSION 33
|
||||
#define ATOM_PATCH_VERSION 4
|
||||
#define ATOM_PATCH_VERSION 7
|
||||
|
||||
#define ATOM_VERSION_IS_RELEASE 1
|
||||
|
||||
|
||||
@@ -10,9 +10,10 @@ namespace atom {
|
||||
ui::KeyboardCode KeyboardCodeFromCharCode(char c, bool* shifted) {
|
||||
*shifted = false;
|
||||
switch (c) {
|
||||
case 8: case 0x7F: return ui::VKEY_BACK;
|
||||
case 9: return ui::VKEY_TAB;
|
||||
case 0xD: case 3: return ui::VKEY_RETURN;
|
||||
case 0x08: return ui::VKEY_BACK;
|
||||
case 0x7F: return ui::VKEY_DELETE;
|
||||
case 0x09: return ui::VKEY_TAB;
|
||||
case 0x0D: return ui::VKEY_RETURN;
|
||||
case 0x1B: return ui::VKEY_ESCAPE;
|
||||
case ' ': return ui::VKEY_SPACE;
|
||||
|
||||
|
||||
@@ -9,21 +9,8 @@ process.atomBinding = (name) ->
|
||||
catch e
|
||||
process.binding "atom_common_#{name}" if /No such module/.test e.message
|
||||
|
||||
# Global module search paths.
|
||||
globalPaths = Module.globalPaths
|
||||
|
||||
# Don't lookup modules in user-defined search paths, see http://git.io/vf8sF.
|
||||
homeDir =
|
||||
if process.platform is 'win32'
|
||||
process.env.USERPROFILE
|
||||
else
|
||||
process.env.HOME
|
||||
if homeDir # Node only add user-defined search paths when $HOME is defined.
|
||||
userModulePath = path.resolve homeDir, '.node_modules'
|
||||
globalPaths.splice globalPaths.indexOf(userModulePath), 2
|
||||
|
||||
# Add common/api/lib to module search paths.
|
||||
globalPaths.push path.resolve(__dirname, '..', 'api', 'lib')
|
||||
Module.globalPaths.push path.resolve(__dirname, '..', 'api', 'lib')
|
||||
|
||||
# setImmediate and process.nextTick makes use of uv_check and uv_prepare to
|
||||
# run the callbacks, however since we only run uv loop on requests, the
|
||||
|
||||
29
atom/common/lib/reset-search-paths.coffee
Normal file
29
atom/common/lib/reset-search-paths.coffee
Normal file
@@ -0,0 +1,29 @@
|
||||
path = require 'path'
|
||||
Module = require 'module'
|
||||
|
||||
# Clear Node's global search paths.
|
||||
Module.globalPaths.length = 0
|
||||
|
||||
# Clear current and parent(init.coffee)'s search paths.
|
||||
module.paths = []
|
||||
module.parent.paths = []
|
||||
|
||||
# Prevent Node from adding paths outside this app to search paths.
|
||||
Module._nodeModulePaths = (from) ->
|
||||
from = path.resolve from
|
||||
|
||||
# If "from" is outside the app then we do nothing.
|
||||
skipOutsidePaths = from.startsWith process.resourcesPath
|
||||
|
||||
# Following logoic is copied from module.js.
|
||||
splitRe = if process.platform is 'win32' then /[\/\\]/ else /\//
|
||||
paths = []
|
||||
|
||||
parts = from.split splitRe
|
||||
for part, tip in parts by -1
|
||||
continue if part is 'node_modules'
|
||||
dir = parts.slice(0, tip + 1).join path.sep
|
||||
break if skipOutsidePaths and not dir.startsWith process.resourcesPath
|
||||
paths.push path.join(dir, 'node_modules')
|
||||
|
||||
paths
|
||||
@@ -61,7 +61,7 @@ struct Converter<blink::WebInputEvent::Type> {
|
||||
else if (type == "mousewheel")
|
||||
*out = blink::WebInputEvent::MouseWheel;
|
||||
else if (type == "keydown")
|
||||
*out = blink::WebInputEvent::KeyDown;
|
||||
*out = blink::WebInputEvent::RawKeyDown;
|
||||
else if (type == "keyup")
|
||||
*out = blink::WebInputEvent::KeyUp;
|
||||
else if (type == "char")
|
||||
|
||||
@@ -20,7 +20,7 @@ void ShowItemInFolder(const base::FilePath& full_path) {
|
||||
DCHECK([NSThread isMainThread]);
|
||||
NSString* path_string = base::SysUTF8ToNSString(full_path.value());
|
||||
if (!path_string || ![[NSWorkspace sharedWorkspace] selectFile:path_string
|
||||
inFileViewerRootedAtPath:nil])
|
||||
inFileViewerRootedAtPath:@""])
|
||||
LOG(WARNING) << "NSWorkspace failed to select file " << full_path.value();
|
||||
}
|
||||
|
||||
|
||||
@@ -4,11 +4,13 @@
|
||||
|
||||
#include "atom/renderer/api/atom_api_web_frame.h"
|
||||
|
||||
#include "atom/common/api/api_messages.h"
|
||||
#include "atom/common/native_mate_converters/callback.h"
|
||||
#include "atom/common/native_mate_converters/gfx_converter.h"
|
||||
#include "atom/common/native_mate_converters/string16_converter.h"
|
||||
#include "atom/renderer/api/atom_api_spell_check_client.h"
|
||||
#include "content/public/renderer/render_frame.h"
|
||||
#include "content/public/renderer/render_view.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "native_mate/object_template_builder.h"
|
||||
#include "third_party/WebKit/public/web/WebDocument.h"
|
||||
@@ -34,6 +36,10 @@ void WebFrame::SetName(const std::string& name) {
|
||||
}
|
||||
|
||||
double WebFrame::SetZoomLevel(double level) {
|
||||
auto render_view = content::RenderView::FromWebView(web_frame_->view());
|
||||
// Notify guests if any for zoom level change.
|
||||
render_view->Send(
|
||||
new AtomViewHostMsg_ZoomLevelChanged(MSG_ROUTING_NONE, level));
|
||||
return web_frame_->view()->setZoomLevel(level);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "atom/common/api/api_messages.h"
|
||||
#include "atom/common/api/atom_bindings.h"
|
||||
#include "atom/common/node_bindings.h"
|
||||
#include "atom/common/node_includes.h"
|
||||
@@ -21,11 +22,13 @@
|
||||
#include "content/public/renderer/render_frame.h"
|
||||
#include "content/public/renderer/render_frame_observer.h"
|
||||
#include "content/public/renderer/render_thread.h"
|
||||
#include "ipc/ipc_message_macros.h"
|
||||
#include "third_party/WebKit/public/web/WebCustomElement.h"
|
||||
#include "third_party/WebKit/public/web/WebLocalFrame.h"
|
||||
#include "third_party/WebKit/public/web/WebPluginParams.h"
|
||||
#include "third_party/WebKit/public/web/WebKit.h"
|
||||
#include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
|
||||
#include "third_party/WebKit/public/web/WebView.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include <shlobj.h>
|
||||
@@ -64,6 +67,22 @@ class AtomRenderFrameObserver : public content::RenderFrameObserver {
|
||||
render_frame()->GetWebFrame(), context);
|
||||
}
|
||||
|
||||
bool OnMessageReceived(const IPC::Message& message) {
|
||||
bool handled = true;
|
||||
IPC_BEGIN_MESSAGE_MAP(AtomRenderFrameObserver, message)
|
||||
IPC_MESSAGE_HANDLER(AtomViewMsg_SetZoomLevel, OnSetZoomLevel)
|
||||
IPC_MESSAGE_UNHANDLED(handled = false)
|
||||
IPC_END_MESSAGE_MAP()
|
||||
|
||||
return handled;
|
||||
}
|
||||
|
||||
void OnSetZoomLevel(double level) {
|
||||
auto view = render_frame()->GetWebFrame()->view();
|
||||
if (view)
|
||||
view->setZoomLevel(level);
|
||||
}
|
||||
|
||||
private:
|
||||
AtomRendererClient* renderer_client_;
|
||||
|
||||
|
||||
@@ -7,16 +7,16 @@ Module = require 'module'
|
||||
# atom-renderer.js, we need to restore it here.
|
||||
process.argv.splice 1, 1
|
||||
|
||||
# Clear search paths.
|
||||
require path.resolve(__dirname, '..', '..', 'common', 'lib', 'reset-search-paths')
|
||||
|
||||
# Import common settings.
|
||||
require path.resolve(__dirname, '..', '..', 'common', 'lib', 'init')
|
||||
|
||||
# Add renderer/api/lib to require's search paths, which contains javascript part
|
||||
# of Atom's built-in libraries.
|
||||
globalPaths = Module.globalPaths
|
||||
globalPaths.push path.resolve(__dirname, '..', 'api', 'lib')
|
||||
# And also app.
|
||||
globalPaths.push path.join(process.resourcesPath, 'app')
|
||||
globalPaths.push path.join(process.resourcesPath, 'app.asar')
|
||||
|
||||
# Import common settings.
|
||||
require path.resolve(__dirname, '..', '..', 'common', 'lib', 'init')
|
||||
|
||||
# The global variable will be used by ipc for event dispatching
|
||||
v8Util = process.atomBinding 'v8_util'
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
// Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "extensions/browser/app_window/size_constraints.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "ui/gfx/geometry/insets.h"
|
||||
|
||||
namespace extensions {
|
||||
|
||||
SizeConstraints::SizeConstraints()
|
||||
: maximum_size_(kUnboundedSize, kUnboundedSize) {}
|
||||
|
||||
SizeConstraints::SizeConstraints(const gfx::Size& min_size,
|
||||
const gfx::Size& max_size)
|
||||
: minimum_size_(min_size), maximum_size_(max_size) {}
|
||||
|
||||
SizeConstraints::~SizeConstraints() {}
|
||||
|
||||
// static
|
||||
gfx::Size SizeConstraints::AddFrameToConstraints(
|
||||
const gfx::Size& size_constraints,
|
||||
const gfx::Insets& frame_insets) {
|
||||
return gfx::Size(
|
||||
size_constraints.width() == kUnboundedSize
|
||||
? kUnboundedSize
|
||||
: size_constraints.width() + frame_insets.width(),
|
||||
size_constraints.height() == kUnboundedSize
|
||||
? kUnboundedSize
|
||||
: size_constraints.height() + frame_insets.height());
|
||||
}
|
||||
|
||||
gfx::Size SizeConstraints::ClampSize(gfx::Size size) const {
|
||||
const gfx::Size max_size = GetMaximumSize();
|
||||
if (max_size.width() != kUnboundedSize)
|
||||
size.set_width(std::min(size.width(), max_size.width()));
|
||||
if (max_size.height() != kUnboundedSize)
|
||||
size.set_height(std::min(size.height(), max_size.height()));
|
||||
size.SetToMax(GetMinimumSize());
|
||||
return size;
|
||||
}
|
||||
|
||||
bool SizeConstraints::HasMinimumSize() const {
|
||||
const gfx::Size min_size = GetMinimumSize();
|
||||
return min_size.width() != kUnboundedSize ||
|
||||
min_size.height() != kUnboundedSize;
|
||||
}
|
||||
|
||||
bool SizeConstraints::HasMaximumSize() const {
|
||||
const gfx::Size max_size = GetMaximumSize();
|
||||
return max_size.width() != kUnboundedSize ||
|
||||
max_size.height() != kUnboundedSize;
|
||||
}
|
||||
|
||||
bool SizeConstraints::HasFixedSize() const {
|
||||
return !GetMinimumSize().IsEmpty() && GetMinimumSize() == GetMaximumSize();
|
||||
}
|
||||
|
||||
gfx::Size SizeConstraints::GetMinimumSize() const {
|
||||
return minimum_size_;
|
||||
}
|
||||
|
||||
gfx::Size SizeConstraints::GetMaximumSize() const {
|
||||
return gfx::Size(
|
||||
maximum_size_.width() == kUnboundedSize
|
||||
? kUnboundedSize
|
||||
: std::max(maximum_size_.width(), minimum_size_.width()),
|
||||
maximum_size_.height() == kUnboundedSize
|
||||
? kUnboundedSize
|
||||
: std::max(maximum_size_.height(), minimum_size_.height()));
|
||||
}
|
||||
|
||||
void SizeConstraints::set_minimum_size(const gfx::Size& min_size) {
|
||||
minimum_size_ = min_size;
|
||||
}
|
||||
|
||||
void SizeConstraints::set_maximum_size(const gfx::Size& max_size) {
|
||||
maximum_size_ = max_size;
|
||||
}
|
||||
|
||||
} // namespace extensions
|
||||
@@ -0,0 +1,57 @@
|
||||
// Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef EXTENSIONS_BROWSER_APP_WINDOW_SIZE_CONSTRAINTS_H_
|
||||
#define EXTENSIONS_BROWSER_APP_WINDOW_SIZE_CONSTRAINTS_H_
|
||||
|
||||
#include "ui/gfx/geometry/size.h"
|
||||
|
||||
namespace gfx {
|
||||
class Insets;
|
||||
}
|
||||
|
||||
namespace extensions {
|
||||
|
||||
class SizeConstraints {
|
||||
public:
|
||||
// The value SizeConstraints uses to represent an unbounded width or height.
|
||||
// This is an enum so that it can be declared inline here.
|
||||
enum { kUnboundedSize = 0 };
|
||||
|
||||
SizeConstraints();
|
||||
SizeConstraints(const gfx::Size& min_size, const gfx::Size& max_size);
|
||||
~SizeConstraints();
|
||||
|
||||
// Adds frame insets to a size constraint.
|
||||
static gfx::Size AddFrameToConstraints(const gfx::Size& size_constraints,
|
||||
const gfx::Insets& frame_insets);
|
||||
|
||||
// Returns the bounds with its size clamped to the min/max size.
|
||||
gfx::Size ClampSize(gfx::Size size) const;
|
||||
|
||||
// When gfx::Size is used as a min/max size, a zero represents an unbounded
|
||||
// component. This method checks whether either component is specified.
|
||||
// Note we can't use gfx::Size::IsEmpty as it returns true if either width
|
||||
// or height is zero.
|
||||
bool HasMinimumSize() const;
|
||||
bool HasMaximumSize() const;
|
||||
|
||||
// This returns true if all components are specified, and min and max are
|
||||
// equal.
|
||||
bool HasFixedSize() const;
|
||||
|
||||
gfx::Size GetMaximumSize() const;
|
||||
gfx::Size GetMinimumSize() const;
|
||||
|
||||
void set_minimum_size(const gfx::Size& min_size);
|
||||
void set_maximum_size(const gfx::Size& max_size);
|
||||
|
||||
private:
|
||||
gfx::Size minimum_size_;
|
||||
gfx::Size maximum_size_;
|
||||
};
|
||||
|
||||
} // namespace extensions
|
||||
|
||||
#endif // EXTENSIONS_BROWSER_APP_WINDOW_SIZE_CONSTRAINTS_H_
|
||||
@@ -1,32 +1,33 @@
|
||||
## Guías
|
||||
|
||||
* [Distribución de aplicaciones](tutorial/application-distribution.md)
|
||||
* [Empaquetamiento de aplicaciones](tutorial/application-packaging.md)
|
||||
* [Utilizando módulos nativos](tutorial/using-native-node-modules.md)
|
||||
* [Depurando el proceso principal](tutorial/debugging-main-process.md)
|
||||
* [Platfaformas Soportadas](tutorial/supported-platforms.md)
|
||||
* [Distribución de la Aplicacion](tutorial/application-distribution.md)
|
||||
* [Empaquetamiento de la Aplicacion](tutorial/application-packaging.md)
|
||||
* [Utilizando Módulos Node Nativos](tutorial/using-native-node-modules.md)
|
||||
* [Depurando el Proceso Principal](tutorial/debugging-main-process.md)
|
||||
* [Utilizando Selenium y WebDriver](tutorial/using-selenium-and-webdriver.md)
|
||||
* [Extensión DevTools](tutorial/devtools-extension.md)
|
||||
* [Utilizando el plugin pepper flash](tutorial/using-pepper-flash-plugin.md)
|
||||
* [Utilizando el plugin Pepper Flash](tutorial/using-pepper-flash-plugin.md)
|
||||
|
||||
## Tutoriales
|
||||
|
||||
* [Introducción](../../docs/tutorial/quick-start.md)
|
||||
* [Integración con el entorno de escritorio](../../docs/tutorial/desktop-environment-integration.md)
|
||||
* [Detección del evento en línea/fuera de línea](../../docs/tutorial/online-offline-events.md)
|
||||
* [Introducción](tutorial/quick-start.md)
|
||||
* [Integración con el entorno de escritorio](tutorial/desktop-environment-integration.md)
|
||||
* [Detección del evento en línea/fuera de línea](tutorial/online-offline-events.md)
|
||||
|
||||
## API
|
||||
## Referencias a la API
|
||||
|
||||
* [Sinopsis](../../docs/api/synopsis.md)
|
||||
* [Proceso](../../docs/api/process.md)
|
||||
* [Parámetros CLI soportados (Chrome)](../../docs/api/chrome-command-line-switches.md)
|
||||
* [Sinopsis](api/synopsis.md)
|
||||
* [Proceso](api/process.md)
|
||||
* [Parámetros CLI soportados (Chrome)](api/chrome-command-line-switches.md)
|
||||
|
||||
Elementos DOM customizados:
|
||||
### Elementos DOM personalizados:
|
||||
|
||||
* [Objeto `File`](../../docs/api/file-object.md)
|
||||
* [Etiqueta `<webview>`](../../docs/api/web-view-tag.md)
|
||||
* [Función `window.open`](../../docs/api/window-open.md)
|
||||
|
||||
Módulos del proceso principal:
|
||||
### Módulos del Proceso Principal:
|
||||
|
||||
* [app](../../docs/api/app.md)
|
||||
* [auto-updater](../../docs/api/auto-updater.md)
|
||||
@@ -34,21 +35,23 @@ Módulos del proceso principal:
|
||||
* [content-tracing](../../docs/api/content-tracing.md)
|
||||
* [dialog](../../docs/api/dialog.md)
|
||||
* [global-shortcut](../../docs/api/global-shortcut.md)
|
||||
* [ipc (main process)](../../docs/api/ipc-main-process.md)
|
||||
* [ipc (proceso principal)](../../docs/api/ipc-main-process.md)
|
||||
* [menu](../../docs/api/menu.md)
|
||||
* [menu-item](../../docs/api/menu-item.md)
|
||||
* [power-monitor](../../docs/api/power-monitor.md)
|
||||
* [power-save-blocker](../../docs/api/power-save-blocker.md)
|
||||
* [protocol](../../docs/api/protocol.md)
|
||||
* [session](../../docs/api/session.md)
|
||||
* [web-contents](../../docs/api/web-contents.md)
|
||||
* [tray](../../docs/api/tray.md)
|
||||
|
||||
Módulos del renderer (página web):
|
||||
### Módulos del proceso de renderizado (Página Web):
|
||||
|
||||
* [ipc (renderer)](../../docs/api/ipc-renderer.md)
|
||||
* [ipc (renderizador)](../../docs/api/ipc-renderer.md)
|
||||
* [remote](../../docs/api/remote.md)
|
||||
* [web-frame](../../docs/api/web-frame.md)
|
||||
|
||||
Módulos de ambos procesos:
|
||||
### Módulos de Ambos Procesos:
|
||||
|
||||
* [clipboard](../../docs/api/clipboard.md)
|
||||
* [crash-reporter](../../docs/api/crash-reporter.md)
|
||||
@@ -58,11 +61,11 @@ Módulos de ambos procesos:
|
||||
|
||||
## Desarrollo
|
||||
|
||||
* [Guía de estilo](../../docs/development/coding-style.md)
|
||||
* [Estructura de directorio](../../docs/development/source-code-directory-structure.md)
|
||||
* [Diferencias técnicas con NW.js (anteriormente conocido como node-webkit)](../../docs/development/atom-shell-vs-node-webkit.md)
|
||||
* [Sistema de compilación](../../docs/development/build-system-overview.md)
|
||||
* [Instrucciones de compilación (Mac)](../../docs/development/build-instructions-osx.md)
|
||||
* [Instrucciones de compilación (Windows)](../../docs/development/build-instructions-windows.md)
|
||||
* [Instrucciones de compilación (Linux)](../../docs/development/build-instructions-linux.md)
|
||||
* [Configurando un servidor de símbolos en el depurador](../../docs/development/setting-up-symbol-server.md)
|
||||
* [Guía de Estilo](development/coding-style.md)
|
||||
* [Estructura de los directorios del Código Fuente](../../development/source-code-directory-structure.md)
|
||||
* [Diferencias Técnicas con NW.js (anteriormente conocido como node-webkit)](../../development/atom-shell-vs-node-webkit.md)
|
||||
* [Repaso del Sistema de Compilación](../../development/build-system-overview.md)
|
||||
* [Instrucciones de Compilación (Mac)](../../development/build-instructions-osx.md)
|
||||
* [Instrucciones de Compilación (Windows)](../../development/build-instructions-windows.md)
|
||||
* [Instrucciones de Compilación (Linux)](../../development/build-instructions-linux.md)
|
||||
* [Configurando un Servidor de Símbolos en el depurador](../../development/setting-up-symbol-server.md)
|
||||
|
||||
119
docs-translations/es/api/chrome-command-line-switches.md
Normal file
119
docs-translations/es/api/chrome-command-line-switches.md
Normal file
@@ -0,0 +1,119 @@
|
||||
# Parámetros CLI soportados (Chrome)
|
||||
|
||||
Esta página lista las líneas de comandos usadas por el navegador Chrome que también son
|
||||
soportadas por Electron. Puedes usar [app.commandLine.appendSwitch][append-switch] para
|
||||
anexarlas en el script principal de tu aplicación antes de que el evento [ready][ready] del
|
||||
modulo [app][app] sea emitido:
|
||||
|
||||
```javascript
|
||||
var app = require('app');
|
||||
app.commandLine.appendSwitch('remote-debugging-port', '8315');
|
||||
app.commandLine.appendSwitch('host-rules', 'MAP * 127.0.0.1');
|
||||
|
||||
app.on('ready', function() {
|
||||
// Your code here
|
||||
});
|
||||
```
|
||||
|
||||
## --client-certificate=`path`
|
||||
|
||||
Establece el `path` del archivo de certificado del cliente.
|
||||
|
||||
## --ignore-connections-limit=`domains`
|
||||
|
||||
Ignora el límite de conexiones para la lista de `domains` separados por `,`.
|
||||
|
||||
## --disable-http-cache
|
||||
|
||||
Deshabilita la cacheé del disco para las peticiones HTTP.
|
||||
|
||||
## --remote-debugging-port=`port`
|
||||
|
||||
Habilita la depuración remota a través de HTTP en el puerto especificado.
|
||||
|
||||
## --proxy-server=`address:port`
|
||||
|
||||
Usa un servidor proxy especificado, que sobreescribe la configuración del sistema.
|
||||
Este cambio solo afecta peticiones HTTP y HTTPS.
|
||||
|
||||
## --proxy-pac-url=`url`
|
||||
|
||||
Utiliza el script PAC en la `url` especificada.
|
||||
|
||||
## --no-proxy-server
|
||||
|
||||
No usa un servidor proxy y siempre establece conexiones directas. Anula cualquier
|
||||
otra bandera de servidor proxy bandera que se pase.
|
||||
|
||||
## --host-rules=`rules`
|
||||
|
||||
Una lista separada por comas de `rules` (reglas) que controlan cómo se asignan los
|
||||
nombres de host.
|
||||
|
||||
Por ejemplo:
|
||||
|
||||
* `MAP * 127.0.0.1` Obliga a todos los nombres de host a ser asignados a 127.0.0.1
|
||||
* `MAP *.google.com proxy` Obliga todos los subdominios google.com a resolverse con
|
||||
"proxy".
|
||||
* `MAP test.com [::1]:77` Obliga a resolver "test.com" con un bucle invertido de IPv6.
|
||||
También obligará a que el puerto de la dirección respuesta sea 77.
|
||||
* `MAP * baz, EXCLUDE www.google.com` Reasigna todo a "baz", excepto a "www.google.com".
|
||||
|
||||
Estas asignaciones especifican el host final en una petición de red (Anfitrión de la conexión TCP
|
||||
y de resolución de conexión directa, y el `CONNECT` en una conexión proxy HTTP, y el host final de
|
||||
la conexión proxy `SOCKS`).
|
||||
|
||||
## --host-resolver-rules=`rules`
|
||||
|
||||
Como `--host-rules` pero estas `rules` solo se aplican al solucionador.
|
||||
|
||||
[app]: app.md
|
||||
[append-switch]: app.md#appcommandlineappendswitchswitch-value
|
||||
[ready]: app.md#event-ready
|
||||
|
||||
## --ignore-certificate-errors
|
||||
|
||||
Ignora errores de certificado relacionados.
|
||||
|
||||
## --ppapi-flash-path=`path`
|
||||
|
||||
Asigna la ruta `path` del pepper flash plugin.
|
||||
|
||||
## --ppapi-flash-version=`version`
|
||||
|
||||
Asigna la versión `version` del pepper flash plugin.
|
||||
|
||||
## --log-net-log=`path`
|
||||
|
||||
Permite guardar y escribir eventos de registros de red en `path`.
|
||||
|
||||
## --ssl-version-fallback-min=`version`
|
||||
|
||||
Establece la versión mínima de SSL/TLS ("tls1", "tls1.1" o "tls1.2") que
|
||||
el repliegue de TLC aceptará.
|
||||
|
||||
## --enable-logging
|
||||
|
||||
Imprime el registro de Chromium en consola.
|
||||
|
||||
Este cambio no puede ser usado en `app.commandLine.appendSwitch` ya que se analiza antes de que la
|
||||
aplicación del usuario este cargada.
|
||||
|
||||
## --v=`log_level`
|
||||
|
||||
Da el maximo nivel activo de V-logging por defecto; 0 es el predeterminado. Valores positivos
|
||||
son normalmente usados para los niveles de V-logging.
|
||||
|
||||
Este modificador sólo funciona cuando también se pasa `--enable-logging`.
|
||||
|
||||
## --vmodule=`pattern`
|
||||
|
||||
Da los niveles máximos de V-logging por módulo para sobreescribir el valor dado por
|
||||
`--v`. Ej. `my_module=2,foo*=3` cambiaria el nivel de registro para todo el código
|
||||
el archivos de origen `my_module.*` y `foo*.*`.
|
||||
|
||||
Cualquier patron que contiene un slash o un slash invertido será probado contra toda la ruta
|
||||
y no sólo con el módulo. Ej. `*/foo/bar/*=2` cambiaría el nivel de registro para todo el código
|
||||
en los archivos origen bajo un directorio `foo/bar`.
|
||||
|
||||
Este modificador sólo funciona cuando también se pasa `--enable-logging`.
|
||||
47
docs-translations/es/api/process.md
Normal file
47
docs-translations/es/api/process.md
Normal file
@@ -0,0 +1,47 @@
|
||||
# process
|
||||
|
||||
El objeto `process` en Electron tiene las siguientes diferencias con respecto
|
||||
al node convencional:
|
||||
|
||||
* `process.type` String - El tipo del proceso puede ser `browser` (ej. proceso
|
||||
principal) o `renderer`.
|
||||
* `process.versions['electron']` String - Versión de Electron.
|
||||
* `process.versions['chrome']` String - Versión de Chromium.
|
||||
* `process.resourcesPath` String - Ruta al código fuente JavaScript.
|
||||
|
||||
## Events
|
||||
|
||||
### Event: 'loaded'
|
||||
|
||||
Se emite cuando Electron ha cargado su script de inicialización interna y
|
||||
está comenzando a cargar la página web o el script principal.
|
||||
|
||||
Puede ser usado por el script precargado para añadir de nuevo los símbolos globales
|
||||
de Node eliminados, al alcance global cuando la integración de Node está apagada:
|
||||
|
||||
```js
|
||||
// preload.js
|
||||
var _setImmediate = setImmediate;
|
||||
var _clearImmediate = clearImmediate;
|
||||
process.once('loaded', function() {
|
||||
global.setImmediate = _setImmediate;
|
||||
global.clearImmediate = _clearImmediate;
|
||||
});
|
||||
```
|
||||
|
||||
## Methods
|
||||
|
||||
El objeto `process` tiene los siguientes métodos:
|
||||
|
||||
### `process.hang`
|
||||
|
||||
Interrumpe el hilo principal del proceso actual.
|
||||
|
||||
|
||||
### process.setFdLimit(maxDescriptors) _OS X_ _Linux_
|
||||
|
||||
* `maxDescriptors` Integer
|
||||
|
||||
Establece el límite dinámico del descriptor del archivo en `maxDescriptors`
|
||||
o en el límite estricto del Sistema Operativo, el que sea menor para el
|
||||
proceso actual.
|
||||
47
docs-translations/es/api/synopsis.md
Normal file
47
docs-translations/es/api/synopsis.md
Normal file
@@ -0,0 +1,47 @@
|
||||
# Synopsis
|
||||
|
||||
Todos los [Módulos integrados de Node.js](http://nodejs.org/api/) se encuentran
|
||||
disponibles en Electron y módulos de terceros son támbien totalmente compatibles
|
||||
(incluyendo los [módulos nativos](../tutorial/using-native-node-modules.md)).
|
||||
|
||||
Electron también provee algunos módulos integrados adicionales para desarrollar
|
||||
aplicaciones nativas de escritorio. Algunos módulos sólo se encuentran disponibles
|
||||
en el proceso principal, algunos sólo en el proceso renderer (pagina web), y
|
||||
algunos pueden ser usados en ambos procesos.
|
||||
|
||||
La regla básica es: Si un módulo es
|
||||
[GUI](https://es.wikipedia.org/wiki/Interfaz_gráfica_de_usuario) o de bajo nivel,
|
||||
entonces solo estará disponible en el proceso principal. Necesitas familiarizarte
|
||||
con el concepto de [scripts para proceso principal vs scripts para proceso renderer]
|
||||
(../tutorial/quick-start.md#the-main-process) para ser capaz de usar esos módulos.
|
||||
|
||||
El script del proceso principal es como un script normal de Node.js:
|
||||
|
||||
```javascript
|
||||
var app = require('app');
|
||||
var BrowserWindow = require('browser-window');
|
||||
|
||||
var window = null;
|
||||
|
||||
app.on('ready', function() {
|
||||
window = new BrowserWindow({width: 800, height: 600});
|
||||
window.loadUrl('https://github.com');
|
||||
});
|
||||
```
|
||||
|
||||
El proceso renderer no es diferente de una página web normal, excepto por la
|
||||
capacidad extra de utilizar módulos de node:
|
||||
|
||||
```html
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
<script>
|
||||
var remote = require('remote');
|
||||
console.log(remote.require('app').getVersion());
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
Para ejecutar tu aplicación, lee [Ejecutar la aplicación](../tutorial/quick-start.md#run-your-app).
|
||||
100
docs-translations/es/styleguide.md
Normal file
100
docs-translations/es/styleguide.md
Normal file
@@ -0,0 +1,100 @@
|
||||
# Gúia de estilo de Electron
|
||||
|
||||
Encuentra el apartado correcto para cada tarea: [leer la documentación de Electron](#reading-electron-documentation)
|
||||
o [escribir documentación para Electron](#writing-electron-documentation).
|
||||
|
||||
## Escribir Documentación para Electron
|
||||
|
||||
Estas son las maneras en las que construimos la documentación de Electron.
|
||||
|
||||
- Máximo un título `h1` por página.
|
||||
- Utilizar `bash` en lugar de `cmd` en los bloques de código (por el resaltado
|
||||
de sintaxis).
|
||||
- Los títulos `h1` en el documento deben corresponder al nombre del objeto
|
||||
(ej. `browser-window` → `BrowserWindow`).
|
||||
- Archivos separados por guiones, mas sin embargo, es correcto.
|
||||
- No subtítulos seguidos por otros subtítulos, añadir por lo menos un enunciado
|
||||
de descripción.
|
||||
- Métodos de cabecera son delimitados con apóstrofes: `codigo`.
|
||||
- Cabeceras de Eventos son delimitados con 'comillas' simples.
|
||||
- No generar listas de mas de dos niveles (debido al renderizador de Markdown
|
||||
desafortunadamente).
|
||||
- Agregar títulos de sección: Eventos, Métodos de Clases y Métodos de Instancia.
|
||||
- Utilizar 'deberá' en lugar de 'debería' al describir resultados.
|
||||
- Eventos y Métodos son cabeceras `h3`.
|
||||
- Argumentos opcionales escritos como `function (required[, optional])`.
|
||||
- Argumentos opcionales son denotados cuando se llaman en listas.
|
||||
- Delimitador de línea de 80-columnas.
|
||||
- Métodos específicos de Plataformas son denotados en italicas seguidas por la cabecera del método.
|
||||
- ```### `method(foo, bar)` _OS X_```
|
||||
- Preferir 'en el ___ proceso' en lugar de 'sobre el'
|
||||
|
||||
### Traducciones de la Documentación
|
||||
|
||||
Traducciones de documentos de Electron se encuentran dentro del folder
|
||||
`docs-translations`.
|
||||
|
||||
Para agregar otro set (o un set parcial):
|
||||
|
||||
- Crear un subdirectorio nombrado igual a la abreviación del lenguaje.
|
||||
- Dentro de ese subdirectorio, duplicar el directorio de `docs`, manteniendo los
|
||||
mismos nombres de directorios y archivos.
|
||||
- Traducir los archivos.
|
||||
- Actualizar el `README.md` dentro del subdirectorio del lenguaje apuntando a
|
||||
los archivos que has traducido.
|
||||
- Agregar un enlace al folder de tu traducción en la sección principal Electron
|
||||
[README](https://github.com/atom/electron#documentation-translations).
|
||||
|
||||
## Leyendo la Documentación de Electron
|
||||
|
||||
Estos son algunos consejos para entender la syntaxis de la documentación de
|
||||
Electron.
|
||||
|
||||
### Métodos
|
||||
|
||||
Un ejemplo de la documentación del [método](https://developer.mozilla.org/en-US/docs/Glossary/Method):
|
||||
|
||||
---
|
||||
|
||||
`methodName(required[, optional]))`
|
||||
|
||||
* `require` String, **required**
|
||||
* `optional` Integer
|
||||
|
||||
---
|
||||
|
||||
El nombre del método es seguido por los argumentos que recibe. Argumentos
|
||||
opcionales son denotados por corchetes rodeados por el argumento opcional y la
|
||||
coma requerida si el argumento opcional fuera seguido por otro argumento.
|
||||
|
||||
Debajo del método se encuentra mas información detallada de cada uno de los
|
||||
argumentos. El tipo de argumento es denotado por los tipos comúnes:
|
||||
[`String`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String),
|
||||
[`Number`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number),
|
||||
[`Object`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object),
|
||||
[`Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)
|
||||
o un tipo personalizado como el [`webContent`](api/web-content.md) de Electron.
|
||||
|
||||
### Eventos
|
||||
|
||||
Un ejemplo de documentación del [evento](https://developer.mozilla.org/en-US/docs/Web/API/Event):
|
||||
|
||||
---
|
||||
|
||||
Event: 'wake-up'
|
||||
|
||||
Returns:
|
||||
|
||||
* `time` String
|
||||
|
||||
---
|
||||
|
||||
El evento es una cadena que es utilizada luego de un método observador `.on`. Si
|
||||
regresa un valor, el y su tipo son denotados abajo. Si se estaba a la escucha y
|
||||
respondió a este evento se debería ver así:
|
||||
|
||||
```javascript
|
||||
Alarm.on('wake-up', function(time) {
|
||||
console.log(time)
|
||||
})
|
||||
```
|
||||
@@ -1,10 +1,11 @@
|
||||
# Distribución de aplicaciones
|
||||
# Distribución de la Aplicación
|
||||
|
||||
Para distribuir tu aplicación con Electron, debes nombrar al directorio de tu aplicación
|
||||
como `app`, y ponerlo bajo el directorio de recursos de Electron (en OSX es `Electron.app/Contents/Resources/`,
|
||||
en Linux y Windows es `resources/`):
|
||||
Para distribuir tu aplicación con Electron, el directorio que contiene la
|
||||
aplicación deberá llamarse `app`, y ser colocado debajo del directorio de
|
||||
recursos de Electron (en OSX es `Electron.app/Contents/Resources/`, en Linux y
|
||||
Windows es `resources/`), de esta forma:
|
||||
|
||||
En OSX:
|
||||
En OS X:
|
||||
|
||||
```text
|
||||
electron/Electron.app/Contents/Resources/app/
|
||||
@@ -22,18 +23,19 @@ electron/resources/app
|
||||
└── index.html
|
||||
```
|
||||
|
||||
Posteriormente ejecutas `Electron.app` (o `electron` en Linux, `electron.exe` en Windows),
|
||||
y Electron iniciará la aplicación. El directorio `electron` será la distribución que recibirán los usuarios finales.
|
||||
Luego ejecutar `Electron.app` (o `electron` en Linux, `electron.exe` en Windows),
|
||||
y Electron será iniciado como tu aplicación. El directorio `electron` será
|
||||
entonces tu distribución que recibirán los usuarios finales.
|
||||
|
||||
## Empaquetando tu aplicación como un archivo
|
||||
## Empaquetando tu aplicación en un archivo
|
||||
|
||||
Además de copiar todos tus archivos fuente para la distribución, también puedes
|
||||
empaquetar tu aplicación como un archivo [asar](https://github.com/atom/asar)
|
||||
y de esta forma evitar la exposición del código fuente de tu aplicación a los usuarios.
|
||||
Además de distribuir tu aplicación al copiar todos los archivos de código fuente,
|
||||
también puedes empaquetar tu aplicación como un archivo [asar](https://github.com/atom/asar)
|
||||
y de esta forma evitar exponer del código fuente de tu aplicación a los usuarios.
|
||||
|
||||
Para usar un archivo `asar` en reemplazo de la carpeta `app`, debes renombrar
|
||||
el archivo a `app.asar`, y ponerlo bajo el directorio de recursos de Electron (como arriba),
|
||||
Electron intentará leer el archivo y ejecutar la aplicación desde él.
|
||||
Para utilizar un archivo `asar` en reemplazo del directorio `app`, debes de
|
||||
renombrar el archivo a `app.asar`, y colocarlo por debajo el directorio de recursos
|
||||
de Electron (ver en seguida), Electron intentará leer el archivo y arrancar desde el.
|
||||
|
||||
En OS X:
|
||||
|
||||
@@ -49,30 +51,33 @@ electron/resources/
|
||||
└── app.asar
|
||||
```
|
||||
|
||||
Más detalles en [Empaquetamiento de aplicaciones](application-packaging-es.md).
|
||||
Más detalles en [Empaquetado de Aplicaciones](application-packaging.md).
|
||||
|
||||
## Rebranding con binarios descargados
|
||||
## Redefinición con Binarios Descargados
|
||||
|
||||
Luego de empaquetar tu aplicación con Electron, podría ser útil agregar tu marca
|
||||
antes de realizar la distribución.
|
||||
Luego de empaquetar tu aplicación en Electron, querrás redefinir Electron antes
|
||||
de distribuirlo a los usuarios.
|
||||
|
||||
### Windows
|
||||
|
||||
Puedes renombrar `electron.exe` a cualquier nombre que desees, y editar su ícono y otras informaciones
|
||||
con herramientas como [rcedit](https://github.com/atom/rcedit) o [ResEdit](http://www.resedit.net).
|
||||
Puedes renombrar `electron.exe` a cualquier nombre que desees, y editar su ícono
|
||||
y otra información con herramientas como [rcedit](https://github.com/atom/rcedit)
|
||||
o [ResEdit](http://www.resedit.net).
|
||||
|
||||
### OS X
|
||||
### OSX
|
||||
|
||||
Puedes renombrar `Electron.app` a cualquier nombre que desees. También debes modificar los campos
|
||||
`CFBundleDisplayName`, `CFBundleIdentifier` y `CFBundleName` en los siguientes archivos:
|
||||
Puedes renombrar `Electron.app` a cualquier nombre que desees, y tendrás que
|
||||
renombrar los campos `CFBundleDisplayName`, `CFBundleIdentifier` y `CFBundleName`
|
||||
en los siguientes archivos:
|
||||
|
||||
* `Electron.app/Contents/Info.plist`
|
||||
* `Electron.app/Contents/Frameworks/Electron Helper.app/Contents/Info.plist`
|
||||
|
||||
También puedes renombrar el helper de la aplicación para evitar que aparezca como `Electron Helper`
|
||||
en el Monitor de Actividades.
|
||||
También puedes renombrar el helper de la aplicación para evitar que aparezca
|
||||
como `Electron Helper` en el Monitor de Actividades. Pero asegurate de renombrar
|
||||
el nombre de archivo del ejecutable.
|
||||
|
||||
La estructura de una aplicación renombrada sería así:
|
||||
La estructura de una aplicación renombrada será:
|
||||
|
||||
```
|
||||
MyApp.app/Contents
|
||||
@@ -98,17 +103,19 @@ MyApp.app/Contents
|
||||
|
||||
Puedes renombrar el ejectuable `electron` a cualquier nombre que desees.
|
||||
|
||||
## Rebranding desde el código fuente de Electron
|
||||
## Redefinición mediante la recompilación de Electron desde el código fuente
|
||||
|
||||
También es posible agregar tu marca a Electron mediante un build personalizado.
|
||||
Para realizar esto debes modificar el archivo `atom.gyp`.
|
||||
También es posible redefinir Electron cambiando el nombre del producto y
|
||||
compilandolo desde sus fuentes. Para realizar esto necesitas modificar el
|
||||
archivo `atom.gyp` y realizar una compilación desde cero.
|
||||
|
||||
### grunt-build-atom-shell
|
||||
|
||||
La modificación del código de Electron para agregar tu marca puede resultar complicada, una tarea Grunt
|
||||
se ha creado para manejar esto de forma automatizada:
|
||||
|
||||
La modificación a mano del código de Electron y su compilación puede resultar
|
||||
complicada, por lo cual se ha generado una tarea Grunt para manejar esto de
|
||||
forma automaticamente:
|
||||
[grunt-build-atom-shell](https://github.com/paulcbetts/grunt-build-atom-shell).
|
||||
|
||||
Esta tarea se encargará de modificar el archivo `.gyp`, compilar el código
|
||||
y reconstruir los módulos nativos de la aplicación para que coincidan con el nuevo nombre.
|
||||
Esta tarea se encargará de modificar el archivo `.gyp`, compilar el código desde
|
||||
las fuentes, y luego reconstruir los módulos nativos de la aplicación para que
|
||||
coincidan con el nuevo nombre del ejecutable.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
## 개발 가이드
|
||||
|
||||
* [지원하는 플랫폼](tutorial/supported-platforms.md)
|
||||
* [어플리케이션 배포](tutorial/application-distribution.md)
|
||||
* [어플리케이션 패키징](tutorial/application-packaging.md)
|
||||
* [네이티브 Node 모듈 사용하기](tutorial/using-native-node-modules.md)
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
**이 모듈은 현재 OS X에서만 사용할 수 있습니다.**
|
||||
|
||||
Windows 어플리케이션 인스톨러를 생성하려면 [atom/grunt-electron-installer](https://github.com/atom/grunt-electron-installer)를 참고하세요.
|
||||
Windows 인스톨러를 생성하려면 [atom/grunt-electron-installer](https://github.com/atom/grunt-electron-installer)를 참고하세요.
|
||||
|
||||
`auto-updater` 모듈은 [Squirrel.Mac](https://github.com/Squirrel/Squirrel.Mac) 프레임워크의 간단한 Wrapper입니다.
|
||||
`auto-updater` 모듈은 [Squirrel.Mac](https://github.com/Squirrel/Squirrel.Mac) 프레임워크의 간단한 wrapper 입니다.
|
||||
|
||||
Squirrel.Mac은 업데이트 설치를 위해 `.app` 폴더에
|
||||
[codesign](https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/codesign.1.html)
|
||||
@@ -14,23 +14,23 @@ Squirrel.Mac은 업데이트 설치를 위해 `.app` 폴더에
|
||||
|
||||
Squirrel은 어플리케이션이 **안전하고 투명한 업데이트**를 제공할 수 있도록 하는데 초점이 맞춰진 OS X 프레임워크입니다.
|
||||
|
||||
Squirrel은 사용자에게 어플리케이션의 업데이트를 알릴 필요 없이 서버가 지시하는 버전을 받아온 후 자동으로 업데이트합니다.
|
||||
이 기능을 사용하면 Squirrel을 통해 클라이언트의 어플리케이션을 지능적으로 업데이트 할 수 있습니다.
|
||||
Squirrel은 사용자에게 어플리케이션의 업데이트를 알릴 필요 없이 자동으로 서버가 지시하는 버전을 받아 어플리케이션을 업데이트합니다.
|
||||
지능적으로 클라이언트 어플리케이션을 업데이트 할 수 있습니다.
|
||||
|
||||
또한 요청시 커스텀 헤더 또는 요청 본문에 인증 정보를 포함시킬 수 있습니다.
|
||||
서버에선 이러한 요청을 분류 처리하여 적당한 업데이트를 제공할 수 있습니다.
|
||||
업데이트 요청은 커스텀 헤더 또는 요청 본문에 인증 정보를 포함시킬 수 있습니다.
|
||||
이에 따라 서버에선 이러한 요청을 분석 처리하여 사용자에게 적당한 업데이트를 제공할 수 있습니다.
|
||||
|
||||
Squirrel JSON 업데이트 요청시 처리는 반드시 어떤 업데이트가 필요한지 요청의 기준에 맞춰 동적으로 생성되어야 합니다.
|
||||
Squirrel은 사용해야 하는 업데이트 선택하는 과정을 서버에 의존합니다. [서버 지원](#server-support)을 참고하세요.
|
||||
Squirrel은 사용해야 하는 업데이트 선택하는 과정을 서버에 의존합니다. [서버 지원](#서버-지원)을 참고하세요.
|
||||
|
||||
Squirrel의 인스톨러는 오류에 관대하게 설계되었습니다. 그리고 업데이트가 유효한지 확인합니다.
|
||||
|
||||
## 업데이트 요청
|
||||
|
||||
Squirrel은 업데이트 확인을 위해 클라이언트 어플리케이션의 요청은 무시합니다.
|
||||
Squirrel은 응답을 분석해야 할 책임이 있기 때문에 `Accept: application/json`이 요청 헤더에 추가됩니다.
|
||||
Squirrel은 클라이언트 어플리케이션이 업데이트 확인을 위해 제공하는 요청을 무시합니다.
|
||||
Squirrel이 응답을 분석할 수 있어야하기 때문에 요청 헤더에 `Accept: application/json` 헤더가 추가됩니다.
|
||||
|
||||
업데이트 응답과 본문 포맷에 대한 요구 사항은 [Server Support](#server-support)를 참고하세요.
|
||||
업데이트 응답과 본문 포맷에 대한 요구 사항은 [서버 지원](#서버-지원)를 참고하세요.
|
||||
|
||||
업데이트 요청에는 서버가 해당 어플리케이션이 어떤 버전을 사용해야 하는지 판단하기 위해 *반드시* 버전 식별자를 포함시켜야 합니다.
|
||||
추가로 OS 버전, 사용자 이름 같은 다른 식별 기준을 포함하여 서버에서 적합한 어플리케이션을 제공할 수 있도록 할 수 있습니다.
|
||||
@@ -46,7 +46,7 @@ autoUpdater.setFeedUrl('http://mycompany.com/myapp/latest?version=' + app.getVer
|
||||
|
||||
## 서버 지원
|
||||
|
||||
업데이트를 제공하는 서버는 반드시 클라이언트로부터 받은 [Update Request](#update-requests)를 기반으로 업데이트를 처리할 수 있어야 합니다.
|
||||
업데이트를 제공하는 서버는 반드시 클라이언트로부터 받은 [업데이트 요청](#업데이트-요청)을 기반으로 업데이트를 처리할 수 있어야 합니다.
|
||||
|
||||
만약 업데이트 요청이 들어오면 서버는 반드시 [200 OK](http://tools.ietf.org/html/rfc2616#section-10.2.1) 상태 코드를 포함한
|
||||
[업데이트 JSON](#update-json-format)을 본문으로 보내야 합니다.
|
||||
|
||||
@@ -84,13 +84,19 @@ Net log 이벤트를 활성화하고 `path`에 로그를 기록합니다.
|
||||
|
||||
## --ssl-version-fallback-min=`version`
|
||||
|
||||
Fallback SSL/TLS 최소 버전을 지정합니다. ("tls1", "tls1.1", "tls1.2")
|
||||
TLS fallback에서 사용할 SSL/TLS 최소 버전을 지정합니다. ("tls1", "tls1.1", "tls1.2")
|
||||
|
||||
## --enable-logging
|
||||
|
||||
Chromium의 로그를 콘솔에 출력합니다.
|
||||
|
||||
이 스위치는 어플리케이션이 로드되기 전에 파싱 되므로 `app.commandLine.appendSwitch`에서 사용할 수 없습니다.
|
||||
|
||||
## --v=`log_level`
|
||||
|
||||
기본 V-logging 최대 활성화 레벨을 지정합니다. 기본값은 0입니다. 기본적으로 양수를 레벨로 사용합니다.
|
||||
|
||||
`--v=-1`를 사용하면 로깅이 비활성화 됩니다.
|
||||
이 스위치는 `--enable-logging` 스위치를 같이 지정해야 작동합니다.
|
||||
|
||||
## --vmodule=`pattern`
|
||||
|
||||
@@ -100,10 +106,4 @@ Fallback SSL/TLS 최소 버전을 지정합니다. ("tls1", "tls1.1", "tls1.2")
|
||||
또한 슬래시(`/`) 또는 백슬래시(`\`)를 포함하는 패턴은 지정한 경로에 대해 패턴을 테스트 합니다.
|
||||
예를 들어 `*/foo/bar/*=2` 표현식은 `foo/bar` 디렉터리 안의 모든 소스 코드의 로깅 레벨을 2로 지정합니다.
|
||||
|
||||
모든 크로미움과 관련된 로그를 비활성화하고 어플리케이션의 로그만 활성화 하려면 다음과 같이 코드를 작성하면 됩니다:
|
||||
|
||||
|
||||
```javascript
|
||||
app.commandLine.appendSwitch('v', -1);
|
||||
app.commandLine.appendSwitch('vmodule', 'console=0');
|
||||
```
|
||||
이 스위치는 `--enable-logging` 스위치를 같이 지정해야 작동합니다.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# MenuItem
|
||||
|
||||
`menu-item` 모듈은 어플리케이션 또는 컨텐츠 [`menu`](menu.md)에 아이템을 추가할 수 있도록 관련 클래스를 제공합니다.
|
||||
`menu-item` 모듈은 어플리케이션 또는 컨텍스트 [`menu`](menu.md)에 아이템을 추가할 수 있도록 관련 클래스를 제공합니다.
|
||||
|
||||
[`menu`](menu.md)에서 예제를 확인할 수 있습니다.
|
||||
|
||||
|
||||
@@ -142,4 +142,4 @@ var image = NativeImage.createFromPath('/Users/somebody/images/icon.png');
|
||||
|
||||
이미지가 템플릿 이미지인지 확인합니다.
|
||||
|
||||
[buffer]: https://iojs.org/api/buffer.html#buffer_class_buffer
|
||||
[buffer]: https://nodejs.org/api/buffer.html#buffer_class_buffer
|
||||
|
||||
@@ -7,6 +7,24 @@ Electron의 `process` 객체는 기존의 node와는 달리 약간의 차이점
|
||||
* `process.versions['chrome']` String - Chromium의 버전.
|
||||
* `process.resourcesPath` String - JavaScript 소스코드의 경로.
|
||||
|
||||
## Events
|
||||
|
||||
### Event: 'loaded'
|
||||
|
||||
Electron 내부 초기화 스크립트의 로드가 완료되고, 웹 페이지나 메인 스크립트를 로드하기 시작할 때 발생하는 이벤트입니다.
|
||||
|
||||
이 이벤트는 preload 스크립트를 통해 node 통합이 꺼져있는 전역 스코프에 node의 전역 심볼들을 다시 추가할 때 사용할 수 있습니다:
|
||||
|
||||
```javascript
|
||||
// preload.js
|
||||
var _setImmediate = setImmediate;
|
||||
var _clearImmediate = clearImmediate;
|
||||
process.once('loaded', function() {
|
||||
global.setImmediate = _setImmediate;
|
||||
global.clearImmediate = _clearImmediate;
|
||||
});
|
||||
```
|
||||
|
||||
## Methods
|
||||
|
||||
`process` 객체는 다음과 같은 메서드를 가지고 있습니다:
|
||||
|
||||
@@ -36,7 +36,7 @@ app.on('ready', function() {
|
||||
var displays = electronScreen.getAllDisplays();
|
||||
var externalDisplay = null;
|
||||
for (var i in displays) {
|
||||
if (displays[i].bounds.x > 0 || displays[i].bounds.y > 0) {
|
||||
if (displays[i].bounds.x != 0 || displays[i].bounds.y != 0) {
|
||||
externalDisplay = displays[i];
|
||||
break;
|
||||
}
|
||||
@@ -45,7 +45,7 @@ app.on('ready', function() {
|
||||
if (externalDisplay) {
|
||||
mainWindow = new BrowserWindow({
|
||||
x: externalDisplay.bounds.x + 50,
|
||||
y: externalDisplay.bounds.y + 50,
|
||||
y: externalDisplay.bounds.y + 50
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
## 소개
|
||||
|
||||
Electron은 자바스크립트와 함께 제공된 풍부한 네이티브 API를 사용하여 멋진 데스크탑 어플리케이션을 만들 수 있도록 해주는 프레임워크입니다.
|
||||
이 프레임워크의 io.js(node.js)는 웹 서버 개발이 아닌 데스크탑 어플리케이션 개발에 초점을 맞췄습니다.
|
||||
이 프레임워크의 Node.js는 웹 서버 개발이 아닌 데스크탑 어플리케이션 개발에 초점을 맞췄습니다.
|
||||
|
||||
이 말은 Electron이 GUI 라이브러리의 자바스크립트 바인딩이라는 뜻이 아닙니다.
|
||||
대신, Electron은 웹 페이지의 GUI를 사용합니다. 쉽게 말해 Electron은 자바스크립트를 사용하여 조작하는 작은 Chromium 브라우저로 볼 수 있습니다.
|
||||
@@ -19,7 +19,7 @@ Electron이 웹페이지를 보여줄 때 Chromium의 multi-processes 구조도
|
||||
Electron 프로세스 내에서 작동하는 웹 페이지를 __랜더러 프로세스__ 라고 불립니다.
|
||||
|
||||
보통 일반 브라우저의 웹 페이지들은 샌드박스가 적용된 환경에서 작동하며 네이티브 리소스에는 접근할 수 없도록 되어 있습니다.
|
||||
하지만 Electron은 웹 페이지 내에서 io.js(node.js) API를 사용하여 low-level 수준으로 운영체제와 상호작용할 수 있습니다.
|
||||
하지만 Electron은 웹 페이지 내에서 Node.js API를 사용하여 low-level 수준으로 운영체제와 상호작용할 수 있습니다.
|
||||
|
||||
### 메인 프로세스와 랜더러 프로세스의 차이점
|
||||
|
||||
@@ -116,7 +116,7 @@ app.on('ready', function() {
|
||||
</head>
|
||||
<body>
|
||||
<h1>헬로 월드!</h1>
|
||||
이 어플리케이션은 io.js <script>document.write(process.version)</script> 과
|
||||
이 어플리케이션은 Node.js <script>document.write(process.version)</script> 과
|
||||
Electron <script>document.write(process.versions['electron'])</script>을 사용합니다.
|
||||
</body>
|
||||
</html>
|
||||
|
||||
26
docs-translations/ko-KR/tutorial/supported-platforms.md
Normal file
26
docs-translations/ko-KR/tutorial/supported-platforms.md
Normal file
@@ -0,0 +1,26 @@
|
||||
# 지원하는 플랫폼
|
||||
|
||||
Electron에선 다음과 같은 플랫폼을 지원합니다:
|
||||
|
||||
### OS X
|
||||
|
||||
OS X는 64비트 바이너리만 제공됩니다. 그리고 최소 OS X 지원 버전은 10.8입니다.
|
||||
|
||||
### Windows
|
||||
|
||||
Windows 7 이후 버전만 지원됩니다. Windows Vista에서도 작동할 수 있지만 아직 모든 작동 테스트가 완료되지 않았습니다.
|
||||
|
||||
윈도우용 바이너리는 `x86`과 `x64` 모두 제공됩니다. 그리고 `ARM` 버전 윈도우는 아직 지원하지 않습니다. (역주: 추후 지원할 가능성이 있습니다)
|
||||
|
||||
### Linux
|
||||
|
||||
Ubuntu 12.04 버전에서 빌드된 `ia32`(`i686`), `x64`(`amd64`) 바이너리가 제공됩니다.
|
||||
그리고 `arm` 버전 바이너리는 ARM v7 hard-float ABI와 Debian Wheezy용 NEON에 맞춰 제공됩니다.
|
||||
|
||||
미리 빌드된 바이너리가 배포판에서 작동할 수 있는지 여부는 Electron이 빌드된 플랫폼에서 링크된 라이브러리에 따라 달라집니다.
|
||||
그래서 현재 Linux 바이너리는 Ubuntu 12.04 버전만 정상적인 작동이 보장됩니다.
|
||||
하지만 다음 플랫폼들은 미리 빌드된 Electron 바이너리가 정상적으로 작동하는 것을 확인했습니다:
|
||||
|
||||
* Ubuntu 12.04 이후 버전
|
||||
* Fedora 21
|
||||
* Debian 8
|
||||
@@ -5,14 +5,16 @@ Electron에선 node.js 네이티브 모듈이 지원됩니다. 하지만 Electro
|
||||
|
||||
## 네이티브 node 모듈 호환성
|
||||
|
||||
Node v0.11.x 버전부터는 V8 API의 중대한 변경이 있었습니다. 하지만 대부분의 네이티브 모듈은 Node v0.10.x 버전을 타겟으로 작성 되었기 때문에
|
||||
새로운 Node 또는 io.js 버전에서 작동하지 않을 수 있습니다. Electron은 내부적으로 __io.js v3.1.0__ 버전을 사용하기 때문에 호환성 문제가 발생할 수 있습니다.
|
||||
네이티브 모듈은 node.js가 새로운 V8 버전을 사용함으로 인해 작동하지 않을 수 있습니다.
|
||||
사용하는 네이티브 모듈이 Electron에 맞춰 작동할 수 있도록 하려면 Electron에서 사용하는 node.js의 버전을 확인할 필요가 있습니다.
|
||||
Electron에서 사용하는 node 버전은 [releases](https://github.com/atom/electron/releases)에서 확인할 수 있으며
|
||||
`process.version`을 출력하여 버전을 확인할 수도 있습니다. ([시작하기](https://github.com/atom/electron/blob/master/docs/tutorial/quick-start.md)의 예제를 참고하세요)
|
||||
|
||||
이 문제를 해결하기 위해선 모듈이 v0.11.x 또는 최신 버전을 지원할 수 있도록 변경해야 합니다.
|
||||
현재 [많은 모듈들](https://www.npmjs.org/browse/depended/nan)이 안정적으로 두 버전 모두 지원하고 있지만 오래된 모듈의 경우 여전히 Node v0.10.x 버전만을 지원하고 있습니다.
|
||||
예를 들어 [nan](https://github.com/rvagg/nan) 모듈을 사용해야 한다면 Node v0.11.x 또는 최신 버전의 Node와 io.js로 포팅 할 필요가 있습니다.
|
||||
혹시 직접 만든 네이티브 모듈이 있다면 [NAN](https://github.com/nodejs/nan/) 모듈을 사용하는 것을 고려해보는 것이 좋습니다.
|
||||
이 모듈은 다중 버전의 node.js를 지원하기 쉽게 해줍니다. 이를 통해 오래된 모듈을 새 버전의 node.js에 맞게 포팅할 수 있습니다.
|
||||
Electron도 이 모듈을 통해 포팅된 네이티브 모듈을 사용할 수 있습니다.
|
||||
|
||||
## 네이티브 모듈 설치하는 방법
|
||||
## 네이티브 모듈을 설치하는 방법
|
||||
|
||||
네이티브 모듈을 설치하는 방법은 세 가지 종류가 있습니다.
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ driver.quit();
|
||||
먼저, `chromedriver` 바이너리를 다운로드 받고 실행합니다:
|
||||
|
||||
```bash
|
||||
$ chromedriver --url-base=/wd/hub --port=9515
|
||||
$ chromedriver --url-base=wd/hub --port=9515
|
||||
Starting ChromeDriver (v2.10.291558) on port 9515
|
||||
Only local connections are allowed.
|
||||
```
|
||||
|
||||
192
docs-translations/pt-BR/tutorial/quick-start.md
Normal file
192
docs-translations/pt-BR/tutorial/quick-start.md
Normal file
@@ -0,0 +1,192 @@
|
||||
# Introdução
|
||||
|
||||
Electron permite criar aplicações desktop com puro JavaScript através de
|
||||
um runtime com APIs ricas e nativas. Você pode ver isso como uma variação do
|
||||
runtime do io.js que é focado em aplicações desktop em vez de web servers.
|
||||
|
||||
Isso não significa que o Electron é uma ligação em JavaScript para blibliotécas
|
||||
de interface gráfica (GUI). Em vez disso, Electron usa páginas web como
|
||||
interface gráfica, então você pode ver isso também como um navegador Chromium
|
||||
mínimo, controlado por JavaScript.
|
||||
|
||||
### Processo Principal
|
||||
|
||||
No Electron, o processo que executa o script principal (main) do `package.json`
|
||||
é chamado __processo principal__. O script que roda no processo principal pode
|
||||
mostrar uma GUI criando páginas web.
|
||||
|
||||
### Processo Renderizador
|
||||
|
||||
Desde que o Electron usa o Chromium para mostrar as páginas web, a arquitetura
|
||||
multi-processo do Chromium também é usada. Cada página web no Electron roda em
|
||||
seu próprio processo, o que é chamado de __processo renderizador__.
|
||||
|
||||
Em navegadores comuns, as páginas web normalmente rodam em um ambiente em sandbox
|
||||
e não tem permissão de acesso para recursos nativos. Usuários Electron, entretanto,
|
||||
tem o poder de usar as APIs do io.js nas páginas web, permitindo interações de baixo
|
||||
nível no sistema operacional.
|
||||
|
||||
### Diferenças Entre o Processo Principal e o Processo Renderizador
|
||||
|
||||
O processo principal cria as páginas web criando instâncias de `BrowserWindow`.
|
||||
Cada instância de `BrowserWindow` roda a página web em seu próprio processo renderizador.
|
||||
Quando uma instância de `BrowserWindow` é destruída, o processo renderizador
|
||||
correspondente também é finalizado.
|
||||
|
||||
O processo principal gerência todas as páginas web de seus processos renderizadores
|
||||
correspondentes. Cada processo renderizador é isolado e toma conta de sua
|
||||
respectiva página web.
|
||||
|
||||
Nas páginas web, chamar APIs nativas relacionadas à GUI não é permitido porque
|
||||
gerênciar recursos de GUI em páginas web é muito perigoso e torna fácil o vazamento de
|
||||
recursos. Se você quer realizar operações com GUI em páginas web, o processo
|
||||
renderizador da página web deve se comunicar com o processo principal para requisitar
|
||||
que o processo principal realize estas operações.
|
||||
|
||||
No Electron, nós fornecemos o módulo [ipc](../../../docs/api/ipc-renderer.md) para
|
||||
comunicação entre o processo principal e o processo renderizador. Que é também um
|
||||
módulo [remoto](../../../docs/api/remote.md) para comunicação RPC.
|
||||
|
||||
## Crie seu Primeiro App Electron
|
||||
|
||||
Geralmente, um app Electron é estruturado assim:
|
||||
|
||||
```text
|
||||
your-app/
|
||||
├── package.json
|
||||
├── main.js
|
||||
└── index.html
|
||||
```
|
||||
|
||||
O formato de `package.json` é exatamente o mesmo que os dos módulos do Node, e
|
||||
e o script especificado pelo campo `main` é o script de inicialização do seu app,
|
||||
que irá executar o processo principal. Um exemplo do seu `package.json` deve parecer
|
||||
com isso:
|
||||
|
||||
```json
|
||||
{
|
||||
"name" : "your-app",
|
||||
"version" : "0.1.0",
|
||||
"main" : "main.js"
|
||||
}
|
||||
```
|
||||
|
||||
__Nota__: Se o campo `main` não estiver presente no `package.jso`, o Electron irá
|
||||
tentar carregar um `index.js`
|
||||
|
||||
O `main.js` deve criar as janelas e os manipuladores de eventos do sistema, um típico
|
||||
exemplo:
|
||||
|
||||
```javascript
|
||||
var app = require('app'); // Módulo para controlar o ciclo de vida do app.
|
||||
var BrowserWindow = require('browser-window'); // Módulo para criar uma janela nativa do browser.
|
||||
|
||||
// Relate falhas para nossos servidores.
|
||||
require('crash-reporter').start();
|
||||
|
||||
// Mantenha uma referência global para o objeto window, se você não o fizer,
|
||||
// a janela será fechada automaticamente quando o objeto JavaScript for
|
||||
// coletado pelo garbage collector.
|
||||
var mainWindow = null;
|
||||
|
||||
// Sair quando todas as janelas estiverem fechadas.
|
||||
app.on('window-all-closed', function() {
|
||||
// No OS X é comum para as aplicações na barra de menu
|
||||
// continuarem ativas até que o usuário saia explicitamente
|
||||
// com Cmd + Q
|
||||
if (process.platform != 'darwin') {
|
||||
app.quit();
|
||||
}
|
||||
});
|
||||
|
||||
// Esse método irá ser chamado quando o Electron finalizar
|
||||
// a inicialização e estiver pronto para criar janelas do browser.
|
||||
app.on('ready', function() {
|
||||
// Criar a janela do navegador.
|
||||
mainWindow = new BrowserWindow({width: 800, height: 600});
|
||||
|
||||
// e carrega o index.html do app.
|
||||
mainWindow.loadUrl('file://' + __dirname + '/index.html');
|
||||
|
||||
// Abre os DevTools.
|
||||
mainWindow.openDevTools();
|
||||
|
||||
// Emitido quando a janela é fechada.
|
||||
mainWindow.on('closed', function() {
|
||||
// Desfaz a referência para o objeto window, normalmente você deverá
|
||||
// guardar as janelas em um array se seu app suportar várias janelas,
|
||||
// essa é a hora que você deverá deletar o elemento correspondente.
|
||||
mainWindow = null;
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
Finalmente o `index.html` é a página web que você quer mostrar:
|
||||
|
||||
```html
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Hello World!</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hello World!</h1>
|
||||
Nós estamos usando io.js <script>document.write(process.version)</script>
|
||||
e Electron <script>document.write(process.versions['electron'])</script>.
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
## Execute seu App
|
||||
|
||||
Uma vez que você criou seus arquivos `main.js`, `index.html, e `package.json` iniciais,
|
||||
você provavelmente vai querer tentar executar seu app localmente para testa-lo a ter
|
||||
certeza que funciona como você espera.
|
||||
|
||||
### electron-prebuilt
|
||||
|
||||
Se você instalou `electron-prebuilt` globalmente com `npm`, então você irá precisar apenas
|
||||
rodar o seguinte comando no diretório fonte do seu app:
|
||||
|
||||
```bash
|
||||
electron .
|
||||
```
|
||||
|
||||
Se você o instalou localmente, então execute:
|
||||
|
||||
```bash
|
||||
./node_modules/.bin/electron .
|
||||
```
|
||||
|
||||
### Binário do Electron Baixado Manualmente
|
||||
|
||||
Se você baixou o Electron manualmente, você pode também usar o binário incluído para
|
||||
executar seu app diretamente.
|
||||
|
||||
#### Windows
|
||||
|
||||
```bash
|
||||
$ .\electron\electron.exe your-app\
|
||||
```
|
||||
|
||||
#### Linux
|
||||
|
||||
```bash
|
||||
$ ./electron/electron your-app/
|
||||
```
|
||||
|
||||
#### OS X
|
||||
|
||||
```bash
|
||||
$ ./Electron.app/Contents/MacOS/Electron your-app/
|
||||
```
|
||||
|
||||
`Electron.app` aqui é uma parte do pacote de lançamento do Electron, você pode baixa-lo
|
||||
[aqui](https://github.com/atom/electron/releases).
|
||||
|
||||
### Executar como uma distribuição
|
||||
|
||||
Depois de terminar seu app, você pode criar uma distribuição seguindo o guia
|
||||
[Application Distribution](./application-distribution.md) e então executar o app
|
||||
empacotado.
|
||||
315
docs-translations/zh-CN/api/app.md
Normal file
315
docs-translations/zh-CN/api/app.md
Normal file
@@ -0,0 +1,315 @@
|
||||
# app
|
||||
|
||||
`app` 模块是为了控制整个应用的生命周期设计的。
|
||||
|
||||
下面的这个例子将会展示如何在最后一个窗口被关闭时退出应用:
|
||||
|
||||
```javascript
|
||||
var app = require('app');
|
||||
app.on('window-all-closed', function() {
|
||||
app.quit();
|
||||
});
|
||||
```
|
||||
|
||||
## 事件
|
||||
|
||||
`app` 对象会触发以下的事件:
|
||||
|
||||
### 事件: 'will-finish-launching'
|
||||
|
||||
当应用程序完成基础的启动的时候被触发。在 Windows 和 Linux 中,
|
||||
`will-finish-launching` 事件与 `ready` 事件是相同的; 在 OS X 中,
|
||||
这个时间相当于 `NSApplication` 中的 `applicationWillFinishLaunching` 提示。
|
||||
你应该经常在这里为 `open-file` 和 `open-url` 设置监听器,并启动崩溃报告和自动更新。
|
||||
|
||||
在大多数的情况下,你应该只在 `ready` 事件处理器中完成所有的业务。
|
||||
|
||||
### 事件: 'ready'
|
||||
|
||||
当 Electron 完成初始化时被触发。
|
||||
|
||||
### 事件: 'window-all-closed'
|
||||
|
||||
当所有的窗口都被关闭时触发。
|
||||
|
||||
这个时间仅在应用还没有退出时才能触发。 如果用户按下了 `Cmd + Q`,
|
||||
或者开发者调用了 `app.quit()` ,Electron 将会先尝试关闭所有的窗口再触发 `will-quit` 事件,
|
||||
在这种情况下 `window-all-closed` 不会被触发。
|
||||
|
||||
### 事件: 'before-quit'
|
||||
|
||||
返回:
|
||||
|
||||
* `event` 事件
|
||||
|
||||
在应用程序开始关闭它的窗口的时候被触发。
|
||||
调用 `event.preventDefault()` 将会阻止终止应用程序的默认行为。
|
||||
|
||||
### 事件: 'will-quit'
|
||||
|
||||
返回:
|
||||
|
||||
* `event` 事件
|
||||
|
||||
当所有的窗口已经被关闭,应用即将退出时被触发。
|
||||
调用 `event.preventDefault()` 将会阻止终止应用程序的默认行为。
|
||||
|
||||
你可以在 `window-all-closed` 事件的描述中看到 `will-quit` 事件
|
||||
和 `window-all-closed` 事件的区别。
|
||||
|
||||
### 事件: 'quit'
|
||||
|
||||
当应用程序正在退出时触发。
|
||||
|
||||
### 事件: 'open-file'
|
||||
|
||||
返回:
|
||||
|
||||
* `event` 事件
|
||||
* `path` 字符串
|
||||
|
||||
当用户想要在应用中打开一个文件时触发。`open-file` 事件常常在应用已经打开并且系统想要再次使用应用打开文件时被触发。
|
||||
`open-file` 也会在一个文件被拖入 dock 且应用还没有运行的时候被触发。
|
||||
请确认在应用启动的时候(甚至在 `ready` 事件被触发前)就对 `open-file` 事件进行监听,以处理这种情况。
|
||||
|
||||
如果你想处理这个事件,你应该调用 `event.preventDefault()` 。
|
||||
|
||||
### 事件: 'open-url'
|
||||
|
||||
返回:
|
||||
|
||||
* `event` 事件
|
||||
* `url` 字符串
|
||||
|
||||
当用户想要在应用中打开一个url的时候被触发。URL格式必须要提前标识才能被你的应用打开。
|
||||
|
||||
如果你想处理这个事件,你应该调用 `event.preventDefault()` 。
|
||||
|
||||
### 事件: 'activate' _OS X_
|
||||
|
||||
返回:
|
||||
|
||||
* `event` 事件
|
||||
* `hasVisibleWindows` 布尔值
|
||||
|
||||
当应用被激活时触发,常用于点击应用的 dock 图标的时候。
|
||||
|
||||
### 事件: 'browser-window-blur'
|
||||
|
||||
返回:
|
||||
|
||||
* `event` 事件
|
||||
* `window` 浏览器窗口
|
||||
|
||||
当一个 [浏览器窗口](browser-window.md) 失去焦点的时候触发。
|
||||
|
||||
### 事件: 'browser-window-focus'
|
||||
|
||||
返回:
|
||||
|
||||
* `event` 事件
|
||||
* `window` 浏览器窗口
|
||||
|
||||
当一个 [浏览器窗口](browser-window.md) 获得焦点的时候触发。
|
||||
|
||||
### 事件: 'browser-window-created'
|
||||
|
||||
返回:
|
||||
|
||||
* `event` 事件
|
||||
* `window` 浏览器窗口
|
||||
|
||||
当一个 [浏览器窗口](browser-window.md) 被创建的时候触发。
|
||||
|
||||
### 事件: 'select-certificate'
|
||||
|
||||
当一个客户端认证被请求的时候被触发。
|
||||
|
||||
返回:
|
||||
|
||||
* `event` 事件
|
||||
* `webContents` [web组件](browser-window.md#class-webcontents)
|
||||
* `url` 字符串
|
||||
* `certificateList` 对象
|
||||
* `data` PEM 编码数据
|
||||
* `issuerName` 发行者的公有名称
|
||||
* `callback` 函数
|
||||
|
||||
```javascript
|
||||
app.on('select-certificate', function(event, host, url, list, callback) {
|
||||
event.preventDefault();
|
||||
callback(list[0]);
|
||||
})
|
||||
```
|
||||
|
||||
The `url` corresponds to the navigation entry requesting the client certificate
|
||||
and `callback` needs to be called with an entry filtered from the list.
|
||||
Using `event.preventDefault()` prevents the application from using the first
|
||||
certificate from the store.
|
||||
|
||||
### 事件: 'gpu-process-crashed'
|
||||
|
||||
当GPU进程崩溃时触发。
|
||||
|
||||
## 方法
|
||||
|
||||
`app` 对象拥有以下的方法:
|
||||
|
||||
**提示:** 有的方法只能用于特定的操作系统。
|
||||
|
||||
### `app.quit()`
|
||||
|
||||
试图关掉所有的窗口。`before-quit` 事件将会被最先触发。如果所有的窗口都被成功关闭了,
|
||||
`will-quit` 事件将会被触发,默认下应用将会被关闭。
|
||||
|
||||
这个方法保证了所有的 `beforeunload` 和 `unload` 事件处理器被正确执行。会存在一个窗口被 `beforeunload` 事件处理器返回 `false` 取消退出的可能性。
|
||||
|
||||
### `app.getAppPath()`
|
||||
|
||||
返回当前应用所在的文件路径。
|
||||
|
||||
### `app.getPath(name)`
|
||||
|
||||
* `name` 字符串
|
||||
|
||||
返回一个与 `name` 参数相关的特殊文件夹或文件路径。当失败时抛出一个 `Error` 。
|
||||
|
||||
你可以通过名称请求以下的路径:
|
||||
|
||||
* `home` 用户的 home 文件夹。
|
||||
* `appData` 所有用户的应用数据文件夹,默认对应:
|
||||
* `%APPDATA%` Windows 中
|
||||
* `$XDG_CONFIG_HOME` or `~/.config` Linux 中
|
||||
* `~/Library/Application Support` OS X 中
|
||||
* `userData` 储存你应用程序设置文件的文件夹,默认是 `appData` 文件夹附加应用的名称。
|
||||
* `cache` 所有用户应用程序缓存的文件夹,默认对应:
|
||||
* `%APPDATA%` Windows 中 (没有一个通用的缓存位置)
|
||||
* `$XDG_CACHE_HOME` 或 `~/.cache` Linux 中
|
||||
* `~/Library/Caches` OS X 中
|
||||
* `userCache` 用于存放应用程序缓存的文件夹,默认是 `cache` 文件夹附加应用的名称。
|
||||
* `temp` 临时文件夹。
|
||||
* `userDesktop` 当前用户的桌面文件夹。
|
||||
* `exe` 当前的可执行文件。
|
||||
* `module` `libchromiumcontent` 库。
|
||||
|
||||
### `app.setPath(name, path)`
|
||||
|
||||
* `name` 字符串
|
||||
* `path` 字符串
|
||||
|
||||
重写 `path` 参数到一个特别的文件夹或者是一个和 `name` 参数有关系的文件。
|
||||
如果这个路径指向的文件夹不存在,这个文件夹将会被这个方法创建。
|
||||
如果错误则抛出 `Error` 。
|
||||
|
||||
你只可以指向 `app.getPath` 中定义过 `name` 的路径。You can only override paths of a `name` defined in `app.getPath`.
|
||||
|
||||
默认情况下,网页的 cookie 和缓存都会储存在 `userData` 文件夹。
|
||||
如果你想要改变这个位置,你需要在 `app` 模块中的 `ready` 事件被触发之前重写 `userData` 的路径。
|
||||
|
||||
### `app.getVersion()`
|
||||
|
||||
返回加载应用程序的版本。如果应用程序的 `package.json` 文件中没有写版本号,
|
||||
将会返回当前包或者可执行文件的版本。
|
||||
|
||||
### `app.getName()`
|
||||
|
||||
返回当前应用程序的 `package.json` 文件中的名称。
|
||||
|
||||
通常 `name` 字段是一个短的小写字符串,其命名规则按照 npm 中的模块命名规则。你应该单独列举一个
|
||||
`productName` 字段,用于表示你的应用程序的完整名称,这个名称将会被 Electron 优先采用。
|
||||
|
||||
### `app.getLocale()`
|
||||
|
||||
返回当前应用程序的位置。
|
||||
|
||||
### `app.resolveProxy(url, callback)`
|
||||
|
||||
* `url` URL
|
||||
* `callback` 函数
|
||||
|
||||
为 `url` 解析代理信息。 `callback` 在请求被执行之后将会被 `callback(proxy)` 调用。
|
||||
|
||||
### `app.addRecentDocument(path)`
|
||||
|
||||
* `path` 字符串
|
||||
|
||||
为最近访问的文档列表中添加 `path` 。
|
||||
|
||||
这个列表由操作系统进行管理。在 Windows 中您可以通过任务条进行访问,在 OS X 中你可以通过dock 菜单进行访问。
|
||||
|
||||
### `app.clearRecentDocuments()`
|
||||
|
||||
清除最近访问的文档列表。
|
||||
|
||||
### `app.setUserTasks(tasks)` _Windows_
|
||||
|
||||
* `tasks` 由 `Task` 对象构成的数组
|
||||
|
||||
将 `tasks` 添加到 Windows 中 JumpList 功能的 [Tasks][tasks] 分类中。
|
||||
|
||||
`tasks` 中的 `Task` 对象格式如下:
|
||||
|
||||
`Task` 对象
|
||||
* `program` 字符串 - 执行程序的路径,通常你应该说明当前程序的路径为 `process.execPath` 字段。
|
||||
* `arguments` 字符串 - 当 `program` 执行时的命令行参数。
|
||||
* `title` 字符串 - JumpList 中显示的标题。
|
||||
* `description` 字符串 - 对这个任务的描述。
|
||||
* `iconPath` 字符串 - JumpList 中显示的 icon 的绝对路径,可以是一个任意包含一个icon的资源文件。你通常可以通过指明 `process.execPath` 来显示程序中的icon。
|
||||
* `iconIndex` 整数 - icon文件中的icon目录。如果一个icon文件包括了两个或多个icon,就需要设置这个值以确定icon。如果一个文件仅包含一个icon,那么这个值为0。
|
||||
|
||||
### `app.commandLine.appendSwitch(switch[, value])`
|
||||
|
||||
通过可选的参数 `value` 给 Chromium 命令行中添加一个开关。
|
||||
Append a switch (with optional `value`) to Chromium's command line.
|
||||
|
||||
**贴士:** 这不会影响 `process.argv` ,这个方法主要被开发者用于控制一些低层级的 Chromium 行为。
|
||||
|
||||
### `app.commandLine.appendArgument(value)`
|
||||
|
||||
给 Chromium 命令行中加入一个参数。这个参数是当前正在被引用的。
|
||||
|
||||
**贴士:** 这不会影响 `process.argv`。
|
||||
|
||||
### `app.dock.bounce([type])` _OS X_
|
||||
|
||||
* `type` 字符串 (可选的) - 可以是 `critical` 或 `informational`。默认下是 `informational`
|
||||
|
||||
当输入 `critical` 时,dock 中的 icon 将会开始弹跳直到应用被激活或者这个请求被取消。
|
||||
|
||||
当输入 `informational` 时,dock 中的 icon 只会弹跳一秒钟。
|
||||
然而,这个请求仍然会激活,直到应用被激活或者请求被取消。
|
||||
|
||||
返回一个表示这个请求的 ID。
|
||||
|
||||
### `app.dock.cancelBounce(id)` _OS X_
|
||||
|
||||
* `id` 整数
|
||||
|
||||
取消这个 `id` 对应的请求。
|
||||
|
||||
### `app.dock.setBadge(text)` _OS X_
|
||||
|
||||
* `text` 字符串
|
||||
|
||||
设置 dock 中显示的字符。
|
||||
|
||||
### `app.dock.getBadge()` _OS X_
|
||||
|
||||
返回 dock 中显示的字符。
|
||||
|
||||
### `app.dock.hide()` _OS X_
|
||||
|
||||
隐藏 dock 中的 icon。
|
||||
|
||||
### `app.dock.show()` _OS X_
|
||||
|
||||
显示 dock 中的 icon。
|
||||
|
||||
### `app.dock.setMenu(menu)` _OS X_
|
||||
|
||||
* `menu` 菜单
|
||||
|
||||
设置应用的 [dock 菜单][dock-menu].
|
||||
|
||||
[dock-menu]:https://developer.apple.com/library/mac/documentation/Carbon/Conceptual/customizing_docktile/concepts/dockconcepts.html#//apple_ref/doc/uid/TP30000986-CH2-TPXREF103
|
||||
[tasks]:http://msdn.microsoft.com/en-us/library/windows/desktop/dd378460(v=vs.85).aspx#tasks
|
||||
@@ -1,5 +1,6 @@
|
||||
## Guides
|
||||
|
||||
* [Supported Platforms](tutorial/supported-platforms.md)
|
||||
* [Application Distribution](tutorial/application-distribution.md)
|
||||
* [Application Packaging](tutorial/application-packaging.md)
|
||||
* [Using Native Node Modules](tutorial/using-native-node-modules.md)
|
||||
|
||||
@@ -197,12 +197,6 @@ You can request the following paths by the name:
|
||||
* `~/Library/Application Support` on OS X
|
||||
* `userData` The directory for storing your app's configuration files, which by
|
||||
default it is the `appData` directory appended with your app's name.
|
||||
* `cache` Per-user application cache directory, which by default points to:
|
||||
* `%APPDATA%` on Windows (which doesn't have a universal cache location)
|
||||
* `$XDG_CACHE_HOME` or `~/.cache` on Linux
|
||||
* `~/Library/Caches` on OS X
|
||||
* `userCache` The directory for placing your app's caches, by default it is the
|
||||
`cache` directory appended with your app's name.
|
||||
* `temp` Temporary directory.
|
||||
* `userDesktop` The current user's Desktop directory.
|
||||
* `exe` The current executable file.
|
||||
|
||||
@@ -89,15 +89,21 @@ Enables net log events to be saved and writes them to `path`.
|
||||
|
||||
## --ssl-version-fallback-min=`version`
|
||||
|
||||
Set the minimum SSL/TLS version ("tls1", "tls1.1" or "tls1.2") that TLS
|
||||
Sets the minimum SSL/TLS version ("tls1", "tls1.1" or "tls1.2") that TLS
|
||||
fallback will accept.
|
||||
|
||||
## --enable-logging
|
||||
|
||||
Prints Chromium's logging into console.
|
||||
|
||||
This switch can not be used in `app.commandLine.appendSwitch` since it is parsed earlier than user's app is loaded.
|
||||
|
||||
## --v=`log_level`
|
||||
|
||||
Gives the default maximal active V-logging level; 0 is the default. Normally
|
||||
positive values are used for V-logging levels.
|
||||
|
||||
Passing `--v=-1` will disable logging.
|
||||
This switch only works when `--enable-logging` is also passed.
|
||||
|
||||
## --vmodule=`pattern`
|
||||
|
||||
@@ -109,10 +115,4 @@ Any pattern containing a forward or backward slash will be tested against the
|
||||
whole pathname and not just the module. E.g. `*/foo/bar/*=2` would change the
|
||||
logging level for all code in the source files under a `foo/bar` directory.
|
||||
|
||||
To disable all chromium related logs and only enable your application logs you
|
||||
can do:
|
||||
|
||||
```javascript
|
||||
app.commandLine.appendSwitch('v', -1);
|
||||
app.commandLine.appendSwitch('vmodule', 'console=0');
|
||||
```
|
||||
This switch only works when `--enable-logging` is also passed.
|
||||
|
||||
@@ -16,7 +16,7 @@ app.on('ready', function() {
|
||||
// Register a 'ctrl+x' shortcut listener.
|
||||
var ret = globalShortcut.register('ctrl+x', function() {
|
||||
console.log('ctrl+x is pressed');
|
||||
})
|
||||
});
|
||||
|
||||
if (!ret) {
|
||||
console.log('registration failed');
|
||||
@@ -62,4 +62,4 @@ Unregisters the global shortcut of `accelerator`.
|
||||
|
||||
### `globalShortcut.unregisterAll()`
|
||||
|
||||
Unregisters all the global shortcuts.
|
||||
Unregisters all of the global shortcuts.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# MenuItem
|
||||
|
||||
The `menu-item` module allows you to add items to an application or content
|
||||
The `menu-item` module allows you to add items to an application or context
|
||||
[`menu`](menu.md).
|
||||
|
||||
See [`menu`](menu.md) for examples.
|
||||
|
||||
@@ -142,7 +142,7 @@ Returns a boolean whether the image is empty.
|
||||
|
||||
Returns the size of the image.
|
||||
|
||||
[buffer]: https://iojs.org/api/buffer.html#buffer_class_buffer
|
||||
[buffer]: https://nodejs.org/api/buffer.html#buffer_class_buffer
|
||||
|
||||
### `image.setTemplateImage(option)`
|
||||
|
||||
|
||||
@@ -9,7 +9,27 @@ upstream node:
|
||||
* `process.versions['chrome']` String - Version of Chromium.
|
||||
* `process.resourcesPath` String - Path to JavaScript source code.
|
||||
|
||||
# Methods
|
||||
## Events
|
||||
|
||||
### Event: 'loaded'
|
||||
|
||||
Emitted when Electron has loaded its internal initialization script and is
|
||||
beginning to load the web page or the main script.
|
||||
|
||||
It can be used by the preload script to add removed Node global symbols back to
|
||||
the global scope when node integration is turned off:
|
||||
|
||||
```js
|
||||
// preload.js
|
||||
var _setImmediate = setImmediate;
|
||||
var _clearImmediate = clearImmediate;
|
||||
process.once('loaded', function() {
|
||||
global.setImmediate = _setImmediate;
|
||||
global.clearImmediate = _clearImmediate;
|
||||
});
|
||||
```
|
||||
|
||||
## Methods
|
||||
|
||||
The `process` object has the following method:
|
||||
|
||||
@@ -17,7 +37,7 @@ The `process` object has the following method:
|
||||
|
||||
Causes the main thread of the current process hang.
|
||||
|
||||
## process.setFdLimit(maxDescriptors) _OS X_ _Linux_
|
||||
### process.setFdLimit(maxDescriptors) _OS X_ _Linux_
|
||||
|
||||
* `maxDescriptors` Integer
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ which sends a file as a response.
|
||||
Intercepts `scheme` protocol and uses `handler` as the protocol's new handler
|
||||
which sends a `String` as a response.
|
||||
|
||||
## `protocol.interceptBufferProtocol(scheme, handler[, completion])`
|
||||
### `protocol.interceptBufferProtocol(scheme, handler[, completion])`
|
||||
|
||||
* `scheme` String
|
||||
* `handler` Function
|
||||
@@ -149,7 +149,7 @@ which sends a `String` as a response.
|
||||
Intercepts `scheme` protocol and uses `handler` as the protocol's new handler
|
||||
which sends a `Buffer` as a response.
|
||||
|
||||
## `protocol.interceptHttpProtocol(scheme, handler[, completion])`
|
||||
### `protocol.interceptHttpProtocol(scheme, handler[, completion])`
|
||||
|
||||
* `scheme` String
|
||||
* `handler` Function
|
||||
@@ -158,7 +158,7 @@ which sends a `Buffer` as a response.
|
||||
Intercepts `scheme` protocol and uses `handler` as the protocol's new handler
|
||||
which sends a new HTTP request as a response.
|
||||
|
||||
## `protocol.uninterceptProtocol(scheme[, completion])`
|
||||
### `protocol.uninterceptProtocol(scheme[, completion])`
|
||||
|
||||
* `scheme` String
|
||||
* `completion` Function
|
||||
|
||||
@@ -38,7 +38,7 @@ app.on('ready', function() {
|
||||
var displays = electronScreen.getAllDisplays();
|
||||
var externalDisplay = null;
|
||||
for (var i in displays) {
|
||||
if (displays[i].bounds.x > 0 || displays[i].bounds.y > 0) {
|
||||
if (displays[i].bounds.x != 0 || displays[i].bounds.y != 0) {
|
||||
externalDisplay = displays[i];
|
||||
break;
|
||||
}
|
||||
@@ -47,7 +47,7 @@ app.on('ready', function() {
|
||||
if (externalDisplay) {
|
||||
mainWindow = new BrowserWindow({
|
||||
x: externalDisplay.bounds.x + 50,
|
||||
y: externalDisplay.bounds.y + 50,
|
||||
y: externalDisplay.bounds.y + 50
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -65,7 +65,11 @@ notated by brackets surrounding the optional argument as well as the comma
|
||||
required if this optional argument follows another argument.
|
||||
|
||||
Below the method is more detailed information on each of the arguments. The type
|
||||
of argument is notated by either the common types: [`String`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String), [`Number`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number), [`Object`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object), [`Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)
|
||||
of argument is notated by either the common types:
|
||||
[`String`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String),
|
||||
[`Number`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number),
|
||||
[`Object`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object),
|
||||
[`Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)
|
||||
or a custom type like Electron's [`webContent`](api/web-content.md).
|
||||
|
||||
### Events
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
Electron enables you to create desktop applications with pure JavaScript by
|
||||
providing a runtime with rich native (operating system) APIs. You could see it
|
||||
as a variant of the io.js runtime that is focused on desktop applications
|
||||
as a variant of the Node.js runtime that is focused on desktop applications
|
||||
instead of web servers.
|
||||
|
||||
This doesn't mean Electron is a JavaScript binding to graphical user interface
|
||||
@@ -22,8 +22,9 @@ multi-process architecture is also used. Each web page in Electron runs in
|
||||
its own process, which is called __the renderer process__.
|
||||
|
||||
In normal browsers, web pages usually run in a sandboxed environment and are not
|
||||
allowed access to native resources. Electron users, however, have the power to use
|
||||
io.js APIs in web pages allowing lower level operating system interactions.
|
||||
allowed access to native resources. Electron users, however, have the power to
|
||||
use Node.js APIs in web pages allowing lower level operating system
|
||||
interactions.
|
||||
|
||||
### Differences Between Main Process and Renderer Process
|
||||
|
||||
@@ -129,7 +130,7 @@ Finally the `index.html` is the web page you want to show:
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hello World!</h1>
|
||||
We are using io.js <script>document.write(process.version)</script>
|
||||
We are using Node.js <script>document.write(process.version)</script>
|
||||
and Electron <script>document.write(process.versions['electron'])</script>.
|
||||
</body>
|
||||
</html>
|
||||
|
||||
31
docs/tutorial/supported-platforms.md
Normal file
31
docs/tutorial/supported-platforms.md
Normal file
@@ -0,0 +1,31 @@
|
||||
# Supported Platforms
|
||||
|
||||
Following platforms are supported by Electron:
|
||||
|
||||
### OS X
|
||||
|
||||
Only 64bit binaries are provided for OS X, and the minimum OS X version
|
||||
supported is OS X 10.8.
|
||||
|
||||
### Windows
|
||||
|
||||
Windows 7 and later are supported, older operating systems are not supported
|
||||
(and do not work).
|
||||
|
||||
Both `x86` and `amd64` (x64) binaries are provided for Windows. Please note, the
|
||||
`ARM` version of Windows is not supported for now.
|
||||
|
||||
### Linux
|
||||
|
||||
The prebuilt `ia32`(`i686`) and `x64`(`amd64`) binaries of Electron are built on
|
||||
Ubuntu 12.04, the `arm` binary is built against ARM v7 with hard-float ABI and
|
||||
NEON for Debian Wheezy.
|
||||
|
||||
Whether the prebuilt binary can run on a distribution depends on whether the
|
||||
distribution includes the libraries that Electron is linked to on the building
|
||||
platform, so only Ubuntu 12.04 is guaranteed to work, but following platforms
|
||||
are also verified to be able to run the prebuilt binaries of Electron:
|
||||
|
||||
* Ubuntu 12.04 and later
|
||||
* Fedora 21
|
||||
* Debian 8
|
||||
@@ -6,16 +6,17 @@ the location of Electron's headers when building native modules.
|
||||
|
||||
## Native Node Module Compatibility
|
||||
|
||||
Since Node v0.11.x there were vital changes in the V8 API. So generally all
|
||||
native modules written for Node v0.10.x won't work for newer Node or io.js
|
||||
versions. And because Electron internally uses __io.js v3.1.0__, it has the
|
||||
same problem.
|
||||
Native modules might break when Node starts using a new version of V8.
|
||||
To make sure the module you're interested in will work with Electron, you should
|
||||
check if it supports the internal Node version used by Electron.
|
||||
You can check what version of Node is used in Electron by looking it up in
|
||||
the [releases](https://github.com/atom/electron/releases) page or by using
|
||||
`process.version` (see [Quick Start](https://github.com/atom/electron/blob/master/docs/tutorial/quick-start.md)
|
||||
for example).
|
||||
|
||||
To solve this, you should use modules that support Node v0.11.x or later,
|
||||
[many modules](https://www.npmjs.org/browse/depended/nan) do support both now.
|
||||
For old modules that only support Node v0.10.x, you should use the
|
||||
[nan](https://github.com/rvagg/nan) module to port it to v0.11.x or later
|
||||
versions of Node or io.js.
|
||||
Consider using [NAN](https://github.com/nodejs/nan/) for your own modules, since
|
||||
it makes it easier to support multiple versions of Node. It's also helpful for
|
||||
porting old modules to newer versions of Node so they can work with Electron.
|
||||
|
||||
## How to Install Native Modules
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ driver.
|
||||
First you need to download the `chromedriver` binary, and run it:
|
||||
|
||||
```bash
|
||||
$ chromedriver --url-base=/wd/hub --port=9515
|
||||
$ chromedriver --url-base=wd/hub --port=9515
|
||||
Starting ChromeDriver (v2.10.291558) on port 9515
|
||||
Only local connections are allowed.
|
||||
```
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
'atom/common/api/lib/native-image.coffee',
|
||||
'atom/common/api/lib/shell.coffee',
|
||||
'atom/common/lib/init.coffee',
|
||||
'atom/common/lib/reset-search-paths.coffee',
|
||||
'atom/renderer/lib/chrome-api.coffee',
|
||||
'atom/renderer/lib/init.coffee',
|
||||
'atom/renderer/lib/inspector.coffee',
|
||||
@@ -123,8 +124,8 @@
|
||||
'atom/browser/atom_download_manager_delegate.h',
|
||||
'atom/browser/atom_browser_main_parts.cc',
|
||||
'atom/browser/atom_browser_main_parts.h',
|
||||
'atom/browser/atom_browser_main_parts_linux.cc',
|
||||
'atom/browser/atom_browser_main_parts_mac.mm',
|
||||
'atom/browser/atom_browser_main_parts_posix.cc',
|
||||
'atom/browser/atom_javascript_dialog_manager.cc',
|
||||
'atom/browser/atom_javascript_dialog_manager.h',
|
||||
'atom/browser/atom_quota_permission_context.cc',
|
||||
@@ -153,6 +154,7 @@
|
||||
'atom/browser/mac/atom_application_delegate.mm',
|
||||
'atom/browser/native_window.cc',
|
||||
'atom/browser/native_window.h',
|
||||
'atom/browser/native_window_views_win.cc',
|
||||
'atom/browser/native_window_views.cc',
|
||||
'atom/browser/native_window_views.h',
|
||||
'atom/browser/native_window_mac.h',
|
||||
@@ -428,6 +430,8 @@
|
||||
'chromium_src/chrome/renderer/tts_dispatcher.cc',
|
||||
'chromium_src/chrome/renderer/tts_dispatcher.h',
|
||||
'chromium_src/chrome/utility/utility_message_handler.h',
|
||||
'chromium_src/extensions/browser/app_window/size_constraints.cc',
|
||||
'chromium_src/extensions/browser/app_window/size_constraints.h',
|
||||
'chromium_src/library_loaders/libspeechd_loader.cc',
|
||||
'chromium_src/library_loaders/libspeechd.h',
|
||||
'chromium_src/net/test/embedded_test_server/stream_listen_socket.cc',
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
"asar": "^0.8.0",
|
||||
"coffee-script": "^1.9.2",
|
||||
"coffeelint": "^1.9.4",
|
||||
"request": "*",
|
||||
"request": "*"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"runas": "^3.0.0"
|
||||
},
|
||||
"private": true,
|
||||
|
||||
@@ -4,10 +4,17 @@ https = require 'https'
|
||||
path = require 'path'
|
||||
ws = require 'ws'
|
||||
remote = require 'remote'
|
||||
BrowserWindow = remote.require 'browser-window'
|
||||
|
||||
describe 'chromium feature', ->
|
||||
fixtures = path.resolve __dirname, 'fixtures'
|
||||
|
||||
listener = null
|
||||
afterEach ->
|
||||
if listener?
|
||||
window.removeEventListener 'message', listener
|
||||
listener = null
|
||||
|
||||
xdescribe 'heap snapshot', ->
|
||||
it 'does not crash', ->
|
||||
process.atomBinding('v8_util').takeHeapSnapshot()
|
||||
@@ -24,20 +31,17 @@ describe 'chromium feature', ->
|
||||
$.get "http://127.0.0.1:#{port}"
|
||||
|
||||
describe 'document.hidden', ->
|
||||
BrowserWindow = remote.require 'browser-window'
|
||||
ipc = remote.require 'ipc'
|
||||
url = "file://#{fixtures}/pages/document-hidden.html"
|
||||
w = null
|
||||
|
||||
afterEach ->
|
||||
w?.destroy()
|
||||
ipc.removeAllListeners 'hidden'
|
||||
|
||||
it 'is set correctly when window is not shown', (done) ->
|
||||
ipc.once 'hidden', (event, hidden) ->
|
||||
assert hidden
|
||||
done()
|
||||
w = new BrowserWindow(show:false)
|
||||
w.webContents.on 'ipc-message', (event, args) ->
|
||||
assert.deepEqual args, ['hidden', true]
|
||||
done()
|
||||
w.loadUrl url
|
||||
|
||||
describe 'navigator.webkitGetUserMedia', ->
|
||||
@@ -62,19 +66,17 @@ describe 'chromium feature', ->
|
||||
|
||||
it 'accepts "node-integration" as feature', (done) ->
|
||||
listener = (event) ->
|
||||
window.removeEventListener 'message', listener
|
||||
b.close()
|
||||
assert.equal event.data, 'undefined'
|
||||
b.close()
|
||||
done()
|
||||
window.addEventListener 'message', listener
|
||||
b = window.open "file://#{fixtures}/pages/window-opener-node.html", '', 'node-integration=no,show=no'
|
||||
|
||||
it 'inherit options of parent window', (done) ->
|
||||
listener = (event) ->
|
||||
window.removeEventListener 'message', listener
|
||||
b.close()
|
||||
size = remote.getCurrentWindow().getSize()
|
||||
assert.equal event.data, "size: #{size.width} #{size.height}"
|
||||
b.close()
|
||||
done()
|
||||
window.addEventListener 'message', listener
|
||||
b = window.open "file://#{fixtures}/pages/window-open-size.html", '', 'show=no'
|
||||
@@ -82,26 +84,25 @@ describe 'chromium feature', ->
|
||||
describe 'window.opener', ->
|
||||
@timeout 10000
|
||||
|
||||
ipc = remote.require 'ipc'
|
||||
url = "file://#{fixtures}/pages/window-opener.html"
|
||||
w = null
|
||||
|
||||
afterEach ->
|
||||
w?.destroy()
|
||||
ipc.removeAllListeners 'opener'
|
||||
|
||||
it 'is null for main window', (done) ->
|
||||
ipc.once 'opener', (event, opener) ->
|
||||
assert.equal opener, null
|
||||
done()
|
||||
BrowserWindow = remote.require 'browser-window'
|
||||
w = new BrowserWindow(show: false)
|
||||
w.webContents.on 'ipc-message', (event, args) ->
|
||||
assert.deepEqual args, ['opener', null]
|
||||
done()
|
||||
w.loadUrl url
|
||||
|
||||
it 'is not null for window opened by window.open', (done) ->
|
||||
ipc.once 'opener', (event, opener) ->
|
||||
listener = (event) ->
|
||||
assert.equal event.data, 'object'
|
||||
b.close()
|
||||
done(if opener isnt null then undefined else opener)
|
||||
done()
|
||||
window.addEventListener 'message', listener
|
||||
b = window.open url, '', 'show=no'
|
||||
|
||||
describe 'window.opener.postMessage', ->
|
||||
|
||||
5
spec/fixtures/pages/window-opener.html
vendored
5
spec/fixtures/pages/window-opener.html
vendored
@@ -1,7 +1,10 @@
|
||||
<html>
|
||||
<body>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
require('ipc').send('opener', window.opener);
|
||||
if (window.opener !== null)
|
||||
window.opener.postMessage(typeof window.opener, '*');
|
||||
else
|
||||
require('ipc').send('opener', window.opener);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -5,14 +5,16 @@
|
||||
"version": "0.1.0",
|
||||
"devDependencies": {
|
||||
"basic-auth": "^1.0.0",
|
||||
"ffi": "2.0.0",
|
||||
"formidable": "1.0.16",
|
||||
"graceful-fs": "3.0.5",
|
||||
"mocha": "2.1.0",
|
||||
"q": "0.9.7",
|
||||
"runas": "3.x",
|
||||
"temp": "0.8.1",
|
||||
"walkdir": "0.0.7",
|
||||
"ws": "0.7.2"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"ffi": "2.0.0",
|
||||
"runas": "3.x"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
'sysroot%': '',
|
||||
|
||||
'variables': {
|
||||
# The minimum OS X SDK version to use.
|
||||
'mac_sdk_min%': '10.10',
|
||||
|
||||
# Set ARM architecture version.
|
||||
'arm_version%': 7,
|
||||
|
||||
@@ -17,6 +20,7 @@
|
||||
},
|
||||
|
||||
# Copy conditionally-set variables out one scope.
|
||||
'mac_sdk_min%': '<(mac_sdk_min)',
|
||||
'arm_version%': '<(arm_version)',
|
||||
'arm_neon%': '<(arm_neon)',
|
||||
|
||||
@@ -35,6 +39,11 @@
|
||||
'source_root': '<!(cd <(DEPTH) && pwd -P)',
|
||||
}], # OS!="win"
|
||||
|
||||
# Search for the available version of SDK.
|
||||
['OS=="mac"', {
|
||||
'mac_sdk%': '<!(python <(DEPTH)/tools/mac/find_sdk.py <(mac_sdk_min))',
|
||||
}],
|
||||
|
||||
# Set default compiler flags depending on ARM version.
|
||||
['arm_version==6', {
|
||||
'arm_arch%': 'armv6',
|
||||
@@ -94,6 +103,15 @@
|
||||
},
|
||||
}], # clang==1
|
||||
|
||||
# Specify the SDKROOT.
|
||||
['OS=="mac"', {
|
||||
'target_defaults': {
|
||||
'xcode_settings': {
|
||||
'SDKROOT': 'macosx<(mac_sdk)', # -isysroot
|
||||
},
|
||||
},
|
||||
}],
|
||||
|
||||
# Setup sysroot environment.
|
||||
['OS=="linux" and target_arch in ["arm", "ia32"]', {
|
||||
'variables': {
|
||||
|
||||
93
tools/mac/find_sdk.py
Executable file
93
tools/mac/find_sdk.py
Executable file
@@ -0,0 +1,93 @@
|
||||
#!/usr/bin/env python
|
||||
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
"""Prints the lowest locally available SDK version greater than or equal to a
|
||||
given minimum sdk version to standard output.
|
||||
|
||||
Usage:
|
||||
python find_sdk.py 10.6 # Ignores SDKs < 10.6
|
||||
"""
|
||||
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
from optparse import OptionParser
|
||||
|
||||
|
||||
def parse_version(version_str):
|
||||
"""'10.6' => [10, 6]"""
|
||||
return map(int, re.findall(r'(\d+)', version_str))
|
||||
|
||||
|
||||
def main():
|
||||
parser = OptionParser()
|
||||
parser.add_option("--verify",
|
||||
action="store_true", dest="verify", default=False,
|
||||
help="return the sdk argument and warn if it doesn't exist")
|
||||
parser.add_option("--sdk_path",
|
||||
action="store", type="string", dest="sdk_path", default="",
|
||||
help="user-specified SDK path; bypasses verification")
|
||||
parser.add_option("--print_sdk_path",
|
||||
action="store_true", dest="print_sdk_path", default=False,
|
||||
help="Additionaly print the path the SDK (appears first).")
|
||||
options, args = parser.parse_args()
|
||||
if len(args) != 1:
|
||||
parser.error('Please specify a minimum SDK version')
|
||||
min_sdk_version = args[0]
|
||||
|
||||
job = subprocess.Popen(['xcode-select', '-print-path'],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT)
|
||||
out, err = job.communicate()
|
||||
if job.returncode != 0:
|
||||
print >> sys.stderr, out
|
||||
print >> sys.stderr, err
|
||||
raise Exception(('Error %d running xcode-select, you might have to run '
|
||||
'|sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer| '
|
||||
'if you are using Xcode 4.') % job.returncode)
|
||||
# The Developer folder moved in Xcode 4.3.
|
||||
xcode43_sdk_path = os.path.join(
|
||||
out.rstrip(), 'Platforms/MacOSX.platform/Developer/SDKs')
|
||||
if os.path.isdir(xcode43_sdk_path):
|
||||
sdk_dir = xcode43_sdk_path
|
||||
else:
|
||||
sdk_dir = os.path.join(out.rstrip(), 'SDKs')
|
||||
sdks = [re.findall('^MacOSX(10\.\d+)\.sdk$', s) for s in os.listdir(sdk_dir)]
|
||||
sdks = [s[0] for s in sdks if s] # [['10.5'], ['10.6']] => ['10.5', '10.6']
|
||||
sdks = [s for s in sdks # ['10.5', '10.6'] => ['10.6']
|
||||
if parse_version(s) >= parse_version(min_sdk_version)]
|
||||
if not sdks:
|
||||
raise Exception('No %s+ SDK found' % min_sdk_version)
|
||||
best_sdk = sorted(sdks, key=parse_version)[0]
|
||||
|
||||
if options.verify and best_sdk != min_sdk_version and not options.sdk_path:
|
||||
print >> sys.stderr, ''
|
||||
print >> sys.stderr, ' vvvvvvv'
|
||||
print >> sys.stderr, ''
|
||||
print >> sys.stderr, \
|
||||
'This build requires the %s SDK, but it was not found on your system.' \
|
||||
% min_sdk_version
|
||||
print >> sys.stderr, \
|
||||
'Either install it, or explicitly set mac_sdk in your GYP_DEFINES.'
|
||||
print >> sys.stderr, ''
|
||||
print >> sys.stderr, ' ^^^^^^^'
|
||||
print >> sys.stderr, ''
|
||||
return min_sdk_version
|
||||
|
||||
if options.print_sdk_path:
|
||||
print subprocess.check_output(['xcodebuild', '-version', '-sdk',
|
||||
'macosx' + best_sdk, 'Path']).strip()
|
||||
|
||||
return best_sdk
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if sys.platform != 'darwin':
|
||||
raise Exception("This script only runs on Mac")
|
||||
print main()
|
||||
sys.exit(0)
|
||||
2
vendor/brightray
vendored
2
vendor/brightray
vendored
Submodule vendor/brightray updated: 6cbb4ad4d1...375436a777
2
vendor/crashpad
vendored
2
vendor/crashpad
vendored
Submodule vendor/crashpad updated: e6a0d433b0...5b777419c3
Reference in New Issue
Block a user