mirror of
https://github.com/electron/electron.git
synced 2026-02-19 03:14:51 -05:00
Compare commits
305 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6ae38d86df | ||
|
|
9f0d9e0fad | ||
|
|
45b626e0cc | ||
|
|
c13724b342 | ||
|
|
5da1e9ed10 | ||
|
|
a8913f5ea0 | ||
|
|
a59756485e | ||
|
|
6949af5427 | ||
|
|
da602a7c01 | ||
|
|
50eb5454d4 | ||
|
|
8ee1e1d208 | ||
|
|
73ec7783af | ||
|
|
a8f172752a | ||
|
|
b7e120b68c | ||
|
|
a85075103f | ||
|
|
fe30880ec0 | ||
|
|
c81128b675 | ||
|
|
2634328720 | ||
|
|
0df59e2714 | ||
|
|
18fdbb6432 | ||
|
|
bd51a4c8cf | ||
|
|
6478244fbf | ||
|
|
e0f660301c | ||
|
|
192014cc3f | ||
|
|
61b69a4e8a | ||
|
|
ec00da416f | ||
|
|
d4929de33c | ||
|
|
a0b15661ed | ||
|
|
9a58706e1f | ||
|
|
ce586e0835 | ||
|
|
795c31918a | ||
|
|
2592487c3f | ||
|
|
f05daa8bdc | ||
|
|
75ec34884d | ||
|
|
96cb4fd6d7 | ||
|
|
d63de1ae15 | ||
|
|
5250871e69 | ||
|
|
426bc97194 | ||
|
|
76098255f0 | ||
|
|
e8594b492e | ||
|
|
d4e362ec89 | ||
|
|
df399f7c8c | ||
|
|
ef8e5505c8 | ||
|
|
71fd147c47 | ||
|
|
c271d89677 | ||
|
|
7cf040e7ca | ||
|
|
a6c92f20c8 | ||
|
|
400e963b8b | ||
|
|
2a7244a366 | ||
|
|
5741bad918 | ||
|
|
1d7445c5aa | ||
|
|
4a1f8cf1c9 | ||
|
|
a2bf1b3907 | ||
|
|
b2d4d76bcf | ||
|
|
9ac555c302 | ||
|
|
43711083f7 | ||
|
|
9b07c2b894 | ||
|
|
363f1da77e | ||
|
|
8655dec00e | ||
|
|
fbc68ecce5 | ||
|
|
8d4ac15834 | ||
|
|
249366c90a | ||
|
|
931182b677 | ||
|
|
2a129f892f | ||
|
|
57a27876ec | ||
|
|
fc2e069efe | ||
|
|
58d4ec5587 | ||
|
|
b0c23294fe | ||
|
|
290dd36bb0 | ||
|
|
84529de10d | ||
|
|
bde4a732c4 | ||
|
|
535b936c87 | ||
|
|
dc880b16f1 | ||
|
|
5eb1f52421 | ||
|
|
3747048218 | ||
|
|
a1a091d805 | ||
|
|
e536d0e7a8 | ||
|
|
e050494e5d | ||
|
|
bbc01e704c | ||
|
|
fff743053a | ||
|
|
e7b7efeb0a | ||
|
|
968fc71b78 | ||
|
|
d0494024a9 | ||
|
|
a12754f980 | ||
|
|
c76f510cea | ||
|
|
968f75529a | ||
|
|
93d5a2e195 | ||
|
|
367285f3f3 | ||
|
|
95b2003193 | ||
|
|
bcdc44c1c6 | ||
|
|
4ae2738ce5 | ||
|
|
e09a2ff811 | ||
|
|
7253a35455 | ||
|
|
1b1cf87115 | ||
|
|
3ec755e978 | ||
|
|
cf4616de7f | ||
|
|
2755fbaadf | ||
|
|
6f222651d7 | ||
|
|
fe4841a1cd | ||
|
|
fe8a2b9ee0 | ||
|
|
b939232670 | ||
|
|
cac3973731 | ||
|
|
19a35b58f0 | ||
|
|
5e51ad30d7 | ||
|
|
e1e5cb5ba4 | ||
|
|
8d124c7157 | ||
|
|
67ed72294b | ||
|
|
1bb5481071 | ||
|
|
876063b1ba | ||
|
|
7d193033f5 | ||
|
|
074ea374e0 | ||
|
|
f6c3a69595 | ||
|
|
f28881e203 | ||
|
|
6312c1108a | ||
|
|
0de40febab | ||
|
|
1701f572e2 | ||
|
|
15a9be6b93 | ||
|
|
a60be1563f | ||
|
|
a2522efb25 | ||
|
|
7c3f22a333 | ||
|
|
2945e1b50a | ||
|
|
aedacd39d2 | ||
|
|
d3f33152d0 | ||
|
|
cfca12d4a5 | ||
|
|
754cd88cc2 | ||
|
|
031426d54e | ||
|
|
980e8ca4dc | ||
|
|
df0094b6cb | ||
|
|
02d94c8b2e | ||
|
|
902be9bab5 | ||
|
|
f646d2dda8 | ||
|
|
92b19f89d9 | ||
|
|
d8eb465eb9 | ||
|
|
c04a9933cc | ||
|
|
5b12f80d01 | ||
|
|
75c44ca057 | ||
|
|
56f709ff1f | ||
|
|
0215c2fbee | ||
|
|
6e079d8bc4 | ||
|
|
a4715f936b | ||
|
|
1d88b31edd | ||
|
|
e07e26ca76 | ||
|
|
c82e73a4ec | ||
|
|
eda4249bf8 | ||
|
|
09201e3e65 | ||
|
|
2ca2d37e93 | ||
|
|
d3416e2873 | ||
|
|
4e4e316005 | ||
|
|
8fc1e055bf | ||
|
|
d51ea21afa | ||
|
|
abf982e4e5 | ||
|
|
998e9792fb | ||
|
|
c87b21148c | ||
|
|
7e67f7632d | ||
|
|
cd68396bd5 | ||
|
|
474e1fcd3b | ||
|
|
cfeeec37eb | ||
|
|
0a84c30d3b | ||
|
|
7ba03ce23d | ||
|
|
cc5db4dab9 | ||
|
|
aa3e8385df | ||
|
|
886ebdb002 | ||
|
|
ea2f87683a | ||
|
|
c116f6b35c | ||
|
|
2413eebd7b | ||
|
|
7708e7a8c4 | ||
|
|
1c0b391419 | ||
|
|
28f5d184b3 | ||
|
|
fc00da9732 | ||
|
|
9ea75b7519 | ||
|
|
61c63a6af9 | ||
|
|
e4bfa373de | ||
|
|
d53915c6ab | ||
|
|
409a431892 | ||
|
|
d82cfc023f | ||
|
|
f9c41f33e5 | ||
|
|
4ec4b01218 | ||
|
|
0a37852757 | ||
|
|
42ffa5813f | ||
|
|
597e17b540 | ||
|
|
9ac0591386 | ||
|
|
cb73a3c572 | ||
|
|
2c672052e6 | ||
|
|
b431e96f9d | ||
|
|
36445f8d8b | ||
|
|
085b1a45ee | ||
|
|
844fccc177 | ||
|
|
0a63395b0f | ||
|
|
623e0f3ae4 | ||
|
|
e9e90b481a | ||
|
|
4a1ee39156 | ||
|
|
e5afa72b4d | ||
|
|
287c948845 | ||
|
|
4625f051c8 | ||
|
|
8d271a6655 | ||
|
|
65b3435156 | ||
|
|
3c60e07653 | ||
|
|
564c5c1664 | ||
|
|
5f4a9316f1 | ||
|
|
a0c0bb18b7 | ||
|
|
284160bf2d | ||
|
|
0229c3187b | ||
|
|
eec8560119 | ||
|
|
fc4ed9be12 | ||
|
|
a614134144 | ||
|
|
5670ee7693 | ||
|
|
420ae1a2cc | ||
|
|
02bbf07d3a | ||
|
|
121163f9ca | ||
|
|
d79626f02f | ||
|
|
7cffbc8a1a | ||
|
|
170ef2362f | ||
|
|
e45f83e62a | ||
|
|
687c9de5d7 | ||
|
|
e43b39a009 | ||
|
|
bfe8928ab1 | ||
|
|
d6d1604623 | ||
|
|
7d5826df85 | ||
|
|
9493c1b0bb | ||
|
|
a2aa20b6b2 | ||
|
|
c8d0968e00 | ||
|
|
8237edcf0d | ||
|
|
13261921a7 | ||
|
|
adc5495d2b | ||
|
|
02d14ed23b | ||
|
|
a0a5b20ef1 | ||
|
|
fd081e162b | ||
|
|
30be4a847f | ||
|
|
0d77ba5222 | ||
|
|
94569f7f8c | ||
|
|
fdfff63119 | ||
|
|
da03784610 | ||
|
|
deef68bcf9 | ||
|
|
6393e2e1e5 | ||
|
|
bf77fcc03e | ||
|
|
386b921914 | ||
|
|
401fe76acd | ||
|
|
2fd3616ef3 | ||
|
|
ffaf535d00 | ||
|
|
9ac5ea5a6c | ||
|
|
edf7496443 | ||
|
|
151b2b5ad5 | ||
|
|
1fc9ef33db | ||
|
|
858f21a69c | ||
|
|
3a4835ff1c | ||
|
|
47d37cc1e3 | ||
|
|
a5224f705d | ||
|
|
b737e602b7 | ||
|
|
59f586ba59 | ||
|
|
70b7659893 | ||
|
|
717b664802 | ||
|
|
75e1fb63c8 | ||
|
|
a9c20dc42f | ||
|
|
dce7e50636 | ||
|
|
edd2bd74c9 | ||
|
|
6f8c46d2f4 | ||
|
|
4bab284f2e | ||
|
|
59b3e74542 | ||
|
|
4af646b760 | ||
|
|
5720d4f802 | ||
|
|
80824b13c6 | ||
|
|
33ad68f7a7 | ||
|
|
4af802f215 | ||
|
|
3b4a45ac65 | ||
|
|
a0548530e7 | ||
|
|
8d6764e0a0 | ||
|
|
36ecb35cb1 | ||
|
|
9ad3b7939f | ||
|
|
8493975840 | ||
|
|
ec880d64bf | ||
|
|
113d644615 | ||
|
|
4105527d07 | ||
|
|
2228184066 | ||
|
|
1af4ecfc26 | ||
|
|
9981fd51da | ||
|
|
458ff5c41f | ||
|
|
7735d8fbfd | ||
|
|
20e368eb89 | ||
|
|
ed3358e501 | ||
|
|
d181ff4e7f | ||
|
|
f8f09eb974 | ||
|
|
28b692aeaa | ||
|
|
aef6d44a01 | ||
|
|
e4b4087fdb | ||
|
|
1d2de6d1fb | ||
|
|
67dd596386 | ||
|
|
bd0836581b | ||
|
|
cdb5e24d2f | ||
|
|
6b02be6da8 | ||
|
|
d1a5c49843 | ||
|
|
dd4e43eb02 | ||
|
|
9007a45051 | ||
|
|
801a19504a | ||
|
|
a6989847ea | ||
|
|
e7d25385b0 | ||
|
|
62f200d252 | ||
|
|
374cf948e4 | ||
|
|
8f558fb252 | ||
|
|
8f2dd91e34 | ||
|
|
896c1793d3 | ||
|
|
85428d8eb3 | ||
|
|
57bee8b788 | ||
|
|
0ad51c394b | ||
|
|
e8455d5c9a | ||
|
|
2768eaa676 |
6
.gitmodules
vendored
6
.gitmodules
vendored
@@ -4,12 +4,12 @@
|
||||
[submodule "vendor/node"]
|
||||
path = vendor/node
|
||||
url = https://github.com/atom/node.git
|
||||
[submodule "vendor/gyp"]
|
||||
path = vendor/gyp
|
||||
url = https://github.com/svn2github/gyp.git
|
||||
[submodule "vendor/depot_tools"]
|
||||
path = vendor/depot_tools
|
||||
url = https://chromium.googlesource.com/chromium/tools/depot_tools.git
|
||||
[submodule "vendor/apm"]
|
||||
path = vendor/apm
|
||||
url = https://github.com/atom/apm.git
|
||||
[submodule "vendor/breakpad"]
|
||||
path = vendor/breakpad
|
||||
url = https://github.com/atom/chromium-breakpad.git
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Atom Shell
|
||||
|
||||
Native layer for the [Atom](https://github.com/github/atom).
|
||||
Native layer for the [Atom editor](https://github.com/atom/atom).
|
||||
|
||||
## Features
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include "app/atom_main_delegate.h"
|
||||
#include "base/environment.h"
|
||||
#include "common/crash_reporter/win/crash_service_main.h"
|
||||
#include "content/public/app/startup_helper_win.h"
|
||||
#include "sandbox/win/src/sandbox_types.h"
|
||||
#else // defined(OS_WIN)
|
||||
@@ -34,16 +35,20 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
|
||||
int argc = 0;
|
||||
wchar_t** wargv = ::CommandLineToArgvW(::GetCommandLineW(), &argc);
|
||||
|
||||
// Attach to the parent console if we've got one so that stdio works
|
||||
AttachConsole(ATTACH_PARENT_PROCESS);
|
||||
|
||||
FILE* dontcare;
|
||||
freopen_s(&dontcare, "CON", "w", stdout);
|
||||
freopen_s(&dontcare, "CON", "w", stderr);
|
||||
freopen_s(&dontcare, "CON", "r", stdin);
|
||||
|
||||
scoped_ptr<base::Environment> env(base::Environment::Create());
|
||||
std::string node_indicator;
|
||||
|
||||
// Make output work in console if we are not in cygiwn.
|
||||
std::string os;
|
||||
if (env->GetVar("OS", &os) && os != "cygwin") {
|
||||
AttachConsole(ATTACH_PARENT_PROCESS);
|
||||
|
||||
FILE* dontcare;
|
||||
freopen_s(&dontcare, "CON", "w", stdout);
|
||||
freopen_s(&dontcare, "CON", "w", stderr);
|
||||
freopen_s(&dontcare, "CON", "r", stdin);
|
||||
}
|
||||
|
||||
std::string node_indicator, crash_service_indicator;
|
||||
if (env->GetVar("ATOM_SHELL_INTERNAL_RUN_AS_NODE", &node_indicator) &&
|
||||
node_indicator == "1") {
|
||||
// Convert argv to to UTF8
|
||||
@@ -81,6 +86,10 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
|
||||
}
|
||||
// Now that conversion is done, we can finally start.
|
||||
return node::Start(argc, argv);
|
||||
} else if (env->GetVar("ATOM_SHELL_INTERNAL_CRASH_SERVICE",
|
||||
&crash_service_indicator) &&
|
||||
crash_service_indicator == "1") {
|
||||
return crash_service::Main(cmd);
|
||||
}
|
||||
|
||||
sandbox::SandboxInterfaceInfo sandbox_info = {0};
|
||||
|
||||
@@ -23,19 +23,23 @@ AtomMainDelegate::~AtomMainDelegate() {
|
||||
bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
|
||||
// Disable logging out to debug.log on Windows
|
||||
#if defined(OS_WIN)
|
||||
logging::InitLogging(
|
||||
L"debug.log",
|
||||
logging::LoggingSettings settings;
|
||||
#if defined(DEBUG)
|
||||
logging::LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG ,
|
||||
settings.logging_dest = logging::LOG_TO_ALL;
|
||||
settings.log_file = L"debug.log";
|
||||
settings.lock_log = logging::LOCK_LOG_FILE;
|
||||
settings.delete_old = logging::DELETE_OLD_LOG_FILE;
|
||||
#else
|
||||
logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG,
|
||||
#endif // defined(NDEBUG)
|
||||
logging::LOCK_LOG_FILE,
|
||||
logging::DELETE_OLD_LOG_FILE,
|
||||
logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS);
|
||||
logging::SetLogItems(true, false, true, false);
|
||||
settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
|
||||
#endif
|
||||
settings.dcheck_state =
|
||||
logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS;
|
||||
logging::InitLogging(settings);
|
||||
#endif // defined(OS_WIN)
|
||||
|
||||
// Logging with pid and timestamp.
|
||||
logging::SetLogItems(true, false, true, false);
|
||||
|
||||
return brightray::MainDelegate::BasicStartupComplete(exit_code);
|
||||
}
|
||||
|
||||
@@ -43,13 +47,29 @@ void AtomMainDelegate::PreSandboxStartup() {
|
||||
#if defined(OS_MACOSX)
|
||||
OverrideChildProcessPath();
|
||||
OverrideFrameworkBundlePath();
|
||||
SetProcessName();
|
||||
#endif
|
||||
InitializeResourceBundle();
|
||||
|
||||
// Disable renderer sandbox for most of node's functions.
|
||||
CommandLine* command_line = CommandLine::ForCurrentProcess();
|
||||
std::string process_type = command_line->GetSwitchValueASCII(
|
||||
switches::kProcessType);
|
||||
|
||||
// Don't append arguments for renderer process.
|
||||
if (process_type == switches::kRendererProcess)
|
||||
return;
|
||||
|
||||
// Add a flag to mark the start of switches added by atom-shell.
|
||||
command_line->AppendSwitch("atom-shell-switches-start");
|
||||
|
||||
// Disable renderer sandbox for most of node's functions.
|
||||
command_line->AppendSwitch(switches::kNoSandbox);
|
||||
|
||||
// Disable accelerated compositing since it caused a lot of troubles (black
|
||||
// devtools, screen flashes) and needed lots of effort to make it right.
|
||||
command_line->AppendSwitch(switches::kDisableAcceleratedCompositing);
|
||||
|
||||
// Add a flag to mark the end of switches added by atom-shell.
|
||||
command_line->AppendSwitch("atom-shell-switches-end");
|
||||
}
|
||||
|
||||
void AtomMainDelegate::InitializeResourceBundle() {
|
||||
|
||||
@@ -23,7 +23,6 @@ class AtomMainDelegate : public brightray::MainDelegate {
|
||||
virtual base::FilePath GetResourcesPakFilePath();
|
||||
virtual void OverrideChildProcessPath();
|
||||
virtual void OverrideFrameworkBundlePath();
|
||||
virtual void SetProcessName();
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
@@ -34,7 +34,7 @@ base::FilePath AtomMainDelegate::GetResourcesPakFilePath() {
|
||||
|
||||
void AtomMainDelegate::OverrideFrameworkBundlePath() {
|
||||
base::mac::SetOverrideFrameworkBundlePath(
|
||||
GetFrameworksPath().Append("Atom.framework"));
|
||||
GetFrameworksPath().Append("Atom Framework.framework"));
|
||||
}
|
||||
|
||||
void AtomMainDelegate::OverrideChildProcessPath() {
|
||||
@@ -45,22 +45,4 @@ void AtomMainDelegate::OverrideChildProcessPath() {
|
||||
PathService::Override(content::CHILD_PROCESS_EXE, helper_path);
|
||||
}
|
||||
|
||||
void AtomMainDelegate::SetProcessName() {
|
||||
const auto& command_line = *CommandLine::ForCurrentProcess();
|
||||
auto process_type = command_line.GetSwitchValueASCII(switches::kProcessType);
|
||||
std::string suffix;
|
||||
if (process_type == switches::kRendererProcess)
|
||||
suffix = "Renderer";
|
||||
else if (process_type == switches::kPluginProcess ||
|
||||
process_type == switches::kPpapiPluginProcess)
|
||||
suffix = "Plug-In Host";
|
||||
else if (process_type == switches::kUtilityProcess)
|
||||
suffix = "Utility";
|
||||
else
|
||||
return;
|
||||
|
||||
base::mac::SetProcessName(base::mac::NSToCFCast(base::SysUTF8ToNSString(
|
||||
brightray::GetApplicationName() + " " + suffix)));
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
||||
209
atom.gyp
209
atom.gyp
@@ -2,32 +2,36 @@
|
||||
'variables': {
|
||||
'project_name': 'atom',
|
||||
'product_name': 'Atom',
|
||||
'framework_name': 'Atom Framework',
|
||||
'app_sources': [
|
||||
'app/atom_main.cc',
|
||||
'app/atom_main.h',
|
||||
],
|
||||
'bundle_sources': [
|
||||
'browser/mac/atom.icns',
|
||||
'browser/resources/mac/atom.icns',
|
||||
],
|
||||
'coffee_sources': [
|
||||
'browser/api/lib/app.coffee',
|
||||
'browser/api/lib/atom-delegate.coffee',
|
||||
'browser/api/lib/auto-updater.coffee',
|
||||
'browser/api/lib/browser-window.coffee',
|
||||
'browser/api/lib/crash-reporter.coffee',
|
||||
'browser/api/lib/dialog.coffee',
|
||||
'browser/api/lib/ipc.coffee',
|
||||
'browser/api/lib/menu.coffee',
|
||||
'browser/api/lib/menu-item.coffee',
|
||||
'browser/api/lib/power-monitor.coffee',
|
||||
'browser/api/lib/protocol.coffee',
|
||||
'browser/atom/atom.coffee',
|
||||
'browser/atom/objects-registry.coffee',
|
||||
'browser/atom/rpc-server.coffee',
|
||||
'browser/lib/init.coffee',
|
||||
'browser/lib/objects-registry.coffee',
|
||||
'browser/lib/rpc-server.coffee',
|
||||
'common/api/lib/callbacks-registry.coffee',
|
||||
'common/api/lib/clipboard.coffee',
|
||||
'common/api/lib/crash-reporter.coffee',
|
||||
'common/api/lib/id-weak-map.coffee',
|
||||
'common/api/lib/screen.coffee',
|
||||
'common/api/lib/shell.coffee',
|
||||
'common/lib/init.coffee',
|
||||
'renderer/lib/init.coffee',
|
||||
'renderer/api/lib/ipc.coffee',
|
||||
'renderer/api/lib/remote.coffee',
|
||||
],
|
||||
@@ -41,14 +45,10 @@
|
||||
'browser/api/atom_api_auto_updater.h',
|
||||
'browser/api/atom_api_browser_ipc.cc',
|
||||
'browser/api/atom_api_browser_ipc.h',
|
||||
'browser/api/atom_api_crash_reporter.h',
|
||||
'browser/api/atom_api_crash_reporter.cc',
|
||||
'browser/api/atom_api_dialog.cc',
|
||||
'browser/api/atom_api_dialog.h',
|
||||
'browser/api/atom_api_event.cc',
|
||||
'browser/api/atom_api_event.h',
|
||||
'browser/api/atom_api_event_emitter.cc',
|
||||
'browser/api/atom_api_event_emitter.h',
|
||||
'browser/api/atom_api_menu.cc',
|
||||
'browser/api/atom_api_menu.h',
|
||||
'browser/api/atom_api_menu_mac.h',
|
||||
@@ -65,7 +65,6 @@
|
||||
'browser/api/atom_browser_bindings.h',
|
||||
'browser/auto_updater.cc',
|
||||
'browser/auto_updater.h',
|
||||
'browser/auto_updater_delegate.cc',
|
||||
'browser/auto_updater_delegate.h',
|
||||
'browser/auto_updater_mac.mm',
|
||||
'browser/auto_updater_win.cc',
|
||||
@@ -87,9 +86,6 @@
|
||||
'browser/browser_mac.mm',
|
||||
'browser/browser_win.cc',
|
||||
'browser/browser_observer.h',
|
||||
'browser/crash_reporter.h',
|
||||
'browser/crash_reporter_mac.mm',
|
||||
'browser/crash_reporter_win.cc',
|
||||
'browser/native_window.cc',
|
||||
'browser/native_window.h',
|
||||
'browser/native_window_mac.h',
|
||||
@@ -109,18 +105,18 @@
|
||||
'browser/ui/accelerator_util.h',
|
||||
'browser/ui/accelerator_util_mac.mm',
|
||||
'browser/ui/accelerator_util_win.cc',
|
||||
'browser/ui/atom_event_processing_window.h',
|
||||
'browser/ui/atom_event_processing_window.mm',
|
||||
'browser/ui/atom_menu_controller_mac.h',
|
||||
'browser/ui/atom_menu_controller_mac.mm',
|
||||
'browser/ui/cocoa/atom_menu_controller.h',
|
||||
'browser/ui/cocoa/atom_menu_controller.mm',
|
||||
'browser/ui/cocoa/event_processing_window.h',
|
||||
'browser/ui/cocoa/event_processing_window.mm',
|
||||
'browser/ui/cocoa/nsalert_synchronous_sheet.h',
|
||||
'browser/ui/cocoa/nsalert_synchronous_sheet.mm',
|
||||
'browser/ui/file_dialog.h',
|
||||
'browser/ui/file_dialog_mac.mm',
|
||||
'browser/ui/file_dialog_win.cc',
|
||||
'browser/ui/message_box.h',
|
||||
'browser/ui/message_box_mac.mm',
|
||||
'browser/ui/message_box_win.cc',
|
||||
'browser/ui/nsalert_synchronous_sheet_mac.h',
|
||||
'browser/ui/nsalert_synchronous_sheet_mac.mm',
|
||||
'browser/ui/win/menu_2.cc',
|
||||
'browser/ui/win/menu_2.h',
|
||||
'browser/ui/win/native_menu_win.cc',
|
||||
@@ -132,8 +128,14 @@
|
||||
'common/api/api_messages.h',
|
||||
'common/api/atom_api_clipboard.cc',
|
||||
'common/api/atom_api_clipboard.h',
|
||||
'common/api/atom_api_crash_reporter.cc',
|
||||
'common/api/atom_api_crash_reporter.h',
|
||||
'common/api/atom_api_event_emitter.cc',
|
||||
'common/api/atom_api_event_emitter.h',
|
||||
'common/api/atom_api_id_weak_map.cc',
|
||||
'common/api/atom_api_id_weak_map.h',
|
||||
'common/api/atom_api_screen.cc',
|
||||
'common/api/atom_api_screen.h',
|
||||
'common/api/atom_api_shell.cc',
|
||||
'common/api/atom_api_shell.h',
|
||||
'common/api/atom_api_v8_util.cc',
|
||||
@@ -143,6 +145,16 @@
|
||||
'common/api/atom_extensions.h',
|
||||
'common/api/object_life_monitor.cc',
|
||||
'common/api/object_life_monitor.h',
|
||||
'common/crash_reporter/crash_reporter.cc',
|
||||
'common/crash_reporter/crash_reporter.h',
|
||||
'common/crash_reporter/crash_reporter_mac.h',
|
||||
'common/crash_reporter/crash_reporter_mac.mm',
|
||||
'common/crash_reporter/crash_reporter_win.cc',
|
||||
'common/crash_reporter/crash_reporter_win.h',
|
||||
'common/crash_reporter/win/crash_service.cc',
|
||||
'common/crash_reporter/win/crash_service.h',
|
||||
'common/crash_reporter/win/crash_service_main.cc',
|
||||
'common/crash_reporter/win/crash_service_main.h',
|
||||
'common/draggable_region.cc',
|
||||
'common/draggable_region.h',
|
||||
'common/node_bindings.cc',
|
||||
@@ -156,9 +168,12 @@
|
||||
'common/platform_util.h',
|
||||
'common/platform_util_mac.mm',
|
||||
'common/platform_util_win.cc',
|
||||
'common/v8_conversions.h',
|
||||
'common/v8_value_converter_impl.cc',
|
||||
'common/v8_value_converter_impl.h',
|
||||
'common/swap_or_assign.h',
|
||||
'common/v8/node_common.h',
|
||||
'common/v8/scoped_persistent.h',
|
||||
'common/v8/native_type_conversions.h',
|
||||
'common/v8/v8_value_converter.cc',
|
||||
'common/v8/v8_value_converter.h',
|
||||
'renderer/api/atom_api_renderer_ipc.cc',
|
||||
'renderer/api/atom_api_renderer_ipc.h',
|
||||
'renderer/api/atom_renderer_bindings.cc',
|
||||
@@ -175,23 +190,13 @@
|
||||
'conditions': [
|
||||
['OS=="win"', {
|
||||
'app_sources': [
|
||||
'app/win/resource.h',
|
||||
'app/win/atom.ico',
|
||||
'app/win/atom.rc',
|
||||
'browser/resources/win/resource.h',
|
||||
'browser/resources/win/atom.ico',
|
||||
'browser/resources/win/atom.rc',
|
||||
'<(libchromiumcontent_src_dir)/content/app/startup_helper_win.cc',
|
||||
],
|
||||
}], # OS=="win"
|
||||
],
|
||||
'fix_framework_link_command': [
|
||||
'install_name_tool',
|
||||
'-change',
|
||||
'@loader_path/../Frameworks/Sparkle.framework/Versions/A/Sparkle',
|
||||
'@rpath/Sparkle.framework/Versions/A/Sparkle',
|
||||
'-change',
|
||||
'@executable_path/../Frameworks/Quincy.framework/Versions/A/Quincy',
|
||||
'@rpath/Quincy.framework/Versions/A/Quincy',
|
||||
'${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}'
|
||||
],
|
||||
'atom_source_root': '<!(python tools/atom_source_root.py)',
|
||||
},
|
||||
'target_defaults': {
|
||||
@@ -236,7 +241,7 @@
|
||||
'<(project_name)_helper',
|
||||
],
|
||||
'xcode_settings': {
|
||||
'INFOPLIST_FILE': 'browser/mac/Info.plist',
|
||||
'INFOPLIST_FILE': 'browser/resources/mac/Info.plist',
|
||||
'LD_RUNPATH_SEARCH_PATHS': [
|
||||
'@executable_path/../Frameworks',
|
||||
],
|
||||
@@ -249,9 +254,10 @@
|
||||
'destination': '<(PRODUCT_DIR)/<(product_name).app/Contents/Frameworks',
|
||||
'files': [
|
||||
'<(PRODUCT_DIR)/<(product_name) Helper.app',
|
||||
'<(PRODUCT_DIR)/<(product_name).framework',
|
||||
'frameworks/Sparkle.framework',
|
||||
'frameworks/Quincy.framework',
|
||||
'<(PRODUCT_DIR)/<(framework_name).framework',
|
||||
'frameworks/Squirrel.framework',
|
||||
'frameworks/ReactiveCocoa.framework',
|
||||
'frameworks/Mantle.framework',
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -262,12 +268,6 @@
|
||||
},
|
||||
],
|
||||
'postbuilds': [
|
||||
{
|
||||
'postbuild_name': 'Fix Framework Link',
|
||||
'action': [
|
||||
'<@(fix_framework_link_command)',
|
||||
],
|
||||
},
|
||||
{
|
||||
# This postbuid step is responsible for creating the following
|
||||
# helpers:
|
||||
@@ -307,13 +307,13 @@
|
||||
],
|
||||
}], # OS=="win"
|
||||
],
|
||||
},
|
||||
}, # target <(project_name)
|
||||
{
|
||||
'target_name': '<(project_name)_lib',
|
||||
'type': 'static_library',
|
||||
'dependencies': [
|
||||
'vendor/brightray/brightray.gyp:brightray',
|
||||
'vendor/node/node.gyp:node',
|
||||
'vendor/node/node.gyp:node_lib',
|
||||
],
|
||||
'sources': [
|
||||
'<@(lib_sources)',
|
||||
@@ -321,6 +321,14 @@
|
||||
'include_dirs': [
|
||||
'.',
|
||||
'vendor',
|
||||
# Include directories for uv and node.
|
||||
'vendor/node/src',
|
||||
'vendor/node/deps/http_parser',
|
||||
'vendor/node/deps/uv/include',
|
||||
# The `node.h` is using `#include"v8.h"`.
|
||||
'vendor/brightray/vendor/download/libchromiumcontent/src/v8/include',
|
||||
# The `node.h` is using `#include"ares.h"`.
|
||||
'vendor/node/deps/cares/include',
|
||||
],
|
||||
'direct_dependent_settings': {
|
||||
'include_dirs': [
|
||||
@@ -337,12 +345,22 @@
|
||||
'-limm32.lib',
|
||||
'-loleacc.lib',
|
||||
'-lComdlg32.lib',
|
||||
'-lWininet.lib',
|
||||
'<(atom_source_root)/<(libchromiumcontent_library_dir)/chromiumviews.lib',
|
||||
],
|
||||
},
|
||||
'dependencies': [
|
||||
'vendor/breakpad/breakpad.gyp:breakpad_handler',
|
||||
'vendor/breakpad/breakpad.gyp:breakpad_sender',
|
||||
],
|
||||
}],
|
||||
['OS=="mac"', {
|
||||
'dependencies': [
|
||||
'vendor/breakpad/breakpad.gyp:breakpad',
|
||||
],
|
||||
}],
|
||||
],
|
||||
},
|
||||
}, # target <(product_name)_lib
|
||||
{
|
||||
'target_name': 'generated_sources',
|
||||
'type': 'none',
|
||||
@@ -382,14 +400,70 @@
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
}, # target generated_sources
|
||||
{
|
||||
'target_name': '<(project_name)_dump_symbols',
|
||||
'type': 'none',
|
||||
'dependencies': [
|
||||
'<(project_name)',
|
||||
],
|
||||
'conditions': [
|
||||
['OS=="mac"', {
|
||||
'dependencies': [
|
||||
'vendor/breakpad/breakpad.gyp:dump_syms',
|
||||
],
|
||||
'actions': [
|
||||
{
|
||||
'action_name': 'Dump Symbols',
|
||||
'inputs': [
|
||||
'<(PRODUCT_DIR)/<(product_name).app/Contents/MacOS/<(product_name)',
|
||||
],
|
||||
'outputs': [
|
||||
'<(PRODUCT_DIR)/Atom-Shell.breakpad.syms',
|
||||
],
|
||||
'action': [
|
||||
'python',
|
||||
'tools/mac/generate_breakpad_symbols.py',
|
||||
'--build-dir=<(PRODUCT_DIR)',
|
||||
'--binary=<(PRODUCT_DIR)/<(product_name).app/Contents/MacOS/<(product_name)',
|
||||
'--symbols-dir=<(PRODUCT_DIR)/Atom-Shell.breakpad.syms',
|
||||
'--libchromiumcontent-dir=<(libchromiumcontent_library_dir)',
|
||||
'--clear',
|
||||
'--jobs=16',
|
||||
],
|
||||
},
|
||||
],
|
||||
}], # OS=="mac"
|
||||
['OS=="win"', {
|
||||
'actions': [
|
||||
{
|
||||
'action_name': 'Dump Symbols',
|
||||
'inputs': [
|
||||
'<(PRODUCT_DIR)/<(project_name).exe',
|
||||
],
|
||||
'outputs': [
|
||||
'<(PRODUCT_DIR)/Atom-Shell.breakpad.syms',
|
||||
],
|
||||
'action': [
|
||||
'python',
|
||||
'tools/win/generate_breakpad_symbols.py',
|
||||
'--symbols-dir=<(PRODUCT_DIR)/Atom-Shell.breakpad.syms',
|
||||
'--jobs=16',
|
||||
'<(PRODUCT_DIR)',
|
||||
'<(libchromiumcontent_library_dir)',
|
||||
],
|
||||
},
|
||||
],
|
||||
}], # OS=="win"
|
||||
],
|
||||
}, # target <(project_name>_dump_symbols
|
||||
],
|
||||
'conditions': [
|
||||
['OS=="mac"', {
|
||||
'targets': [
|
||||
{
|
||||
'target_name': '<(project_name)_framework',
|
||||
'product_name': '<(product_name)',
|
||||
'product_name': '<(framework_name)',
|
||||
'type': 'shared_library',
|
||||
'dependencies': [
|
||||
'<(project_name)_lib',
|
||||
@@ -408,20 +482,22 @@
|
||||
'link_settings': {
|
||||
'libraries': [
|
||||
'$(SDKROOT)/System/Library/Frameworks/Carbon.framework',
|
||||
'frameworks/Sparkle.framework',
|
||||
'frameworks/Quincy.framework',
|
||||
'frameworks/Squirrel.framework',
|
||||
'frameworks/ReactiveCocoa.framework',
|
||||
'frameworks/Mantle.framework',
|
||||
],
|
||||
},
|
||||
'mac_bundle': 1,
|
||||
'mac_bundle_resources': [
|
||||
'browser/mac/MainMenu.xib',
|
||||
'common/resources/mac/MainMenu.xib',
|
||||
'<(libchromiumcontent_resources_dir)/content_shell.pak',
|
||||
],
|
||||
'xcode_settings': {
|
||||
'INFOPLIST_FILE': 'common/resources/mac/Info.plist',
|
||||
'LIBRARY_SEARCH_PATHS': [
|
||||
'<(libchromiumcontent_library_dir)',
|
||||
],
|
||||
'LD_DYLIB_INSTALL_NAME': '@rpath/<(product_name).framework/<(product_name)',
|
||||
'LD_DYLIB_INSTALL_NAME': '@rpath/<(framework_name).framework/<(framework_name)',
|
||||
'LD_RUNPATH_SEARCH_PATHS': [
|
||||
'@loader_path/Libraries',
|
||||
],
|
||||
@@ -431,25 +507,26 @@
|
||||
},
|
||||
'copies': [
|
||||
{
|
||||
'destination': '<(PRODUCT_DIR)/<(product_name).framework/Versions/A/Libraries',
|
||||
'destination': '<(PRODUCT_DIR)/<(framework_name).framework/Versions/A/Libraries',
|
||||
'files': [
|
||||
'<(libchromiumcontent_library_dir)/ffmpegsumo.so',
|
||||
'<(libchromiumcontent_library_dir)/libchromiumcontent.dylib',
|
||||
],
|
||||
},
|
||||
],
|
||||
'postbuilds': [
|
||||
{
|
||||
'postbuild_name': 'Fix Framework Link',
|
||||
'action': [
|
||||
'<@(fix_framework_link_command)',
|
||||
'destination': '<(PRODUCT_DIR)/<(framework_name).framework/Versions/A/Resources',
|
||||
'files': [
|
||||
'<(PRODUCT_DIR)/Inspector',
|
||||
'<(PRODUCT_DIR)/crash_report_sender.app',
|
||||
],
|
||||
},
|
||||
],
|
||||
'postbuilds': [
|
||||
{
|
||||
'postbuild_name': 'Add symlinks for framework subdirectories',
|
||||
'action': [
|
||||
'tools/mac/create-framework-subdir-symlinks.sh',
|
||||
'<(product_name)',
|
||||
'<(framework_name)',
|
||||
'Libraries',
|
||||
'Frameworks',
|
||||
],
|
||||
@@ -471,19 +548,11 @@
|
||||
],
|
||||
'mac_bundle': 1,
|
||||
'xcode_settings': {
|
||||
'INFOPLIST_FILE': 'renderer/mac/Info.plist',
|
||||
'INFOPLIST_FILE': 'renderer/resources/mac/Info.plist',
|
||||
'LD_RUNPATH_SEARCH_PATHS': [
|
||||
'@executable_path/../../..',
|
||||
],
|
||||
},
|
||||
'postbuilds': [
|
||||
{
|
||||
'postbuild_name': 'Fix Framework Link',
|
||||
'action': [
|
||||
'<@(fix_framework_link_command)',
|
||||
],
|
||||
},
|
||||
],
|
||||
}, # target helper
|
||||
],
|
||||
}], # OS==Mac
|
||||
|
||||
@@ -7,8 +7,9 @@
|
||||
#include "base/values.h"
|
||||
#include "base/command_line.h"
|
||||
#include "browser/browser.h"
|
||||
#include "common/v8_conversions.h"
|
||||
#include "vendor/node/src/node.h"
|
||||
#include "common/v8/native_type_conversions.h"
|
||||
|
||||
#include "common/v8/node_common.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
@@ -48,70 +49,69 @@ void App::OnWillFinishLaunching() {
|
||||
}
|
||||
|
||||
void App::OnFinishLaunching() {
|
||||
Emit("finish-launching");
|
||||
Emit("ready");
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> App::New(const v8::Arguments &args) {
|
||||
v8::HandleScope scope;
|
||||
void App::New(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
v8::HandleScope scope(args.GetIsolate());
|
||||
|
||||
if (!args.IsConstructCall())
|
||||
return node::ThrowError("Require constructor call");
|
||||
|
||||
new App(args.This());
|
||||
|
||||
return args.This();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> App::Quit(const v8::Arguments &args) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
void App::Quit(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
Browser::Get()->Quit();
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> App::Exit(const v8::Arguments &args) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
void App::Exit(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
exit(args[0]->IntegerValue());
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> App::Terminate(const v8::Arguments &args) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
void App::Terminate(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
Browser::Get()->Terminate();
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> App::Focus(const v8::Arguments &args) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
void App::Focus(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
Browser::Get()->Focus();
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> App::GetVersion(const v8::Arguments &args) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
std::string version(Browser::Get()->GetVersion());
|
||||
|
||||
return v8::String::New(version.data(), version.size());
|
||||
void App::GetVersion(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
args.GetReturnValue().Set(ToV8Value(Browser::Get()->GetVersion()));
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> App::AppendSwitch(const v8::Arguments &args) {
|
||||
v8::HandleScope scope;
|
||||
void App::SetVersion(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
std::string version;
|
||||
if (!FromV8Arguments(args, &version))
|
||||
return node::ThrowError("Bad argument");
|
||||
|
||||
Browser::Get()->SetVersion(version);
|
||||
}
|
||||
|
||||
// static
|
||||
void App::GetName(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
return args.GetReturnValue().Set(ToV8Value(Browser::Get()->GetName()));
|
||||
}
|
||||
|
||||
// static
|
||||
void App::SetName(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
std::string name;
|
||||
if (!FromV8Arguments(args, &name))
|
||||
return node::ThrowError("Bad argument");
|
||||
|
||||
Browser::Get()->SetName(name);
|
||||
}
|
||||
|
||||
// static
|
||||
void App::AppendSwitch(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
std::string switch_string;
|
||||
if (!FromV8Arguments(args, &switch_string))
|
||||
return node::ThrowError("Bad argument");
|
||||
@@ -123,28 +123,25 @@ v8::Handle<v8::Value> App::AppendSwitch(const v8::Arguments &args) {
|
||||
CommandLine::ForCurrentProcess()->AppendSwitchASCII(
|
||||
switch_string, value);
|
||||
}
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> App::AppendArgument(const v8::Arguments &args) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
void App::AppendArgument(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
std::string value;
|
||||
if (!FromV8Arguments(args, &value))
|
||||
return node::ThrowError("Bad argument");
|
||||
|
||||
CommandLine::ForCurrentProcess()->AppendArg(value);
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> App::DockBounce(const v8::Arguments& args) {
|
||||
std::string type = FromV8Value(args[0]);
|
||||
void App::DockBounce(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
std::string type;
|
||||
if (!FromV8Arguments(args, &type))
|
||||
return node::ThrowError("Bad argument");
|
||||
|
||||
int request_id = -1;
|
||||
|
||||
if (type == "critical")
|
||||
@@ -154,34 +151,30 @@ v8::Handle<v8::Value> App::DockBounce(const v8::Arguments& args) {
|
||||
else
|
||||
return node::ThrowTypeError("Invalid bounce type");
|
||||
|
||||
return v8::Integer::New(request_id);
|
||||
args.GetReturnValue().Set(request_id);
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> App::DockCancelBounce(const v8::Arguments& args) {
|
||||
void App::DockCancelBounce(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
Browser::Get()->DockCancelBounce(FromV8Value(args[0]));
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> App::DockSetBadgeText(const v8::Arguments& args) {
|
||||
void App::DockSetBadgeText(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
Browser::Get()->DockSetBadgeText(FromV8Value(args[0]));
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> App::DockGetBadgeText(const v8::Arguments& args) {
|
||||
void App::DockGetBadgeText(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
std::string text(Browser::Get()->DockGetBadgeText());
|
||||
return ToV8Value(text);
|
||||
args.GetReturnValue().Set(ToV8Value(text));
|
||||
}
|
||||
|
||||
#endif // defined(OS_MACOSX)
|
||||
|
||||
// static
|
||||
void App::Initialize(v8::Handle<v8::Object> target) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(App::New);
|
||||
v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(New);
|
||||
t->InstanceTemplate()->SetInternalFieldCount(1);
|
||||
t->SetClassName(v8::String::NewSymbol("Application"));
|
||||
|
||||
@@ -190,6 +183,9 @@ void App::Initialize(v8::Handle<v8::Object> target) {
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "terminate", Terminate);
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "focus", Focus);
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "getVersion", GetVersion);
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "setVersion", SetVersion);
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "getName", GetName);
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "setName", SetName);
|
||||
|
||||
target->Set(v8::String::NewSymbol("Application"), t->GetFunction());
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
#define ATOM_BROWSER_API_ATOM_API_APP_H_
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "browser/api/atom_api_event_emitter.h"
|
||||
#include "browser/browser_observer.h"
|
||||
#include "common/api/atom_api_event_emitter.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
@@ -33,21 +33,24 @@ class App : public EventEmitter,
|
||||
virtual void OnFinishLaunching() OVERRIDE;
|
||||
|
||||
private:
|
||||
static v8::Handle<v8::Value> New(const v8::Arguments &args);
|
||||
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
|
||||
static v8::Handle<v8::Value> Quit(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> Exit(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> Terminate(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> Focus(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> GetVersion(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> AppendSwitch(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> AppendArgument(const v8::Arguments &args);
|
||||
static void Quit(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void Exit(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void Terminate(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void Focus(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void GetVersion(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void SetVersion(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void GetName(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void SetName(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void AppendSwitch(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void AppendArgument(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
static v8::Handle<v8::Value> DockBounce(const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> DockCancelBounce(const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> DockSetBadgeText(const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> DockGetBadgeText(const v8::Arguments& args);
|
||||
static void DockBounce(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void DockCancelBounce(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void DockSetBadgeText(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void DockGetBadgeText(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
#endif // defined(OS_MACOSX)
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(App);
|
||||
|
||||
@@ -4,9 +4,12 @@
|
||||
|
||||
#include "browser/api/atom_api_auto_updater.h"
|
||||
|
||||
#include "base/time/time.h"
|
||||
#include "base/values.h"
|
||||
#include "browser/auto_updater.h"
|
||||
#include "common/v8_conversions.h"
|
||||
#include "common/v8/native_type_conversions.h"
|
||||
|
||||
#include "common/v8/node_common.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
@@ -15,117 +18,80 @@ namespace api {
|
||||
AutoUpdater::AutoUpdater(v8::Handle<v8::Object> wrapper)
|
||||
: EventEmitter(wrapper) {
|
||||
auto_updater::AutoUpdater::SetDelegate(this);
|
||||
auto_updater::AutoUpdater::Init();
|
||||
}
|
||||
|
||||
AutoUpdater::~AutoUpdater() {
|
||||
auto_updater::AutoUpdater::SetDelegate(NULL);
|
||||
}
|
||||
|
||||
void AutoUpdater::WillInstallUpdate(const std::string& version,
|
||||
const base::Closure& install) {
|
||||
continue_update_ = install;
|
||||
|
||||
void AutoUpdater::OnError(const std::string& error) {
|
||||
base::ListValue args;
|
||||
args.AppendString(version);
|
||||
bool prevent_default = Emit("will-install-update-raw", &args);
|
||||
|
||||
if (!prevent_default)
|
||||
install.Run();
|
||||
args.AppendString(error);
|
||||
Emit("error", &args);
|
||||
}
|
||||
|
||||
void AutoUpdater::ReadyForUpdateOnQuit(const std::string& version,
|
||||
const base::Closure& quit_and_install) {
|
||||
void AutoUpdater::OnCheckingForUpdate() {
|
||||
Emit("checking-for-update");
|
||||
}
|
||||
|
||||
void AutoUpdater::OnUpdateAvailable() {
|
||||
Emit("update-available");
|
||||
}
|
||||
|
||||
void AutoUpdater::OnUpdateNotAvailable() {
|
||||
Emit("update-not-available");
|
||||
}
|
||||
|
||||
void AutoUpdater::OnUpdateDownloaded(const std::string& release_notes,
|
||||
const std::string& release_name,
|
||||
const base::Time& release_date,
|
||||
const std::string& update_url,
|
||||
const base::Closure& quit_and_install) {
|
||||
quit_and_install_ = quit_and_install;
|
||||
|
||||
base::ListValue args;
|
||||
args.AppendString(version);
|
||||
Emit("ready-for-update-on-quit-raw", &args);
|
||||
args.AppendString(release_notes);
|
||||
args.AppendString(release_name);
|
||||
args.AppendDouble(release_date.ToJsTime());
|
||||
args.AppendString(update_url);
|
||||
Emit("update-downloaded-raw", &args);
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> AutoUpdater::New(const v8::Arguments &args) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
void AutoUpdater::New(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
if (!args.IsConstructCall())
|
||||
return node::ThrowError("Require constructor call");
|
||||
|
||||
new AutoUpdater(args.This());
|
||||
|
||||
return args.This();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> AutoUpdater::SetFeedURL(const v8::Arguments &args) {
|
||||
void AutoUpdater::SetFeedURL(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
auto_updater::AutoUpdater::SetFeedURL(FromV8Value(args[0]));
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> AutoUpdater::SetAutomaticallyChecksForUpdates(
|
||||
const v8::Arguments &args) {
|
||||
auto_updater::AutoUpdater::SetAutomaticallyChecksForUpdates(
|
||||
args[0]->BooleanValue());
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> AutoUpdater::SetAutomaticallyDownloadsUpdates(
|
||||
const v8::Arguments &args) {
|
||||
auto_updater::AutoUpdater::SetAutomaticallyDownloadsUpdates(
|
||||
args[0]->BooleanValue());
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> AutoUpdater::CheckForUpdates(const v8::Arguments &args) {
|
||||
void AutoUpdater::CheckForUpdates(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
auto_updater::AutoUpdater::CheckForUpdates();
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> AutoUpdater::CheckForUpdatesInBackground(
|
||||
const v8::Arguments &args) {
|
||||
auto_updater::AutoUpdater::CheckForUpdatesInBackground();
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> AutoUpdater::ContinueUpdate(const v8::Arguments &args) {
|
||||
AutoUpdater* self = AutoUpdater::Unwrap<AutoUpdater>(args.This());
|
||||
self->continue_update_.Run();
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> AutoUpdater::QuitAndInstall(const v8::Arguments &args) {
|
||||
void AutoUpdater::QuitAndInstall(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
AutoUpdater* self = AutoUpdater::Unwrap<AutoUpdater>(args.This());
|
||||
self->quit_and_install_.Run();
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
void AutoUpdater::Initialize(v8::Handle<v8::Object> target) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
v8::Local<v8::FunctionTemplate> t(
|
||||
v8::FunctionTemplate::New(AutoUpdater::New));
|
||||
t->InstanceTemplate()->SetInternalFieldCount(1);
|
||||
t->SetClassName(v8::String::NewSymbol("AutoUpdater"));
|
||||
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "setFeedUrl", SetFeedURL);
|
||||
NODE_SET_PROTOTYPE_METHOD(t,
|
||||
"setAutomaticallyChecksForUpdates",
|
||||
SetAutomaticallyChecksForUpdates);
|
||||
NODE_SET_PROTOTYPE_METHOD(t,
|
||||
"setAutomaticallyDownloadsUpdates",
|
||||
SetAutomaticallyDownloadsUpdates);
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "checkForUpdates", CheckForUpdates);
|
||||
NODE_SET_PROTOTYPE_METHOD(t,
|
||||
"checkForUpdatesInBackground",
|
||||
CheckForUpdatesInBackground);
|
||||
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "continueUpdate", ContinueUpdate);
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "quitAndInstall", QuitAndInstall);
|
||||
|
||||
target->Set(v8::String::NewSymbol("AutoUpdater"), t->GetFunction());
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
|
||||
#include "base/callback.h"
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "browser/api/atom_api_event_emitter.h"
|
||||
#include "browser/auto_updater_delegate.h"
|
||||
#include "common/api/atom_api_event_emitter.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
@@ -24,28 +24,27 @@ class AutoUpdater : public EventEmitter,
|
||||
protected:
|
||||
explicit AutoUpdater(v8::Handle<v8::Object> wrapper);
|
||||
|
||||
virtual void WillInstallUpdate(const std::string& version,
|
||||
const base::Closure& install) OVERRIDE;
|
||||
virtual void ReadyForUpdateOnQuit(
|
||||
const std::string& version,
|
||||
// AutoUpdaterDelegate implementations.
|
||||
virtual void OnError(const std::string& error) OVERRIDE;
|
||||
virtual void OnCheckingForUpdate() OVERRIDE;
|
||||
virtual void OnUpdateAvailable() OVERRIDE;
|
||||
virtual void OnUpdateNotAvailable() OVERRIDE;
|
||||
virtual void OnUpdateDownloaded(
|
||||
const std::string& release_notes,
|
||||
const std::string& release_name,
|
||||
const base::Time& release_date,
|
||||
const std::string& update_url,
|
||||
const base::Closure& quit_and_install) OVERRIDE;
|
||||
|
||||
private:
|
||||
static v8::Handle<v8::Value> New(const v8::Arguments &args);
|
||||
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
|
||||
static v8::Handle<v8::Value> SetFeedURL(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> SetAutomaticallyChecksForUpdates(
|
||||
const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> SetAutomaticallyDownloadsUpdates(
|
||||
const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> CheckForUpdates(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> CheckForUpdatesInBackground(
|
||||
const v8::Arguments &args);
|
||||
static void SetFeedURL(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void CheckForUpdates(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
|
||||
static v8::Handle<v8::Value> ContinueUpdate(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> QuitAndInstall(const v8::Arguments &args);
|
||||
static void ContinueUpdate(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void QuitAndInstall(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
|
||||
base::Closure continue_update_;
|
||||
base::Closure quit_and_install_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AutoUpdater);
|
||||
|
||||
@@ -4,58 +4,41 @@
|
||||
|
||||
#include "browser/api/atom_api_browser_ipc.h"
|
||||
|
||||
#include "base/values.h"
|
||||
#include "common/api/api_messages.h"
|
||||
#include "common/v8_conversions.h"
|
||||
#include "common/v8_value_converter_impl.h"
|
||||
#include "common/v8/node_common.h"
|
||||
#include "common/v8/native_type_conversions.h"
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
#include "vendor/node/src/node.h"
|
||||
#include "vendor/node/src/node_internals.h"
|
||||
|
||||
using content::RenderViewHost;
|
||||
using content::V8ValueConverter;
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> BrowserIPC::Send(const v8::Arguments &args) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
void BrowserIPC::Send(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
string16 channel;
|
||||
int process_id, routing_id;
|
||||
if (!FromV8Arguments(args, &channel, &process_id, &routing_id))
|
||||
scoped_ptr<base::Value> arguments;
|
||||
if (!FromV8Arguments(args, &channel, &process_id, &routing_id, &arguments))
|
||||
return node::ThrowTypeError("Bad argument");
|
||||
|
||||
DCHECK(arguments && arguments->IsType(base::Value::TYPE_LIST));
|
||||
|
||||
RenderViewHost* render_view_host(RenderViewHost::FromID(
|
||||
process_id, routing_id));
|
||||
if (!render_view_host)
|
||||
return node::ThrowError("Invalid render view host");
|
||||
|
||||
// Convert Arguments to Array, so we can use V8ValueConverter to convert it
|
||||
// to ListValue.
|
||||
v8::Local<v8::Array> v8_args = v8::Array::New(args.Length() - 3);
|
||||
for (int i = 0; i < args.Length() - 3; ++i)
|
||||
v8_args->Set(i, args[i + 3]);
|
||||
|
||||
scoped_ptr<V8ValueConverter> converter(new V8ValueConverterImpl());
|
||||
scoped_ptr<base::Value> arguments(
|
||||
converter->FromV8Value(v8_args, v8::Context::GetCurrent()));
|
||||
|
||||
DCHECK(arguments && arguments->IsType(base::Value::TYPE_LIST));
|
||||
|
||||
render_view_host->Send(new AtomViewMsg_Message(
|
||||
args.GetReturnValue().Set(render_view_host->Send(new AtomViewMsg_Message(
|
||||
routing_id,
|
||||
channel,
|
||||
*static_cast<base::ListValue*>(arguments.get())));
|
||||
|
||||
return v8::Undefined();
|
||||
*static_cast<base::ListValue*>(arguments.get()))));
|
||||
}
|
||||
|
||||
// static
|
||||
void BrowserIPC::Initialize(v8::Handle<v8::Object> target) {
|
||||
node::SetMethod(target, "send", Send);
|
||||
NODE_SET_METHOD(target, "send", Send);
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
|
||||
@@ -17,7 +17,7 @@ class BrowserIPC {
|
||||
static void Initialize(v8::Handle<v8::Object> target);
|
||||
|
||||
private:
|
||||
static v8::Handle<v8::Value> Send(const v8::Arguments &args);
|
||||
static void Send(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
|
||||
DISALLOW_IMPLICIT_CONSTRUCTORS(BrowserIPC);
|
||||
};
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "browser/api/atom_api_crash_reporter.h"
|
||||
|
||||
#include "browser/crash_reporter.h"
|
||||
#include "common/v8_conversions.h"
|
||||
#include "vendor/node/src/node.h"
|
||||
#include "vendor/node/src/node_internals.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> CrashReporter::SetCompanyName(const v8::Arguments &args) {
|
||||
crash_reporter::CrashReporter::SetCompanyName(FromV8Value(args[0]));
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> CrashReporter::SetSubmissionURL(
|
||||
const v8::Arguments &args) {
|
||||
crash_reporter::CrashReporter::SetSubmissionURL(FromV8Value(args[0]));
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> CrashReporter::SetAutoSubmit(const v8::Arguments &args) {
|
||||
crash_reporter::CrashReporter::SetAutoSubmit(FromV8Value(args[0]));
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
void CrashReporter::Initialize(v8::Handle<v8::Object> target) {
|
||||
node::SetMethod(target, "setCompanyName", SetCompanyName);
|
||||
node::SetMethod(target, "setSubmissionUrl", SetSubmissionURL);
|
||||
node::SetMethod(target, "setAutoSubmit", SetAutoSubmit);
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
|
||||
} // namespace atom
|
||||
|
||||
NODE_MODULE(atom_browser_crash_reporter, atom::api::CrashReporter::Initialize)
|
||||
@@ -8,10 +8,8 @@
|
||||
#include "browser/native_window.h"
|
||||
#include "browser/ui/file_dialog.h"
|
||||
#include "browser/ui/message_box.h"
|
||||
#include "common/v8_conversions.h"
|
||||
#include "vendor/node/src/node_internals.h"
|
||||
|
||||
using node::node_isolate;
|
||||
#include "common/v8/node_common.h"
|
||||
#include "common/v8/native_type_conversions.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
@@ -20,19 +18,17 @@ namespace api {
|
||||
namespace {
|
||||
|
||||
template<typename T>
|
||||
void CallV8Function(v8::Persistent<v8::Function> callback, T arg) {
|
||||
DCHECK(!callback.IsEmpty());
|
||||
void CallV8Function(const RefCountedV8Function& callback, T arg) {
|
||||
v8::Locker locker(node_isolate);
|
||||
v8::HandleScope handle_scope(node_isolate);
|
||||
|
||||
v8::HandleScope scope;
|
||||
v8::Handle<v8::Value> value = ToV8Value(arg);
|
||||
callback->Call(callback, 1, &value);
|
||||
callback.Dispose(node_isolate);
|
||||
callback->NewHandle(node_isolate)->Call(
|
||||
v8::Context::GetCurrent()->Global(), 1, &value);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void CallV8Function2(v8::Persistent<v8::Function> callback,
|
||||
bool result,
|
||||
T arg) {
|
||||
void CallV8Function2(const RefCountedV8Function& callback, bool result, T arg) {
|
||||
if (result)
|
||||
return CallV8Function<T>(callback, arg);
|
||||
else
|
||||
@@ -40,8 +36,6 @@ void CallV8Function2(v8::Persistent<v8::Function> callback,
|
||||
}
|
||||
|
||||
void Initialize(v8::Handle<v8::Object> target) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
NODE_SET_METHOD(target, "showMessageBox", ShowMessageBox);
|
||||
NODE_SET_METHOD(target, "showOpenDialog", ShowOpenDialog);
|
||||
NODE_SET_METHOD(target, "showSaveDialog", ShowSaveDialog);
|
||||
@@ -49,9 +43,7 @@ void Initialize(v8::Handle<v8::Object> target) {
|
||||
|
||||
} // namespace
|
||||
|
||||
v8::Handle<v8::Value> ShowMessageBox(const v8::Arguments &args) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
void ShowMessageBox(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
int type;
|
||||
std::vector<std::string> buttons;
|
||||
std::string title, message, detail;
|
||||
@@ -59,9 +51,8 @@ v8::Handle<v8::Value> ShowMessageBox(const v8::Arguments &args) {
|
||||
return node::ThrowTypeError("Bad argument");
|
||||
|
||||
NativeWindow* native_window = FromV8Value(args[5]);
|
||||
v8::Persistent<v8::Function> callback = FromV8Value(args[6]);
|
||||
|
||||
if (callback.IsEmpty()) {
|
||||
if (!args[6]->IsFunction()) {
|
||||
int chosen = atom::ShowMessageBox(
|
||||
native_window,
|
||||
(MessageBoxType)type,
|
||||
@@ -69,8 +60,9 @@ v8::Handle<v8::Value> ShowMessageBox(const v8::Arguments &args) {
|
||||
title,
|
||||
message,
|
||||
detail);
|
||||
return scope.Close(v8::Integer::New(chosen));
|
||||
args.GetReturnValue().Set(chosen);
|
||||
} else {
|
||||
RefCountedV8Function callback = FromV8Value(args[6]);
|
||||
atom::ShowMessageBox(
|
||||
native_window,
|
||||
(MessageBoxType)type,
|
||||
@@ -79,13 +71,10 @@ v8::Handle<v8::Value> ShowMessageBox(const v8::Arguments &args) {
|
||||
message,
|
||||
detail,
|
||||
base::Bind(&CallV8Function<int>, callback));
|
||||
return v8::Undefined();
|
||||
}
|
||||
}
|
||||
|
||||
v8::Handle<v8::Value> ShowOpenDialog(const v8::Arguments &args) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
void ShowOpenDialog(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
std::string title;
|
||||
base::FilePath default_path;
|
||||
int properties;
|
||||
@@ -93,23 +82,23 @@ v8::Handle<v8::Value> ShowOpenDialog(const v8::Arguments &args) {
|
||||
return node::ThrowTypeError("Bad argument");
|
||||
|
||||
NativeWindow* native_window = FromV8Value(args[3]);
|
||||
v8::Persistent<v8::Function> callback = FromV8Value(args[4]);
|
||||
|
||||
if (callback.IsEmpty()) {
|
||||
if (!args[4]->IsFunction()) {
|
||||
std::vector<base::FilePath> paths;
|
||||
if (!file_dialog::ShowOpenDialog(native_window,
|
||||
title,
|
||||
default_path,
|
||||
properties,
|
||||
&paths))
|
||||
return v8::Undefined();
|
||||
return;
|
||||
|
||||
v8::Handle<v8::Array> result = v8::Array::New(paths.size());
|
||||
for (size_t i = 0; i < paths.size(); ++i)
|
||||
result->Set(i, ToV8Value(paths[i]));
|
||||
|
||||
return scope.Close(result);
|
||||
args.GetReturnValue().Set(result);
|
||||
} else {
|
||||
RefCountedV8Function callback = FromV8Value(args[4]);
|
||||
file_dialog::ShowOpenDialog(
|
||||
native_window,
|
||||
title,
|
||||
@@ -117,37 +106,31 @@ v8::Handle<v8::Value> ShowOpenDialog(const v8::Arguments &args) {
|
||||
properties,
|
||||
base::Bind(&CallV8Function2<const std::vector<base::FilePath>&>,
|
||||
callback));
|
||||
return v8::Undefined();
|
||||
}
|
||||
}
|
||||
|
||||
v8::Handle<v8::Value> ShowSaveDialog(const v8::Arguments &args) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
void ShowSaveDialog(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
std::string title;
|
||||
base::FilePath default_path;
|
||||
if (!FromV8Arguments(args, &title, &default_path))
|
||||
return node::ThrowTypeError("Bad argument");
|
||||
|
||||
NativeWindow* native_window = FromV8Value(args[2]);
|
||||
v8::Persistent<v8::Function> callback = FromV8Value(args[3]);
|
||||
|
||||
if (callback.IsEmpty()) {
|
||||
if (!args[3]->IsFunction()) {
|
||||
base::FilePath path;
|
||||
if (!file_dialog::ShowSaveDialog(native_window,
|
||||
title,
|
||||
default_path,
|
||||
&path))
|
||||
return v8::Undefined();
|
||||
|
||||
return scope.Close(ToV8Value(path));
|
||||
if (file_dialog::ShowSaveDialog(native_window,
|
||||
title,
|
||||
default_path,
|
||||
&path))
|
||||
args.GetReturnValue().Set(ToV8Value(path));
|
||||
} else {
|
||||
RefCountedV8Function callback = FromV8Value(args[3]);
|
||||
file_dialog::ShowSaveDialog(
|
||||
native_window,
|
||||
title,
|
||||
default_path,
|
||||
base::Bind(&CallV8Function2<const base::FilePath&>, callback));
|
||||
return v8::Undefined();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@ namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
||||
v8::Handle<v8::Value> ShowMessageBox(const v8::Arguments &args);
|
||||
v8::Handle<v8::Value> ShowOpenDialog(const v8::Arguments &args);
|
||||
v8::Handle<v8::Value> ShowSaveDialog(const v8::Arguments &args);
|
||||
void ShowMessageBox(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
void ShowOpenDialog(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
void ShowSaveDialog(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
|
||||
} // namespace api
|
||||
|
||||
|
||||
@@ -6,15 +6,14 @@
|
||||
|
||||
#include "browser/native_window.h"
|
||||
#include "common/api/api_messages.h"
|
||||
#include "common/v8_conversions.h"
|
||||
|
||||
using node::node_isolate;
|
||||
#include "common/v8/node_common.h"
|
||||
#include "common/v8/native_type_conversions.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
||||
v8::Persistent<v8::FunctionTemplate> Event::constructor_template_;
|
||||
ScopedPersistent<v8::Function> Event::constructor_template_;
|
||||
|
||||
Event::Event()
|
||||
: sender_(NULL),
|
||||
@@ -29,24 +28,20 @@ Event::~Event() {
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Object> Event::CreateV8Object() {
|
||||
v8::HandleScope scope;
|
||||
|
||||
if (constructor_template_.IsEmpty()) {
|
||||
v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(New);
|
||||
constructor_template_ = v8::Persistent<v8::FunctionTemplate>::New(
|
||||
node_isolate, t);
|
||||
constructor_template_->InstanceTemplate()->SetInternalFieldCount(1);
|
||||
constructor_template_->SetClassName(v8::String::NewSymbol("Event"));
|
||||
t->InstanceTemplate()->SetInternalFieldCount(1);
|
||||
t->SetClassName(v8::String::NewSymbol("Event"));
|
||||
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "preventDefault", PreventDefault);
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "sendReply", SendReply);
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "destroy", Destroy);
|
||||
|
||||
constructor_template_.reset(t->GetFunction());
|
||||
}
|
||||
|
||||
v8::Handle<v8::Object> v8_event =
|
||||
constructor_template_->GetFunction()->NewInstance(0, NULL);
|
||||
|
||||
return scope.Close(v8_event);
|
||||
v8::Handle<v8::Function> t = constructor_template_.NewHandle(node_isolate);
|
||||
return t->NewInstance(0, NULL);
|
||||
}
|
||||
|
||||
void Event::SetSenderAndMessage(NativeWindow* sender, IPC::Message* message) {
|
||||
@@ -64,26 +59,22 @@ void Event::OnWindowClosed() {
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Event::New(const v8::Arguments& args) {
|
||||
void Event::New(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
Event* event = new Event;
|
||||
event->Wrap(args.This());
|
||||
|
||||
return args.This();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Event::PreventDefault(const v8::Arguments& args) {
|
||||
void Event::PreventDefault(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
Event* event = Unwrap<Event>(args.This());
|
||||
if (event == NULL)
|
||||
return node::ThrowError("Event is already destroyed");
|
||||
|
||||
event->prevent_default_ = true;
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Event::SendReply(const v8::Arguments& args) {
|
||||
void Event::SendReply(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
Event* event = Unwrap<Event>(args.This());
|
||||
if (event == NULL)
|
||||
return node::ThrowError("Event is already destroyed");
|
||||
@@ -97,14 +88,11 @@ v8::Handle<v8::Value> Event::SendReply(const v8::Arguments& args) {
|
||||
event->sender_->Send(event->message_);
|
||||
|
||||
delete event;
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Event::Destroy(const v8::Arguments& args) {
|
||||
void Event::Destroy(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
delete Unwrap<Event>(args.This());
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
|
||||
@@ -7,8 +7,9 @@
|
||||
|
||||
#include "base/basictypes.h"
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/string16.h"
|
||||
#include "base/strings/string16.h"
|
||||
#include "browser/native_window_observer.h"
|
||||
#include "common/v8/scoped_persistent.h"
|
||||
#include "vendor/node/src/node_object_wrap.h"
|
||||
|
||||
namespace IPC {
|
||||
@@ -32,9 +33,6 @@ class Event : public node::ObjectWrap,
|
||||
// Pass the sender and message to be replied.
|
||||
void SetSenderAndMessage(NativeWindow* sender, IPC::Message* message);
|
||||
|
||||
// Accessor to return handle_, this follows Google C++ Style.
|
||||
v8::Persistent<v8::Object>& handle() { return handle_; }
|
||||
|
||||
// Whether event.preventDefault() is called.
|
||||
bool prevent_default() const { return prevent_default_; }
|
||||
|
||||
@@ -45,13 +43,13 @@ class Event : public node::ObjectWrap,
|
||||
virtual void OnWindowClosed() OVERRIDE;
|
||||
|
||||
private:
|
||||
static v8::Handle<v8::Value> New(const v8::Arguments& args);
|
||||
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
|
||||
static v8::Handle<v8::Value> PreventDefault(const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> SendReply(const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> Destroy(const v8::Arguments& args);
|
||||
static void PreventDefault(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void SendReply(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void Destroy(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
|
||||
static v8::Persistent<v8::FunctionTemplate> constructor_template_;
|
||||
static ScopedPersistent<v8::Function> constructor_template_;
|
||||
|
||||
// Replyer for the synchronous messages.
|
||||
NativeWindow* sender_;
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
#include "browser/api/atom_api_menu.h"
|
||||
|
||||
#include "browser/ui/accelerator_util.h"
|
||||
#include "common/v8_conversions.h"
|
||||
#include "common/v8/node_common.h"
|
||||
#include "common/v8/native_type_conversions.h"
|
||||
|
||||
#define UNWRAP_MEMNU_AND_CHECK \
|
||||
Menu* self = ObjectWrap::Unwrap<Menu>(args.This()); \
|
||||
@@ -23,7 +24,8 @@ v8::Handle<v8::Value> CallDelegate(v8::Handle<v8::Value> default_value,
|
||||
v8::Handle<v8::Object> menu,
|
||||
const char* method,
|
||||
int command_id) {
|
||||
v8::HandleScope scope;
|
||||
v8::Locker locker(node_isolate);
|
||||
v8::HandleScope handle_scope(node_isolate);
|
||||
|
||||
v8::Handle<v8::Value> delegate = menu->Get(v8::String::New("delegate"));
|
||||
if (!delegate->IsObject())
|
||||
@@ -36,7 +38,7 @@ v8::Handle<v8::Value> CallDelegate(v8::Handle<v8::Value> default_value,
|
||||
|
||||
v8::Handle<v8::Value> argv = v8::Integer::New(command_id);
|
||||
|
||||
return scope.Close(
|
||||
return handle_scope.Close(
|
||||
function->Call(v8::Context::GetCurrent()->Global(), 1, &argv));
|
||||
}
|
||||
|
||||
@@ -51,32 +53,36 @@ Menu::~Menu() {
|
||||
}
|
||||
|
||||
bool Menu::IsCommandIdChecked(int command_id) const {
|
||||
v8::HandleScope scope;
|
||||
v8::Locker locker(node_isolate);
|
||||
v8::HandleScope handle_scope(node_isolate);
|
||||
return CallDelegate(v8::False(),
|
||||
handle(),
|
||||
const_cast<Menu*>(this)->handle(),
|
||||
"isCommandIdChecked",
|
||||
command_id)->BooleanValue();
|
||||
}
|
||||
|
||||
bool Menu::IsCommandIdEnabled(int command_id) const {
|
||||
v8::HandleScope scope;
|
||||
v8::Locker locker(node_isolate);
|
||||
v8::HandleScope handle_scope(node_isolate);
|
||||
return CallDelegate(v8::True(),
|
||||
handle(),
|
||||
const_cast<Menu*>(this)->handle(),
|
||||
"isCommandIdEnabled",
|
||||
command_id)->BooleanValue();
|
||||
}
|
||||
|
||||
bool Menu::IsCommandIdVisible(int command_id) const {
|
||||
v8::HandleScope scope;
|
||||
v8::Locker locker(node_isolate);
|
||||
v8::HandleScope handle_scope(node_isolate);
|
||||
return CallDelegate(v8::True(),
|
||||
handle(),
|
||||
const_cast<Menu*>(this)->handle(),
|
||||
"isCommandIdVisible",
|
||||
command_id)->BooleanValue();
|
||||
}
|
||||
|
||||
bool Menu::GetAcceleratorForCommandId(int command_id,
|
||||
ui::Accelerator* accelerator) {
|
||||
v8::HandleScope scope;
|
||||
v8::Locker locker(node_isolate);
|
||||
v8::HandleScope handle_scope(node_isolate);
|
||||
v8::Handle<v8::Value> shortcut = CallDelegate(v8::Undefined(),
|
||||
handle(),
|
||||
"getAcceleratorForCommandId",
|
||||
@@ -90,48 +96,48 @@ bool Menu::GetAcceleratorForCommandId(int command_id,
|
||||
}
|
||||
|
||||
bool Menu::IsItemForCommandIdDynamic(int command_id) const {
|
||||
v8::HandleScope scope;
|
||||
v8::Locker locker(node_isolate);
|
||||
v8::HandleScope handle_scope(node_isolate);
|
||||
return CallDelegate(v8::False(),
|
||||
handle(),
|
||||
const_cast<Menu*>(this)->handle(),
|
||||
"isItemForCommandIdDynamic",
|
||||
command_id)->BooleanValue();
|
||||
}
|
||||
|
||||
string16 Menu::GetLabelForCommandId(int command_id) const {
|
||||
v8::HandleScope scope;
|
||||
v8::Locker locker(node_isolate);
|
||||
v8::HandleScope handle_scope(node_isolate);
|
||||
return FromV8Value(CallDelegate(v8::False(),
|
||||
handle(),
|
||||
const_cast<Menu*>(this)->handle(),
|
||||
"getLabelForCommandId",
|
||||
command_id));
|
||||
}
|
||||
|
||||
string16 Menu::GetSublabelForCommandId(int command_id) const {
|
||||
v8::HandleScope scope;
|
||||
v8::Locker locker(node_isolate);
|
||||
v8::HandleScope handle_scope(node_isolate);
|
||||
return FromV8Value(CallDelegate(v8::False(),
|
||||
handle(),
|
||||
const_cast<Menu*>(this)->handle(),
|
||||
"getSubLabelForCommandId",
|
||||
command_id));
|
||||
}
|
||||
|
||||
void Menu::ExecuteCommand(int command_id, int event_flags) {
|
||||
v8::HandleScope scope;
|
||||
v8::Locker locker(node_isolate);
|
||||
v8::HandleScope handle_scope(node_isolate);
|
||||
CallDelegate(v8::False(), handle(), "executeCommand", command_id);
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Menu::New(const v8::Arguments &args) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
void Menu::New(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
if (!args.IsConstructCall())
|
||||
return node::ThrowError("Require constructor call");
|
||||
|
||||
Menu::Create(args.This());
|
||||
|
||||
return args.This();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Menu::InsertItem(const v8::Arguments &args) {
|
||||
void Menu::InsertItem(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_MEMNU_AND_CHECK;
|
||||
|
||||
int index, command_id;
|
||||
@@ -143,12 +149,10 @@ v8::Handle<v8::Value> Menu::InsertItem(const v8::Arguments &args) {
|
||||
self->model_->AddItem(command_id, label);
|
||||
else
|
||||
self->model_->InsertItemAt(index, command_id, label);
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Menu::InsertCheckItem(const v8::Arguments &args) {
|
||||
void Menu::InsertCheckItem(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_MEMNU_AND_CHECK;
|
||||
|
||||
int index, command_id;
|
||||
@@ -160,12 +164,10 @@ v8::Handle<v8::Value> Menu::InsertCheckItem(const v8::Arguments &args) {
|
||||
self->model_->AddCheckItem(command_id, label);
|
||||
else
|
||||
self->model_->InsertCheckItemAt(index, command_id, label);
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Menu::InsertRadioItem(const v8::Arguments &args) {
|
||||
void Menu::InsertRadioItem(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_MEMNU_AND_CHECK;
|
||||
|
||||
int index, command_id, group_id;
|
||||
@@ -177,12 +179,10 @@ v8::Handle<v8::Value> Menu::InsertRadioItem(const v8::Arguments &args) {
|
||||
self->model_->AddRadioItem(command_id, label, group_id);
|
||||
else
|
||||
self->model_->InsertRadioItemAt(index, command_id, label, group_id);
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Menu::InsertSeparator(const v8::Arguments &args) {
|
||||
void Menu::InsertSeparator(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_MEMNU_AND_CHECK;
|
||||
|
||||
int index;
|
||||
@@ -193,12 +193,10 @@ v8::Handle<v8::Value> Menu::InsertSeparator(const v8::Arguments &args) {
|
||||
self->model_->AddSeparator(ui::NORMAL_SEPARATOR);
|
||||
else
|
||||
self->model_->InsertSeparatorAt(index, ui::NORMAL_SEPARATOR);
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Menu::InsertSubMenu(const v8::Arguments &args) {
|
||||
void Menu::InsertSubMenu(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_MEMNU_AND_CHECK;
|
||||
|
||||
int index, command_id;
|
||||
@@ -215,12 +213,10 @@ v8::Handle<v8::Value> Menu::InsertSubMenu(const v8::Arguments &args) {
|
||||
else
|
||||
self->model_->InsertSubMenuAt(
|
||||
index, command_id, label, submenu->model_.get());
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Menu::SetIcon(const v8::Arguments &args) {
|
||||
void Menu::SetIcon(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_MEMNU_AND_CHECK;
|
||||
|
||||
int index;
|
||||
@@ -229,12 +225,10 @@ v8::Handle<v8::Value> Menu::SetIcon(const v8::Arguments &args) {
|
||||
return node::ThrowTypeError("Bad argument");
|
||||
|
||||
// FIXME use webkit_glue's image decoder here.
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Menu::SetSublabel(const v8::Arguments &args) {
|
||||
void Menu::SetSublabel(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_MEMNU_AND_CHECK;
|
||||
|
||||
int index;
|
||||
@@ -243,74 +237,72 @@ v8::Handle<v8::Value> Menu::SetSublabel(const v8::Arguments &args) {
|
||||
return node::ThrowTypeError("Bad argument");
|
||||
|
||||
self->model_->SetSublabel(index, label);
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Menu::Clear(const v8::Arguments &args) {
|
||||
void Menu::Clear(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_MEMNU_AND_CHECK;
|
||||
|
||||
self->model_->Clear();
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Menu::GetIndexOfCommandId(const v8::Arguments &args) {
|
||||
void Menu::GetIndexOfCommandId(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_MEMNU_AND_CHECK;
|
||||
int index = args[0]->IntegerValue();
|
||||
return v8::Integer::New(self->model_->GetIndexOfCommandId(index));
|
||||
int index = FromV8Value(args[0]);
|
||||
args.GetReturnValue().Set(self->model_->GetIndexOfCommandId(index));
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Menu::GetItemCount(const v8::Arguments &args) {
|
||||
void Menu::GetItemCount(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_MEMNU_AND_CHECK;
|
||||
return v8::Integer::New(self->model_->GetItemCount());
|
||||
args.GetReturnValue().Set(self->model_->GetItemCount());
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Menu::GetCommandIdAt(const v8::Arguments &args) {
|
||||
void Menu::GetCommandIdAt(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_MEMNU_AND_CHECK;
|
||||
int index = args[0]->IntegerValue();
|
||||
return v8::Integer::New(self->model_->GetCommandIdAt(index));
|
||||
int index = FromV8Value(args[0]);
|
||||
args.GetReturnValue().Set(self->model_->GetCommandIdAt(index));
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Menu::GetLabelAt(const v8::Arguments &args) {
|
||||
void Menu::GetLabelAt(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_MEMNU_AND_CHECK;
|
||||
int index = args[0]->IntegerValue();
|
||||
return ToV8Value(self->model_->GetLabelAt(index));
|
||||
int index = FromV8Value(args[0]);
|
||||
args.GetReturnValue().Set(ToV8Value(self->model_->GetLabelAt(index)));
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Menu::GetSublabelAt(const v8::Arguments &args) {
|
||||
void Menu::GetSublabelAt(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_MEMNU_AND_CHECK;
|
||||
int index = args[0]->IntegerValue();
|
||||
return ToV8Value(self->model_->GetSublabelAt(index));
|
||||
int index = FromV8Value(args[0]);
|
||||
args.GetReturnValue().Set(ToV8Value(self->model_->GetSublabelAt(index)));
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Menu::IsItemCheckedAt(const v8::Arguments &args) {
|
||||
void Menu::IsItemCheckedAt(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_MEMNU_AND_CHECK;
|
||||
int index = args[0]->IntegerValue();
|
||||
return v8::Boolean::New(self->model_->IsItemCheckedAt(index));
|
||||
int index = FromV8Value(args[0]);
|
||||
args.GetReturnValue().Set(self->model_->IsItemCheckedAt(index));
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Menu::IsEnabledAt(const v8::Arguments &args) {
|
||||
void Menu::IsEnabledAt(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_MEMNU_AND_CHECK;
|
||||
return v8::Boolean::New(self->model_->IsEnabledAt(args[0]->IntegerValue()));
|
||||
int index = FromV8Value(args[0]);
|
||||
args.GetReturnValue().Set(self->model_->IsEnabledAt(index));
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Menu::IsVisibleAt(const v8::Arguments &args) {
|
||||
void Menu::IsVisibleAt(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_MEMNU_AND_CHECK;
|
||||
return v8::Boolean::New(self->model_->IsVisibleAt(args[0]->IntegerValue()));
|
||||
int index = FromV8Value(args[0]);
|
||||
args.GetReturnValue().Set(self->model_->IsVisibleAt(index));
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Menu::Popup(const v8::Arguments &args) {
|
||||
void Menu::Popup(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_MEMNU_AND_CHECK;
|
||||
|
||||
atom::NativeWindow* window;
|
||||
@@ -318,13 +310,10 @@ v8::Handle<v8::Value> Menu::Popup(const v8::Arguments &args) {
|
||||
return node::ThrowTypeError("Bad argument");
|
||||
|
||||
self->Popup(window);
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
void Menu::Initialize(v8::Handle<v8::Object> target) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
v8::Local<v8::FunctionTemplate> t(v8::FunctionTemplate::New(Menu::New));
|
||||
t->InstanceTemplate()->SetInternalFieldCount(1);
|
||||
t->SetClassName(v8::String::NewSymbol("Menu"));
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#define ATOM_BROWSER_API_ATOM_API_MENU_H_
|
||||
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "browser/api/atom_api_event_emitter.h"
|
||||
#include "common/api/atom_api_event_emitter.h"
|
||||
#include "ui/base/models/simple_menu_model.h"
|
||||
|
||||
namespace atom {
|
||||
@@ -44,36 +44,38 @@ class Menu : public EventEmitter,
|
||||
scoped_ptr<ui::SimpleMenuModel> model_;
|
||||
|
||||
private:
|
||||
static v8::Handle<v8::Value> New(const v8::Arguments &args);
|
||||
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
|
||||
static v8::Handle<v8::Value> InsertItem(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> InsertCheckItem(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> InsertRadioItem(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> InsertSeparator(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> InsertSubMenu(const v8::Arguments &args);
|
||||
static void InsertItem(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void InsertCheckItem(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void InsertRadioItem(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void InsertSeparator(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void InsertSubMenu(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
|
||||
static v8::Handle<v8::Value> SetIcon(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> SetSublabel(const v8::Arguments &args);
|
||||
static void SetIcon(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void SetSublabel(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
|
||||
static v8::Handle<v8::Value> Clear(const v8::Arguments &args);
|
||||
static void Clear(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
|
||||
static v8::Handle<v8::Value> GetIndexOfCommandId(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> GetItemCount(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> GetCommandIdAt(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> GetLabelAt(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> GetSublabelAt(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> IsItemCheckedAt(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> IsEnabledAt(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> IsVisibleAt(const v8::Arguments &args);
|
||||
static void GetIndexOfCommandId(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void GetItemCount(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void GetCommandIdAt(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void GetLabelAt(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void GetSublabelAt(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void IsItemCheckedAt(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void IsEnabledAt(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void IsVisibleAt(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
|
||||
static v8::Handle<v8::Value> Popup(const v8::Arguments &args);
|
||||
static void Popup(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
|
||||
#if defined(OS_WIN)
|
||||
static v8::Handle<v8::Value> AttachToWindow(const v8::Arguments &args);
|
||||
static void AttachToWindow(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
#elif defined(OS_MACOSX)
|
||||
static v8::Handle<v8::Value> SetApplicationMenu(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> SendActionToFirstResponder(
|
||||
const v8::Arguments &args);
|
||||
static void SetApplicationMenu(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void SendActionToFirstResponder(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
#endif
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(Menu);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "browser/api/atom_api_menu.h"
|
||||
|
||||
#import "browser/ui/atom_menu_controller_mac.h"
|
||||
#import "browser/ui/cocoa/atom_menu_controller.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
@@ -21,7 +21,7 @@ class MenuMac : public Menu {
|
||||
protected:
|
||||
virtual void Popup(NativeWindow* window) OVERRIDE;
|
||||
|
||||
scoped_nsobject<AtomMenuController> menu_controller_;
|
||||
base::scoped_nsobject<AtomMenuController> menu_controller_;
|
||||
|
||||
private:
|
||||
friend class Menu;
|
||||
|
||||
@@ -4,11 +4,12 @@
|
||||
|
||||
#import "browser/api/atom_api_menu_mac.h"
|
||||
|
||||
#include "base/message_loop.h"
|
||||
#include "base/mac/scoped_sending_event.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "browser/native_window.h"
|
||||
#include "common/v8_conversions.h"
|
||||
#include "common/v8/node_common.h"
|
||||
#include "common/v8/native_type_conversions.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/browser/web_contents_view.h"
|
||||
|
||||
@@ -24,7 +25,7 @@ MenuMac::~MenuMac() {
|
||||
}
|
||||
|
||||
void MenuMac::Popup(NativeWindow* native_window) {
|
||||
scoped_nsobject<AtomMenuController> menu_controller(
|
||||
base::scoped_nsobject<AtomMenuController> menu_controller(
|
||||
[[AtomMenuController alloc] initWithModel:model_.get()]);
|
||||
|
||||
NSWindow* window = native_window->GetNativeWindow();
|
||||
@@ -46,7 +47,8 @@ void MenuMac::Popup(NativeWindow* native_window) {
|
||||
|
||||
{
|
||||
// Make sure events can be pumped while the menu is up.
|
||||
MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current());
|
||||
base::MessageLoop::ScopedNestableTaskAllower allow(
|
||||
base::MessageLoop::current());
|
||||
|
||||
// One of the events that could be pumped is |window.close()|.
|
||||
// User-initiated event-tracking loops protect against this by
|
||||
@@ -71,9 +73,7 @@ void MenuMac::SendActionToFirstResponder(const std::string& action) {
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Menu::SetApplicationMenu(const v8::Arguments &args) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
void Menu::SetApplicationMenu(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
if (!args[0]->IsObject())
|
||||
return node::ThrowTypeError("Bad argument");
|
||||
|
||||
@@ -81,28 +81,22 @@ v8::Handle<v8::Value> Menu::SetApplicationMenu(const v8::Arguments &args) {
|
||||
if (!menu)
|
||||
return node::ThrowError("Menu is destroyed");
|
||||
|
||||
scoped_nsobject<AtomMenuController> menu_controller(
|
||||
base::scoped_nsobject<AtomMenuController> menu_controller(
|
||||
[[AtomMenuController alloc] initWithModel:menu->model_.get()]);
|
||||
[NSApp setMainMenu:[menu_controller menu]];
|
||||
|
||||
// Ensure the menu_controller_ is destroyed after main menu is set.
|
||||
menu_controller.swap(menu->menu_controller_);
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Menu::SendActionToFirstResponder(
|
||||
const v8::Arguments &args) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
void Menu::SendActionToFirstResponder(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
std::string action;
|
||||
if (!FromV8Arguments(args, &action))
|
||||
return node::ThrowTypeError("Bad argument");
|
||||
|
||||
MenuMac::SendActionToFirstResponder(action);
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
|
||||
@@ -6,10 +6,12 @@
|
||||
|
||||
#include "browser/native_window_win.h"
|
||||
#include "browser/ui/win/menu_2.h"
|
||||
#include "common/v8_conversions.h"
|
||||
#include "common/v8/native_type_conversions.h"
|
||||
#include "ui/gfx/point.h"
|
||||
#include "ui/gfx/screen.h"
|
||||
|
||||
#include "common/v8/node_common.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
@@ -28,9 +30,7 @@ void MenuWin::Popup(NativeWindow* native_window) {
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Menu::AttachToWindow(const v8::Arguments& args) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
void Menu::AttachToWindow(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
Menu* self = ObjectWrap::Unwrap<Menu>(args.This());
|
||||
if (self == NULL)
|
||||
return node::ThrowError("Menu is already destroyed");
|
||||
@@ -40,8 +40,6 @@ v8::Handle<v8::Value> Menu::AttachToWindow(const v8::Arguments& args) {
|
||||
return node::ThrowTypeError("Bad argument");
|
||||
|
||||
static_cast<NativeWindowWin*>(native_window)->SetMenu(self->model_.get());
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
#include "browser/api/atom_api_power_monitor.h"
|
||||
|
||||
#include "base/power_monitor/power_monitor.h"
|
||||
#include "base/power_monitor/power_monitor_device_source.h"
|
||||
|
||||
#include "common/v8/node_common.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
@@ -35,20 +38,18 @@ void PowerMonitor::OnResume() {
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> PowerMonitor::New(const v8::Arguments& args) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
void PowerMonitor::New(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
if (!args.IsConstructCall())
|
||||
return node::ThrowError("Require constructor call");
|
||||
|
||||
new PowerMonitor(args.This());
|
||||
|
||||
return args.This();
|
||||
}
|
||||
|
||||
// static
|
||||
void PowerMonitor::Initialize(v8::Handle<v8::Object> target) {
|
||||
v8::HandleScope scope;
|
||||
#if defined(OS_MACOSX)
|
||||
base::PowerMonitorDeviceSource::AllocateSystemIOPorts();
|
||||
#endif
|
||||
|
||||
v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(
|
||||
PowerMonitor::New);
|
||||
|
||||
@@ -5,10 +5,9 @@
|
||||
#ifndef ATOM_BROWSER_API_ATOM_API_POWER_MONITOR_H_
|
||||
#define ATOM_BROWSER_API_ATOM_API_POWER_MONITOR_H_
|
||||
|
||||
#include "browser/api/atom_api_event_emitter.h"
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/power_monitor/power_observer.h"
|
||||
#include "common/api/atom_api_event_emitter.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
@@ -29,7 +28,7 @@ class PowerMonitor : public EventEmitter,
|
||||
virtual void OnResume() OVERRIDE;
|
||||
|
||||
private:
|
||||
static v8::Handle<v8::Value> New(const v8::Arguments &args);
|
||||
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(PowerMonitor);
|
||||
};
|
||||
|
||||
@@ -9,11 +9,11 @@
|
||||
#include "browser/net/adapter_request_job.h"
|
||||
#include "browser/net/atom_url_request_context_getter.h"
|
||||
#include "browser/net/atom_url_request_job_factory.h"
|
||||
#include "common/v8_conversions.h"
|
||||
#include "common/v8/native_type_conversions.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "net/url_request/url_request_context.h"
|
||||
#include "vendor/node/src/node.h"
|
||||
#include "vendor/node/src/node_internals.h"
|
||||
|
||||
#include "common/v8/node_common.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
@@ -24,10 +24,10 @@ typedef net::URLRequestJobFactory::ProtocolHandler ProtocolHandler;
|
||||
namespace {
|
||||
|
||||
// The protocol module object.
|
||||
v8::Persistent<v8::Object> g_protocol_object;
|
||||
ScopedPersistent<v8::Object> g_protocol_object;
|
||||
|
||||
// Registered protocol handlers.
|
||||
typedef std::map<std::string, v8::Persistent<v8::Function>> HandlersMap;
|
||||
typedef std::map<std::string, RefCountedV8Function> HandlersMap;
|
||||
static HandlersMap g_handlers;
|
||||
|
||||
static const char* kEarlyUseProtocolError = "This method can only be used"
|
||||
@@ -35,25 +35,24 @@ static const char* kEarlyUseProtocolError = "This method can only be used"
|
||||
|
||||
// Emit an event for the protocol module.
|
||||
void EmitEventInUI(const std::string& event, const std::string& parameter) {
|
||||
v8::HandleScope scope;
|
||||
v8::Locker locker(node_isolate);
|
||||
v8::HandleScope handle_scope(node_isolate);
|
||||
|
||||
v8::Handle<v8::Value> argv[] = {
|
||||
ToV8Value(event),
|
||||
ToV8Value(parameter),
|
||||
ToV8Value(event),
|
||||
ToV8Value(parameter),
|
||||
};
|
||||
node::MakeCallback(g_protocol_object, "emit", arraysize(argv), argv);
|
||||
node::MakeCallback(g_protocol_object.NewHandle(node_isolate),
|
||||
"emit", 2, argv);
|
||||
}
|
||||
|
||||
// Convert the URLRequest object to V8 object.
|
||||
v8::Handle<v8::Object> ConvertURLRequestToV8Object(
|
||||
const net::URLRequest* request) {
|
||||
v8::Local<v8::Object> obj = v8::Object::New();
|
||||
obj->Set(v8::String::New("method"),
|
||||
v8::String::New(request->method().c_str()));
|
||||
obj->Set(v8::String::New("url"),
|
||||
v8::String::New(request->url().spec().c_str()));
|
||||
obj->Set(v8::String::New("referrer"),
|
||||
v8::String::New(request->referrer().c_str()));
|
||||
obj->Set(ToV8Value("method"), ToV8Value(request->method()));
|
||||
obj->Set(ToV8Value("url"), ToV8Value(request->url().spec()));
|
||||
obj->Set(ToV8Value("referrer"), ToV8Value(request->referrer()));
|
||||
return obj;
|
||||
}
|
||||
|
||||
@@ -74,13 +73,16 @@ class CustomProtocolRequestJob : public AdapterRequestJob {
|
||||
virtual void GetJobTypeInUI() OVERRIDE {
|
||||
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
|
||||
|
||||
v8::Locker locker(node_isolate);
|
||||
v8::HandleScope handle_scope(node_isolate);
|
||||
|
||||
// Call the JS handler.
|
||||
v8::HandleScope scope;
|
||||
v8::Handle<v8::Value> argv[] = {
|
||||
ConvertURLRequestToV8Object(request()),
|
||||
};
|
||||
v8::Handle<v8::Value> result = g_handlers[request()->url().scheme()]->Call(
|
||||
v8::Context::GetCurrent()->Global(), arraysize(argv), argv);
|
||||
RefCountedV8Function callback = g_handlers[request()->url().scheme()];
|
||||
v8::Handle<v8::Value> result = callback->NewHandle(node_isolate)->Call(
|
||||
v8::Context::GetCurrent()->Global(), 1, argv);
|
||||
|
||||
// Determine the type of the job we are going to create.
|
||||
if (result->IsString()) {
|
||||
@@ -180,14 +182,15 @@ class CustomProtocolHandler : public ProtocolHandler {
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Protocol::RegisterProtocol(const v8::Arguments& args) {
|
||||
void Protocol::RegisterProtocol(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
std::string scheme;
|
||||
v8::Persistent<v8::Function> callback;
|
||||
RefCountedV8Function callback;
|
||||
if (!FromV8Arguments(args, &scheme, &callback))
|
||||
return node::ThrowTypeError("Bad argument");
|
||||
|
||||
if (g_handlers.find(scheme) != g_handlers.end() ||
|
||||
net::URLRequest::IsHandledProtocol(scheme))
|
||||
GetRequestJobFactory()->IsHandledProtocol(scheme))
|
||||
return node::ThrowError("The scheme is already registered");
|
||||
|
||||
if (AtomBrowserContext::Get()->url_request_context_getter() == NULL)
|
||||
@@ -199,12 +202,11 @@ v8::Handle<v8::Value> Protocol::RegisterProtocol(const v8::Arguments& args) {
|
||||
content::BrowserThread::PostTask(content::BrowserThread::IO,
|
||||
FROM_HERE,
|
||||
base::Bind(&RegisterProtocolInIO, scheme));
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Protocol::UnregisterProtocol(const v8::Arguments& args) {
|
||||
void Protocol::UnregisterProtocol(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
std::string scheme;
|
||||
if (!FromV8Arguments(args, &scheme))
|
||||
return node::ThrowTypeError("Bad argument");
|
||||
@@ -221,19 +223,23 @@ v8::Handle<v8::Value> Protocol::UnregisterProtocol(const v8::Arguments& args) {
|
||||
content::BrowserThread::PostTask(content::BrowserThread::IO,
|
||||
FROM_HERE,
|
||||
base::Bind(&UnregisterProtocolInIO, scheme));
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Protocol::IsHandledProtocol(const v8::Arguments& args) {
|
||||
return ToV8Value(net::URLRequest::IsHandledProtocol(FromV8Value(args[0])));
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Protocol::InterceptProtocol(const v8::Arguments& args) {
|
||||
void Protocol::IsHandledProtocol(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
std::string scheme;
|
||||
v8::Persistent<v8::Function> callback;
|
||||
if (!FromV8Arguments(args, &scheme))
|
||||
return node::ThrowTypeError("Bad argument");
|
||||
|
||||
args.GetReturnValue().Set(GetRequestJobFactory()->IsHandledProtocol(scheme));
|
||||
}
|
||||
|
||||
// static
|
||||
void Protocol::InterceptProtocol(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
std::string scheme;
|
||||
RefCountedV8Function callback;
|
||||
if (!FromV8Arguments(args, &scheme, &callback))
|
||||
return node::ThrowTypeError("Bad argument");
|
||||
|
||||
@@ -252,11 +258,11 @@ v8::Handle<v8::Value> Protocol::InterceptProtocol(const v8::Arguments& args) {
|
||||
content::BrowserThread::PostTask(content::BrowserThread::IO,
|
||||
FROM_HERE,
|
||||
base::Bind(&InterceptProtocolInIO, scheme));
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Protocol::UninterceptProtocol(const v8::Arguments& args) {
|
||||
void Protocol::UninterceptProtocol(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
std::string scheme;
|
||||
if (!FromV8Arguments(args, &scheme))
|
||||
return node::ThrowTypeError("Bad argument");
|
||||
@@ -274,7 +280,6 @@ v8::Handle<v8::Value> Protocol::UninterceptProtocol(const v8::Arguments& args) {
|
||||
FROM_HERE,
|
||||
base::Bind(&UninterceptProtocolInIO,
|
||||
scheme));
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
@@ -361,14 +366,13 @@ void Protocol::UninterceptProtocolInIO(const std::string& scheme) {
|
||||
// static
|
||||
void Protocol::Initialize(v8::Handle<v8::Object> target) {
|
||||
// Remember the protocol object, used for emitting event later.
|
||||
g_protocol_object = v8::Persistent<v8::Object>::New(
|
||||
node::node_isolate, target);
|
||||
g_protocol_object.reset(target);
|
||||
|
||||
node::SetMethod(target, "registerProtocol", RegisterProtocol);
|
||||
node::SetMethod(target, "unregisterProtocol", UnregisterProtocol);
|
||||
node::SetMethod(target, "isHandledProtocol", IsHandledProtocol);
|
||||
node::SetMethod(target, "interceptProtocol", InterceptProtocol);
|
||||
node::SetMethod(target, "uninterceptProtocol", UninterceptProtocol);
|
||||
NODE_SET_METHOD(target, "registerProtocol", RegisterProtocol);
|
||||
NODE_SET_METHOD(target, "unregisterProtocol", UnregisterProtocol);
|
||||
NODE_SET_METHOD(target, "isHandledProtocol", IsHandledProtocol);
|
||||
NODE_SET_METHOD(target, "interceptProtocol", InterceptProtocol);
|
||||
NODE_SET_METHOD(target, "uninterceptProtocol", UninterceptProtocol);
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
|
||||
@@ -20,12 +20,16 @@ class Protocol {
|
||||
static void Initialize(v8::Handle<v8::Object> target);
|
||||
|
||||
private:
|
||||
static v8::Handle<v8::Value> RegisterProtocol(const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> UnregisterProtocol(const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> IsHandledProtocol(const v8::Arguments& args);
|
||||
static void RegisterProtocol(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void UnregisterProtocol(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void IsHandledProtocol(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
|
||||
static v8::Handle<v8::Value> InterceptProtocol(const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> UninterceptProtocol(const v8::Arguments& args);
|
||||
static void InterceptProtocol(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void UninterceptProtocol(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
|
||||
static void RegisterProtocolInIO(const std::string& scheme);
|
||||
static void UnregisterProtocolInIO(const std::string& scheme);
|
||||
|
||||
@@ -4,18 +4,19 @@
|
||||
|
||||
#include "browser/api/atom_api_window.h"
|
||||
|
||||
#include "base/values.h"
|
||||
#include "base/bind.h"
|
||||
#include "base/process/kill.h"
|
||||
#include "browser/native_window.h"
|
||||
#include "common/v8_conversions.h"
|
||||
#include "common/v8_value_converter_impl.h"
|
||||
#include "common/v8/native_type_conversions.h"
|
||||
#include "content/public/browser/navigation_entry.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "ui/gfx/point.h"
|
||||
#include "ui/gfx/rect.h"
|
||||
#include "ui/gfx/size.h"
|
||||
|
||||
using content::V8ValueConverter;
|
||||
#include "common/v8/node_common.h"
|
||||
#include "vendor/node/src/node_buffer.h"
|
||||
|
||||
using content::NavigationController;
|
||||
using node::ObjectWrap;
|
||||
|
||||
@@ -78,130 +79,124 @@ void Window::OnRendererResponsive() {
|
||||
Emit("responsive");
|
||||
}
|
||||
|
||||
void Window::OnRenderViewDeleted(int process_id, int routing_id) {
|
||||
base::ListValue args;
|
||||
args.AppendInteger(process_id);
|
||||
args.AppendInteger(routing_id);
|
||||
Emit("render-view-deleted", &args);
|
||||
}
|
||||
|
||||
void Window::OnRendererCrashed() {
|
||||
Emit("crashed");
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::New(const v8::Arguments &args) {
|
||||
v8::HandleScope scope;
|
||||
void Window::OnCapturePageDone(const RefCountedV8Function& callback,
|
||||
const std::vector<unsigned char>& data) {
|
||||
v8::Locker locker(node_isolate);
|
||||
v8::HandleScope handle_scope(node_isolate);
|
||||
|
||||
v8::Local<v8::Value> buffer = node::Buffer::New(
|
||||
reinterpret_cast<const char*>(data.data()),
|
||||
data.size());
|
||||
callback->NewHandle(node_isolate)->Call(
|
||||
v8::Context::GetCurrent()->Global(), 1, &buffer);
|
||||
}
|
||||
|
||||
// static
|
||||
void Window::New(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
if (!args.IsConstructCall())
|
||||
return node::ThrowError("Require constructor call");
|
||||
|
||||
if (!args[0]->IsObject())
|
||||
return node::ThrowTypeError("Need options creating Window");
|
||||
|
||||
scoped_ptr<V8ValueConverter> converter(new V8ValueConverterImpl());
|
||||
scoped_ptr<base::Value> options(
|
||||
converter->FromV8Value(args[0], v8::Context::GetCurrent()));
|
||||
scoped_ptr<base::Value> options;
|
||||
if (!FromV8Arguments(args, &options))
|
||||
return node::ThrowTypeError("Bad argument");
|
||||
|
||||
if (!options || !options->IsType(base::Value::TYPE_DICTIONARY))
|
||||
return node::ThrowTypeError("Invalid options");
|
||||
return node::ThrowTypeError("Options must be dictionary");
|
||||
|
||||
new Window(args.This(), static_cast<base::DictionaryValue*>(options.get()));
|
||||
|
||||
// Give js code a chance to do initialization.
|
||||
node::MakeCallback(args.This(), "_init", 0, NULL);
|
||||
|
||||
return args.This();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::Destroy(const v8::Arguments &args) {
|
||||
void Window::Destroy(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
base::ProcessHandle handle = self->window_->GetRenderProcessHandle();
|
||||
delete self;
|
||||
|
||||
return v8::Undefined();
|
||||
// Make sure the renderer process is terminated, it could happen that the
|
||||
// renderer process became a zombie.
|
||||
base::MessageLoop::current()->PostDelayedTask(
|
||||
FROM_HERE,
|
||||
base::Bind(base::IgnoreResult(base::KillProcess), handle, 0, false),
|
||||
base::TimeDelta::FromMilliseconds(5000));
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::Close(const v8::Arguments &args) {
|
||||
void Window::Close(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
self->window_->Close();
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::Focus(const v8::Arguments &args) {
|
||||
void Window::Focus(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
self->window_->Focus(args[0]->IsBoolean() ? args[0]->BooleanValue(): true);
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::IsFocused(const v8::Arguments &args) {
|
||||
void Window::IsFocused(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
return ToV8Value(self->window_->IsFocused());
|
||||
args.GetReturnValue().Set(self->window_->IsFocused());
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::Show(const v8::Arguments &args) {
|
||||
void Window::Show(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
self->window_->Show();
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::Hide(const v8::Arguments &args) {
|
||||
void Window::Hide(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
self->window_->Hide();
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::IsVisible(const v8::Arguments& args) {
|
||||
void Window::IsVisible(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
return ToV8Value(self->window_->IsVisible());
|
||||
return args.GetReturnValue().Set(self->window_->IsVisible());
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::Maximize(const v8::Arguments &args) {
|
||||
void Window::Maximize(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
self->window_->Maximize();
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::Unmaximize(const v8::Arguments &args) {
|
||||
void Window::Unmaximize(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
self->window_->Unmaximize();
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::Minimize(const v8::Arguments &args) {
|
||||
void Window::Minimize(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
self->window_->Minimize();
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::Restore(const v8::Arguments &args) {
|
||||
void Window::Restore(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
self->window_->Restore();
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::SetFullscreen(const v8::Arguments &args) {
|
||||
void Window::SetFullscreen(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
bool fs;
|
||||
@@ -209,18 +204,16 @@ v8::Handle<v8::Value> Window::SetFullscreen(const v8::Arguments &args) {
|
||||
return node::ThrowTypeError("Bad argument");
|
||||
|
||||
self->window_->SetFullscreen(fs);
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::IsFullscreen(const v8::Arguments &args) {
|
||||
void Window::IsFullscreen(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
return ToV8Value(self->window_->IsFullscreen());
|
||||
args.GetReturnValue().Set(self->window_->IsFullscreen());
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::SetSize(const v8::Arguments &args) {
|
||||
void Window::SetSize(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
int width, height;
|
||||
@@ -228,11 +221,10 @@ v8::Handle<v8::Value> Window::SetSize(const v8::Arguments &args) {
|
||||
return node::ThrowTypeError("Bad argument");
|
||||
|
||||
self->window_->SetSize(gfx::Size(width, height));
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::GetSize(const v8::Arguments &args) {
|
||||
void Window::GetSize(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
gfx::Size size = self->window_->GetSize();
|
||||
@@ -240,11 +232,11 @@ v8::Handle<v8::Value> Window::GetSize(const v8::Arguments &args) {
|
||||
ret->Set(0, ToV8Value(size.width()));
|
||||
ret->Set(1, ToV8Value(size.height()));
|
||||
|
||||
return ret;
|
||||
args.GetReturnValue().Set(ret);
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::SetMinimumSize(const v8::Arguments &args) {
|
||||
void Window::SetMinimumSize(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
int width, height;
|
||||
@@ -252,11 +244,10 @@ v8::Handle<v8::Value> Window::SetMinimumSize(const v8::Arguments &args) {
|
||||
return node::ThrowTypeError("Bad argument");
|
||||
|
||||
self->window_->SetMinimumSize(gfx::Size(width, height));
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::GetMinimumSize(const v8::Arguments &args) {
|
||||
void Window::GetMinimumSize(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
gfx::Size size = self->window_->GetMinimumSize();
|
||||
@@ -264,24 +255,22 @@ v8::Handle<v8::Value> Window::GetMinimumSize(const v8::Arguments &args) {
|
||||
ret->Set(0, ToV8Value(size.width()));
|
||||
ret->Set(1, ToV8Value(size.height()));
|
||||
|
||||
return ret;
|
||||
args.GetReturnValue().Set(ret);
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::SetMaximumSize(const v8::Arguments &args) {
|
||||
void Window::SetMaximumSize(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
|
||||
int width, height;
|
||||
if (!FromV8Arguments(args, &width, &height))
|
||||
return node::ThrowTypeError("Bad argument");
|
||||
|
||||
self->window_->SetMaximumSize(gfx::Size(width, height));
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::GetMaximumSize(const v8::Arguments &args) {
|
||||
void Window::GetMaximumSize(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
gfx::Size size = self->window_->GetMaximumSize();
|
||||
@@ -289,11 +278,11 @@ v8::Handle<v8::Value> Window::GetMaximumSize(const v8::Arguments &args) {
|
||||
ret->Set(0, ToV8Value(size.width()));
|
||||
ret->Set(1, ToV8Value(size.height()));
|
||||
|
||||
return ret;
|
||||
args.GetReturnValue().Set(ret);
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::SetResizable(const v8::Arguments &args) {
|
||||
void Window::SetResizable(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
bool resizable;
|
||||
@@ -301,18 +290,16 @@ v8::Handle<v8::Value> Window::SetResizable(const v8::Arguments &args) {
|
||||
return node::ThrowTypeError("Bad argument");
|
||||
|
||||
self->window_->SetResizable(resizable);
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::IsResizable(const v8::Arguments &args) {
|
||||
void Window::IsResizable(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
return ToV8Value(self->window_->IsResizable());
|
||||
args.GetReturnValue().Set(self->window_->IsResizable());
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::SetAlwaysOnTop(const v8::Arguments &args) {
|
||||
void Window::SetAlwaysOnTop(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
bool top;
|
||||
@@ -320,27 +307,22 @@ v8::Handle<v8::Value> Window::SetAlwaysOnTop(const v8::Arguments &args) {
|
||||
return node::ThrowTypeError("Bad argument");
|
||||
|
||||
self->window_->SetAlwaysOnTop(top);
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::IsAlwaysOnTop(const v8::Arguments &args) {
|
||||
void Window::IsAlwaysOnTop(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
return ToV8Value(self->window_->IsAlwaysOnTop());
|
||||
args.GetReturnValue().Set(self->window_->IsAlwaysOnTop());
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::Center(const v8::Arguments &args) {
|
||||
void Window::Center(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
self->window_->Center();
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::SetPosition(const v8::Arguments &args) {
|
||||
void Window::SetPosition(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
int x, y;
|
||||
@@ -348,11 +330,10 @@ v8::Handle<v8::Value> Window::SetPosition(const v8::Arguments &args) {
|
||||
return node::ThrowTypeError("Bad argument");
|
||||
|
||||
self->window_->SetPosition(gfx::Point(x, y));
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::GetPosition(const v8::Arguments &args) {
|
||||
void Window::GetPosition(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
gfx::Point pos = self->window_->GetPosition();
|
||||
@@ -360,11 +341,11 @@ v8::Handle<v8::Value> Window::GetPosition(const v8::Arguments &args) {
|
||||
ret->Set(0, ToV8Value(pos.x()));
|
||||
ret->Set(1, ToV8Value(pos.y()));
|
||||
|
||||
return ret;
|
||||
args.GetReturnValue().Set(ret);
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::SetTitle(const v8::Arguments &args) {
|
||||
void Window::SetTitle(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
std::string title;
|
||||
@@ -372,27 +353,23 @@ v8::Handle<v8::Value> Window::SetTitle(const v8::Arguments &args) {
|
||||
return node::ThrowTypeError("Bad argument");
|
||||
|
||||
self->window_->SetTitle(title);
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::GetTitle(const v8::Arguments &args) {
|
||||
void Window::GetTitle(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
return ToV8Value(self->window_->GetTitle());
|
||||
args.GetReturnValue().Set(ToV8Value(self->window_->GetTitle()));
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::FlashFrame(const v8::Arguments &args) {
|
||||
void Window::FlashFrame(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
self->window_->FlashFrame(
|
||||
args[0]->IsBoolean() ? args[0]->BooleanValue(): true);
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::SetKiosk(const v8::Arguments &args) {
|
||||
void Window::SetKiosk(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
bool kiosk;
|
||||
@@ -400,42 +377,34 @@ v8::Handle<v8::Value> Window::SetKiosk(const v8::Arguments &args) {
|
||||
return node::ThrowTypeError("Bad argument");
|
||||
|
||||
self->window_->SetKiosk(kiosk);
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::IsKiosk(const v8::Arguments &args) {
|
||||
void Window::IsKiosk(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
return ToV8Value(self->window_->IsKiosk());
|
||||
args.GetReturnValue().Set(self->window_->IsKiosk());
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::OpenDevTools(const v8::Arguments &args) {
|
||||
void Window::OpenDevTools(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
self->window_->OpenDevTools();
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::CloseDevTools(const v8::Arguments &args) {
|
||||
void Window::CloseDevTools(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
self->window_->CloseDevTools();
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::IsDevToolsOpened(const v8::Arguments& args) {
|
||||
void Window::IsDevToolsOpened(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
return ToV8Value(self->window_->IsDevToolsOpened());
|
||||
args.GetReturnValue().Set(self->window_->IsDevToolsOpened());
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::InspectElement(const v8::Arguments& args) {
|
||||
void Window::InspectElement(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
int x, y;
|
||||
@@ -443,148 +412,140 @@ v8::Handle<v8::Value> Window::InspectElement(const v8::Arguments& args) {
|
||||
return node::ThrowTypeError("Bad argument");
|
||||
|
||||
self->window_->InspectElement(x, y);
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::FocusOnWebView(const v8::Arguments &args) {
|
||||
void Window::FocusOnWebView(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
self->window_->FocusOnWebView();
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::BlurWebView(const v8::Arguments &args) {
|
||||
void Window::BlurWebView(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
self->window_->BlurWebView();
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::IsWebViewFocused(const v8::Arguments& args) {
|
||||
void Window::IsWebViewFocused(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
return ToV8Value(self->window_->IsWebViewFocused());
|
||||
args.GetReturnValue().Set(self->window_->IsWebViewFocused());
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::RestartHangMonitorTimeout(
|
||||
const v8::Arguments &args) {
|
||||
void Window::CapturePage(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
self->window_->RestartHangMonitorTimeout();
|
||||
gfx::Rect rect;
|
||||
RefCountedV8Function callback;
|
||||
if (!FromV8Arguments(args, &rect, &callback) &&
|
||||
!FromV8Arguments(args, &callback))
|
||||
return node::ThrowTypeError("Bad argument");
|
||||
|
||||
return v8::Undefined();
|
||||
self->window_->CapturePage(rect, base::Bind(&Window::OnCapturePageDone,
|
||||
base::Unretained(self),
|
||||
callback));
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::GetPageTitle(const v8::Arguments &args) {
|
||||
void Window::GetPageTitle(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
return ToV8Value(self->window_->GetWebContents()->GetTitle());
|
||||
args.GetReturnValue().Set(ToV8Value(
|
||||
self->window_->GetWebContents()->GetTitle()));
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::IsLoading(const v8::Arguments &args) {
|
||||
void Window::IsLoading(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
return ToV8Value(self->window_->GetWebContents()->IsLoading());
|
||||
args.GetReturnValue().Set(self->window_->GetWebContents()->IsLoading());
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::IsWaitingForResponse(const v8::Arguments &args) {
|
||||
void Window::IsWaitingForResponse(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
return ToV8Value(self->window_->GetWebContents()->IsWaitingForResponse());
|
||||
args.GetReturnValue().Set(
|
||||
self->window_->GetWebContents()->IsWaitingForResponse());
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::Stop(const v8::Arguments &args) {
|
||||
void Window::Stop(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
self->window_->GetWebContents()->Stop();
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::GetRoutingID(const v8::Arguments &args) {
|
||||
void Window::GetRoutingID(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
return ToV8Value(self->window_->GetWebContents()->GetRoutingID());
|
||||
args.GetReturnValue().Set(self->window_->GetWebContents()->GetRoutingID());
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::GetProcessID(const v8::Arguments &args) {
|
||||
void Window::GetProcessID(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
return ToV8Value(
|
||||
args.GetReturnValue().Set(
|
||||
self->window_->GetWebContents()->GetRenderProcessHost()->GetID());
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::IsCrashed(const v8::Arguments &args) {
|
||||
void Window::IsCrashed(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
return ToV8Value(self->window_->GetWebContents()->IsCrashed());
|
||||
args.GetReturnValue().Set(self->window_->GetWebContents()->IsCrashed());
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::LoadURL(const v8::Arguments &args) {
|
||||
void Window::LoadURL(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
std::string url;
|
||||
GURL url;
|
||||
if (!FromV8Arguments(args, &url))
|
||||
return node::ThrowTypeError("Bad argument");
|
||||
|
||||
NavigationController& controller =
|
||||
self->window_->GetWebContents()->GetController();
|
||||
controller.LoadURL(GURL(url),
|
||||
content::Referrer(),
|
||||
content::PAGE_TRANSITION_AUTO_TOPLEVEL,
|
||||
std::string());
|
||||
|
||||
return v8::Undefined();
|
||||
content::NavigationController::LoadURLParams params(url);
|
||||
params.transition_type = content::PAGE_TRANSITION_TYPED;
|
||||
params.override_user_agent = content::NavigationController::UA_OVERRIDE_TRUE;
|
||||
controller.LoadURLWithParams(params);
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::GetURL(const v8::Arguments &args) {
|
||||
void Window::GetURL(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
NavigationController& controller =
|
||||
self->window_->GetWebContents()->GetController();
|
||||
std::string url;
|
||||
GURL url;
|
||||
if (controller.GetActiveEntry())
|
||||
url = controller.GetActiveEntry()->GetVirtualURL().spec();
|
||||
url = controller.GetActiveEntry()->GetVirtualURL();
|
||||
|
||||
return ToV8Value(url);
|
||||
args.GetReturnValue().Set(ToV8Value(url));
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::CanGoBack(const v8::Arguments &args) {
|
||||
void Window::CanGoBack(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
NavigationController& controller =
|
||||
self->window_->GetWebContents()->GetController();
|
||||
|
||||
return ToV8Value(controller.CanGoBack());
|
||||
args.GetReturnValue().Set(controller.CanGoBack());
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::CanGoForward(const v8::Arguments &args) {
|
||||
void Window::CanGoForward(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
NavigationController& controller =
|
||||
self->window_->GetWebContents()->GetController();
|
||||
|
||||
return ToV8Value(controller.CanGoForward());
|
||||
args.GetReturnValue().Set(controller.CanGoForward());
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::CanGoToOffset(const v8::Arguments &args) {
|
||||
void Window::CanGoToOffset(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
int offset;
|
||||
@@ -594,33 +555,29 @@ v8::Handle<v8::Value> Window::CanGoToOffset(const v8::Arguments &args) {
|
||||
NavigationController& controller =
|
||||
self->window_->GetWebContents()->GetController();
|
||||
|
||||
return ToV8Value(controller.CanGoToOffset(offset));
|
||||
args.GetReturnValue().Set(controller.CanGoToOffset(offset));
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::GoBack(const v8::Arguments &args) {
|
||||
void Window::GoBack(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
NavigationController& controller =
|
||||
self->window_->GetWebContents()->GetController();
|
||||
controller.GoBack();
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::GoForward(const v8::Arguments &args) {
|
||||
void Window::GoForward(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
NavigationController& controller =
|
||||
self->window_->GetWebContents()->GetController();
|
||||
controller.GoForward();
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::GoToIndex(const v8::Arguments &args) {
|
||||
void Window::GoToIndex(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
int index;
|
||||
@@ -630,12 +587,10 @@ v8::Handle<v8::Value> Window::GoToIndex(const v8::Arguments &args) {
|
||||
NavigationController& controller =
|
||||
self->window_->GetWebContents()->GetController();
|
||||
controller.GoToIndex(index);
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::GoToOffset(const v8::Arguments &args) {
|
||||
void Window::GoToOffset(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
int offset;
|
||||
@@ -645,37 +600,30 @@ v8::Handle<v8::Value> Window::GoToOffset(const v8::Arguments &args) {
|
||||
NavigationController& controller =
|
||||
self->window_->GetWebContents()->GetController();
|
||||
controller.GoToOffset(offset);
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::Reload(const v8::Arguments &args) {
|
||||
void Window::Reload(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
NavigationController& controller =
|
||||
self->window_->GetWebContents()->GetController();
|
||||
controller.Reload(args[0]->IsBoolean() ? args[0]->BooleanValue(): false);
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::ReloadIgnoringCache(const v8::Arguments &args) {
|
||||
void Window::ReloadIgnoringCache(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
NavigationController& controller =
|
||||
self->window_->GetWebContents()->GetController();
|
||||
controller.ReloadIgnoringCache(
|
||||
args[0]->IsBoolean() ? args[0]->BooleanValue(): false);
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
void Window::Initialize(v8::Handle<v8::Object> target) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(Window::New);
|
||||
t->InstanceTemplate()->SetInternalFieldCount(1);
|
||||
t->SetClassName(v8::String::NewSymbol("BrowserWindow"));
|
||||
@@ -718,9 +666,7 @@ void Window::Initialize(v8::Handle<v8::Object> target) {
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "focusOnWebView", FocusOnWebView);
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "blurWebView", BlurWebView);
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "isWebViewFocused", IsWebViewFocused);
|
||||
NODE_SET_PROTOTYPE_METHOD(t,
|
||||
"restartHangMonitorTimeout",
|
||||
RestartHangMonitorTimeout);
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "capturePage", CapturePage);
|
||||
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "getPageTitle", GetPageTitle);
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "isLoading", IsLoading);
|
||||
|
||||
@@ -5,9 +5,12 @@
|
||||
#ifndef ATOM_BROWSER_API_ATOM_API_WINDOW_H_
|
||||
#define ATOM_BROWSER_API_ATOM_API_WINDOW_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "browser/api/atom_api_event_emitter.h"
|
||||
#include "browser/native_window_observer.h"
|
||||
#include "common/api/atom_api_event_emitter.h"
|
||||
#include "common/v8/scoped_persistent.h"
|
||||
|
||||
namespace base {
|
||||
class DictionaryValue;
|
||||
@@ -41,74 +44,80 @@ class Window : public EventEmitter,
|
||||
virtual void OnWindowBlur() OVERRIDE;
|
||||
virtual void OnRendererUnresponsive() OVERRIDE;
|
||||
virtual void OnRendererResponsive() OVERRIDE;
|
||||
virtual void OnRenderViewDeleted(int process_id, int routing_id) OVERRIDE;
|
||||
virtual void OnRendererCrashed() OVERRIDE;
|
||||
|
||||
private:
|
||||
static v8::Handle<v8::Value> New(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> Destroy(const v8::Arguments &args);
|
||||
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void Destroy(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
|
||||
// APIs for NativeWindow.
|
||||
static v8::Handle<v8::Value> Close(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> Focus(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> IsFocused(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> Show(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> Hide(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> IsVisible(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> Maximize(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> Unmaximize(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> Minimize(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> Restore(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> SetFullscreen(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> IsFullscreen(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> SetSize(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> GetSize(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> SetMinimumSize(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> GetMinimumSize(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> SetMaximumSize(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> GetMaximumSize(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> SetResizable(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> IsResizable(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> SetAlwaysOnTop(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> IsAlwaysOnTop(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> Center(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> SetPosition(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> GetPosition(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> SetTitle(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> GetTitle(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> FlashFrame(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> SetKiosk(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> IsKiosk(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> OpenDevTools(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> CloseDevTools(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> IsDevToolsOpened(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> InspectElement(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> FocusOnWebView(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> BlurWebView(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> IsWebViewFocused(const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> RestartHangMonitorTimeout(
|
||||
const v8::Arguments &args);
|
||||
static void Close(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void Focus(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void IsFocused(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void Show(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void Hide(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void IsVisible(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void Maximize(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void Unmaximize(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void Minimize(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void Restore(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void SetFullscreen(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void IsFullscreen(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void SetSize(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void GetSize(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void SetMinimumSize(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void GetMinimumSize(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void SetMaximumSize(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void GetMaximumSize(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void SetResizable(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void IsResizable(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void SetAlwaysOnTop(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void IsAlwaysOnTop(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void Center(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void SetPosition(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void GetPosition(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void SetTitle(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void GetTitle(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void FlashFrame(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void SetKiosk(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void IsKiosk(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void OpenDevTools(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void CloseDevTools(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void IsDevToolsOpened(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void InspectElement(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void FocusOnWebView(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void BlurWebView(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void IsWebViewFocused(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void CapturePage(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
|
||||
// APIs for WebContents.
|
||||
static v8::Handle<v8::Value> GetPageTitle(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> IsLoading(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> IsWaitingForResponse(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> Stop(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> GetRoutingID(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> GetProcessID(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> IsCrashed(const v8::Arguments &args);
|
||||
static void GetPageTitle(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void IsLoading(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void IsWaitingForResponse(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void Stop(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void GetRoutingID(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void GetProcessID(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void IsCrashed(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
|
||||
// APIs for NavigationController.
|
||||
static v8::Handle<v8::Value> LoadURL(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> GetURL(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> CanGoBack(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> CanGoForward(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> CanGoToOffset(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> GoBack(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> GoForward(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> GoToIndex(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> GoToOffset(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> Reload(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> ReloadIgnoringCache(const v8::Arguments &args);
|
||||
static void LoadURL(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void GetURL(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void CanGoBack(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void CanGoForward(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void CanGoToOffset(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void GoBack(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void GoForward(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void GoToIndex(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void GoToOffset(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void Reload(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void ReloadIgnoringCache(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
|
||||
// Called when capturePage is done.
|
||||
void OnCapturePageDone(const RefCountedV8Function& callback,
|
||||
const std::vector<unsigned char>& data);
|
||||
|
||||
scoped_ptr<NativeWindow> window_;
|
||||
|
||||
|
||||
@@ -7,16 +7,11 @@
|
||||
#include <vector>
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/values.h"
|
||||
#include "browser/api/atom_api_event.h"
|
||||
#include "common/v8_conversions.h"
|
||||
#include "common/v8_value_converter_impl.h"
|
||||
#include "common/v8/native_type_conversions.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "vendor/node/src/node.h"
|
||||
#include "vendor/node/src/node_internals.h"
|
||||
|
||||
using content::V8ValueConverter;
|
||||
using node::node_isolate;
|
||||
#include "common/v8/node_common.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
@@ -26,31 +21,14 @@ AtomBrowserBindings::AtomBrowserBindings() {
|
||||
AtomBrowserBindings::~AtomBrowserBindings() {
|
||||
}
|
||||
|
||||
void AtomBrowserBindings::AfterLoad() {
|
||||
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
|
||||
|
||||
v8::HandleScope scope;
|
||||
|
||||
v8::Handle<v8::Object> global = node::g_context->Global();
|
||||
v8::Handle<v8::Object> atom =
|
||||
global->Get(v8::String::New("__atom"))->ToObject();
|
||||
DCHECK(!atom.IsEmpty());
|
||||
|
||||
browser_main_parts_ = v8::Persistent<v8::Object>::New(
|
||||
node_isolate,
|
||||
atom->Get(v8::String::New("browserMainParts"))->ToObject());
|
||||
DCHECK(!browser_main_parts_.IsEmpty());
|
||||
}
|
||||
|
||||
void AtomBrowserBindings::OnRendererMessage(int process_id,
|
||||
int routing_id,
|
||||
const string16& channel,
|
||||
const base::ListValue& args) {
|
||||
v8::HandleScope scope;
|
||||
v8::Locker locker(node_isolate);
|
||||
v8::HandleScope handle_scope(node_isolate);
|
||||
|
||||
v8::Handle<v8::Context> context = v8::Context::GetCurrent();
|
||||
|
||||
scoped_ptr<V8ValueConverter> converter(new V8ValueConverterImpl());
|
||||
scoped_ptr<V8ValueConverter> converter(new V8ValueConverter);
|
||||
|
||||
// process.emit(channel, 'message', process_id, routing_id);
|
||||
std::vector<v8::Handle<v8::Value>> arguments;
|
||||
@@ -58,17 +36,20 @@ void AtomBrowserBindings::OnRendererMessage(int process_id,
|
||||
arguments.push_back(ToV8Value(channel));
|
||||
const base::Value* value;
|
||||
if (args.Get(0, &value))
|
||||
arguments.push_back(converter->ToV8Value(value, context));
|
||||
arguments.push_back(converter->ToV8Value(value, global_env->context()));
|
||||
arguments.push_back(v8::Integer::New(process_id));
|
||||
arguments.push_back(v8::Integer::New(routing_id));
|
||||
|
||||
for (size_t i = 1; i < args.GetSize(); i++) {
|
||||
const base::Value* value;
|
||||
if (args.Get(i, &value))
|
||||
arguments.push_back(converter->ToV8Value(value, context));
|
||||
arguments.push_back(converter->ToV8Value(value, global_env->context()));
|
||||
}
|
||||
|
||||
node::MakeCallback(node::process, "emit", arguments.size(), &arguments[0]);
|
||||
node::MakeCallback(global_env->process_object(),
|
||||
"emit",
|
||||
arguments.size(),
|
||||
&arguments[0]);
|
||||
}
|
||||
|
||||
void AtomBrowserBindings::OnRendererMessageSync(
|
||||
@@ -78,11 +59,10 @@ void AtomBrowserBindings::OnRendererMessageSync(
|
||||
const base::ListValue& args,
|
||||
NativeWindow* sender,
|
||||
IPC::Message* message) {
|
||||
v8::HandleScope scope;
|
||||
v8::Locker locker(node_isolate);
|
||||
v8::HandleScope handle_scope(node_isolate);
|
||||
|
||||
v8::Handle<v8::Context> context = v8::Context::GetCurrent();
|
||||
|
||||
scoped_ptr<V8ValueConverter> converter(new V8ValueConverterImpl());
|
||||
scoped_ptr<V8ValueConverter> converter(new V8ValueConverter);
|
||||
|
||||
// Create the event object.
|
||||
v8::Handle<v8::Object> event = api::Event::CreateV8Object();
|
||||
@@ -94,7 +74,7 @@ void AtomBrowserBindings::OnRendererMessageSync(
|
||||
arguments.push_back(ToV8Value(channel));
|
||||
const base::Value* value;
|
||||
if (args.Get(0, &value))
|
||||
arguments.push_back(converter->ToV8Value(value, context));
|
||||
arguments.push_back(converter->ToV8Value(value, global_env->context()));
|
||||
arguments.push_back(event);
|
||||
arguments.push_back(v8::Integer::New(process_id));
|
||||
arguments.push_back(v8::Integer::New(routing_id));
|
||||
@@ -102,10 +82,13 @@ void AtomBrowserBindings::OnRendererMessageSync(
|
||||
for (size_t i = 1; i < args.GetSize(); i++) {
|
||||
const base::Value* value;
|
||||
if (args.Get(i, &value))
|
||||
arguments.push_back(converter->ToV8Value(value, context));
|
||||
arguments.push_back(converter->ToV8Value(value, global_env->context()));
|
||||
}
|
||||
|
||||
node::MakeCallback(node::process, "emit", arguments.size(), &arguments[0]);
|
||||
node::MakeCallback(global_env->process_object(),
|
||||
"emit",
|
||||
arguments.size(),
|
||||
&arguments[0]);
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
||||
@@ -5,8 +5,9 @@
|
||||
#ifndef ATOM_BROWSER_API_ATOM_BROWSER_BINDINGS_
|
||||
#define ATOM_BROWSER_API_ATOM_BROWSER_BINDINGS_
|
||||
|
||||
#include "base/string16.h"
|
||||
#include "base/strings/string16.h"
|
||||
#include "common/api/atom_bindings.h"
|
||||
#include "common/v8/scoped_persistent.h"
|
||||
|
||||
namespace base {
|
||||
class ListValue;
|
||||
@@ -25,9 +26,6 @@ class AtomBrowserBindings : public AtomBindings {
|
||||
AtomBrowserBindings();
|
||||
virtual ~AtomBrowserBindings();
|
||||
|
||||
// Called when the node.js main script has been loaded.
|
||||
virtual void AfterLoad();
|
||||
|
||||
// Called when received a message from renderer.
|
||||
void OnRendererMessage(int process_id,
|
||||
int routing_id,
|
||||
@@ -42,14 +40,7 @@ class AtomBrowserBindings : public AtomBindings {
|
||||
NativeWindow* sender,
|
||||
IPC::Message* message);
|
||||
|
||||
// The require('atom').browserMainParts object.
|
||||
v8::Handle<v8::Object> browser_main_parts() {
|
||||
return browser_main_parts_;
|
||||
}
|
||||
|
||||
private:
|
||||
v8::Persistent<v8::Object> browser_main_parts_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomBrowserBindings);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
bindings = process.atomBinding 'app'
|
||||
EventEmitter = require('events').EventEmitter
|
||||
|
||||
bindings = process.atomBinding 'app'
|
||||
|
||||
Application = bindings.Application
|
||||
Application::__proto__ = EventEmitter.prototype
|
||||
|
||||
@@ -9,9 +10,6 @@ app = new Application
|
||||
app.getHomeDir = ->
|
||||
process.env[if process.platform is 'win32' then 'USERPROFILE' else 'HOME']
|
||||
|
||||
app.getBrowserWindows = ->
|
||||
require('../../atom/objects-registry.js').getAllWindows()
|
||||
|
||||
app.setApplicationMenu = (menu) ->
|
||||
require('menu').setApplicationMenu menu
|
||||
|
||||
@@ -24,10 +22,13 @@ app.commandLine =
|
||||
|
||||
if process.platform is 'darwin'
|
||||
app.dock =
|
||||
bounce: (type = 'informational') -> bindings.dockBounce type
|
||||
bounce: (type='informational') -> bindings.dockBounce type
|
||||
cancelBounce: bindings.dockCancelBounce
|
||||
setBadge: bindings.dockSetBadgeText
|
||||
getBadge: bindings.dockGetBadgeText
|
||||
|
||||
# Support old event name.
|
||||
app.once 'ready', -> app.emit 'finish-launching'
|
||||
|
||||
# Only one App object pemitted.
|
||||
module.exports = app
|
||||
|
||||
@@ -1 +1,6 @@
|
||||
module.exports = global.__atom
|
||||
module.exports =
|
||||
browserMainParts:
|
||||
preMainMessageLoopRun: ->
|
||||
|
||||
setImmediate ->
|
||||
module.exports.browserMainParts.preMainMessageLoopRun()
|
||||
|
||||
@@ -4,9 +4,8 @@ EventEmitter = require('events').EventEmitter
|
||||
AutoUpdater::__proto__ = EventEmitter.prototype
|
||||
|
||||
autoUpdater = new AutoUpdater
|
||||
autoUpdater.on 'will-install-update-raw', (event, version) ->
|
||||
@emit 'will-install-update', event, version, => @continueUpdate()
|
||||
autoUpdater.on 'ready-for-update-on-quit-raw', (event, version) ->
|
||||
@emit 'ready-for-update-on-quit', event, version, => @quitAndInstall()
|
||||
autoUpdater.on 'update-downloaded-raw', (args...) ->
|
||||
args[2] = new Date(args[2]) # releaseDate
|
||||
@emit 'update-downloaded', args..., => @quitAndInstall()
|
||||
|
||||
module.exports = autoUpdater
|
||||
|
||||
@@ -1,16 +1,32 @@
|
||||
EventEmitter = require('events').EventEmitter
|
||||
IDWeakMap = require 'id-weak-map'
|
||||
app = require 'app'
|
||||
v8Util = process.atomBinding 'v8_util'
|
||||
|
||||
BrowserWindow = process.atomBinding('window').BrowserWindow
|
||||
BrowserWindow::__proto__ = EventEmitter.prototype
|
||||
|
||||
# Store all created windows in the weak map.
|
||||
BrowserWindow.windows = new IDWeakMap
|
||||
|
||||
BrowserWindow::_init = ->
|
||||
# Simulate the application menu on platforms other than OS X.
|
||||
if process.platform isnt 'darwin'
|
||||
menu = app.getApplicationMenu()
|
||||
@setMenu menu if menu?
|
||||
|
||||
# Remember the window.
|
||||
id = BrowserWindow.windows.add this
|
||||
|
||||
# Remove the window from weak map immediately when it's destroyed, since we
|
||||
# could be iterating windows before GC happended.
|
||||
@once 'destroyed', ->
|
||||
BrowserWindow.windows.remove id if BrowserWindow.windows.has id
|
||||
|
||||
# Tell the rpc server that a render view has been deleted and we need to
|
||||
# release all objects owned by it.
|
||||
@on 'render-view-deleted', (event, processId, routingId) ->
|
||||
process.emit 'ATOM_BROWSER_RELEASE_RENDER_VIEW', processId, routingId
|
||||
|
||||
BrowserWindow::toggleDevTools = ->
|
||||
if @isDevToolsOpened() then @closeDevTools() else @openDevTools()
|
||||
|
||||
@@ -25,12 +41,16 @@ BrowserWindow::setMenu = (menu) ->
|
||||
@menu = menu # Keep a reference of menu in case of GC.
|
||||
@menu.attachToWindow this
|
||||
|
||||
BrowserWindow.getAllWindows = ->
|
||||
windows = BrowserWindow.windows
|
||||
windows.get key for key in windows.keys()
|
||||
|
||||
BrowserWindow.getFocusedWindow = ->
|
||||
windows = app.getBrowserWindows()
|
||||
windows = BrowserWindow.getAllWindows()
|
||||
return window for window in windows when window.isFocused()
|
||||
|
||||
BrowserWindow.fromProcessIdAndRoutingId = (processId, routingId) ->
|
||||
windows = app.getBrowserWindows()
|
||||
windows = BrowserWindow.getAllWindows()
|
||||
return window for window in windows when window.getProcessId() == processId and
|
||||
window.getRoutingId() == routingId
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
module.exports = process.atomBinding 'crash_reporter'
|
||||
@@ -8,7 +8,7 @@ sendWrap = (channel, processId, routingId, args...) ->
|
||||
processId = window.getProcessId()
|
||||
routingId = window.getRoutingId()
|
||||
|
||||
send channel, processId, routingId, args...
|
||||
send channel, processId, routingId, [args...]
|
||||
|
||||
class Ipc extends EventEmitter
|
||||
constructor: ->
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
BrowserWindow = require 'browser-window'
|
||||
EventEmitter = require('events').EventEmitter
|
||||
IDWeakMap = require 'id-weak-map'
|
||||
MenuItem = require 'menu-item'
|
||||
|
||||
app = require 'app'
|
||||
bindings = process.atomBinding 'menu'
|
||||
|
||||
Menu = bindings.Menu
|
||||
@@ -52,7 +50,7 @@ Menu.setApplicationMenu = (menu) ->
|
||||
if process.platform is 'darwin'
|
||||
bindings.setApplicationMenu menu
|
||||
else
|
||||
windows = app.getBrowserWindows()
|
||||
windows = BrowserWindow.getAllWindows()
|
||||
w.setMenu menu for w in windows
|
||||
|
||||
Menu.getApplicationMenu = -> applicationMenu
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
fs = require 'fs'
|
||||
path = require 'path'
|
||||
|
||||
if process.platform is 'win32'
|
||||
# Redirect node's console to use our own implementations, since node can not
|
||||
# handle output when running as GUI program.
|
||||
console.log = console.error = console.warn = process.log
|
||||
process.stdout.write = process.stderr.write = process.log
|
||||
|
||||
# Always returns EOF for stdin stream.
|
||||
Readable = require('stream').Readable
|
||||
stdin = new Readable
|
||||
stdin.push null
|
||||
process.__defineGetter__ 'stdin', -> stdin
|
||||
|
||||
# Provide default Content API implementations.
|
||||
atom = {}
|
||||
|
||||
atom.browserMainParts =
|
||||
preMainMessageLoopRun: ->
|
||||
# This is the start of the whole application, usually we should initialize
|
||||
# the main window here.
|
||||
|
||||
# Store atom object in global scope, apps can just override methods of it to
|
||||
# implement various logics.
|
||||
global.__atom = atom
|
||||
|
||||
# Add browser/api/lib to require's search paths,
|
||||
# which contains javascript part of Atom's built-in libraries.
|
||||
globalPaths = require('module').globalPaths
|
||||
globalPaths.push path.join process.resourcesPath, 'browser', 'api', 'lib'
|
||||
|
||||
# And also common/api/lib
|
||||
globalPaths.push path.join process.resourcesPath, 'common', 'api', 'lib'
|
||||
|
||||
# Don't quit on fatal error.
|
||||
process.on 'uncaughtException', (error) ->
|
||||
# Show error in GUI.
|
||||
message = error.stack ? "#{error.name}: #{error.message}"
|
||||
require('dialog').showMessageBox
|
||||
type: 'warning'
|
||||
title: 'An javascript error occured in the browser'
|
||||
message: 'uncaughtException'
|
||||
detail: message
|
||||
buttons: ['OK']
|
||||
|
||||
# Load the RPC server.
|
||||
require './rpc-server.js'
|
||||
|
||||
# Now we try to load app's package.json.
|
||||
packageJson = null
|
||||
|
||||
packagePath = path.join process.resourcesPath, 'app'
|
||||
try
|
||||
# First we try to load process.resourcesPath/app
|
||||
packageJson = JSON.parse(fs.readFileSync(path.join(packagePath, 'package.json')))
|
||||
catch error
|
||||
# If not found then we load browser/default_app
|
||||
packagePath = path.join process.resourcesPath, 'browser', 'default_app'
|
||||
packageJson = JSON.parse(fs.readFileSync(path.join(packagePath, 'package.json')))
|
||||
|
||||
# Finally load app's main.js and transfer control to C++.
|
||||
require path.join(packagePath, packageJson.main)
|
||||
@@ -4,14 +4,39 @@
|
||||
|
||||
#include "browser/atom_browser_client.h"
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "browser/atom_browser_context.h"
|
||||
#include "browser/atom_browser_main_parts.h"
|
||||
#include "browser/native_window.h"
|
||||
#include "browser/net/atom_url_request_context_getter.h"
|
||||
#include "webkit/glue/webpreferences.h"
|
||||
#include "browser/window_list.h"
|
||||
#include "common/options_switches.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "content/public/browser/site_instance.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "webkit/common/webpreferences.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
AtomBrowserClient::AtomBrowserClient() {
|
||||
namespace {
|
||||
|
||||
struct FindByProcessId {
|
||||
explicit FindByProcessId(int child_process_id)
|
||||
: child_process_id_(child_process_id) {
|
||||
}
|
||||
|
||||
bool operator() (NativeWindow* const window) {
|
||||
int id = window->GetWebContents()->GetRenderProcessHost()->GetID();
|
||||
return id == child_process_id_;
|
||||
}
|
||||
|
||||
int child_process_id_;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
AtomBrowserClient::AtomBrowserClient()
|
||||
: dying_render_process_(NULL) {
|
||||
}
|
||||
|
||||
AtomBrowserClient::~AtomBrowserClient() {
|
||||
@@ -50,8 +75,42 @@ bool AtomBrowserClient::ShouldSwapProcessesForNavigation(
|
||||
content::SiteInstance* site_instance,
|
||||
const GURL& current_url,
|
||||
const GURL& new_url) {
|
||||
// Restart renderer process if navigating to the same url.
|
||||
return current_url == new_url;
|
||||
if (site_instance->HasProcess())
|
||||
dying_render_process_ = site_instance->GetProcess();
|
||||
|
||||
// Restart renderer process for all navigations.
|
||||
return true;
|
||||
}
|
||||
|
||||
void AtomBrowserClient::AppendExtraCommandLineSwitches(
|
||||
CommandLine* command_line,
|
||||
int child_process_id) {
|
||||
WindowList* list = WindowList::GetInstance();
|
||||
NativeWindow* window = NULL;
|
||||
|
||||
// Find the owner of this child process.
|
||||
WindowList::const_iterator iter = std::find_if(
|
||||
list->begin(), list->end(), FindByProcessId(child_process_id));
|
||||
if (iter != list->end())
|
||||
window = *iter;
|
||||
|
||||
// If the render process is a newly started one, which means the window still
|
||||
// uses the old going-to-be-swapped render process, then we try to find the
|
||||
// window from the swapped render process.
|
||||
if (window == NULL && dying_render_process_ != NULL) {
|
||||
child_process_id = dying_render_process_->GetID();
|
||||
WindowList::const_iterator iter = std::find_if(
|
||||
list->begin(), list->end(), FindByProcessId(child_process_id));
|
||||
if (iter != list->end())
|
||||
window = *iter;
|
||||
}
|
||||
|
||||
// Append --node-integration to renderer process.
|
||||
if (window != NULL)
|
||||
command_line->AppendSwitchASCII(switches::kNodeIntegration,
|
||||
window->node_integration());
|
||||
|
||||
dying_render_process_ = NULL;
|
||||
}
|
||||
|
||||
brightray::BrowserMainParts* AtomBrowserClient::OverrideCreateBrowserMainParts(
|
||||
|
||||
@@ -25,11 +25,16 @@ class AtomBrowserClient : public brightray::BrowserClient {
|
||||
content::SiteInstance* site_instance,
|
||||
const GURL& current_url,
|
||||
const GURL& new_url) OVERRIDE;
|
||||
virtual void AppendExtraCommandLineSwitches(CommandLine* command_line,
|
||||
int child_process_id) OVERRIDE;
|
||||
|
||||
private:
|
||||
virtual brightray::BrowserMainParts* OverrideCreateBrowserMainParts(
|
||||
const content::MainFunctionParams&) OVERRIDE;
|
||||
|
||||
// The render process which would be swapped out soon.
|
||||
content::RenderProcessHost* dying_render_process_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomBrowserClient);
|
||||
};
|
||||
|
||||
|
||||
@@ -33,6 +33,14 @@ class AtomResourceContext : public content::ResourceContext {
|
||||
return getter_->GetURLRequestContext();
|
||||
}
|
||||
|
||||
virtual bool AllowMicAccess(const GURL& origin) OVERRIDE {
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool AllowCameraAccess(const GURL& origin) OVERRIDE {
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
AtomURLRequestContextGetter* getter_;
|
||||
|
||||
|
||||
@@ -4,15 +4,18 @@
|
||||
|
||||
#include "browser/atom_browser_main_parts.h"
|
||||
|
||||
#include "base/power_monitor/power_monitor.h"
|
||||
#include "browser/api/atom_browser_bindings.h"
|
||||
#include "browser/atom_browser_client.h"
|
||||
#include "browser/atom_browser_context.h"
|
||||
#include "browser/browser.h"
|
||||
#include "common/node_bindings.h"
|
||||
#include "net/proxy/proxy_resolver_v8.h"
|
||||
#include "vendor/node/src/node.h"
|
||||
#include "vendor/node/src/node_internals.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include "ui/gfx/win/dpi.h"
|
||||
#endif
|
||||
|
||||
#include "common/v8/node_common.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
@@ -43,37 +46,29 @@ brightray::BrowserContext* AtomBrowserMainParts::CreateBrowserContext() {
|
||||
void AtomBrowserMainParts::PostEarlyInitialization() {
|
||||
brightray::BrowserMainParts::PostEarlyInitialization();
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
base::PowerMonitor::AllocateSystemIOPorts();
|
||||
#endif
|
||||
|
||||
node_bindings_->Initialize();
|
||||
|
||||
v8::V8::Initialize();
|
||||
|
||||
// Create context.
|
||||
v8::Locker locker(node_isolate);
|
||||
v8::HandleScope handle_scope(node_isolate);
|
||||
v8::Local<v8::Context> context = v8::Context::New(node_isolate);
|
||||
|
||||
// Create the global environment.
|
||||
global_env = node_bindings_->CreateEnvironment(context);
|
||||
|
||||
// Wrap whole process in one global context.
|
||||
node::g_context->Enter();
|
||||
context->Enter();
|
||||
|
||||
atom_bindings_->BindTo(node::process);
|
||||
|
||||
node_bindings_->Load();
|
||||
|
||||
atom_bindings_->AfterLoad();
|
||||
// Add atom-shell extended APIs.
|
||||
atom_bindings_->BindTo(global_env->process_object());
|
||||
}
|
||||
|
||||
void AtomBrowserMainParts::PreMainMessageLoopRun() {
|
||||
node_bindings_->PrepareMessageLoop();
|
||||
|
||||
brightray::BrowserMainParts::PreMainMessageLoopRun();
|
||||
|
||||
{
|
||||
v8::HandleScope scope;
|
||||
v8::Context::Scope context_scope(node::g_context);
|
||||
|
||||
v8::Handle<v8::Value> args;
|
||||
node::MakeCallback(atom_bindings_->browser_main_parts(),
|
||||
"preMainMessageLoopRun",
|
||||
0, &args);
|
||||
}
|
||||
|
||||
node_bindings_->PrepareMessageLoop();
|
||||
node_bindings_->RunMessageLoop();
|
||||
|
||||
// Make sure the url request job factory is created before the
|
||||
@@ -89,8 +84,17 @@ void AtomBrowserMainParts::PreMainMessageLoopRun() {
|
||||
}
|
||||
|
||||
int AtomBrowserMainParts::PreCreateThreads() {
|
||||
// TODO(zcbenz): Calling CreateIsolate() on Windows when updated to Chrome30.
|
||||
// Note that we are overriding the PreCreateThreads of brightray, since we
|
||||
// are integrating node in browser, we can just be sure that an V8 instance
|
||||
// would be prepared, while the ProxyResolverV8::CreateIsolate() would
|
||||
// try to create a V8 isolate, which messed everything on Windows, so we
|
||||
// have to override and call RememberDefaultIsolate on Windows instead.
|
||||
net::ProxyResolverV8::RememberDefaultIsolate();
|
||||
|
||||
#if defined(OS_WIN)
|
||||
gfx::EnableHighDPISupport();
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,9 @@ void AtomBrowserMainParts::PreMainMessageLoopStart() {
|
||||
[NSApp setDelegate:delegate];
|
||||
|
||||
base::FilePath frameworkPath = brightray::MainApplicationBundlePath()
|
||||
.Append("Contents").Append("Frameworks").Append("Atom.framework");
|
||||
.Append("Contents")
|
||||
.Append("Frameworks")
|
||||
.Append("Atom Framework.framework");
|
||||
NSBundle* frameworkBundle = [NSBundle
|
||||
bundleWithPath:base::mac::FilePathToNSString(frameworkPath)];
|
||||
NSNib* mainNib = [[NSNib alloc] initWithNibNamed:@"MainMenu"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "browser/atom_javascript_dialog_manager.h"
|
||||
|
||||
#include "base/utf_string_conversions.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
|
||||
@@ -26,7 +26,9 @@ class AtomJavaScriptDialogManager : public content::JavaScriptDialogManager {
|
||||
const string16& message_text,
|
||||
bool is_reload,
|
||||
const DialogClosedCallback& callback) OVERRIDE;
|
||||
virtual void ResetJavaScriptState(
|
||||
virtual void CancelActiveAndPendingDialogs(
|
||||
content::WebContents* web_contents) OVERRIDE {}
|
||||
virtual void WebContentsDestroyed(
|
||||
content::WebContents* web_contents) OVERRIDE {}
|
||||
};
|
||||
|
||||
|
||||
@@ -19,13 +19,8 @@ class AutoUpdater {
|
||||
static AutoUpdaterDelegate* GetDelegate();
|
||||
static void SetDelegate(AutoUpdaterDelegate* delegate);
|
||||
|
||||
static void Init();
|
||||
|
||||
static void SetFeedURL(const std::string& url);
|
||||
static void SetAutomaticallyChecksForUpdates(bool yes);
|
||||
static void SetAutomaticallyDownloadsUpdates(bool yes);
|
||||
static void CheckForUpdates();
|
||||
static void CheckForUpdatesInBackground();
|
||||
|
||||
private:
|
||||
static AutoUpdaterDelegate* delegate_;
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "browser/auto_updater_delegate.h"
|
||||
|
||||
#include "base/callback.h"
|
||||
|
||||
namespace auto_updater {
|
||||
|
||||
void AutoUpdaterDelegate::WillInstallUpdate(const std::string& version,
|
||||
const base::Closure& install) {
|
||||
install.Run();
|
||||
}
|
||||
|
||||
void AutoUpdaterDelegate::ReadyForUpdateOnQuit(
|
||||
const std::string& version,
|
||||
const base::Closure& quit_and_install) {
|
||||
}
|
||||
|
||||
} // namespace auto_updater
|
||||
@@ -9,17 +9,32 @@
|
||||
|
||||
#include "base/callback_forward.h"
|
||||
|
||||
namespace base {
|
||||
class Time;
|
||||
}
|
||||
|
||||
namespace auto_updater {
|
||||
|
||||
class AutoUpdaterDelegate {
|
||||
public:
|
||||
// The application is going to relaunch to install update.
|
||||
virtual void WillInstallUpdate(const std::string& version,
|
||||
const base::Closure& install);
|
||||
// An error happened.
|
||||
virtual void OnError(const std::string& error) {}
|
||||
|
||||
// User has chosen to update on quit.
|
||||
virtual void ReadyForUpdateOnQuit(const std::string& version,
|
||||
const base::Closure& quit_and_install);
|
||||
// Checking to see if there is an update
|
||||
virtual void OnCheckingForUpdate() {}
|
||||
|
||||
// There is an update available and it is being downloaded
|
||||
virtual void OnUpdateAvailable() {}
|
||||
|
||||
// There is no available update.
|
||||
virtual void OnUpdateNotAvailable() {}
|
||||
|
||||
// There is a new update which has been downloaded.
|
||||
virtual void OnUpdateDownloaded(const std::string& release_notes,
|
||||
const std::string& release_name,
|
||||
const base::Time& release_date,
|
||||
const std::string& update_url,
|
||||
const base::Closure& quit_and_install) {}
|
||||
|
||||
protected:
|
||||
virtual ~AutoUpdaterDelegate() {}
|
||||
|
||||
@@ -4,106 +4,87 @@
|
||||
|
||||
#include "browser/auto_updater.h"
|
||||
|
||||
// Sparkle's headers are throwing compilation warnings, supress them.
|
||||
#pragma GCC diagnostic ignored "-Wmissing-method-return-type"
|
||||
#import <Sparkle/Sparkle.h>
|
||||
#import <ReactiveCocoa/RACCommand.h>
|
||||
#import <ReactiveCocoa/RACSignal.h>
|
||||
#import <ReactiveCocoa/NSObject+RACPropertySubscribing.h>
|
||||
#import <Squirrel/Squirrel.h>
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "base/time/time.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "browser/auto_updater_delegate.h"
|
||||
|
||||
using auto_updater::AutoUpdaterDelegate;
|
||||
namespace auto_updater {
|
||||
|
||||
namespace {
|
||||
|
||||
struct NSInvocationDeleter {
|
||||
inline void operator()(NSInvocation* invocation) const {
|
||||
[invocation release];
|
||||
}
|
||||
};
|
||||
// The gloal SQRLUpdater object.
|
||||
SQRLUpdater* g_updater = nil;
|
||||
|
||||
typedef scoped_ptr<NSInvocation, NSInvocationDeleter> ScopedNSInvocation;
|
||||
|
||||
// We are passing the NSInvocation as scoped_ptr, because we want to make sure
|
||||
// whether or not the callback is called, the NSInvocation should alwasy be
|
||||
// released, the only way to ensure it is to use scoped_ptr.
|
||||
void CallNSInvocation(ScopedNSInvocation invocation) {
|
||||
[invocation.get() invoke];
|
||||
void RelaunchToInstallUpdate() {
|
||||
[[g_updater relaunchToInstallUpdate] subscribeError:^(NSError* error) {
|
||||
AutoUpdaterDelegate* delegate = AutoUpdater::GetDelegate();
|
||||
if (delegate)
|
||||
delegate->OnError(base::SysNSStringToUTF8(error.localizedDescription));
|
||||
}];
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@interface SUUpdaterDelegate : NSObject {
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation SUUpdaterDelegate
|
||||
|
||||
- (BOOL)updater:(SUUpdater*)updater
|
||||
shouldPostponeRelaunchForUpdate:(SUAppcastItem*)update
|
||||
untilInvoking:(NSInvocation*)invocation {
|
||||
AutoUpdaterDelegate* delegate = auto_updater::AutoUpdater::GetDelegate();
|
||||
if (!delegate)
|
||||
return NO;
|
||||
|
||||
std::string version(base::SysNSStringToUTF8([update versionString]));
|
||||
ScopedNSInvocation invocation_ptr([invocation retain]);
|
||||
delegate->WillInstallUpdate(
|
||||
version,
|
||||
base::Bind(&CallNSInvocation, base::Passed(invocation_ptr.Pass())));
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)updater:(SUUpdater*)updater
|
||||
willInstallUpdateOnQuit:(SUAppcastItem*)update
|
||||
immediateInstallationInvocation:(NSInvocation*)invocation {
|
||||
AutoUpdaterDelegate* delegate = auto_updater::AutoUpdater::GetDelegate();
|
||||
if (!delegate)
|
||||
return;
|
||||
|
||||
std::string version(base::SysNSStringToUTF8([update versionString]));
|
||||
ScopedNSInvocation invocation_ptr([invocation retain]);
|
||||
delegate->ReadyForUpdateOnQuit(
|
||||
version,
|
||||
base::Bind(&CallNSInvocation, base::Passed(invocation_ptr.Pass())));
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
namespace auto_updater {
|
||||
|
||||
// static
|
||||
void AutoUpdater::Init() {
|
||||
SUUpdaterDelegate* delegate = [[SUUpdaterDelegate alloc] init];
|
||||
[[SUUpdater sharedUpdater] setDelegate:delegate];
|
||||
}
|
||||
void AutoUpdater::SetFeedURL(const std::string& feed) {
|
||||
if (g_updater == nil) {
|
||||
// Initialize the SQRLUpdater.
|
||||
NSURL* url = [NSURL URLWithString:base::SysUTF8ToNSString(feed)];
|
||||
NSURLRequest* urlRequest = [NSURLRequest requestWithURL:url];
|
||||
g_updater = [[SQRLUpdater alloc] initWithUpdateRequest:urlRequest];
|
||||
|
||||
// static
|
||||
void AutoUpdater::SetFeedURL(const std::string& url) {
|
||||
NSString* url_str(base::SysUTF8ToNSString(url));
|
||||
[[SUUpdater sharedUpdater] setFeedURL:[NSURL URLWithString:url_str]];
|
||||
}
|
||||
AutoUpdaterDelegate* delegate = GetDelegate();
|
||||
if (!delegate)
|
||||
return;
|
||||
|
||||
// static
|
||||
void AutoUpdater::SetAutomaticallyChecksForUpdates(bool yes) {
|
||||
[[SUUpdater sharedUpdater] setAutomaticallyChecksForUpdates:yes];
|
||||
}
|
||||
|
||||
// static
|
||||
void AutoUpdater::SetAutomaticallyDownloadsUpdates(bool yes) {
|
||||
[[SUUpdater sharedUpdater] setAutomaticallyDownloadsUpdates:yes];
|
||||
[[g_updater rac_valuesForKeyPath:@"state" observer:g_updater]
|
||||
subscribeNext:^(NSNumber *stateNumber) {
|
||||
int state = [stateNumber integerValue];
|
||||
if (state == SQRLUpdaterStateCheckingForUpdate) {
|
||||
delegate->OnCheckingForUpdate();
|
||||
} else if (state == SQRLUpdaterStateDownloadingUpdate) {
|
||||
delegate->OnUpdateAvailable();
|
||||
}
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
void AutoUpdater::CheckForUpdates() {
|
||||
[[SUUpdater sharedUpdater] checkForUpdates:nil];
|
||||
}
|
||||
AutoUpdaterDelegate* delegate = GetDelegate();
|
||||
if (!delegate)
|
||||
return;
|
||||
|
||||
// static
|
||||
void AutoUpdater::CheckForUpdatesInBackground() {
|
||||
[[SUUpdater sharedUpdater] checkForUpdatesInBackground];
|
||||
[[[[g_updater.checkForUpdatesCommand
|
||||
execute:nil]
|
||||
// Send a `nil` after everything...
|
||||
concat:[RACSignal return:nil]]
|
||||
// But only take the first value. If an update is sent, we'll get that.
|
||||
// Otherwise, we'll get our inserted `nil` value.
|
||||
take:1]
|
||||
subscribeNext:^(SQRLDownloadedUpdate *downloadedUpdate) {
|
||||
if (downloadedUpdate) {
|
||||
SQRLUpdate* update = downloadedUpdate.update;
|
||||
// There is a new update that has been downloaded.
|
||||
delegate->OnUpdateDownloaded(
|
||||
base::SysNSStringToUTF8(update.releaseNotes),
|
||||
base::SysNSStringToUTF8(update.releaseName),
|
||||
base::Time::FromDoubleT(update.releaseDate.timeIntervalSince1970),
|
||||
base::SysNSStringToUTF8(update.updateURL.absoluteString),
|
||||
base::Bind(RelaunchToInstallUpdate));
|
||||
} else {
|
||||
// When the completed event is sent with no update, then we know there
|
||||
// is no update available.
|
||||
delegate->OnUpdateNotAvailable();
|
||||
}
|
||||
} error:^(NSError *error) {
|
||||
delegate->OnError(base::SysNSStringToUTF8(error.localizedDescription));
|
||||
}];
|
||||
}
|
||||
|
||||
} // namespace auto_updater
|
||||
|
||||
@@ -33,6 +33,34 @@ void Browser::Quit() {
|
||||
window_list->CloseAllWindows();
|
||||
}
|
||||
|
||||
std::string Browser::GetVersion() const {
|
||||
if (version_override_.empty()) {
|
||||
std::string version = GetExecutableFileVersion();
|
||||
if (!version.empty())
|
||||
return version;
|
||||
}
|
||||
|
||||
return version_override_;
|
||||
}
|
||||
|
||||
void Browser::SetVersion(const std::string& version) {
|
||||
version_override_ = version;
|
||||
}
|
||||
|
||||
std::string Browser::GetName() const {
|
||||
if (name_override_.empty()) {
|
||||
std::string name = GetExecutableFileProductName();
|
||||
if (!name.empty())
|
||||
return name;
|
||||
}
|
||||
|
||||
return name_override_;
|
||||
}
|
||||
|
||||
void Browser::SetName(const std::string& name) {
|
||||
name_override_ = name;
|
||||
}
|
||||
|
||||
bool Browser::OpenFile(const std::string& file_path) {
|
||||
bool prevent_default = false;
|
||||
FOR_EACH_OBSERVER(BrowserObserver,
|
||||
|
||||
@@ -31,7 +31,16 @@ class Browser : public WindowListObserver {
|
||||
void Focus();
|
||||
|
||||
// Returns the version of the executable (or bundle).
|
||||
std::string GetVersion();
|
||||
std::string GetVersion() const;
|
||||
|
||||
// Overrides the application version.
|
||||
void SetVersion(const std::string& version);
|
||||
|
||||
// Returns the application's name, default is just Atom-Shell.
|
||||
std::string GetName() const;
|
||||
|
||||
// Overrides the application name.
|
||||
void SetName(const std::string& name);
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
// Bounce the dock icon.
|
||||
@@ -68,6 +77,12 @@ class Browser : public WindowListObserver {
|
||||
bool is_quiting() const { return is_quiting_; }
|
||||
|
||||
protected:
|
||||
// Returns the version of application bundle or executable file.
|
||||
std::string GetExecutableFileVersion() const;
|
||||
|
||||
// Returns the name of application bundle or executable file.
|
||||
std::string GetExecutableFileProductName() const;
|
||||
|
||||
// Send the will-quit message and then terminate the application.
|
||||
void NotifyAndTerminate();
|
||||
|
||||
@@ -84,6 +99,9 @@ class Browser : public WindowListObserver {
|
||||
// Observers of the browser.
|
||||
ObserverList<BrowserObserver> observers_;
|
||||
|
||||
std::string version_override_;
|
||||
std::string name_override_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(Browser);
|
||||
};
|
||||
|
||||
|
||||
@@ -19,12 +19,18 @@ void Browser::Focus() {
|
||||
[[AtomApplication sharedApplication] activateIgnoringOtherApps:YES];
|
||||
}
|
||||
|
||||
std::string Browser::GetVersion() {
|
||||
std::string Browser::GetExecutableFileVersion() const {
|
||||
NSDictionary* infoDictionary = base::mac::OuterBundle().infoDictionary;
|
||||
NSString *version = [infoDictionary objectForKey:@"CFBundleVersion"];
|
||||
return base::SysNSStringToUTF8(version);
|
||||
}
|
||||
|
||||
std::string Browser::GetExecutableFileProductName() const {
|
||||
NSDictionary* infoDictionary = base::mac::OuterBundle().infoDictionary;
|
||||
NSString *version = [infoDictionary objectForKey:@"CFBundleName"];
|
||||
return base::SysNSStringToUTF8(version);
|
||||
}
|
||||
|
||||
void Browser::CancelQuit() {
|
||||
[[AtomApplication sharedApplication] replyToApplicationShouldTerminate:NO];
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "base/path_service.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "common/atom_version.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
@@ -43,7 +44,7 @@ void Browser::Focus() {
|
||||
EnumWindows(&WindowsEnumerationHandler, reinterpret_cast<LPARAM>(&pid));
|
||||
}
|
||||
|
||||
std::string Browser::GetVersion() {
|
||||
std::string Browser::GetExecutableFileVersion() const {
|
||||
base::FilePath path;
|
||||
if (PathService::Get(base::FILE_EXE, &path)) {
|
||||
scoped_ptr<FileVersionInfo> version_info(
|
||||
@@ -51,7 +52,18 @@ std::string Browser::GetVersion() {
|
||||
return UTF16ToUTF8(version_info->product_version());
|
||||
}
|
||||
|
||||
return "";
|
||||
return ATOM_VERSION_STRING;
|
||||
}
|
||||
|
||||
std::string Browser::GetExecutableFileProductName() const {
|
||||
base::FilePath path;
|
||||
if (PathService::Get(base::FILE_EXE, &path)) {
|
||||
scoped_ptr<FileVersionInfo> version_info(
|
||||
FileVersionInfo::CreateFileVersionInfo(path));
|
||||
return UTF16ToUTF8(version_info->product_name());
|
||||
}
|
||||
|
||||
return "Atom-Shell";
|
||||
}
|
||||
|
||||
void Browser::CancelQuit() {
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_BROWSER_CRASH_REPORTER_H_
|
||||
#define ATOM_BROWSER_CRASH_REPORTER_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "base/basictypes.h"
|
||||
|
||||
namespace crash_reporter {
|
||||
|
||||
class CrashReporter {
|
||||
public:
|
||||
static void SetCompanyName(const std::string& name);
|
||||
static void SetSubmissionURL(const std::string& url);
|
||||
static void SetAutoSubmit(bool yes);
|
||||
|
||||
private:
|
||||
DISALLOW_IMPLICIT_CONSTRUCTORS(CrashReporter);
|
||||
};
|
||||
|
||||
} // namespace crash_reporter
|
||||
|
||||
#endif // ATOM_BROWSER_CRASH_REPORTER_H_
|
||||
@@ -1,31 +0,0 @@
|
||||
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "browser/crash_reporter.h"
|
||||
|
||||
#import <Quincy/BWQuincyManager.h>
|
||||
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
|
||||
namespace crash_reporter {
|
||||
|
||||
// static
|
||||
void CrashReporter::SetCompanyName(const std::string& name) {
|
||||
BWQuincyManager *manager = [BWQuincyManager sharedQuincyManager];
|
||||
[manager setCompanyName:base::SysUTF8ToNSString(name)];
|
||||
}
|
||||
|
||||
// static
|
||||
void CrashReporter::SetSubmissionURL(const std::string& url) {
|
||||
BWQuincyManager *manager = [BWQuincyManager sharedQuincyManager];
|
||||
[manager setSubmissionURL:base::SysUTF8ToNSString(url)];
|
||||
}
|
||||
|
||||
// static
|
||||
void CrashReporter::SetAutoSubmit(bool yes) {
|
||||
BWQuincyManager *manager = [BWQuincyManager sharedQuincyManager];
|
||||
[manager setAutoSubmitCrashReport:yes];
|
||||
}
|
||||
|
||||
} // namespace crash_reporter
|
||||
@@ -1,22 +0,0 @@
|
||||
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "browser/crash_reporter.h"
|
||||
|
||||
namespace crash_reporter {
|
||||
|
||||
// static
|
||||
void CrashReporter::SetCompanyName(const std::string& name) {
|
||||
}
|
||||
|
||||
// static
|
||||
void CrashReporter::SetSubmissionURL(const std::string& url) {
|
||||
}
|
||||
|
||||
// static
|
||||
void CrashReporter::SetAutoSubmit(bool yes) {
|
||||
}
|
||||
|
||||
} // namespace crash_reporter
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
var app = require('app');
|
||||
var dialog = require('dialog');
|
||||
var delegate = require('atom-delegate');
|
||||
var ipc = require('ipc');
|
||||
var Menu = require('menu');
|
||||
var MenuItem = require('menu-item');
|
||||
@@ -18,7 +17,7 @@ app.on('open-url', function(event, url) {
|
||||
dialog.showMessageBox({message: url, buttons: ['OK']});
|
||||
});
|
||||
|
||||
app.on('finish-launching', function() {
|
||||
app.on('ready', function() {
|
||||
app.commandLine.appendSwitch('js-flags', '--harmony_collections');
|
||||
|
||||
mainWindow = new BrowserWindow({ width: 800, height: 600 });
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
var app = require('app');
|
||||
var dialog = require('dialog');
|
||||
var path = require('path');
|
||||
var optimist = require('optimist');
|
||||
|
||||
@@ -9,7 +8,7 @@ app.on('window-all-closed', function() {
|
||||
app.quit();
|
||||
});
|
||||
|
||||
var argv = optimist(process.argv.slice(1)).argv;
|
||||
var argv = optimist(process.argv.slice(1)).boolean('ci').argv;
|
||||
|
||||
// Start the specified app if there is one specified in command line, otherwise
|
||||
// start the default app.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "atom",
|
||||
"name": "atom-shell-default-app",
|
||||
"version": "0.1.0",
|
||||
"main": "main.js",
|
||||
"dependencies": {
|
||||
|
||||
77
browser/lib/init.coffee
Normal file
77
browser/lib/init.coffee
Normal file
@@ -0,0 +1,77 @@
|
||||
fs = require 'fs'
|
||||
path = require 'path'
|
||||
|
||||
# Expose information of current process.
|
||||
process.__atom_type = 'browser'
|
||||
process.resourcesPath = path.resolve process.argv[1], '..', '..', '..'
|
||||
|
||||
# We modified the original process.argv to let node.js load the atom.js,
|
||||
# we need to restore it here.
|
||||
process.argv.splice 1, 1
|
||||
|
||||
# Pick out switches appended by atom-shell.
|
||||
startMark = process.argv.indexOf '--atom-shell-switches-start'
|
||||
endMark = process.argv.indexOf '--atom-shell-switches-end'
|
||||
process.execArgv = process.argv.splice startMark, endMark - startMark + 1
|
||||
|
||||
# Add browser/api/lib to require's search paths,
|
||||
# which contains javascript part of Atom's built-in libraries.
|
||||
globalPaths = require('module').globalPaths
|
||||
globalPaths.push path.join process.resourcesPath, 'browser', 'api', 'lib'
|
||||
|
||||
# Do loading in next tick since we still need some initialize work before
|
||||
# native bindings can work.
|
||||
setImmediate ->
|
||||
# Import common settings.
|
||||
require path.resolve(__dirname, '..', '..', 'common', 'lib', 'init.js')
|
||||
|
||||
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.
|
||||
console.log = console.error = console.warn = process.log
|
||||
process.stdout.write = process.stderr.write = process.log
|
||||
|
||||
# Always returns EOF for stdin stream.
|
||||
Readable = require('stream').Readable
|
||||
stdin = new Readable
|
||||
stdin.push null
|
||||
process.__defineGetter__ 'stdin', -> stdin
|
||||
|
||||
# Don't quit on fatal error.
|
||||
process.on 'uncaughtException', (error) ->
|
||||
# Show error in GUI.
|
||||
message = error.stack ? "#{error.name}: #{error.message}"
|
||||
require('dialog').showMessageBox
|
||||
type: 'warning'
|
||||
title: 'An javascript error occured in the browser'
|
||||
message: 'uncaughtException'
|
||||
detail: message
|
||||
buttons: ['OK']
|
||||
|
||||
# Load the RPC server.
|
||||
require './rpc-server.js'
|
||||
|
||||
# Now we try to load app's package.json.
|
||||
packageJson = null
|
||||
|
||||
packagePath = path.join process.resourcesPath, 'app'
|
||||
try
|
||||
# First we try to load process.resourcesPath/app
|
||||
packageJson = JSON.parse(fs.readFileSync(path.join(packagePath, 'package.json')))
|
||||
catch error
|
||||
# If not found then we load browser/default_app
|
||||
packagePath = path.join process.resourcesPath, 'browser', 'default_app'
|
||||
packageJson = JSON.parse(fs.readFileSync(path.join(packagePath, 'package.json')))
|
||||
|
||||
# Set application's version.
|
||||
app = require 'app'
|
||||
app.setVersion packageJson.version if packageJson.version?
|
||||
|
||||
# Set application's name.
|
||||
if packageJson.productName?
|
||||
app.setName packageJson.productName
|
||||
else if packageJson.name?
|
||||
app.setName packageJson.name
|
||||
|
||||
# Finally load app's main.js and transfer control to C++.
|
||||
require path.join(packagePath, packageJson.main)
|
||||
@@ -1,4 +1,3 @@
|
||||
BrowserWindow = require 'browser-window'
|
||||
EventEmitter = require('events').EventEmitter
|
||||
IDWeakMap = require 'id-weak-map'
|
||||
v8Util = process.atomBinding 'v8_util'
|
||||
@@ -41,6 +40,8 @@ class ObjectsStore
|
||||
|
||||
class ObjectsRegistry extends EventEmitter
|
||||
constructor: ->
|
||||
@setMaxListeners Number.MAX_VALUE
|
||||
|
||||
# Objects in weak map will be not referenced (so we won't leak memory), and
|
||||
# every object created in browser will have a unique id in weak map.
|
||||
@objectsWeakMap = new IDWeakMap
|
||||
@@ -49,13 +50,6 @@ class ObjectsRegistry extends EventEmitter
|
||||
v8Util.setHiddenValue obj, 'atomId', id
|
||||
id
|
||||
|
||||
# Remember all windows in the weak map.
|
||||
@windowsWeakMap = new IDWeakMap
|
||||
process.on 'ATOM_BROWSER_INTERNAL_NEW', (obj) =>
|
||||
if obj.constructor is BrowserWindow
|
||||
id = @windowsWeakMap.add obj
|
||||
obj.on 'destroyed', => @windowsWeakMap.remove id
|
||||
|
||||
# Register a new object, the object would be kept referenced until you release
|
||||
# it explicitly.
|
||||
add: (processId, routingId, obj) ->
|
||||
@@ -87,9 +81,4 @@ class ObjectsRegistry extends EventEmitter
|
||||
@emit "release-renderer-view-#{processId}-#{routingId}"
|
||||
ObjectsStore.releaseForRenderView processId, routingId
|
||||
|
||||
# Return an array of all browser windows.
|
||||
getAllWindows: ->
|
||||
keys = @windowsWeakMap.keys()
|
||||
@windowsWeakMap.get key for key in keys
|
||||
|
||||
module.exports = new ObjectsRegistry
|
||||
@@ -78,6 +78,10 @@ callFunction = (event, processId, routingId, func, caller, args) ->
|
||||
ret = func.apply caller, args
|
||||
event.returnValue = valueToMeta processId, routingId, ret
|
||||
|
||||
# Send by BrowserWindow when its render view is deleted.
|
||||
process.on 'ATOM_BROWSER_RELEASE_RENDER_VIEW', (processId, routingId) ->
|
||||
objectsRegistry.clear processId, routingId
|
||||
|
||||
ipc.on 'ATOM_BROWSER_REQUIRE', (event, processId, routingId, module) ->
|
||||
try
|
||||
event.returnValue = valueToMeta processId, routingId, require(module)
|
||||
@@ -90,10 +94,6 @@ ipc.on 'ATOM_BROWSER_GLOBAL', (event, processId, routingId, name) ->
|
||||
catch e
|
||||
event.returnValue = errorToMeta e
|
||||
|
||||
ipc.on 'ATOM_BROWSER_RELEASE_RENDER_VIEW', (event, processId, routingId) ->
|
||||
objectsRegistry.clear processId, routingId
|
||||
event.returnValue = null
|
||||
|
||||
ipc.on 'ATOM_BROWSER_CURRENT_WINDOW', (event, processId, routingId) ->
|
||||
try
|
||||
BrowserWindow = require 'browser-window'
|
||||
@@ -7,8 +7,9 @@
|
||||
#include <string>
|
||||
|
||||
#include "base/file_util.h"
|
||||
#include "base/message_loop.h"
|
||||
#include "base/utf_string_conversions.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/values.h"
|
||||
#include "brightray/browser/inspectable_web_contents.h"
|
||||
#include "brightray/browser/inspectable_web_contents_view.h"
|
||||
@@ -16,6 +17,7 @@
|
||||
#include "browser/atom_browser_context.h"
|
||||
#include "browser/atom_browser_main_parts.h"
|
||||
#include "browser/atom_javascript_dialog_manager.h"
|
||||
#include "browser/browser.h"
|
||||
#include "browser/window_list.h"
|
||||
#include "content/public/browser/devtools_agent_host.h"
|
||||
#include "content/public/browser/invalidate_type.h"
|
||||
@@ -26,13 +28,16 @@
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
#include "content/public/browser/render_widget_host_view.h"
|
||||
#include "content/public/common/renderer_preferences.h"
|
||||
#include "common/api/api_messages.h"
|
||||
#include "common/atom_version.h"
|
||||
#include "common/options_switches.h"
|
||||
#include "ipc/ipc_message_macros.h"
|
||||
#include "ui/gfx/codec/png_codec.h"
|
||||
#include "ui/gfx/point.h"
|
||||
#include "ui/gfx/rect.h"
|
||||
#include "ui/gfx/size.h"
|
||||
#include "webkit/glue/image_decoder.h"
|
||||
#include "webkit/common/user_agent/user_agent_util.h"
|
||||
|
||||
using content::NavigationEntry;
|
||||
|
||||
@@ -43,21 +48,33 @@ NativeWindow::NativeWindow(content::WebContents* web_contents,
|
||||
: content::WebContentsObserver(web_contents),
|
||||
has_frame_(true),
|
||||
is_closed_(false),
|
||||
not_responding_(false),
|
||||
node_integration_("all"),
|
||||
weak_factory_(this),
|
||||
inspectable_web_contents_(
|
||||
brightray::InspectableWebContents::Create(web_contents)) {
|
||||
options->GetBoolean(switches::kFrame, &has_frame_);
|
||||
|
||||
// Read icon before window is created.
|
||||
std::string icon;
|
||||
if (options->GetString(switches::kIcon, &icon)) {
|
||||
if (!SetIcon(icon))
|
||||
LOG(ERROR) << "Failed to set icon to " << icon;
|
||||
}
|
||||
if (options->GetString(switches::kIcon, &icon) && !SetIcon(icon))
|
||||
LOG(ERROR) << "Failed to set icon to " << icon;
|
||||
|
||||
// Read iframe security before any navigation.
|
||||
options->GetString(switches::kNodeIntegration, &node_integration_);
|
||||
|
||||
web_contents->SetDelegate(this);
|
||||
|
||||
WindowList::AddWindow(this);
|
||||
|
||||
// Override the user agent to contain application and atom-shell's version.
|
||||
Browser* browser = Browser::Get();
|
||||
std::string product_name = base::StringPrintf(
|
||||
"%s/%s Atom-Shell/" ATOM_VERSION_STRING,
|
||||
browser->GetName().c_str(),
|
||||
browser->GetVersion().c_str());
|
||||
web_contents->GetMutableRendererPrefs()->user_agent_override =
|
||||
webkit_glue::BuildUserAgentFromProduct(product_name);
|
||||
|
||||
// Get notified of title updated message.
|
||||
registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED,
|
||||
content::Source<content::WebContents>(web_contents));
|
||||
@@ -150,7 +167,7 @@ void NativeWindow::CloseDevTools() {
|
||||
}
|
||||
|
||||
bool NativeWindow::IsDevToolsOpened() {
|
||||
return inspectable_web_contents()->IsDevToolsOpened();
|
||||
return inspectable_web_contents()->IsDevToolsViewShowing();
|
||||
}
|
||||
|
||||
void NativeWindow::InspectElement(int x, int y) {
|
||||
@@ -173,24 +190,19 @@ bool NativeWindow::IsWebViewFocused() {
|
||||
return GetWebContents()->GetRenderViewHost()->GetView()->HasFocus();
|
||||
}
|
||||
|
||||
void NativeWindow::RestartHangMonitorTimeout() {
|
||||
GetWebContents()->GetRenderViewHost()->RestartHangMonitorTimeout();
|
||||
}
|
||||
|
||||
bool NativeWindow::SetIcon(const std::string& str_path) {
|
||||
base::FilePath path = base::FilePath::FromUTF8Unsafe(str_path);
|
||||
|
||||
// Read the file from disk.
|
||||
std::string file_contents;
|
||||
if (path.empty() || !file_util::ReadFileToString(path, &file_contents))
|
||||
if (path.empty() || !base::ReadFileToString(path, &file_contents))
|
||||
return false;
|
||||
|
||||
// Decode the bitmap using WebKit's image decoder.
|
||||
const unsigned char* data =
|
||||
reinterpret_cast<const unsigned char*>(file_contents.data());
|
||||
webkit_glue::ImageDecoder decoder;
|
||||
scoped_ptr<SkBitmap> decoded(new SkBitmap());
|
||||
*decoded = decoder.Decode(data, file_contents.length());
|
||||
gfx::PNGCodec::Decode(data, file_contents.length(), decoded.get());
|
||||
if (decoded->empty())
|
||||
return false; // Unable to decode.
|
||||
|
||||
@@ -198,6 +210,23 @@ bool NativeWindow::SetIcon(const std::string& str_path) {
|
||||
return true;
|
||||
}
|
||||
|
||||
base::ProcessHandle NativeWindow::GetRenderProcessHandle() {
|
||||
return GetWebContents()->GetRenderProcessHost()->GetHandle();
|
||||
}
|
||||
|
||||
void NativeWindow::CapturePage(const gfx::Rect& rect,
|
||||
const CapturePageCallback& callback) {
|
||||
gfx::Rect flipped_y_rect = rect;
|
||||
flipped_y_rect.set_y(-rect.y());
|
||||
|
||||
GetWebContents()->GetRenderViewHost()->CopyFromBackingStore(
|
||||
flipped_y_rect,
|
||||
gfx::Size(),
|
||||
base::Bind(&NativeWindow::OnCapturePageDone,
|
||||
weak_factory_.GetWeakPtr(),
|
||||
callback));
|
||||
}
|
||||
|
||||
void NativeWindow::CloseWebContents() {
|
||||
bool prevent_default = false;
|
||||
FOR_EACH_OBSERVER(NativeWindowObserver,
|
||||
@@ -210,6 +239,21 @@ void NativeWindow::CloseWebContents() {
|
||||
|
||||
content::WebContents* web_contents(GetWebContents());
|
||||
|
||||
// Assume the window is not responding if it doesn't cancel the close and is
|
||||
// not closed in 500ms, in this way we can quickly show the unresponsive
|
||||
// dialog when the window is busy executing some script withouth waiting for
|
||||
// the unresponsive timeout.
|
||||
if (window_unresposive_closure_.IsCancelled()) {
|
||||
window_unresposive_closure_.Reset(
|
||||
base::Bind(&NativeWindow::RendererUnresponsive,
|
||||
weak_factory_.GetWeakPtr(),
|
||||
web_contents));
|
||||
base::MessageLoop::current()->PostDelayedTask(
|
||||
FROM_HERE,
|
||||
window_unresposive_closure_.callback(),
|
||||
base::TimeDelta::FromMilliseconds(500));
|
||||
}
|
||||
|
||||
if (web_contents->NeedToFireBeforeUnload())
|
||||
web_contents->GetRenderViewHost()->FirePageBeforeUnload(false);
|
||||
else
|
||||
@@ -224,6 +268,14 @@ void NativeWindow::NotifyWindowClosed() {
|
||||
if (is_closed_)
|
||||
return;
|
||||
|
||||
// The OnRenderViewDeleted is not called when the WebContents is destroyed
|
||||
// directly (e.g. when closing the window), so we make sure it's always
|
||||
// emitted to users by sending it before window is closed..
|
||||
FOR_EACH_OBSERVER(NativeWindowObserver, observers_,
|
||||
OnRenderViewDeleted(
|
||||
GetWebContents()->GetRenderProcessHost()->GetID(),
|
||||
GetWebContents()->GetRoutingID()));
|
||||
|
||||
is_closed_ = true;
|
||||
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowClosed());
|
||||
|
||||
@@ -234,22 +286,28 @@ void NativeWindow::NotifyWindowBlur() {
|
||||
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowBlur());
|
||||
}
|
||||
|
||||
// Window opened by window.open.
|
||||
void NativeWindow::WebContentsCreated(
|
||||
content::WebContents* source_contents,
|
||||
int64 source_frame_id,
|
||||
const string16& frame_name,
|
||||
const GURL& target_url,
|
||||
content::WebContents* new_contents) {
|
||||
LOG(WARNING) << "Please use node-style Window API to create window, "
|
||||
"using window.open has very strict constrains.";
|
||||
// In atom-shell all reloads and navigations started by renderer process would
|
||||
// be redirected to this method, so we can have precise control of how we
|
||||
// would open the url (in our case, is to restart the renderer process). See
|
||||
// AtomRendererClient::ShouldFork for how this is done.
|
||||
content::WebContents* NativeWindow::OpenURLFromTab(
|
||||
content::WebContents* source,
|
||||
const content::OpenURLParams& params) {
|
||||
if (params.disposition != CURRENT_TAB)
|
||||
return NULL;
|
||||
|
||||
scoped_ptr<base::DictionaryValue> options(new base::DictionaryValue);
|
||||
options->SetInteger(switches::kWidth, 800);
|
||||
options->SetInteger(switches::kHeight, 600);
|
||||
content::NavigationController::LoadURLParams load_url_params(params.url);
|
||||
load_url_params.referrer = params.referrer;
|
||||
load_url_params.transition_type = params.transition;
|
||||
load_url_params.extra_headers = params.extra_headers;
|
||||
load_url_params.should_replace_current_entry =
|
||||
params.should_replace_current_entry;
|
||||
load_url_params.is_renderer_initiated = params.is_renderer_initiated;
|
||||
load_url_params.transferred_global_request_id =
|
||||
params.transferred_global_request_id;
|
||||
|
||||
NativeWindow* window = Create(new_contents, options.get());
|
||||
window->InitFromOptions(options.get());
|
||||
source->GetController().LoadURLWithParams(load_url_params);
|
||||
return source;
|
||||
}
|
||||
|
||||
content::JavaScriptDialogManager* NativeWindow::GetJavaScriptDialogManager() {
|
||||
@@ -266,6 +324,9 @@ void NativeWindow::BeforeUnloadFired(content::WebContents* tab,
|
||||
|
||||
if (!proceed)
|
||||
WindowList::WindowCloseCancelled(this);
|
||||
|
||||
// When the "beforeunload" callback is fired the window is certainly live.
|
||||
window_unresposive_closure_.Cancel();
|
||||
}
|
||||
|
||||
void NativeWindow::RequestToLockMouse(content::WebContents* web_contents,
|
||||
@@ -308,6 +369,9 @@ void NativeWindow::CloseContents(content::WebContents* source) {
|
||||
CloseImmediately();
|
||||
|
||||
NotifyWindowClosed();
|
||||
|
||||
// Do not sent "unresponsive" event after window is closed.
|
||||
window_unresposive_closure_.Cancel();
|
||||
}
|
||||
|
||||
bool NativeWindow::IsPopupOrPanel(const content::WebContents* source) const {
|
||||
@@ -316,19 +380,34 @@ bool NativeWindow::IsPopupOrPanel(const content::WebContents* source) const {
|
||||
}
|
||||
|
||||
void NativeWindow::RendererUnresponsive(content::WebContents* source) {
|
||||
not_responding_ = true;
|
||||
base::MessageLoop::current()->PostDelayedTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&NativeWindow::RendererUnresponsiveDelayed,
|
||||
base::Unretained(this)),
|
||||
base::TimeDelta::FromSeconds(1));
|
||||
window_unresposive_closure_.Cancel();
|
||||
|
||||
if (!HasModalDialog())
|
||||
FOR_EACH_OBSERVER(NativeWindowObserver,
|
||||
observers_,
|
||||
OnRendererUnresponsive());
|
||||
}
|
||||
|
||||
void NativeWindow::RendererResponsive(content::WebContents* source) {
|
||||
not_responding_ = false;
|
||||
window_unresposive_closure_.Cancel();
|
||||
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnRendererResponsive());
|
||||
}
|
||||
|
||||
void NativeWindow::RenderViewDeleted(content::RenderViewHost* rvh) {
|
||||
FOR_EACH_OBSERVER(NativeWindowObserver, observers_,
|
||||
OnRenderViewDeleted(rvh->GetProcess()->GetID(),
|
||||
rvh->GetRoutingID()));
|
||||
}
|
||||
|
||||
void NativeWindow::RenderProcessGone(base::TerminationStatus status) {
|
||||
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnRendererCrashed());
|
||||
}
|
||||
|
||||
void NativeWindow::BeforeUnloadFired(const base::TimeTicks& proceed_time) {
|
||||
// Do nothing, we override this method just to avoid compilation error since
|
||||
// there are two virtual functions named BeforeUnloadFired.
|
||||
}
|
||||
|
||||
bool NativeWindow::OnMessageReceived(const IPC::Message& message) {
|
||||
bool handled = true;
|
||||
IPC_BEGIN_MESSAGE_MAP(NativeWindow, message)
|
||||
@@ -343,17 +422,6 @@ bool NativeWindow::OnMessageReceived(const IPC::Message& message) {
|
||||
return handled;
|
||||
}
|
||||
|
||||
void NativeWindow::RenderViewGone(base::TerminationStatus status) {
|
||||
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnRendererCrashed());
|
||||
}
|
||||
|
||||
void NativeWindow::RendererUnresponsiveDelayed() {
|
||||
if (not_responding_)
|
||||
FOR_EACH_OBSERVER(NativeWindowObserver,
|
||||
observers_,
|
||||
OnRendererUnresponsive());
|
||||
}
|
||||
|
||||
void NativeWindow::Observe(int type,
|
||||
const content::NotificationSource& source,
|
||||
const content::NotificationDetails& details) {
|
||||
@@ -374,6 +442,15 @@ void NativeWindow::Observe(int type,
|
||||
}
|
||||
}
|
||||
|
||||
void NativeWindow::OnCapturePageDone(const CapturePageCallback& callback,
|
||||
bool succeed,
|
||||
const SkBitmap& bitmap) {
|
||||
std::vector<unsigned char> data;
|
||||
if (succeed)
|
||||
gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, true, &data);
|
||||
callback.Run(data);
|
||||
}
|
||||
|
||||
void NativeWindow::OnRendererMessage(const string16& channel,
|
||||
const base::ListValue& args) {
|
||||
AtomBrowserMainParts::Get()->atom_bindings()->OnRendererMessage(
|
||||
|
||||
@@ -6,8 +6,10 @@
|
||||
#define ATOM_BROWSER_NATIVE_WINDOW_H_
|
||||
|
||||
#include "base/basictypes.h"
|
||||
#include "base/cancelable_callback.h"
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "base/observer_list.h"
|
||||
#include "browser/native_window_observer.h"
|
||||
#include "content/public/browser/notification_registrar.h"
|
||||
@@ -49,6 +51,9 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
||||
public content::WebContentsObserver,
|
||||
public content::NotificationObserver {
|
||||
public:
|
||||
typedef base::Callback<void(const std::vector<unsigned char>& buffer)>
|
||||
CapturePageCallback;
|
||||
|
||||
virtual ~NativeWindow();
|
||||
|
||||
// Create window with existing WebContents.
|
||||
@@ -95,6 +100,7 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
||||
virtual void FlashFrame(bool flash) = 0;
|
||||
virtual void SetKiosk(bool kiosk) = 0;
|
||||
virtual bool IsKiosk() = 0;
|
||||
virtual bool HasModalDialog() = 0;
|
||||
virtual gfx::NativeWindow GetNativeWindow() = 0;
|
||||
|
||||
virtual bool IsClosed() const { return is_closed_; }
|
||||
@@ -102,12 +108,22 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
||||
virtual void CloseDevTools();
|
||||
virtual bool IsDevToolsOpened();
|
||||
virtual void InspectElement(int x, int y);
|
||||
|
||||
virtual void FocusOnWebView();
|
||||
virtual void BlurWebView();
|
||||
virtual bool IsWebViewFocused();
|
||||
virtual void RestartHangMonitorTimeout();
|
||||
|
||||
virtual bool SetIcon(const std::string& path);
|
||||
|
||||
// Returns the process handle of render process, useful for killing the
|
||||
// render process manually
|
||||
virtual base::ProcessHandle GetRenderProcessHandle();
|
||||
|
||||
// Captures the page with |rect|, |callback| would be called when capturing is
|
||||
// done.
|
||||
virtual void CapturePage(const gfx::Rect& rect,
|
||||
const CapturePageCallback& callback);
|
||||
|
||||
// The same with closing a tab in a real browser.
|
||||
//
|
||||
// Should be called by platform code when user want to close the window.
|
||||
@@ -124,6 +140,7 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
||||
}
|
||||
|
||||
bool has_frame() const { return has_frame_; }
|
||||
std::string node_integration() const { return node_integration_; }
|
||||
|
||||
protected:
|
||||
explicit NativeWindow(content::WebContents* web_contents,
|
||||
@@ -141,11 +158,9 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
||||
const std::vector<DraggableRegion>& regions) = 0;
|
||||
|
||||
// Implementations of content::WebContentsDelegate.
|
||||
virtual void WebContentsCreated(content::WebContents* source_contents,
|
||||
int64 source_frame_id,
|
||||
const string16& frame_name,
|
||||
const GURL& target_url,
|
||||
content::WebContents* new_contents) OVERRIDE;
|
||||
virtual content::WebContents* OpenURLFromTab(
|
||||
content::WebContents* source,
|
||||
const content::OpenURLParams& params) OVERRIDE;
|
||||
virtual content::JavaScriptDialogManager*
|
||||
GetJavaScriptDialogManager() OVERRIDE;
|
||||
virtual void BeforeUnloadFired(content::WebContents* tab,
|
||||
@@ -167,7 +182,9 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
||||
virtual void RendererResponsive(content::WebContents* source) OVERRIDE;
|
||||
|
||||
// Implementations of content::WebContentsObserver.
|
||||
virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE;
|
||||
virtual void RenderViewDeleted(content::RenderViewHost*) OVERRIDE;
|
||||
virtual void RenderProcessGone(base::TerminationStatus status) OVERRIDE;
|
||||
virtual void BeforeUnloadFired(const base::TimeTicks& proceed_time) OVERRIDE;
|
||||
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
|
||||
|
||||
// Implementations of content::NotificationObserver
|
||||
@@ -182,7 +199,10 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
||||
gfx::Image icon_;
|
||||
|
||||
private:
|
||||
void RendererUnresponsiveDelayed();
|
||||
// Called when CapturePage has done.
|
||||
void OnCapturePageDone(const CapturePageCallback& callback,
|
||||
bool succeed,
|
||||
const SkBitmap& bitmap);
|
||||
|
||||
void OnRendererMessage(const string16& channel,
|
||||
const base::ListValue& args);
|
||||
@@ -200,8 +220,14 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
||||
// The windows has been closed.
|
||||
bool is_closed_;
|
||||
|
||||
// The window is not responding.
|
||||
bool not_responding_;
|
||||
// The security token of iframe.
|
||||
std::string node_integration_;
|
||||
|
||||
// Closure that would be called when window is unresponsive when closing,
|
||||
// it should be cancelled when we can prove that the window is responsive.
|
||||
base::CancelableClosure window_unresposive_closure_;
|
||||
|
||||
base::WeakPtrFactory<NativeWindow> weak_factory_;
|
||||
|
||||
scoped_ptr<AtomJavaScriptDialogManager> dialog_manager_;
|
||||
scoped_ptr<brightray::InspectableWebContents> inspectable_web_contents_;
|
||||
|
||||
@@ -53,6 +53,7 @@ class NativeWindowMac : public NativeWindow {
|
||||
virtual void FlashFrame(bool flash) OVERRIDE;
|
||||
virtual void SetKiosk(bool kiosk) OVERRIDE;
|
||||
virtual bool IsKiosk() OVERRIDE;
|
||||
virtual bool HasModalDialog() OVERRIDE;
|
||||
virtual gfx::NativeWindow GetNativeWindow() OVERRIDE;
|
||||
|
||||
void NotifyWindowBlur() { NativeWindow::NotifyWindowBlur(); }
|
||||
|
||||
@@ -11,9 +11,10 @@
|
||||
#define BASE_MAC_FOUNDATION_UTIL_H_
|
||||
|
||||
#include "base/mac/mac_util.h"
|
||||
#include "base/mac/scoped_nsobject.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "base/values.h"
|
||||
#import "browser/ui/atom_event_processing_window.h"
|
||||
#import "browser/ui/cocoa/event_processing_window.h"
|
||||
#include "brightray/browser/inspectable_web_contents.h"
|
||||
#include "brightray/browser/inspectable_web_contents_view.h"
|
||||
#include "common/draggable_region.h"
|
||||
@@ -75,7 +76,7 @@ static const CGFloat kAtomWindowCornerRadius = 4.0;
|
||||
|
||||
@end
|
||||
|
||||
@interface AtomNSWindow : AtomEventProcessingWindow {
|
||||
@interface AtomNSWindow : EventProcessingWindow {
|
||||
@protected
|
||||
atom::NativeWindowMac* shell_;
|
||||
}
|
||||
@@ -141,7 +142,7 @@ NativeWindowMac::NativeWindowMac(content::WebContents* web_contents,
|
||||
: NativeWindow(web_contents, options),
|
||||
is_kiosk_(false),
|
||||
attention_request_id_(0) {
|
||||
int width, height;
|
||||
int width = 800, height = 600;
|
||||
options->GetInteger(switches::kWidth, &width);
|
||||
options->GetInteger(switches::kHeight, &height);
|
||||
|
||||
@@ -387,6 +388,10 @@ bool NativeWindowMac::IsKiosk() {
|
||||
return is_kiosk_;
|
||||
}
|
||||
|
||||
bool NativeWindowMac::HasModalDialog() {
|
||||
return [window() attachedSheet] != nil;
|
||||
}
|
||||
|
||||
gfx::NativeWindow NativeWindowMac::GetNativeWindow() {
|
||||
return window();
|
||||
}
|
||||
@@ -435,9 +440,9 @@ void NativeWindowMac::HandleKeyboardEvent(
|
||||
event.type == content::NativeWebKeyboardEvent::Char)
|
||||
return;
|
||||
|
||||
AtomEventProcessingWindow* event_window =
|
||||
static_cast<AtomEventProcessingWindow*>(window());
|
||||
DCHECK([event_window isKindOfClass:[AtomEventProcessingWindow class]]);
|
||||
EventProcessingWindow* event_window =
|
||||
static_cast<EventProcessingWindow*>(window());
|
||||
DCHECK([event_window isKindOfClass:[EventProcessingWindow class]]);
|
||||
[event_window redispatchKeyEvent:event.os_event];
|
||||
}
|
||||
|
||||
@@ -486,7 +491,7 @@ void NativeWindowMac::InstallDraggableRegionViews() {
|
||||
// Note that [webView subviews] returns the view's mutable internal array and
|
||||
// it should be copied to avoid mutating the original array while enumerating
|
||||
// it.
|
||||
scoped_nsobject<NSArray> subviews([[webView subviews] copy]);
|
||||
base::scoped_nsobject<NSArray> subviews([[webView subviews] copy]);
|
||||
for (NSView* subview in subviews.get())
|
||||
if ([subview isKindOfClass:[ControlRegionView class]])
|
||||
[subview removeFromSuperview];
|
||||
@@ -497,7 +502,7 @@ void NativeWindowMac::InstallDraggableRegionViews() {
|
||||
system_drag_exclude_areas_.begin();
|
||||
iter != system_drag_exclude_areas_.end();
|
||||
++iter) {
|
||||
scoped_nsobject<NSView> controlRegion(
|
||||
base::scoped_nsobject<NSView> controlRegion(
|
||||
[[ControlRegionView alloc] initWithShellWindow:this]);
|
||||
[controlRegion setFrame:NSMakeRect(iter->x(),
|
||||
webViewHeight - iter->bottom(),
|
||||
|
||||
@@ -35,6 +35,9 @@ class NativeWindowObserver {
|
||||
// Called when renderer recovers.
|
||||
virtual void OnRendererResponsive() {}
|
||||
|
||||
// Called when a render view has been deleted.
|
||||
virtual void OnRenderViewDeleted(int process_id, int routing_id) {}
|
||||
|
||||
// Called when renderer has crashed.
|
||||
virtual void OnRendererCrashed() {}
|
||||
};
|
||||
|
||||
@@ -194,6 +194,17 @@ class NativeWindowFramelessView : public views::NonClientFrameView {
|
||||
DISALLOW_COPY_AND_ASSIGN(NativeWindowFramelessView);
|
||||
};
|
||||
|
||||
bool WindowHasModalDialog(HWND parent, HWND except, HWND after = NULL) {
|
||||
HWND hwnd = ::FindWindowEx(parent, after, NULL, NULL);
|
||||
if (hwnd != except &&
|
||||
(::GetWindowLong(hwnd, GWL_STYLE) & (WS_VISIBLE | WS_POPUP)))
|
||||
return true;
|
||||
else if (hwnd == NULL)
|
||||
return false;
|
||||
else
|
||||
return WindowHasModalDialog(parent, except, hwnd);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
NativeWindowWin::NativeWindowWin(content::WebContents* web_contents,
|
||||
@@ -359,6 +370,11 @@ bool NativeWindowWin::IsKiosk() {
|
||||
return IsFullscreen();
|
||||
}
|
||||
|
||||
bool NativeWindowWin::HasModalDialog() {
|
||||
return WindowHasModalDialog(GetNativeWindow(),
|
||||
GetWebContents()->GetView()->GetNativeView());
|
||||
}
|
||||
|
||||
gfx::NativeWindow NativeWindowWin::GetNativeWindow() {
|
||||
return window_->GetNativeView();
|
||||
}
|
||||
@@ -423,10 +439,9 @@ void NativeWindowWin::Layout() {
|
||||
OnViewWasResized();
|
||||
}
|
||||
|
||||
void NativeWindowWin::ViewHierarchyChanged(bool is_add,
|
||||
views::View* parent,
|
||||
views::View* child) {
|
||||
if (is_add && child == this)
|
||||
void NativeWindowWin::ViewHierarchyChanged(
|
||||
const ViewHierarchyChangedDetails& details) {
|
||||
if (details.is_add && details.child == this)
|
||||
AddChildView(web_view_);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#ifndef ATOM_BROWSER_NATIVE_WINDOW_WIN_H_
|
||||
#define ATOM_BROWSER_NATIVE_WINDOW_WIN_H_
|
||||
|
||||
#include "base/string16.h"
|
||||
#include "base/strings/string16.h"
|
||||
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "browser/native_window.h"
|
||||
@@ -65,6 +65,7 @@ class NativeWindowWin : public NativeWindow,
|
||||
virtual void FlashFrame(bool flash) OVERRIDE;
|
||||
virtual void SetKiosk(bool kiosk) OVERRIDE;
|
||||
virtual bool IsKiosk() OVERRIDE;
|
||||
virtual bool HasModalDialog() OVERRIDE;
|
||||
virtual gfx::NativeWindow GetNativeWindow() OVERRIDE;
|
||||
|
||||
void OnMenuCommand(int position, HMENU menu);
|
||||
@@ -86,9 +87,8 @@ class NativeWindowWin : public NativeWindow,
|
||||
|
||||
// Overridden from views::View:
|
||||
virtual void Layout() OVERRIDE;
|
||||
virtual void ViewHierarchyChanged(bool is_add,
|
||||
views::View* parent,
|
||||
views::View* child) OVERRIDE;
|
||||
virtual void ViewHierarchyChanged(
|
||||
const ViewHierarchyChangedDetails& details) OVERRIDE;
|
||||
virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE;
|
||||
|
||||
// Overridden from views::WidgetDelegate:
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "browser/net/adapter_request_job.h"
|
||||
|
||||
#include "base/threading/sequenced_worker_pool.h"
|
||||
#include "browser/net/url_request_string_job.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "net/base/net_errors.h"
|
||||
@@ -87,7 +88,13 @@ void AdapterRequestJob::CreateStringJobAndStart(const std::string& mime_type,
|
||||
void AdapterRequestJob::CreateFileJobAndStart(const base::FilePath& path) {
|
||||
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
|
||||
|
||||
real_job_ = new net::URLRequestFileJob(request(), network_delegate(), path);
|
||||
real_job_ = new net::URLRequestFileJob(
|
||||
request(),
|
||||
network_delegate(),
|
||||
path,
|
||||
content::BrowserThread::GetBlockingPool()->
|
||||
GetTaskRunnerWithShutdownBehavior(
|
||||
base::SequencedWorkerPool::SKIP_ON_SHUTDOWN));
|
||||
real_job_->Start();
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
#include "browser/net/atom_url_request_context_getter.h"
|
||||
|
||||
#include "base/string_util.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/threading/sequenced_worker_pool.h"
|
||||
#include "base/threading/worker_pool.h"
|
||||
#include "browser/net/atom_url_request_job_factory.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
@@ -36,8 +37,8 @@ using content::BrowserThread;
|
||||
|
||||
AtomURLRequestContextGetter::AtomURLRequestContextGetter(
|
||||
const base::FilePath& base_path,
|
||||
MessageLoop* io_loop,
|
||||
MessageLoop* file_loop,
|
||||
base::MessageLoop* io_loop,
|
||||
base::MessageLoop* file_loop,
|
||||
scoped_ptr<brightray::NetworkDelegate> network_delegate,
|
||||
content::ProtocolHandlerMap* protocol_handlers)
|
||||
: base_path_(base_path),
|
||||
@@ -74,6 +75,7 @@ net::URLRequestContext* AtomURLRequestContextGetter::GetURLRequestContext() {
|
||||
base_path_.Append(FILE_PATH_LITERAL("Cookies")),
|
||||
false,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr));
|
||||
storage_->set_server_bound_cert_service(new net::ServerBoundCertService(
|
||||
new net::DefaultServerBoundCertStore(NULL),
|
||||
@@ -98,7 +100,9 @@ net::URLRequestContext* AtomURLRequestContextGetter::GetURLRequestContext() {
|
||||
storage_->set_ssl_config_service(new net::SSLConfigServiceDefaults);
|
||||
storage_->set_http_auth_handler_factory(
|
||||
net::HttpAuthHandlerFactory::CreateDefault(host_resolver.get()));
|
||||
storage_->set_http_server_properties(new net::HttpServerPropertiesImpl);
|
||||
scoped_ptr<net::HttpServerProperties> server_properties(
|
||||
new net::HttpServerPropertiesImpl);
|
||||
storage_->set_http_server_properties(server_properties.Pass());
|
||||
|
||||
base::FilePath cache_path = base_path_.Append(FILE_PATH_LITERAL("Cache"));
|
||||
net::HttpCache::DefaultBackend* main_backend =
|
||||
@@ -147,10 +151,15 @@ net::URLRequestContext* AtomURLRequestContextGetter::GetURLRequestContext() {
|
||||
}
|
||||
protocol_handlers_.clear();
|
||||
|
||||
scoped_ptr<net::FileProtocolHandler> file_protocol_handler(
|
||||
new net::FileProtocolHandler(
|
||||
content::BrowserThread::GetBlockingPool()->
|
||||
GetTaskRunnerWithShutdownBehavior(
|
||||
base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)));
|
||||
job_factory_->SetProtocolHandler(chrome::kDataScheme,
|
||||
new net::DataProtocolHandler);
|
||||
job_factory_->SetProtocolHandler(chrome::kFileScheme,
|
||||
new net::FileProtocolHandler);
|
||||
file_protocol_handler.release());
|
||||
storage_->set_job_factory(job_factory_);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include "browser/net/atom_url_request_job_factory.h"
|
||||
|
||||
#include "base/stl_util.h"
|
||||
#include "googleurl/src/gurl.h"
|
||||
#include "net/base/load_flags.h"
|
||||
#include "net/url_request/url_request.h"
|
||||
|
||||
@@ -102,4 +101,9 @@ bool AtomURLRequestJobFactory::IsHandledURL(const GURL& url) const {
|
||||
return IsHandledProtocol(url.scheme());
|
||||
}
|
||||
|
||||
bool AtomURLRequestJobFactory::IsSafeRedirectTarget(
|
||||
const GURL& location) const {
|
||||
return IsHandledURL(location);
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
||||
@@ -45,6 +45,7 @@ class AtomURLRequestJobFactory : public net::URLRequestJobFactory {
|
||||
net::NetworkDelegate* network_delegate) const OVERRIDE;
|
||||
virtual bool IsHandledProtocol(const std::string& scheme) const OVERRIDE;
|
||||
virtual bool IsHandledURL(const GURL& url) const OVERRIDE;
|
||||
virtual bool IsSafeRedirectTarget(const GURL& location) const OVERRIDE;
|
||||
|
||||
private:
|
||||
typedef std::map<std::string, ProtocolHandler*> ProtocolHandlerMap;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>atom.icns</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>0.6.10</string>
|
||||
<string>0.9.0</string>
|
||||
<key>NSMainNibFile</key>
|
||||
<string>MainMenu</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
|
Before Width: | Height: | Size: 345 KiB After Width: | Height: | Size: 345 KiB |
@@ -50,8 +50,8 @@ END
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 0,6,10,0
|
||||
PRODUCTVERSION 0,6,10,0
|
||||
FILEVERSION 0,9,0,0
|
||||
PRODUCTVERSION 0,9,0,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
@@ -68,12 +68,12 @@ BEGIN
|
||||
BEGIN
|
||||
VALUE "CompanyName", "GitHub, Inc."
|
||||
VALUE "FileDescription", "Atom-Shell"
|
||||
VALUE "FileVersion", "0.6.10"
|
||||
VALUE "FileVersion", "0.9.0"
|
||||
VALUE "InternalName", "atom.exe"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2013 GitHub, Inc. All rights reserved."
|
||||
VALUE "OriginalFilename", "atom.exe"
|
||||
VALUE "ProductName", "Atom-Shell"
|
||||
VALUE "ProductVersion", "0.6.10"
|
||||
VALUE "ProductVersion", "0.9.0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "base/string_util.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/string_split.h"
|
||||
#include "ui/base/accelerators/accelerator.h"
|
||||
@@ -105,11 +105,11 @@ bool StringToAccelerator(const std::string& description,
|
||||
key = KeyboardCodeFromCharCode(tokens[i][0], &shifted);
|
||||
if (shifted)
|
||||
modifiers |= ui::EF_SHIFT_DOWN;
|
||||
} else if (tokens[i] == "ctrl") {
|
||||
} else if (tokens[i] == "ctrl" || tokens[i] == "control") {
|
||||
modifiers |= ui::EF_CONTROL_DOWN;
|
||||
} else if (tokens[i] == "command") {
|
||||
// The "Command" would be translated to "Ctrl" on platforms other than
|
||||
// OS X.
|
||||
} else if (tokens[i] == "cmd" || tokens[i] == "command") {
|
||||
modifiers |= ui::EF_COMMAND_DOWN;
|
||||
} else if (tokens[i] == "commandorcontrol" || tokens[i] == "cmdorctrl") {
|
||||
#if defined(OS_MACOSX)
|
||||
modifiers |= ui::EF_COMMAND_DOWN;
|
||||
#else
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include "ui/base/accelerators/accelerator.h"
|
||||
#import "ui/base/accelerators/platform_accelerator_cocoa.h"
|
||||
#import "ui/base/keycodes/keyboard_code_conversion_mac.h"
|
||||
#import "ui/events/keycodes/keyboard_code_conversion_mac.h"
|
||||
|
||||
namespace accelerator_util {
|
||||
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_BROWSER_UI_ATOM_MENU_CONTROLLER_MAC_H_
|
||||
#define ATOM_BROWSER_UI_ATOM_MENU_CONTROLLER_MAC_H_
|
||||
#ifndef ATOM_BROWSER_UI_COCOA_ATOM_MENU_CONTROLLER_H_
|
||||
#define ATOM_BROWSER_UI_COCOA_ATOM_MENU_CONTROLLER_H_
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#include "base/memory/scoped_nsobject.h"
|
||||
#include "base/string16.h"
|
||||
#include "base/mac/scoped_nsobject.h"
|
||||
#include "base/strings/string16.h"
|
||||
|
||||
namespace ui {
|
||||
class MenuModel;
|
||||
@@ -24,7 +24,7 @@ class MenuModel;
|
||||
@interface AtomMenuController : NSObject<NSMenuDelegate> {
|
||||
@protected
|
||||
ui::MenuModel* model_; // weak
|
||||
scoped_nsobject<NSMenu> menu_;
|
||||
base::scoped_nsobject<NSMenu> menu_;
|
||||
BOOL isMenuOpen_;
|
||||
}
|
||||
|
||||
@@ -69,4 +69,4 @@ class MenuModel;
|
||||
- (NSMenu*)menuFromModel:(ui::MenuModel*)model;
|
||||
@end
|
||||
|
||||
#endif // ATOM_BROWSER_UI_ATOM_MENU_CONTROLLER_MAC_H_
|
||||
#endif // ATOM_BROWSER_UI_COCOA_ATOM_MENU_CONTROLLER_H_
|
||||
@@ -3,7 +3,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#import "browser/ui/atom_menu_controller_mac.h"
|
||||
#import "browser/ui/cocoa/atom_menu_controller.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
@@ -133,7 +133,7 @@ int EventFlagsFromNSEvent(NSEvent* event) {
|
||||
fromModel:(ui::MenuModel*)model {
|
||||
string16 label16 = model->GetLabelAt(index);
|
||||
NSString* label = l10n_util::FixUpWindowsStyleLabel(label16);
|
||||
scoped_nsobject<NSMenuItem> item(
|
||||
base::scoped_nsobject<NSMenuItem> item(
|
||||
[[NSMenuItem alloc] initWithTitle:label
|
||||
action:@selector(itemSelected:)
|
||||
keyEquivalent:@""]);
|
||||
@@ -2,17 +2,15 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_BROWSER_UI_ATOM_EVENT_PROCESSING_WINDOW_H_
|
||||
#define ATOM_BROWSER_UI_ATOM_EVENT_PROCESSING_WINDOW_H_
|
||||
#ifndef ATOM_BROWSER_UI_COCOA_EVENT_PROCESSING_WINDOW_H_
|
||||
#define ATOM_BROWSER_UI_COCOA_EVENT_PROCESSING_WINDOW_H_
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#include "base/memory/scoped_nsobject.h"
|
||||
|
||||
// Override NSWindow to access unhandled keyboard events (for command
|
||||
// processing); subclassing NSWindow is the only method to do
|
||||
// this.
|
||||
@interface AtomEventProcessingWindow : NSWindow {
|
||||
@interface EventProcessingWindow : NSWindow {
|
||||
@private
|
||||
BOOL redispatchingEvent_;
|
||||
BOOL eventHandled_;
|
||||
@@ -29,4 +27,4 @@
|
||||
- (BOOL)performKeyEquivalent:(NSEvent*)theEvent;
|
||||
@end
|
||||
|
||||
#endif // ATOM_BROWSER_UI_ATOM_EVENT_PROCESSING_WINDOW_H_
|
||||
#endif // ATOM_BROWSER_UI_COCOA_EVENT_PROCESSING_WINDOW_H_
|
||||
@@ -2,17 +2,17 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#import "browser/ui/atom_event_processing_window.h"
|
||||
#import "browser/ui/cocoa/event_processing_window.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#import "content/public/browser/render_widget_host_view_mac_base.h"
|
||||
|
||||
@interface AtomEventProcessingWindow ()
|
||||
@interface EventProcessingWindow ()
|
||||
// Duplicate the given key event, but changing the associated window.
|
||||
- (NSEvent*)keyEventForWindow:(NSWindow*)window fromKeyEvent:(NSEvent*)event;
|
||||
@end
|
||||
|
||||
@implementation AtomEventProcessingWindow
|
||||
@implementation EventProcessingWindow
|
||||
|
||||
- (BOOL)redispatchKeyEvent:(NSEvent*)event {
|
||||
DCHECK(event);
|
||||
@@ -103,4 +103,4 @@
|
||||
return NO;
|
||||
}
|
||||
|
||||
@end // AtomEventProcessingWindow
|
||||
@end // EventProcessingWindow
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#import "browser/ui/nsalert_synchronous_sheet_mac.h"
|
||||
#import "browser/ui/cocoa/nsalert_synchronous_sheet.h"
|
||||
|
||||
// Private methods -- use prefixes to avoid collisions with Apple's methods
|
||||
@interface NSAlert (SynchronousSheetPrivate)
|
||||
@@ -24,7 +24,7 @@ void SetupDialog(NSSavePanel* dialog,
|
||||
NSString* default_dir = nil;
|
||||
NSString* default_filename = nil;
|
||||
if (!default_path.empty()) {
|
||||
if (file_util::DirectoryExists(default_path)) {
|
||||
if (base::DirectoryExists(default_path)) {
|
||||
default_dir = base::SysUTF8ToNSString(default_path.value());
|
||||
} else {
|
||||
default_dir = base::SysUTF8ToNSString(default_path.DirName().value());
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
|
||||
#include "base/file_util.h"
|
||||
#include "base/i18n/case_conversion.h"
|
||||
#include "base/string_util.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/string_split.h"
|
||||
#include "base/utf_string_conversions.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/win/registry.h"
|
||||
#include "browser/native_window.h"
|
||||
#include "third_party/wtl/include/atlapp.h"
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "base/callback.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "browser/native_window.h"
|
||||
#include "browser/ui/nsalert_synchronous_sheet_mac.h"
|
||||
#include "browser/ui/cocoa/nsalert_synchronous_sheet.h"
|
||||
|
||||
@interface ModalDelegate : NSObject {
|
||||
@private
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
#include "browser/ui/message_box.h"
|
||||
|
||||
#include "base/callback.h"
|
||||
#include "base/message_loop.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/string_util.h"
|
||||
#include "base/utf_string_conversions.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "browser/native_window.h"
|
||||
#include "skia/ext/skia_utils_win.h"
|
||||
#include "ui/views/controls/button/label_button.h"
|
||||
|
||||
@@ -8,22 +8,22 @@
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/message_loop.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/stl_util.h"
|
||||
#include "base/string_util.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/win/wrapped_window_proc.h"
|
||||
#include "browser/ui/win/menu_2.h"
|
||||
#include "ui/base/accelerators/accelerator.h"
|
||||
#include "ui/base/keycodes/keyboard_codes.h"
|
||||
#include "ui/events/keycodes/keyboard_codes.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "ui/base/l10n/l10n_util_win.h"
|
||||
#include "ui/base/models/menu_model.h"
|
||||
#include "ui/base/win/hwnd_util.h"
|
||||
#include "ui/gfx/canvas.h"
|
||||
#include "ui/gfx/font.h"
|
||||
#include "ui/gfx/image/image.h"
|
||||
#include "ui/gfx/image/image_skia.h"
|
||||
#include "ui/gfx/rect.h"
|
||||
#include "ui/gfx/win/hwnd_util.h"
|
||||
#include "ui/native_theme/native_theme.h"
|
||||
#include "ui/native_theme/native_theme_win.h"
|
||||
#include "ui/views/controls/menu/menu_config.h"
|
||||
@@ -84,8 +84,8 @@ class NativeMenuWin::MenuHostWindow {
|
||||
RegisterClass();
|
||||
hwnd_ = CreateWindowEx(l10n_util::GetExtendedStyles(), kWindowClassName,
|
||||
L"", 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, NULL, NULL);
|
||||
ui::CheckWindowCreated(hwnd_);
|
||||
ui::SetWindowUserData(hwnd_, this);
|
||||
gfx::CheckWindowCreated(hwnd_);
|
||||
gfx::SetWindowUserData(hwnd_, this);
|
||||
}
|
||||
|
||||
~MenuHostWindow() {
|
||||
@@ -353,7 +353,7 @@ class NativeMenuWin::MenuHostWindow {
|
||||
WPARAM w_param,
|
||||
LPARAM l_param) {
|
||||
MenuHostWindow* host =
|
||||
reinterpret_cast<MenuHostWindow*>(ui::GetWindowUserData(window));
|
||||
reinterpret_cast<MenuHostWindow*>(gfx::GetWindowUserData(window));
|
||||
// host is null during initial construction.
|
||||
LRESULT l_result = 0;
|
||||
if (!host || !host->ProcessWindowMessage(window, message, w_param, l_param,
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "base/observer_list.h"
|
||||
#include "base/string16.h"
|
||||
#include "base/strings/string16.h"
|
||||
|
||||
namespace gfx {
|
||||
class Point;
|
||||
|
||||
58
common.gypi
58
common.gypi
@@ -13,6 +13,7 @@
|
||||
}],
|
||||
],
|
||||
# Reflects node's config.gypi.
|
||||
'component%': 'static_library',
|
||||
'python': 'python',
|
||||
'node_install_npm': 'false',
|
||||
'node_prefix': '',
|
||||
@@ -29,11 +30,12 @@
|
||||
'node_use_openssl': 'true',
|
||||
'node_use_perfctr': 'false',
|
||||
'node_use_systemtap': 'false',
|
||||
'v8_postmortem_support': 'false',
|
||||
},
|
||||
# Settings to compile node under Windows.
|
||||
'target_defaults': {
|
||||
'target_conditions': [
|
||||
['_target_name in ["libuv", "http_parser", "cares", "openssl", "node", "zlib"]', {
|
||||
['_target_name in ["libuv", "http_parser", "cares", "openssl", "openssl-cli", "node_lib", "zlib"]', {
|
||||
'msvs_disabled_warnings': [
|
||||
4013, # 'free' undefined; assuming extern returning int
|
||||
4054, #
|
||||
@@ -41,17 +43,20 @@
|
||||
4189, #
|
||||
4131, # uses old-style declarator
|
||||
4133, # incompatible types
|
||||
4146, # unary minus operator applied to unsigned type, result still unsigned
|
||||
4152, # function/data pointer conversion in expression
|
||||
4206, # translation unit is empty
|
||||
4204, # non-constant aggregate initializer
|
||||
4214, # bit field types other than int
|
||||
4232, # address of dllimport 'free' is not static, identity not guaranteed
|
||||
4291, # no matching operator delete found
|
||||
4295, # array is too small to include a terminating null character
|
||||
4389, # '==' : signed/unsigned mismatch
|
||||
4505, # unreferenced local function has been removed
|
||||
4701, # potentially uninitialized local variable 'sizew' used
|
||||
4706, # assignment within conditional expression
|
||||
4996, #
|
||||
4804, # unsafe use of type 'bool' in operation
|
||||
4996, # this function or variable may be unsafe.
|
||||
],
|
||||
'msvs_settings': {
|
||||
'VCCLCompilerTool': {
|
||||
@@ -59,9 +64,24 @@
|
||||
},
|
||||
},
|
||||
'xcode_settings': {
|
||||
'GCC_TREAT_WARNINGS_AS_ERRORS': 'NO'
|
||||
'GCC_TREAT_WARNINGS_AS_ERRORS': 'NO',
|
||||
'WARNING_CFLAGS': [
|
||||
'-Wno-parentheses-equality',
|
||||
'-Wno-unused-function',
|
||||
'-Wno-sometimes-uninitialized',
|
||||
'-Wno-pointer-sign',
|
||||
'-Wno-string-plus-int',
|
||||
'-Wno-unused-variable',
|
||||
'-Wno-deprecated-declarations',
|
||||
'-Wno-return-type',
|
||||
],
|
||||
},
|
||||
}],
|
||||
['_target_name in ["node_lib", "atom_lib"]', {
|
||||
'include_dirs': [
|
||||
'vendor/brightray/vendor/download/libchromiumcontent/src/v8/include',
|
||||
],
|
||||
}],
|
||||
['_target_name=="libuv"', {
|
||||
'conditions': [
|
||||
['OS=="win"', {
|
||||
@@ -72,6 +92,15 @@
|
||||
}], # OS=="win"
|
||||
],
|
||||
}],
|
||||
['_target_name.startswith("breakpad") or _target_name in ["crash_report_sender", "dump_syms"]', {
|
||||
'xcode_settings': {
|
||||
'WARNING_CFLAGS': [
|
||||
'-Wno-deprecated-declarations',
|
||||
'-Wno-unused-private-field',
|
||||
'-Wno-unused-function',
|
||||
],
|
||||
},
|
||||
}],
|
||||
],
|
||||
'msvs_cygwin_shell': 0, # Strangely setting it to 1 would make building under cygwin fail.
|
||||
'msvs_disabled_warnings': [
|
||||
@@ -107,6 +136,9 @@
|
||||
],
|
||||
},
|
||||
},
|
||||
'xcode_settings': {
|
||||
'DEBUG_INFORMATION_FORMAT': 'dwarf-with-dsym',
|
||||
},
|
||||
},
|
||||
'conditions': [
|
||||
# Settings to compile with clang under OS X.
|
||||
@@ -164,5 +196,25 @@
|
||||
],
|
||||
},
|
||||
}], # msvs_express==1
|
||||
# The breakdpad on Windows assumes Debug_x64 and Release_x64 configurations.
|
||||
['OS=="win"', {
|
||||
'target_defaults': {
|
||||
'configurations': {
|
||||
'Debug_x64': {
|
||||
},
|
||||
'Release_x64': {
|
||||
},
|
||||
},
|
||||
},
|
||||
}], # OS=="win"
|
||||
# The breakdpad on Mac assumes Release_Base configuration.
|
||||
['OS=="mac"', {
|
||||
'target_defaults': {
|
||||
'configurations': {
|
||||
'Release_Base': {
|
||||
},
|
||||
},
|
||||
},
|
||||
}], # OS=="mac"
|
||||
],
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
// Multiply-included file, no traditional include guard.
|
||||
|
||||
#include "base/string16.h"
|
||||
#include "base/strings/string16.h"
|
||||
#include "base/values.h"
|
||||
#include "common/draggable_region.h"
|
||||
#include "content/public/common/common_param_traits.h"
|
||||
|
||||
@@ -6,92 +6,79 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "common/v8/native_type_conversions.h"
|
||||
#include "ui/base/clipboard/clipboard.h"
|
||||
#include "vendor/node/src/node.h"
|
||||
|
||||
#include "common/v8/node_common.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Clipboard::Has(const v8::Arguments &args) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
if (!args[0]->IsString())
|
||||
void Clipboard::Has(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
std::string format_string;
|
||||
if (!FromV8Arguments(args, &format_string))
|
||||
return node::ThrowTypeError("Bad argument");
|
||||
|
||||
ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
|
||||
|
||||
std::string format_string(*v8::String::Utf8Value(args[0]));
|
||||
ui::Clipboard::FormatType format(ui::Clipboard::GetFormatType(format_string));
|
||||
|
||||
return scope.Close(v8::Boolean::New(
|
||||
clipboard->IsFormatAvailable(format, ui::Clipboard::BUFFER_STANDARD)));
|
||||
args.GetReturnValue().Set(
|
||||
clipboard->IsFormatAvailable(format, ui::Clipboard::BUFFER_STANDARD));
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Clipboard::Read(const v8::Arguments &args) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
if (!args[0]->IsString())
|
||||
void Clipboard::Read(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
std::string format_string;
|
||||
if (!FromV8Arguments(args, &format_string))
|
||||
return node::ThrowTypeError("Bad argument");
|
||||
|
||||
ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
|
||||
|
||||
std::string format_string(*v8::String::Utf8Value(args[0]));
|
||||
ui::Clipboard::FormatType format(ui::Clipboard::GetFormatType(format_string));
|
||||
|
||||
std::string data;
|
||||
clipboard->ReadData(format, &data);
|
||||
|
||||
return scope.Close(v8::String::New(data.c_str(), data.size()));
|
||||
args.GetReturnValue().Set(ToV8Value(data));
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Clipboard::ReadText(const v8::Arguments &args) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
void Clipboard::ReadText(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
|
||||
|
||||
std::string data;
|
||||
clipboard->ReadAsciiText(ui::Clipboard::BUFFER_STANDARD, &data);
|
||||
|
||||
return scope.Close(v8::String::New(data.c_str(), data.size()));
|
||||
args.GetReturnValue().Set(ToV8Value(data));
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Clipboard::WriteText(const v8::Arguments &args) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
if (!args[0]->IsString())
|
||||
void Clipboard::WriteText(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
std::string text;
|
||||
if (!FromV8Arguments(args, &text))
|
||||
return node::ThrowTypeError("Bad argument");
|
||||
|
||||
ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
|
||||
std::string text(*v8::String::Utf8Value(args[0]));
|
||||
|
||||
ui::Clipboard::ObjectMap object_map;
|
||||
object_map[ui::Clipboard::CBF_TEXT].push_back(
|
||||
std::vector<char>(text.begin(), text.end()));
|
||||
clipboard->WriteObjects(ui::Clipboard::BUFFER_STANDARD, object_map, NULL);
|
||||
|
||||
return v8::Undefined();
|
||||
ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
|
||||
clipboard->WriteObjects(ui::Clipboard::BUFFER_STANDARD, object_map);
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Clipboard::Clear(const v8::Arguments &args) {
|
||||
ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
|
||||
clipboard->Clear(ui::Clipboard::BUFFER_STANDARD);
|
||||
|
||||
return v8::Undefined();
|
||||
void Clipboard::Clear(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
ui::Clipboard::GetForCurrentThread()->Clear(ui::Clipboard::BUFFER_STANDARD);
|
||||
}
|
||||
|
||||
// static
|
||||
void Clipboard::Initialize(v8::Handle<v8::Object> target) {
|
||||
node::SetMethod(target, "has", Has);
|
||||
node::SetMethod(target, "read", Read);
|
||||
node::SetMethod(target, "readText", ReadText);
|
||||
node::SetMethod(target, "writeText", WriteText);
|
||||
node::SetMethod(target, "clear", Clear);
|
||||
NODE_SET_METHOD(target, "has", Has);
|
||||
NODE_SET_METHOD(target, "read", Read);
|
||||
NODE_SET_METHOD(target, "readText", ReadText);
|
||||
NODE_SET_METHOD(target, "writeText", WriteText);
|
||||
NODE_SET_METHOD(target, "clear", Clear);
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
|
||||
@@ -17,11 +17,11 @@ class Clipboard {
|
||||
static void Initialize(v8::Handle<v8::Object> target);
|
||||
|
||||
private:
|
||||
static v8::Handle<v8::Value> Has(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> Read(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> ReadText(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> WriteText(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> Clear(const v8::Arguments &args);
|
||||
static void Has(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void Read(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void ReadText(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void WriteText(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void Clear(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
|
||||
DISALLOW_IMPLICIT_CONSTRUCTORS(Clipboard);
|
||||
};
|
||||
|
||||
38
common/api/atom_api_crash_reporter.cc
Normal file
38
common/api/atom_api_crash_reporter.cc
Normal file
@@ -0,0 +1,38 @@
|
||||
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "common/api/atom_api_crash_reporter.h"
|
||||
|
||||
#include "common/crash_reporter/crash_reporter.h"
|
||||
#include "common/v8/native_type_conversions.h"
|
||||
|
||||
#include "common/v8/node_common.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
||||
// static
|
||||
void CrashReporter::Start(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
std::string product_name, company_name, submit_url;
|
||||
bool auto_submit, skip_system;
|
||||
std::map<std::string, std::string> dict;
|
||||
if (!FromV8Arguments(args, &product_name, &company_name, &submit_url,
|
||||
&auto_submit, &skip_system, &dict))
|
||||
return node::ThrowTypeError("Bad argument");
|
||||
|
||||
crash_reporter::CrashReporter::GetInstance()->Start(
|
||||
product_name, company_name, submit_url, auto_submit, skip_system, dict);
|
||||
}
|
||||
|
||||
// static
|
||||
void CrashReporter::Initialize(v8::Handle<v8::Object> target) {
|
||||
NODE_SET_METHOD(target, "start", Start);
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
|
||||
} // namespace atom
|
||||
|
||||
NODE_MODULE(atom_common_crash_reporter, atom::api::CrashReporter::Initialize)
|
||||
@@ -2,8 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_BROWSER_API_ATOM_API_CRASH_REPORTER_H_
|
||||
#define ATOM_BROWSER_API_ATOM_API_CRASH_REPORTER_H_
|
||||
#ifndef ATOM_COMMON_API_ATOM_API_CRASH_REPORTER_H_
|
||||
#define ATOM_COMMON_API_ATOM_API_CRASH_REPORTER_H_
|
||||
|
||||
#include "base/basictypes.h"
|
||||
#include "v8/include/v8.h"
|
||||
@@ -17,9 +17,7 @@ class CrashReporter {
|
||||
static void Initialize(v8::Handle<v8::Object> target);
|
||||
|
||||
private:
|
||||
static v8::Handle<v8::Value> SetCompanyName(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> SetSubmissionURL(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> SetAutoSubmit(const v8::Arguments &args);
|
||||
static void Start(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
|
||||
DISALLOW_IMPLICIT_CONSTRUCTORS(CrashReporter);
|
||||
};
|
||||
@@ -28,4 +26,4 @@ class CrashReporter {
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_BROWSER_API_ATOM_API_CRASH_REPORTER_H_
|
||||
#endif // ATOM_COMMON_API_ATOM_API_CRASH_REPORTER_H_
|
||||
@@ -2,17 +2,15 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "browser/api/atom_api_event_emitter.h"
|
||||
#include "common/api/atom_api_event_emitter.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "base/values.h"
|
||||
#include "browser/api/atom_api_event.h"
|
||||
#include "common/v8_value_converter_impl.h"
|
||||
#include "vendor/node/src/node.h"
|
||||
#include "vendor/node/src/node_internals.h"
|
||||
#include "common/v8/native_type_conversions.h"
|
||||
|
||||
#include "common/v8/node_common.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
@@ -20,16 +18,18 @@ namespace api {
|
||||
|
||||
EventEmitter::EventEmitter(v8::Handle<v8::Object> wrapper) {
|
||||
Wrap(wrapper);
|
||||
|
||||
// process.emit('ATOM_BROWSER_INTERNAL_NEW', this).
|
||||
v8::Handle<v8::Value> args[] = {
|
||||
v8::String::New("ATOM_BROWSER_INTERNAL_NEW"),
|
||||
wrapper,
|
||||
};
|
||||
node::MakeCallback(node::process, "emit", 2, args);
|
||||
}
|
||||
|
||||
EventEmitter::~EventEmitter() {
|
||||
// Use Locker in browser process.
|
||||
scoped_ptr<v8::Locker> locker;
|
||||
if (node::g_standalone_mode)
|
||||
locker.reset(new v8::Locker(node_isolate));
|
||||
|
||||
// Clear the aligned pointer, it should have been done by ObjectWrap but
|
||||
// somehow node v0.11.x changed this behaviour.
|
||||
v8::HandleScope handle_scope(node_isolate);
|
||||
handle()->SetAlignedPointerInInternalField(0, NULL);
|
||||
}
|
||||
|
||||
bool EventEmitter::Emit(const std::string& name) {
|
||||
@@ -38,10 +38,15 @@ bool EventEmitter::Emit(const std::string& name) {
|
||||
}
|
||||
|
||||
bool EventEmitter::Emit(const std::string& name, base::ListValue* args) {
|
||||
v8::HandleScope scope;
|
||||
// Use Locker in browser process.
|
||||
scoped_ptr<v8::Locker> locker;
|
||||
if (node::g_standalone_mode)
|
||||
locker.reset(new v8::Locker(node_isolate));
|
||||
|
||||
v8::HandleScope handle_scope(node_isolate);
|
||||
|
||||
v8::Handle<v8::Context> context = v8::Context::GetCurrent();
|
||||
scoped_ptr<content::V8ValueConverter> converter(new V8ValueConverterImpl);
|
||||
scoped_ptr<V8ValueConverter> converter(new V8ValueConverter);
|
||||
|
||||
v8::Handle<v8::Object> v8_event = Event::CreateV8Object();
|
||||
Event* event = Event::Unwrap<Event>(v8_event);
|
||||
@@ -49,7 +54,7 @@ bool EventEmitter::Emit(const std::string& name, base::ListValue* args) {
|
||||
// Generate arguments for calling handle.emit.
|
||||
std::vector<v8::Handle<v8::Value>> v8_args;
|
||||
v8_args.reserve(args->GetSize() + 2);
|
||||
v8_args.push_back(v8::String::New(name.c_str(), name.size()));
|
||||
v8_args.push_back(ToV8Value(name));
|
||||
v8_args.push_back(v8_event);
|
||||
for (size_t i = 0; i < args->GetSize(); i++) {
|
||||
base::Value* value = NULL;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user