mirror of
https://github.com/electron/electron.git
synced 2026-02-26 03:01:17 -05:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
40066ca343 | ||
|
|
6671e78f5d | ||
|
|
0480e32f99 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -6,7 +6,6 @@
|
||||
/external_binaries/
|
||||
/out/
|
||||
/vendor/brightray/vendor/download/
|
||||
/vendor/debian_wheezy_amd64-sysroot/
|
||||
/vendor/debian_wheezy_arm-sysroot/
|
||||
/vendor/debian_wheezy_i386-sysroot/
|
||||
/vendor/python_26/
|
||||
|
||||
8
.gitmodules
vendored
8
.gitmodules
vendored
@@ -1,21 +1,21 @@
|
||||
[submodule "vendor/brightray"]
|
||||
path = vendor/brightray
|
||||
url = https://github.com/electron/brightray.git
|
||||
url = https://github.com/atom/brightray.git
|
||||
[submodule "vendor/node"]
|
||||
path = vendor/node
|
||||
url = https://github.com/electron/node.git
|
||||
url = https://github.com/atom/node.git
|
||||
[submodule "vendor/depot_tools"]
|
||||
path = vendor/depot_tools
|
||||
url = https://chromium.googlesource.com/chromium/tools/depot_tools.git
|
||||
[submodule "vendor/breakpad"]
|
||||
path = vendor/breakpad
|
||||
url = https://github.com/electron/chromium-breakpad.git
|
||||
url = https://github.com/atom/chromium-breakpad.git
|
||||
[submodule "vendor/native_mate"]
|
||||
path = vendor/native_mate
|
||||
url = https://github.com/zcbenz/native-mate.git
|
||||
[submodule "vendor/crashpad"]
|
||||
path = vendor/crashpad
|
||||
url = https://github.com/electron/crashpad.git
|
||||
url = https://github.com/atom/crashpad.git
|
||||
[submodule "vendor/requests"]
|
||||
path = vendor/requests
|
||||
url = https://github.com/kennethreitz/requests
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
v5.10.0
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
## 이슈 제출
|
||||
|
||||
* [여기](https://github.com/electron/electron/issues/new)에서 새로운 이슈를 만들 수
|
||||
* [여기](https://github.com/atom/electron/issues/new)에서 새로운 이슈를 만들 수
|
||||
있습니다. 하지만 이슈를 작성하기 전에 아래의 항목들을 숙지하고 가능한한 이슈 보고에
|
||||
대해 최대한 많은 정보와 자세한 설명을 포함해야 합니다. 가능하다면 다음 항목을 포함해야
|
||||
합니다:
|
||||
@@ -23,7 +23,7 @@
|
||||
* 추가로 다음 사항을 준수하면 이슈를 해결하는데 큰 도움이 됩니다:
|
||||
* 스크린샷 또는 GIF 애니메이션 이미지들
|
||||
* 터미널에 출력된 에러의 내용 또는 개발자 도구, 알림창에 뜬 내용
|
||||
* [Cursory search](https://github.com/electron/electron/issues?utf8=✓&q=is%3Aissue+)를
|
||||
* [Cursory search](https://github.com/atom/electron/issues?utf8=✓&q=is%3Aissue+)를
|
||||
통해 이미 비슷한 내용의 이슈가 등록되어있는지 확인
|
||||
|
||||
## Pull Request 하기
|
||||
|
||||
@@ -12,7 +12,7 @@ propose changes to this document in a pull request.
|
||||
|
||||
## Submitting Issues
|
||||
|
||||
* You can create an issue [here](https://github.com/electron/electron/issues/new),
|
||||
* You can create an issue [here](https://github.com/atom/electron/issues/new),
|
||||
but before doing that please read the notes below and include as many details as
|
||||
possible with your report. If you can, please include:
|
||||
* The version of Electron you are using
|
||||
@@ -22,13 +22,13 @@ possible with your report. If you can, please include:
|
||||
* Other things that will help resolve your issue:
|
||||
* Screenshots and animated GIFs
|
||||
* Error output that appears in your terminal, dev tools or as an alert
|
||||
* Perform a [cursory search](https://github.com/electron/electron/issues?utf8=✓&q=is%3Aissue+)
|
||||
* Perform a [cursory search](https://github.com/atom/electron/issues?utf8=✓&q=is%3Aissue+)
|
||||
to see if a similar issue has already been submitted
|
||||
|
||||
## Submitting Pull Requests
|
||||
|
||||
* Include screenshots and animated GIFs in your pull request whenever possible.
|
||||
* Follow the JavaScript, C++, and Python [coding style defined in docs](/docs/development/coding-style.md).
|
||||
* Follow the CoffeeScript, JavaScript, C++ and Python [coding style defined in docs](/docs/development/coding-style.md).
|
||||
* Write documentation in [Markdown](https://daringfireball.net/projects/markdown).
|
||||
See the [Documentation Styleguide](/docs/styleguide.md).
|
||||
* Use short, present tense commit messages. See [Commit Message Styleguide](#git-commit-messages).
|
||||
|
||||
27
README-ko.md
27
README-ko.md
@@ -1,11 +1,10 @@
|
||||
[](http://electron.atom.io/)
|
||||
|
||||
[](https://travis-ci.org/atom/electron)
|
||||
[](https://ci.appveyor.com/project/Atom/electron)
|
||||
[](https://david-dm.org/atom/electron#info=devDependencies)
|
||||
[](http://atom-slack.herokuapp.com/)
|
||||
|
||||
### [Electron](https://github.com/electron/electron/) 한국어 참조문서
|
||||
### [Electron](https://github.com/atom/electron/) 한국어 참조문서
|
||||
|
||||
:zap: *프레임워크 이름이 Atom Shell에서 Electron으로 변경되었습니다* :zap:
|
||||
|
||||
@@ -24,7 +23,7 @@ Electron에 대한 중요한 알림을 받고 싶다면 Twitter에서
|
||||
## 다운로드
|
||||
|
||||
Linux, Windows, OS X 용으로 미리 빌드된 Electron 바이너리와 디버그 심볼이 준비되어
|
||||
있습니다. [releases](https://github.com/electron/electron/releases) 페이지에서 받아 볼
|
||||
있습니다. [releases](https://github.com/atom/electron/releases) 페이지에서 받아 볼
|
||||
수 있습니다.
|
||||
|
||||
또한 [`npm`](https://docs.npmjs.com/)을 통해 미리 빌드된 Electron 바이너리를 설치할
|
||||
@@ -44,25 +43,25 @@ npm install electron-prebuilt --save-dev
|
||||
|
||||
## 참조 문서
|
||||
|
||||
[Docs](https://github.com/electron/electron/tree/master/docs/README.md)에 개발 지침과
|
||||
[Docs](https://github.com/atom/electron/tree/master/docs/README.md)에 개발 지침과
|
||||
API 레퍼런스가 있습니다. Electron을 빌드 하는 방법과 프로젝트에 기여하는법 또한 문서에
|
||||
포함되어 있으니 참고하시기 바랍니다.
|
||||
|
||||
## 참조 문서 (번역)
|
||||
|
||||
- [브라질 포르투갈어](https://github.com/electron/electron/tree/master/docs-translations/pt-BR)
|
||||
- [한국어](https://github.com/electron/electron/tree/master/docs-translations/ko-KR)
|
||||
- [일본어](https://github.com/electron/electron/tree/master/docs-translations/jp)
|
||||
- [스페인어](https://github.com/electron/electron/tree/master/docs-translations/es)
|
||||
- [중국어 간체](https://github.com/electron/electron/tree/master/docs-translations/zh-CN)
|
||||
- [중국어 번체](https://github.com/electron/electron/tree/master/docs-translations/zh-TW)
|
||||
- [우크라이나어](https://github.com/electron/electron/tree/master/docs-translations/uk-UA)
|
||||
- [러시아어](https://github.com/electron/electron/tree/master/docs-translations/ru-RU)
|
||||
- [프랑스어](https://github.com/electron/electron/tree/master/docs-translations/fr-FR)
|
||||
- [브라질 포르투갈어](https://github.com/atom/electron/tree/master/docs-translations/pt-BR)
|
||||
- [한국어](https://github.com/atom/electron/tree/master/docs-translations/ko-KR)
|
||||
- [일본어](https://github.com/atom/electron/tree/master/docs-translations/jp)
|
||||
- [스페인어](https://github.com/atom/electron/tree/master/docs-translations/es)
|
||||
- [중국어 간체](https://github.com/atom/electron/tree/master/docs-translations/zh-CN)
|
||||
- [중국어 번체](https://github.com/atom/electron/tree/master/docs-translations/zh-TW)
|
||||
- [우크라이나어](https://github.com/atom/electron/tree/master/docs-translations/uk-UA)
|
||||
- [러시아어](https://github.com/atom/electron/tree/master/docs-translations/ru-RU)
|
||||
- [프랑스어](https://github.com/atom/electron/tree/master/docs-translations/fr-FR)
|
||||
|
||||
## 시작하기
|
||||
|
||||
[`atom/electron-quick-start`](https://github.com/electron/electron-quick-start)
|
||||
[`atom/electron-quick-start`](https://github.com/atom/electron-quick-start)
|
||||
저장소를 클론하여 Electron을 간단히 접해볼 수 있습니다.
|
||||
|
||||
## 커뮤니티
|
||||
|
||||
29
README.md
29
README.md
@@ -1,8 +1,7 @@
|
||||
[](http://electron.atom.io/)
|
||||
|
||||
[](https://travis-ci.org/electron/electron)
|
||||
[](https://ci.appveyor.com/project/Atom/electron)
|
||||
[](https://david-dm.org/electron/electron#info=devDependencies)
|
||||
[](https://travis-ci.org/atom/electron)
|
||||
[](https://david-dm.org/atom/electron#info=devDependencies)
|
||||
[](http://atom-slack.herokuapp.com/)
|
||||
|
||||
:zap: *Formerly known as Atom Shell* :zap:
|
||||
@@ -22,7 +21,7 @@ behavior to atom@github.com.
|
||||
## Downloads
|
||||
|
||||
Prebuilt binaries and debug symbols of Electron for Linux, Windows and OS X can
|
||||
be found on the [releases](https://github.com/electron/electron/releases) page.
|
||||
be found on the [releases](https://github.com/atom/electron/releases) page.
|
||||
|
||||
You can also use [`npm`](https://docs.npmjs.com/) to install prebuilt electron
|
||||
binaries:
|
||||
@@ -42,24 +41,24 @@ npm install electron-prebuilt --save-dev
|
||||
## Documentation
|
||||
|
||||
Guides and the API reference are located in the
|
||||
[docs](https://github.com/electron/electron/tree/master/docs) directory. It also
|
||||
[docs](https://github.com/atom/electron/tree/master/docs) directory. It also
|
||||
contains documents describing how to build and contribute to Electron.
|
||||
|
||||
## Documentation Translations
|
||||
|
||||
- [Brazilian Portuguese](https://github.com/electron/electron/tree/master/docs-translations/pt-BR)
|
||||
- [Korean](https://github.com/electron/electron/tree/master/docs-translations/ko-KR)
|
||||
- [Japanese](https://github.com/electron/electron/tree/master/docs-translations/jp)
|
||||
- [Spanish](https://github.com/electron/electron/tree/master/docs-translations/es)
|
||||
- [Simplified Chinese](https://github.com/electron/electron/tree/master/docs-translations/zh-CN)
|
||||
- [Traditional Chinese](https://github.com/electron/electron/tree/master/docs-translations/zh-TW)
|
||||
- [Ukrainian](https://github.com/electron/electron/tree/master/docs-translations/uk-UA)
|
||||
- [Russian](https://github.com/electron/electron/tree/master/docs-translations/ru-RU)
|
||||
- [French](https://github.com/electron/electron/tree/master/docs-translations/fr-FR)
|
||||
- [Brazilian Portuguese](https://github.com/atom/electron/tree/master/docs-translations/pt-BR)
|
||||
- [Korean](https://github.com/atom/electron/tree/master/docs-translations/ko-KR)
|
||||
- [Japanese](https://github.com/atom/electron/tree/master/docs-translations/jp)
|
||||
- [Spanish](https://github.com/atom/electron/tree/master/docs-translations/es)
|
||||
- [Simplified Chinese](https://github.com/atom/electron/tree/master/docs-translations/zh-CN)
|
||||
- [Traditional Chinese](https://github.com/atom/electron/tree/master/docs-translations/zh-TW)
|
||||
- [Ukrainian](https://github.com/atom/electron/tree/master/docs-translations/uk-UA)
|
||||
- [Russian](https://github.com/atom/electron/tree/master/docs-translations/ru-RU)
|
||||
- [French](https://github.com/atom/electron/tree/master/docs-translations/fr-FR)
|
||||
|
||||
## Quick Start
|
||||
|
||||
Clone and run the [`electron/electron-quick-start`](https://github.com/electron/electron-quick-start)
|
||||
Clone and run the [`atom/electron-quick-start`](https://github.com/atom/electron-quick-start)
|
||||
repository to see a minimal Electron app in action.
|
||||
|
||||
## Community
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
'product_name%': 'Electron',
|
||||
'company_name%': 'GitHub, Inc',
|
||||
'company_abbr%': 'github',
|
||||
'version%': '0.37.7',
|
||||
'version%': '0.36.12',
|
||||
},
|
||||
'includes': [
|
||||
'filenames.gypi',
|
||||
@@ -29,7 +29,6 @@
|
||||
'type': 'executable',
|
||||
'dependencies': [
|
||||
'js2asar',
|
||||
'app2asar',
|
||||
'<(project_name)_lib',
|
||||
],
|
||||
'sources': [
|
||||
@@ -67,6 +66,12 @@
|
||||
'<(PRODUCT_DIR)/<(product_name) Framework.framework',
|
||||
],
|
||||
},
|
||||
{
|
||||
'destination': '<(PRODUCT_DIR)/<(product_name).app/Contents/Resources',
|
||||
'files': [
|
||||
'default_app',
|
||||
],
|
||||
},
|
||||
],
|
||||
'postbuilds': [
|
||||
{
|
||||
@@ -87,7 +92,7 @@
|
||||
},
|
||||
# The application doesn't have real localizations, it just has
|
||||
# empty .lproj directories, which is enough to convince Cocoa
|
||||
# that Electron supports those languages.
|
||||
# atom-shell supports those languages.
|
||||
{
|
||||
'postbuild_name': 'Make Empty Localizations',
|
||||
'variables': {
|
||||
@@ -138,6 +143,7 @@
|
||||
],
|
||||
}, {
|
||||
'copied_libraries': [
|
||||
'<(libchromiumcontent_dir)/pdf.dll',
|
||||
'<(libchromiumcontent_dir)/ffmpeg.dll',
|
||||
],
|
||||
}],
|
||||
@@ -162,6 +168,12 @@
|
||||
'external_binaries/vccorlib120.dll',
|
||||
],
|
||||
},
|
||||
{
|
||||
'destination': '<(PRODUCT_DIR)/resources',
|
||||
'files': [
|
||||
'default_app',
|
||||
]
|
||||
},
|
||||
],
|
||||
}, {
|
||||
'dependencies': [
|
||||
@@ -197,6 +209,12 @@
|
||||
'<(libchromiumcontent_dir)/snapshot_blob.bin',
|
||||
],
|
||||
},
|
||||
{
|
||||
'destination': '<(PRODUCT_DIR)/resources',
|
||||
'files': [
|
||||
'default_app',
|
||||
]
|
||||
},
|
||||
],
|
||||
}], # OS=="linux"
|
||||
],
|
||||
@@ -310,9 +328,6 @@
|
||||
],
|
||||
}], # OS=="mac" and mas_build==1
|
||||
['OS=="linux"', {
|
||||
'sources': [
|
||||
'<@(lib_sources_nss)',
|
||||
],
|
||||
'link_settings': {
|
||||
'ldflags': [
|
||||
# Make binary search for libraries under current directory, so we
|
||||
@@ -356,49 +371,17 @@
|
||||
'<@(js_sources)',
|
||||
],
|
||||
'outputs': [
|
||||
'<(resources_path)/electron.asar',
|
||||
'<(resources_path)/atom.asar',
|
||||
],
|
||||
'action': [
|
||||
'python',
|
||||
'tools/js2asar.py',
|
||||
'<@(_outputs)',
|
||||
'lib',
|
||||
'<@(_inputs)',
|
||||
],
|
||||
}
|
||||
],
|
||||
}, # target js2asar
|
||||
{
|
||||
'target_name': 'app2asar',
|
||||
'type': 'none',
|
||||
'actions': [
|
||||
{
|
||||
'action_name': 'app2asar',
|
||||
'variables': {
|
||||
'conditions': [
|
||||
['OS=="mac"', {
|
||||
'resources_path': '<(PRODUCT_DIR)/<(product_name).app/Contents/Resources',
|
||||
},{
|
||||
'resources_path': '<(PRODUCT_DIR)/resources',
|
||||
}],
|
||||
],
|
||||
},
|
||||
'inputs': [
|
||||
'<@(default_app_sources)',
|
||||
],
|
||||
'outputs': [
|
||||
'<(resources_path)/default_app.asar',
|
||||
],
|
||||
'action': [
|
||||
'python',
|
||||
'tools/js2asar.py',
|
||||
'<@(_outputs)',
|
||||
'default_app',
|
||||
'<@(_inputs)',
|
||||
],
|
||||
}
|
||||
],
|
||||
}, # target app2asar
|
||||
{
|
||||
'target_name': 'atom_js2c',
|
||||
'type': 'none',
|
||||
@@ -507,7 +490,7 @@
|
||||
'action': [
|
||||
'install_name_tool',
|
||||
'-change',
|
||||
'/usr/local/lib/libffmpeg.dylib',
|
||||
'@loader_path/libffmpeg.dylib',
|
||||
'@rpath/libffmpeg.dylib',
|
||||
'${BUILT_PRODUCTS_DIR}/<(product_name) Framework.framework/Versions/A/<(product_name) Framework',
|
||||
],
|
||||
@@ -5,7 +5,7 @@
|
||||
#ifndef ATOM_APP_ATOM_LIBRARY_MAIN_H_
|
||||
#define ATOM_APP_ATOM_LIBRARY_MAIN_H_
|
||||
|
||||
#include "build/build_config.h"
|
||||
#include "base/basictypes.h"
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
extern "C" {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "atom/common/crash_reporter/win/crash_service_main.h"
|
||||
#include "base/environment.h"
|
||||
#include "base/win/windows_version.h"
|
||||
#include "content/public/app/sandbox_helper_win.h"
|
||||
#include "content/public/app/startup_helper_win.h"
|
||||
#include "sandbox/win/src/sandbox_types.h"
|
||||
#include "ui/gfx/win/dpi.h"
|
||||
#elif defined(OS_LINUX) // defined(OS_WIN)
|
||||
|
||||
@@ -98,6 +98,10 @@ void AtomMainDelegate::PreSandboxStartup() {
|
||||
std::string process_type = command_line->GetSwitchValueASCII(
|
||||
switches::kProcessType);
|
||||
|
||||
if (process_type == switches::kUtilityProcess) {
|
||||
AtomContentUtilityClient::PreSandboxStartup();
|
||||
}
|
||||
|
||||
// Only append arguments for browser process.
|
||||
if (!IsBrowserProcess(command_line))
|
||||
return;
|
||||
@@ -131,7 +135,7 @@ content::ContentUtilityClient* AtomMainDelegate::CreateContentUtilityClient() {
|
||||
}
|
||||
|
||||
scoped_ptr<brightray::ContentClient> AtomMainDelegate::CreateContentClient() {
|
||||
return scoped_ptr<brightray::ContentClient>(new AtomContentClient);
|
||||
return scoped_ptr<brightray::ContentClient>(new AtomContentClient).Pass();
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
||||
@@ -15,17 +15,15 @@
|
||||
#include "atom/browser/browser.h"
|
||||
#include "atom/browser/login_handler.h"
|
||||
#include "atom/common/native_mate_converters/callback.h"
|
||||
#include "atom/common/native_mate_converters/net_converter.h"
|
||||
#include "atom/common/native_mate_converters/file_path_converter.h"
|
||||
#include "atom/common/native_mate_converters/gurl_converter.h"
|
||||
#include "atom/common/native_mate_converters/image_converter.h"
|
||||
#include "atom/common/native_mate_converters/net_converter.h"
|
||||
#include "atom/common/native_mate_converters/value_converter.h"
|
||||
#include "atom/common/node_includes.h"
|
||||
#include "atom/common/options_switches.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/environment.h"
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/path_service.h"
|
||||
#include "brightray/browser/brightray_paths.h"
|
||||
#include "chrome/common/chrome_paths.h"
|
||||
@@ -159,39 +157,6 @@ void PassLoginInformation(scoped_refptr<LoginHandler> login_handler,
|
||||
login_handler->CancelAuth();
|
||||
}
|
||||
|
||||
#if defined(USE_NSS_CERTS)
|
||||
int ImportIntoCertStore(
|
||||
CertificateManagerModel* model,
|
||||
const base::DictionaryValue& options) {
|
||||
std::string file_data, cert_path;
|
||||
base::string16 password;
|
||||
net::CertificateList imported_certs;
|
||||
int rv = -1;
|
||||
options.GetString("certificate", &cert_path);
|
||||
options.GetString("password", &password);
|
||||
|
||||
if (!cert_path.empty()) {
|
||||
if (base::ReadFileToString(base::FilePath(cert_path), &file_data)) {
|
||||
auto module = model->cert_db()->GetPublicModule();
|
||||
rv = model->ImportFromPKCS12(module,
|
||||
file_data,
|
||||
password,
|
||||
true,
|
||||
&imported_certs);
|
||||
if (imported_certs.size() > 1) {
|
||||
auto it = imported_certs.begin();
|
||||
++it; // skip first which would be the client certificate.
|
||||
for (; it != imported_certs.end(); ++it)
|
||||
rv &= model->SetCertTrust(it->get(),
|
||||
net::CA_CERT,
|
||||
net::NSSCertDatabase::TRUSTED_SSL);
|
||||
}
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace
|
||||
|
||||
App::App() {
|
||||
@@ -264,25 +229,9 @@ void App::OnLogin(LoginHandler* login_handler) {
|
||||
login_handler->CancelAuth();
|
||||
}
|
||||
|
||||
void App::OnCreateWindow(const GURL& target_url,
|
||||
const std::string& frame_name,
|
||||
WindowOpenDisposition disposition,
|
||||
int render_process_id,
|
||||
int render_frame_id) {
|
||||
v8::Locker locker(isolate());
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
content::RenderFrameHost* rfh =
|
||||
content::RenderFrameHost::FromID(render_process_id, render_frame_id);
|
||||
content::WebContents* web_contents =
|
||||
content::WebContents::FromRenderFrameHost(rfh);
|
||||
if (web_contents) {
|
||||
auto api_web_contents = WebContents::CreateFrom(isolate(), web_contents);
|
||||
api_web_contents->OnCreateWindow(target_url, frame_name, disposition);
|
||||
}
|
||||
}
|
||||
|
||||
void App::AllowCertificateError(
|
||||
content::WebContents* web_contents,
|
||||
int pid,
|
||||
int fid,
|
||||
int cert_error,
|
||||
const net::SSLInfo& ssl_info,
|
||||
const GURL& request_url,
|
||||
@@ -292,6 +241,9 @@ void App::AllowCertificateError(
|
||||
bool expired_previous_decision,
|
||||
const base::Callback<void(bool)>& callback,
|
||||
content::CertificateRequestResultType* request) {
|
||||
auto rfh = content::RenderFrameHost::FromID(pid, fid);
|
||||
auto web_contents = content::WebContents::FromRenderFrameHost(rfh);
|
||||
|
||||
v8::Locker locker(isolate());
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
bool prevent_default = Emit("certificate-error",
|
||||
@@ -351,15 +303,10 @@ base::FilePath App::GetPath(mate::Arguments* args, const std::string& name) {
|
||||
void App::SetPath(mate::Arguments* args,
|
||||
const std::string& name,
|
||||
const base::FilePath& path) {
|
||||
if (!path.IsAbsolute()) {
|
||||
args->ThrowError("path must be absolute");
|
||||
return;
|
||||
}
|
||||
|
||||
bool succeed = false;
|
||||
int key = GetPathConstant(name);
|
||||
if (key >= 0)
|
||||
succeed = PathService::OverrideAndCreateIfNeeded(key, path, true, false);
|
||||
succeed = PathService::Override(key, path);
|
||||
if (!succeed)
|
||||
args->ThrowError("Failed to set path");
|
||||
}
|
||||
@@ -409,36 +356,6 @@ bool App::MakeSingleInstance(
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(USE_NSS_CERTS)
|
||||
void App::ImportCertificate(
|
||||
const base::DictionaryValue& options,
|
||||
const net::CompletionCallback& callback) {
|
||||
auto browser_context = AtomBrowserMainParts::Get()->browser_context();
|
||||
if (!certificate_manager_model_) {
|
||||
scoped_ptr<base::DictionaryValue> copy = options.CreateDeepCopy();
|
||||
CertificateManagerModel::Create(browser_context,
|
||||
base::Bind(&App::OnCertificateManagerModelCreated,
|
||||
base::Unretained(this),
|
||||
base::Passed(©),
|
||||
callback));
|
||||
return;
|
||||
}
|
||||
|
||||
int rv = ImportIntoCertStore(certificate_manager_model_.get(), options);
|
||||
callback.Run(rv);
|
||||
}
|
||||
|
||||
void App::OnCertificateManagerModelCreated(
|
||||
scoped_ptr<base::DictionaryValue> options,
|
||||
const net::CompletionCallback& callback,
|
||||
scoped_ptr<CertificateManagerModel> model) {
|
||||
certificate_manager_model_ = std::move(model);
|
||||
int rv = ImportIntoCertStore(certificate_manager_model_.get(),
|
||||
*(options.get()));
|
||||
callback.Run(rv);
|
||||
}
|
||||
#endif
|
||||
|
||||
mate::ObjectTemplateBuilder App::GetObjectTemplateBuilder(
|
||||
v8::Isolate* isolate) {
|
||||
auto browser = base::Unretained(Browser::Get());
|
||||
@@ -457,10 +374,6 @@ mate::ObjectTemplateBuilder App::GetObjectTemplateBuilder(
|
||||
base::Bind(&Browser::ClearRecentDocuments, browser))
|
||||
.SetMethod("setAppUserModelId",
|
||||
base::Bind(&Browser::SetAppUserModelID, browser))
|
||||
.SetMethod("setAsDefaultProtocolClient",
|
||||
base::Bind(&Browser::SetAsDefaultProtocolClient, browser))
|
||||
.SetMethod("removeAsDefaultProtocolClient",
|
||||
base::Bind(&Browser::RemoveAsDefaultProtocolClient, browser))
|
||||
#if defined(OS_MACOSX)
|
||||
.SetMethod("hide", base::Bind(&Browser::Hide, browser))
|
||||
.SetMethod("show", base::Bind(&Browser::Show, browser))
|
||||
@@ -478,9 +391,6 @@ mate::ObjectTemplateBuilder App::GetObjectTemplateBuilder(
|
||||
.SetMethod("allowNTLMCredentialsForAllDomains",
|
||||
&App::AllowNTLMCredentialsForAllDomains)
|
||||
.SetMethod("getLocale", &App::GetLocale)
|
||||
#if defined(USE_NSS_CERTS)
|
||||
.SetMethod("importCertificate", &App::ImportCertificate)
|
||||
#endif
|
||||
.SetMethod("makeSingleInstance", &App::MakeSingleInstance);
|
||||
}
|
||||
|
||||
@@ -500,6 +410,7 @@ void AppendSwitch(const std::string& switch_string, mate::Arguments* args) {
|
||||
auto command_line = base::CommandLine::ForCurrentProcess();
|
||||
|
||||
if (switch_string == atom::switches::kPpapiFlashPath ||
|
||||
switch_string == atom::switches::kClientCertificate ||
|
||||
switch_string == switches::kLogNetLog) {
|
||||
base::FilePath path;
|
||||
args->GetNext(&path);
|
||||
|
||||
@@ -14,11 +14,6 @@
|
||||
#include "chrome/browser/process_singleton.h"
|
||||
#include "content/public/browser/gpu_data_manager_observer.h"
|
||||
#include "native_mate/handle.h"
|
||||
#include "net/base/completion_callback.h"
|
||||
|
||||
#if defined(USE_NSS_CERTS)
|
||||
#include "chrome/browser/certificate_manager_model.h"
|
||||
#endif
|
||||
|
||||
namespace base {
|
||||
class FilePath;
|
||||
@@ -39,20 +34,6 @@ class App : public AtomBrowserClient::Delegate,
|
||||
public:
|
||||
static mate::Handle<App> Create(v8::Isolate* isolate);
|
||||
|
||||
// Called when window with disposition needs to be created.
|
||||
void OnCreateWindow(const GURL& target_url,
|
||||
const std::string& frame_name,
|
||||
WindowOpenDisposition disposition,
|
||||
int render_process_id,
|
||||
int render_frame_id);
|
||||
|
||||
#if defined(USE_NSS_CERTS)
|
||||
void OnCertificateManagerModelCreated(
|
||||
scoped_ptr<base::DictionaryValue> options,
|
||||
const net::CompletionCallback& callback,
|
||||
scoped_ptr<CertificateManagerModel> model);
|
||||
#endif
|
||||
|
||||
protected:
|
||||
App();
|
||||
virtual ~App();
|
||||
@@ -71,7 +52,8 @@ class App : public AtomBrowserClient::Delegate,
|
||||
|
||||
// content::ContentBrowserClient:
|
||||
void AllowCertificateError(
|
||||
content::WebContents* web_contents,
|
||||
int render_process_id,
|
||||
int render_frame_id,
|
||||
int cert_error,
|
||||
const net::SSLInfo& ssl_info,
|
||||
const GURL& request_url,
|
||||
@@ -110,21 +92,12 @@ class App : public AtomBrowserClient::Delegate,
|
||||
const ProcessSingleton::NotificationCallback& callback);
|
||||
std::string GetLocale();
|
||||
|
||||
#if defined(USE_NSS_CERTS)
|
||||
void ImportCertificate(const base::DictionaryValue& options,
|
||||
const net::CompletionCallback& callback);
|
||||
#endif
|
||||
|
||||
#if defined(OS_WIN)
|
||||
bool IsAeroGlassEnabled();
|
||||
#endif
|
||||
|
||||
scoped_ptr<ProcessSingleton> process_singleton_;
|
||||
|
||||
#if defined(USE_NSS_CERTS)
|
||||
scoped_ptr<CertificateManagerModel> certificate_manager_model_;
|
||||
#endif
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(App);
|
||||
};
|
||||
|
||||
|
||||
@@ -53,7 +53,13 @@ scoped_refptr<TracingController::TraceDataSink> GetTraceDataSink(
|
||||
|
||||
void StopRecording(const base::FilePath& path,
|
||||
const CompletionCallback& callback) {
|
||||
TracingController::GetInstance()->StopTracing(
|
||||
TracingController::GetInstance()->DisableRecording(
|
||||
GetTraceDataSink(path, callback));
|
||||
}
|
||||
|
||||
void CaptureMonitoringSnapshot(const base::FilePath& path,
|
||||
const CompletionCallback& callback) {
|
||||
TracingController::GetInstance()->CaptureMonitoringSnapshot(
|
||||
GetTraceDataSink(path, callback));
|
||||
}
|
||||
|
||||
@@ -64,8 +70,13 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
||||
dict.SetMethod("getCategories", base::Bind(
|
||||
&TracingController::GetCategories, controller));
|
||||
dict.SetMethod("startRecording", base::Bind(
|
||||
&TracingController::StartTracing, controller));
|
||||
&TracingController::EnableRecording, controller));
|
||||
dict.SetMethod("stopRecording", &StopRecording);
|
||||
dict.SetMethod("startMonitoring", base::Bind(
|
||||
&TracingController::EnableMonitoring, controller));
|
||||
dict.SetMethod("stopMonitoring", base::Bind(
|
||||
&TracingController::DisableMonitoring, controller));
|
||||
dict.SetMethod("captureMonitoringSnapshot", &CaptureMonitoringSnapshot);
|
||||
dict.SetMethod("getTraceBufferUsage", base::Bind(
|
||||
&TracingController::GetTraceBufferUsage, controller));
|
||||
dict.SetMethod("setWatchEvent", base::Bind(
|
||||
|
||||
@@ -180,8 +180,7 @@ void SetCookieOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
|
||||
|
||||
GetCookieStore(getter)->GetCookieMonster()->SetCookieWithDetailsAsync(
|
||||
GURL(url), name, value, domain, path, expiration_time, secure, http_only,
|
||||
false, false, false, net::COOKIE_PRIORITY_DEFAULT,
|
||||
base::Bind(OnSetCookie, callback));
|
||||
false, net::COOKIE_PRIORITY_DEFAULT, base::Bind(OnSetCookie, callback));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "atom/browser/api/atom_api_desktop_capturer.h"
|
||||
|
||||
#include "atom/common/api/atom_api_native_image.h"
|
||||
#include "atom/common/node_includes.h"
|
||||
#include "atom/common/native_mate_converters/gfx_converter.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "chrome/browser/media/desktop_media_list.h"
|
||||
@@ -13,8 +14,6 @@
|
||||
#include "third_party/webrtc/modules/desktop_capture/screen_capturer.h"
|
||||
#include "third_party/webrtc/modules/desktop_capture/window_capturer.h"
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
|
||||
namespace mate {
|
||||
|
||||
template<>
|
||||
@@ -64,8 +63,8 @@ void DesktopCapturer::StartHandling(bool capture_window,
|
||||
capture_screen ? webrtc::ScreenCapturer::Create(options) : nullptr);
|
||||
scoped_ptr<webrtc::WindowCapturer> window_capturer(
|
||||
capture_window ? webrtc::WindowCapturer::Create(options) : nullptr);
|
||||
media_list_.reset(new NativeDesktopMediaList(
|
||||
std::move(screen_capturer), std::move(window_capturer)));
|
||||
media_list_.reset(new NativeDesktopMediaList(screen_capturer.Pass(),
|
||||
window_capturer.Pass()));
|
||||
|
||||
media_list_->SetThumbnailSize(thumbnail_size);
|
||||
media_list_->StartUpdating(this);
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace {
|
||||
using WrapDownloadItemCallback = base::Callback<void(v8::Local<v8::Value>)>;
|
||||
WrapDownloadItemCallback g_wrap_download_item;
|
||||
|
||||
std::map<uint32_t, linked_ptr<v8::Global<v8::Value>>> g_download_item_objects;
|
||||
std::map<uint32, linked_ptr<v8::Global<v8::Value>>> g_download_item_objects;
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -106,11 +106,11 @@ void DownloadItem::Cancel() {
|
||||
download_item_->Remove();
|
||||
}
|
||||
|
||||
int64_t DownloadItem::GetReceivedBytes() const {
|
||||
int64 DownloadItem::GetReceivedBytes() const {
|
||||
return download_item_->GetReceivedBytes();
|
||||
}
|
||||
|
||||
int64_t DownloadItem::GetTotalBytes() const {
|
||||
int64 DownloadItem::GetTotalBytes() const {
|
||||
return download_item_->GetTotalBytes();
|
||||
}
|
||||
|
||||
|
||||
@@ -30,8 +30,8 @@ class DownloadItem : public mate::TrackableObject<DownloadItem>,
|
||||
void Pause();
|
||||
void Resume();
|
||||
void Cancel();
|
||||
int64_t GetReceivedBytes() const;
|
||||
int64_t GetTotalBytes() const;
|
||||
int64 GetReceivedBytes() const;
|
||||
int64 GetTotalBytes() const;
|
||||
std::string GetMimeType() const;
|
||||
bool HasUserGesture() const;
|
||||
std::string GetFilename() const;
|
||||
|
||||
@@ -117,7 +117,7 @@ class Protocol : public mate::Wrappable {
|
||||
scoped_ptr<CustomProtocolHandler<RequestJob>> protocol_handler(
|
||||
new CustomProtocolHandler<RequestJob>(
|
||||
isolate(), request_context_getter_, handler));
|
||||
if (job_factory_->SetProtocolHandler(scheme, std::move(protocol_handler)))
|
||||
if (job_factory_->SetProtocolHandler(scheme, protocol_handler.Pass()))
|
||||
return PROTOCOL_OK;
|
||||
else
|
||||
return PROTOCOL_FAIL;
|
||||
@@ -161,7 +161,7 @@ class Protocol : public mate::Wrappable {
|
||||
isolate(), request_context_getter_, handler));
|
||||
original_protocols_.set(
|
||||
scheme,
|
||||
job_factory_->ReplaceProtocol(scheme, std::move(protocol_handler)));
|
||||
job_factory_->ReplaceProtocol(scheme, protocol_handler.Pass()));
|
||||
return PROTOCOL_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,13 +23,12 @@
|
||||
#include "atom/common/native_mate_converters/net_converter.h"
|
||||
#include "atom/common/node_includes.h"
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/guid.h"
|
||||
#include "base/prefs/pref_service.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/thread_task_runner_handle.h"
|
||||
#include "brightray/browser/net/devtools_network_conditions.h"
|
||||
#include "brightray/browser/net/devtools_network_controller_handle.h"
|
||||
#include "brightray/browser/net/devtools_network_controller.h"
|
||||
#include "chrome/common/pref_names.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/storage_partition.h"
|
||||
@@ -50,12 +49,12 @@ namespace {
|
||||
|
||||
struct ClearStorageDataOptions {
|
||||
GURL origin;
|
||||
uint32_t storage_types = StoragePartition::REMOVE_DATA_MASK_ALL;
|
||||
uint32_t quota_types = StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL;
|
||||
uint32 storage_types = StoragePartition::REMOVE_DATA_MASK_ALL;
|
||||
uint32 quota_types = StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL;
|
||||
};
|
||||
|
||||
uint32_t GetStorageMask(const std::vector<std::string>& storage_types) {
|
||||
uint32_t storage_mask = 0;
|
||||
uint32 GetStorageMask(const std::vector<std::string>& storage_types) {
|
||||
uint32 storage_mask = 0;
|
||||
for (const auto& it : storage_types) {
|
||||
auto type = base::ToLowerASCII(it);
|
||||
if (type == "appcache")
|
||||
@@ -78,8 +77,8 @@ uint32_t GetStorageMask(const std::vector<std::string>& storage_types) {
|
||||
return storage_mask;
|
||||
}
|
||||
|
||||
uint32_t GetQuotaMask(const std::vector<std::string>& quota_types) {
|
||||
uint32_t quota_mask = 0;
|
||||
uint32 GetQuotaMask(const std::vector<std::string>& quota_types) {
|
||||
uint32 quota_mask = 0;
|
||||
for (const auto& it : quota_types) {
|
||||
auto type = base::ToLowerASCII(it);
|
||||
if (type == "temporary")
|
||||
@@ -289,8 +288,7 @@ void ClearHostResolverCacheInIO(
|
||||
} // namespace
|
||||
|
||||
Session::Session(AtomBrowserContext* browser_context)
|
||||
: devtools_network_emulation_client_id_(base::GenerateGUID()),
|
||||
browser_context_(browser_context) {
|
||||
: browser_context_(browser_context) {
|
||||
AttachAsUserData(browser_context);
|
||||
|
||||
// Observe DownloadManger to get download notifications.
|
||||
@@ -383,19 +381,25 @@ void Session::EnableNetworkEmulation(const mate::Dictionary& options) {
|
||||
download_throughput,
|
||||
upload_throughput));
|
||||
}
|
||||
auto controller = browser_context_->GetDevToolsNetworkController();
|
||||
|
||||
browser_context_->network_controller_handle()->SetNetworkState(
|
||||
devtools_network_emulation_client_id_, std::move(conditions));
|
||||
browser_context_->network_delegate()->SetDevToolsNetworkEmulationClientId(
|
||||
devtools_network_emulation_client_id_);
|
||||
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
|
||||
base::Bind(&brightray::DevToolsNetworkController::SetNetworkState,
|
||||
base::Unretained(controller),
|
||||
std::string(),
|
||||
base::Passed(&conditions)));
|
||||
}
|
||||
|
||||
void Session::DisableNetworkEmulation() {
|
||||
scoped_ptr<brightray::DevToolsNetworkConditions> conditions;
|
||||
browser_context_->network_controller_handle()->SetNetworkState(
|
||||
devtools_network_emulation_client_id_, std::move(conditions));
|
||||
browser_context_->network_delegate()->SetDevToolsNetworkEmulationClientId(
|
||||
std::string());
|
||||
scoped_ptr<brightray::DevToolsNetworkConditions> conditions(
|
||||
new brightray::DevToolsNetworkConditions(false));
|
||||
auto controller = browser_context_->GetDevToolsNetworkController();
|
||||
|
||||
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
|
||||
base::Bind(&brightray::DevToolsNetworkController::SetNetworkState,
|
||||
base::Unretained(controller),
|
||||
std::string(),
|
||||
base::Passed(&conditions)));
|
||||
}
|
||||
|
||||
void Session::SetCertVerifyProc(v8::Local<v8::Value> val,
|
||||
|
||||
@@ -86,9 +86,6 @@ class Session: public mate::TrackableObject<Session>,
|
||||
v8::Global<v8::Value> cookies_;
|
||||
v8::Global<v8::Value> web_request_;
|
||||
|
||||
// The X-DevTools-Emulate-Network-Conditions-Client-Id.
|
||||
std::string devtools_network_emulation_client_id_;
|
||||
|
||||
scoped_refptr<AtomBrowserContext> browser_context_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(Session);
|
||||
|
||||
@@ -13,16 +13,12 @@
|
||||
#include "atom/browser/atom_browser_client.h"
|
||||
#include "atom/browser/atom_browser_context.h"
|
||||
#include "atom/browser/atom_browser_main_parts.h"
|
||||
#include "atom/browser/atom_security_state_model_client.h"
|
||||
#include "atom/browser/native_window.h"
|
||||
#include "atom/browser/net/atom_network_delegate.h"
|
||||
#include "atom/browser/web_contents_permission_helper.h"
|
||||
#include "atom/browser/web_contents_preferences.h"
|
||||
#include "atom/browser/web_view_guest_delegate.h"
|
||||
#include "atom/common/api/api_messages.h"
|
||||
#include "atom/common/api/event_emitter_caller.h"
|
||||
#include "atom/common/color_util.h"
|
||||
#include "atom/common/mouse_util.h"
|
||||
#include "atom/common/native_mate_converters/blink_converter.h"
|
||||
#include "atom/common/native_mate_converters/callback.h"
|
||||
#include "atom/common/native_mate_converters/content_converter.h"
|
||||
@@ -32,14 +28,13 @@
|
||||
#include "atom/common/native_mate_converters/image_converter.h"
|
||||
#include "atom/common/native_mate_converters/string16_converter.h"
|
||||
#include "atom/common/native_mate_converters/value_converter.h"
|
||||
#include "atom/common/options_switches.h"
|
||||
#include "atom/common/mouse_util.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "brightray/browser/inspectable_web_contents.h"
|
||||
#include "brightray/browser/inspectable_web_contents_view.h"
|
||||
#include "chrome/browser/printing/print_view_manager_basic.h"
|
||||
#include "chrome/browser/printing/print_preview_message_handler.h"
|
||||
#include "content/browser/renderer_host/render_widget_host_impl.h"
|
||||
#include "content/common/view_messages.h"
|
||||
#include "content/public/browser/favicon_status.h"
|
||||
#include "content/public/browser/native_web_keyboard_event.h"
|
||||
@@ -49,7 +44,6 @@
|
||||
#include "content/public/browser/render_frame_host.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
#include "content/public/browser/render_widget_host.h"
|
||||
#include "content/public/browser/render_widget_host_view.h"
|
||||
#include "content/public/browser/resource_request_details.h"
|
||||
#include "content/public/browser/service_worker_context.h"
|
||||
@@ -156,7 +150,7 @@ struct Converter<net::HttpResponseHeaders*> {
|
||||
} else {
|
||||
scoped_ptr<base::ListValue> values(new base::ListValue());
|
||||
values->AppendString(value);
|
||||
response_headers.Set(key, std::move(values));
|
||||
response_headers.Set(key, values.Pass());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -217,10 +211,7 @@ content::ServiceWorkerContext* GetServiceWorkerContext(
|
||||
|
||||
WebContents::WebContents(content::WebContents* web_contents)
|
||||
: content::WebContentsObserver(web_contents),
|
||||
embedder_(nullptr),
|
||||
type_(REMOTE),
|
||||
request_id_(0),
|
||||
background_throttling_(true) {
|
||||
type_(REMOTE) {
|
||||
AttachAsUserData(web_contents);
|
||||
web_contents->SetUserAgentOverride(GetBrowserContext()->GetUserAgent());
|
||||
}
|
||||
@@ -228,11 +219,7 @@ WebContents::WebContents(content::WebContents* web_contents)
|
||||
WebContents::WebContents(v8::Isolate* isolate,
|
||||
const mate::Dictionary& options)
|
||||
: embedder_(nullptr),
|
||||
request_id_(0),
|
||||
background_throttling_(true) {
|
||||
// Read options.
|
||||
options.Get("backgroundThrottling", &background_throttling_);
|
||||
|
||||
request_id_(0) {
|
||||
// Whether it is a guest WebContents.
|
||||
bool is_guest = false;
|
||||
options.Get("isGuest", &is_guest);
|
||||
@@ -280,8 +267,6 @@ WebContents::WebContents(v8::Isolate* isolate,
|
||||
|
||||
// Intialize permission helper.
|
||||
WebContentsPermissionHelper::CreateForWebContents(web_contents);
|
||||
// Intialize security state client.
|
||||
AtomSecurityStateModelClient::CreateForWebContents(web_contents);
|
||||
|
||||
web_contents->SetUserAgentOverride(GetBrowserContext()->GetUserAgent());
|
||||
|
||||
@@ -318,9 +303,9 @@ WebContents::~WebContents() {
|
||||
}
|
||||
|
||||
bool WebContents::AddMessageToConsole(content::WebContents* source,
|
||||
int32_t level,
|
||||
int32 level,
|
||||
const base::string16& message,
|
||||
int32_t line_no,
|
||||
int32 line_no,
|
||||
const base::string16& source_id) {
|
||||
if (type_ == BROWSER_WINDOW) {
|
||||
return false;
|
||||
@@ -330,13 +315,20 @@ bool WebContents::AddMessageToConsole(content::WebContents* source,
|
||||
}
|
||||
}
|
||||
|
||||
void WebContents::OnCreateWindow(const GURL& target_url,
|
||||
const std::string& frame_name,
|
||||
WindowOpenDisposition disposition) {
|
||||
bool WebContents::ShouldCreateWebContents(
|
||||
content::WebContents* web_contents,
|
||||
int route_id,
|
||||
int main_frame_route_id,
|
||||
WindowContainerType window_container_type,
|
||||
const std::string& frame_name,
|
||||
const GURL& target_url,
|
||||
const std::string& partition_id,
|
||||
content::SessionStorageNamespace* session_storage_namespace) {
|
||||
if (type_ == BROWSER_WINDOW)
|
||||
Emit("-new-window", target_url, frame_name, disposition);
|
||||
Emit("-new-window", target_url, frame_name, NEW_FOREGROUND_TAB);
|
||||
else
|
||||
Emit("new-window", target_url, frame_name, disposition);
|
||||
Emit("new-window", target_url, frame_name, NEW_FOREGROUND_TAB);
|
||||
return false;
|
||||
}
|
||||
|
||||
content::WebContents* WebContents::OpenURLFromTab(
|
||||
@@ -462,7 +454,6 @@ void WebContents::FindReply(content::WebContents* web_contents,
|
||||
result.Set("requestId", request_id);
|
||||
result.Set("selectionArea", selection_rect);
|
||||
result.Set("finalUpdate", final_update);
|
||||
result.Set("activeMatchOrdinal", active_match_ordinal);
|
||||
Emit("found-in-page", result);
|
||||
} else if (final_update) {
|
||||
result.Set("requestId", request_id);
|
||||
@@ -518,11 +509,11 @@ void WebContents::PluginCrashed(const base::FilePath& plugin_path,
|
||||
Emit("plugin-crashed", info.name, info.version);
|
||||
}
|
||||
|
||||
void WebContents::MediaStartedPlaying(const MediaPlayerId& id) {
|
||||
void WebContents::MediaStartedPlaying() {
|
||||
Emit("media-started-playing");
|
||||
}
|
||||
|
||||
void WebContents::MediaStoppedPlaying(const MediaPlayerId& id) {
|
||||
void WebContents::MediaPaused() {
|
||||
Emit("media-paused");
|
||||
}
|
||||
|
||||
@@ -552,21 +543,18 @@ void WebContents::DidFinishLoad(content::RenderFrameHost* render_frame_host,
|
||||
void WebContents::DidFailProvisionalLoad(
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const GURL& url,
|
||||
int code,
|
||||
const base::string16& description,
|
||||
int error_code,
|
||||
const base::string16& error_description,
|
||||
bool was_ignored_by_handler) {
|
||||
bool is_main_frame = !render_frame_host->GetParent();
|
||||
Emit("did-fail-provisional-load", code, description, url, is_main_frame);
|
||||
Emit("did-fail-load", code, description, url, is_main_frame);
|
||||
Emit("did-fail-provisional-load", error_code, error_description, url);
|
||||
}
|
||||
|
||||
void WebContents::DidFailLoad(content::RenderFrameHost* render_frame_host,
|
||||
const GURL& url,
|
||||
const GURL& validated_url,
|
||||
int error_code,
|
||||
const base::string16& error_description,
|
||||
bool was_ignored_by_handler) {
|
||||
bool is_main_frame = !render_frame_host->GetParent();
|
||||
Emit("did-fail-load", error_code, error_description, url, is_main_frame);
|
||||
Emit("did-fail-load", error_code, error_description, validated_url);
|
||||
}
|
||||
|
||||
void WebContents::DidStartLoading() {
|
||||
@@ -586,8 +574,7 @@ void WebContents::DidGetResourceResponseStart(
|
||||
details.http_response_code,
|
||||
details.method,
|
||||
details.referrer,
|
||||
details.headers.get(),
|
||||
ResourceTypeToString(details.resource_type));
|
||||
details.headers.get());
|
||||
}
|
||||
|
||||
void WebContents::DidGetRedirectForResourceRequest(
|
||||
@@ -633,10 +620,6 @@ void WebContents::DidUpdateFaviconURL(
|
||||
Emit("page-favicon-updated", unique_urls);
|
||||
}
|
||||
|
||||
void WebContents::DevToolsReloadPage() {
|
||||
Emit("devtools-reload-page");
|
||||
}
|
||||
|
||||
void WebContents::DevToolsFocused() {
|
||||
Emit("devtools-focused");
|
||||
}
|
||||
@@ -727,8 +710,7 @@ void WebContents::LoadURL(const GURL& url, const mate::Dictionary& options) {
|
||||
Emit("did-fail-load",
|
||||
static_cast<int>(net::ERR_INVALID_URL),
|
||||
net::ErrorToShortString(net::ERR_INVALID_URL),
|
||||
url.possibly_invalid_spec(),
|
||||
true);
|
||||
url.possibly_invalid_spec());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -751,25 +733,6 @@ void WebContents::LoadURL(const GURL& url, const mate::Dictionary& options) {
|
||||
params.should_clear_history_list = true;
|
||||
params.override_user_agent = content::NavigationController::UA_OVERRIDE_TRUE;
|
||||
web_contents()->GetController().LoadURLWithParams(params);
|
||||
|
||||
// Set the background color of RenderWidgetHostView.
|
||||
// We have to call it right after LoadURL because the RenderViewHost is only
|
||||
// created after loading a page.
|
||||
const auto view = web_contents()->GetRenderWidgetHostView();
|
||||
WebContentsPreferences* web_preferences =
|
||||
WebContentsPreferences::FromWebContents(web_contents());
|
||||
std::string color_name;
|
||||
if (web_preferences->web_preferences()->GetString(options::kBackgroundColor,
|
||||
&color_name)) {
|
||||
view->SetBackgroundColor(ParseHexColor(color_name));
|
||||
} else {
|
||||
view->SetBackgroundColor(SK_ColorTRANSPARENT);
|
||||
}
|
||||
|
||||
// For the same reason we can only disable hidden here.
|
||||
const auto host = static_cast<content::RenderWidgetHostImpl*>(
|
||||
view->GetRenderWidgetHost());
|
||||
host->disable_hidden_ = !background_throttling_;
|
||||
}
|
||||
|
||||
void WebContents::DownloadURL(const GURL& url) {
|
||||
@@ -793,14 +756,6 @@ bool WebContents::IsLoading() const {
|
||||
return web_contents()->IsLoading();
|
||||
}
|
||||
|
||||
bool WebContents::IsLoadingMainFrame() const {
|
||||
// Comparing site instances works because Electron always creates a new site
|
||||
// instance when navigating, regardless of origin. See AtomBrowserClient.
|
||||
return (web_contents()->GetLastCommittedURL().is_empty() ||
|
||||
web_contents()->GetSiteInstance() !=
|
||||
web_contents()->GetPendingSiteInstance()) && IsLoading();
|
||||
}
|
||||
|
||||
bool WebContents::IsWaitingForResponse() const {
|
||||
return web_contents()->IsWaitingForResponse();
|
||||
}
|
||||
@@ -857,20 +812,14 @@ void WebContents::OpenDevTools(mate::Arguments* args) {
|
||||
if (type_ == REMOTE)
|
||||
return;
|
||||
|
||||
std::string state;
|
||||
bool detach = false;
|
||||
if (type_ == WEB_VIEW) {
|
||||
state = "detach";
|
||||
detach = true;
|
||||
} else if (args && args->Length() == 1) {
|
||||
bool detach = false;
|
||||
mate::Dictionary options;
|
||||
if (args->GetNext(&options)) {
|
||||
options.Get("mode", &state);
|
||||
options.Get("detach", &detach);
|
||||
if (state.empty() && detach)
|
||||
state = "detach";
|
||||
}
|
||||
args->GetNext(&options) && options.Get("detach", &detach);
|
||||
}
|
||||
managed_web_contents()->SetDockState(state);
|
||||
managed_web_contents()->SetCanDock(!detach);
|
||||
managed_web_contents()->ShowDevTools();
|
||||
}
|
||||
|
||||
@@ -1049,8 +998,8 @@ void WebContents::ReplaceMisspelling(const base::string16& word) {
|
||||
web_contents()->ReplaceMisspelling(word);
|
||||
}
|
||||
|
||||
uint32_t WebContents::FindInPage(mate::Arguments* args) {
|
||||
uint32_t request_id = GetNextRequestId();
|
||||
uint32 WebContents::FindInPage(mate::Arguments* args) {
|
||||
uint32 request_id = GetNextRequestId();
|
||||
base::string16 search_text;
|
||||
blink::WebFindOptions options;
|
||||
if (!args->GetNext(&search_text) || search_text.empty()) {
|
||||
@@ -1121,7 +1070,7 @@ void WebContents::BeginFrameSubscription(
|
||||
if (view) {
|
||||
scoped_ptr<FrameSubscriber> frame_subscriber(new FrameSubscriber(
|
||||
isolate(), view, callback));
|
||||
view->BeginFrameSubscription(std::move(frame_subscriber));
|
||||
view->BeginFrameSubscription(frame_subscriber.Pass());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1149,6 +1098,11 @@ void WebContents::SetSize(const SetSizeParams& params) {
|
||||
guest_delegate_->SetSize(params);
|
||||
}
|
||||
|
||||
void WebContents::SetAllowTransparency(bool allow) {
|
||||
if (guest_delegate_)
|
||||
guest_delegate_->SetAllowTransparency(allow);
|
||||
}
|
||||
|
||||
bool WebContents::IsGuest() const {
|
||||
return type_ == WEB_VIEW;
|
||||
}
|
||||
@@ -1203,7 +1157,6 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
|
||||
.SetMethod("_getURL", &WebContents::GetURL)
|
||||
.SetMethod("getTitle", &WebContents::GetTitle)
|
||||
.SetMethod("isLoading", &WebContents::IsLoading)
|
||||
.SetMethod("isLoadingMainFrame", &WebContents::IsLoadingMainFrame)
|
||||
.SetMethod("isWaitingForResponse", &WebContents::IsWaitingForResponse)
|
||||
.SetMethod("_stop", &WebContents::Stop)
|
||||
.SetMethod("_goBack", &WebContents::GoBack)
|
||||
@@ -1247,6 +1200,7 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
|
||||
&WebContents::BeginFrameSubscription)
|
||||
.SetMethod("endFrameSubscription", &WebContents::EndFrameSubscription)
|
||||
.SetMethod("setSize", &WebContents::SetSize)
|
||||
.SetMethod("setAllowTransparency", &WebContents::SetAllowTransparency)
|
||||
.SetMethod("isGuest", &WebContents::IsGuest)
|
||||
.SetMethod("getWebPreferences", &WebContents::GetWebPreferences)
|
||||
.SetMethod("getOwnerBrowserWindow", &WebContents::GetOwnerBrowserWindow)
|
||||
|
||||
@@ -62,7 +62,6 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
GURL GetURL() const;
|
||||
base::string16 GetTitle() const;
|
||||
bool IsLoading() const;
|
||||
bool IsLoadingMainFrame() const;
|
||||
bool IsWaitingForResponse() const;
|
||||
void Stop();
|
||||
void ReloadIgnoringCache();
|
||||
@@ -111,7 +110,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
void Unselect();
|
||||
void Replace(const base::string16& word);
|
||||
void ReplaceMisspelling(const base::string16& word);
|
||||
uint32_t FindInPage(mate::Arguments* args);
|
||||
uint32 FindInPage(mate::Arguments* args);
|
||||
void StopFindInPage(content::StopFindAction action);
|
||||
|
||||
// Focus.
|
||||
@@ -132,6 +131,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
|
||||
// Methods for creating <webview>.
|
||||
void SetSize(const SetSizeParams& params);
|
||||
void SetAllowTransparency(bool allow);
|
||||
bool IsGuest() const;
|
||||
|
||||
// Callback triggered on permission response.
|
||||
@@ -139,11 +139,6 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
const GURL& origin,
|
||||
bool allowed);
|
||||
|
||||
// Create window with the given disposition.
|
||||
void OnCreateWindow(const GURL& target_url,
|
||||
const std::string& frame_name,
|
||||
WindowOpenDisposition disposition);
|
||||
|
||||
// Returns the web preferences of current WebContents.
|
||||
v8::Local<v8::Value> GetWebPreferences(v8::Isolate* isolate);
|
||||
|
||||
@@ -167,10 +162,19 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
|
||||
// content::WebContentsDelegate:
|
||||
bool AddMessageToConsole(content::WebContents* source,
|
||||
int32_t level,
|
||||
int32 level,
|
||||
const base::string16& message,
|
||||
int32_t line_no,
|
||||
int32 line_no,
|
||||
const base::string16& source_id) override;
|
||||
bool ShouldCreateWebContents(
|
||||
content::WebContents* web_contents,
|
||||
int route_id,
|
||||
int main_frame_route_id,
|
||||
WindowContainerType window_container_type,
|
||||
const std::string& frame_name,
|
||||
const GURL& target_url,
|
||||
const std::string& partition_id,
|
||||
content::SessionStorageNamespace* session_storage_namespace) override;
|
||||
content::WebContents* OpenURLFromTab(
|
||||
content::WebContents* source,
|
||||
const content::OpenURLParams& params) override;
|
||||
@@ -248,13 +252,10 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
const std::vector<content::FaviconURL>& urls) override;
|
||||
void PluginCrashed(const base::FilePath& plugin_path,
|
||||
base::ProcessId plugin_pid) override;
|
||||
void MediaStartedPlaying(const MediaPlayerId& id) override;
|
||||
void MediaStoppedPlaying(const MediaPlayerId& id) override;
|
||||
void MediaStartedPlaying() override;
|
||||
void MediaPaused() override;
|
||||
void DidChangeThemeColor(SkColor theme_color) override;
|
||||
|
||||
// brightray::InspectableWebContentsDelegate:
|
||||
void DevToolsReloadPage() override;
|
||||
|
||||
// brightray::InspectableWebContentsViewDelegate:
|
||||
void DevToolsFocused() override;
|
||||
void DevToolsOpened() override;
|
||||
@@ -269,7 +270,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
|
||||
AtomBrowserContext* GetBrowserContext() const;
|
||||
|
||||
uint32_t GetNextRequestId() {
|
||||
uint32 GetNextRequestId() {
|
||||
return ++request_id_;
|
||||
}
|
||||
|
||||
@@ -298,10 +299,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
Type type_;
|
||||
|
||||
// Request id used for findInPage request.
|
||||
uint32_t request_id_;
|
||||
|
||||
// Whether background throttling is disabled.
|
||||
bool background_throttling_;
|
||||
uint32 request_id_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(WebContents);
|
||||
};
|
||||
|
||||
@@ -52,11 +52,6 @@ namespace api {
|
||||
|
||||
namespace {
|
||||
|
||||
// This function is implemented in JavaScript
|
||||
using DeprecatedOptionsCheckCallback =
|
||||
base::Callback<std::string(v8::Local<v8::Value>)>;
|
||||
DeprecatedOptionsCheckCallback g_deprecated_options_check;
|
||||
|
||||
void OnCapturePageDone(
|
||||
v8::Isolate* isolate,
|
||||
const base::Callback<void(const gfx::Image&)>& callback,
|
||||
@@ -141,10 +136,6 @@ Window::Window(v8::Isolate* isolate, const mate::Dictionary& options) {
|
||||
if (options.Get(options::kZoomFactor, &value))
|
||||
web_preferences.Set(options::kZoomFactor, value);
|
||||
|
||||
// Copy the backgroundColor to webContents.
|
||||
if (options.Get(options::kBackgroundColor, &value))
|
||||
web_preferences.Set(options::kBackgroundColor, value);
|
||||
|
||||
// Creates the WebContents used by BrowserWindow.
|
||||
auto web_contents = WebContents::Create(isolate, web_preferences);
|
||||
web_contents_.Reset(isolate, web_contents.ToV8());
|
||||
@@ -252,10 +243,6 @@ void Window::OnWindowScrollTouchEnd() {
|
||||
Emit("scroll-touch-end");
|
||||
}
|
||||
|
||||
void Window::OnWindowSwipe(const std::string& direction) {
|
||||
Emit("swipe", direction);
|
||||
}
|
||||
|
||||
void Window::OnWindowEnterHtmlFullScreen() {
|
||||
Emit("enter-html-full-screen");
|
||||
}
|
||||
@@ -304,13 +291,6 @@ mate::Wrappable* Window::New(v8::Isolate* isolate, mate::Arguments* args) {
|
||||
options = mate::Dictionary::CreateEmpty(isolate);
|
||||
}
|
||||
|
||||
std::string deprecation_message = g_deprecated_options_check.Run(
|
||||
options.GetHandle());
|
||||
if (deprecation_message.length() > 0) {
|
||||
args->ThrowError(deprecation_message);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new Window(isolate, options);
|
||||
}
|
||||
|
||||
@@ -440,10 +420,6 @@ std::vector<int> Window::GetMaximumSize() {
|
||||
return result;
|
||||
}
|
||||
|
||||
void Window::SetSheetOffset(double offset) {
|
||||
window_->SetSheetOffset(offset);
|
||||
}
|
||||
|
||||
void Window::SetResizable(bool resizable) {
|
||||
window_->SetResizable(resizable);
|
||||
}
|
||||
@@ -750,7 +726,6 @@ void Window::BuildPrototype(v8::Isolate* isolate,
|
||||
.SetMethod("getMinimumSize", &Window::GetMinimumSize)
|
||||
.SetMethod("setMaximumSize", &Window::SetMaximumSize)
|
||||
.SetMethod("getMaximumSize", &Window::GetMaximumSize)
|
||||
.SetMethod("setSheetOffset", &Window::SetSheetOffset)
|
||||
.SetMethod("setResizable", &Window::SetResizable)
|
||||
.SetMethod("isResizable", &Window::IsResizable)
|
||||
.SetMethod("setMovable", &Window::SetMovable)
|
||||
@@ -822,10 +797,6 @@ v8::Local<v8::Value> Window::From(v8::Isolate* isolate,
|
||||
return v8::Null(isolate);
|
||||
}
|
||||
|
||||
void SetDeprecatedOptionsCheck(const DeprecatedOptionsCheckCallback& callback) {
|
||||
g_deprecated_options_check = callback;
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
|
||||
} // namespace atom
|
||||
@@ -848,8 +819,6 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
||||
|
||||
mate::Dictionary dict(isolate, exports);
|
||||
dict.Set("BrowserWindow", browser_window);
|
||||
dict.SetMethod("_setDeprecatedOptionsCheck",
|
||||
&atom::api::SetDeprecatedOptionsCheck);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -69,7 +69,6 @@ class Window : public mate::TrackableObject<Window>,
|
||||
void OnWindowMoved() override;
|
||||
void OnWindowScrollTouchBegin() override;
|
||||
void OnWindowScrollTouchEnd() override;
|
||||
void OnWindowSwipe(const std::string& direction) override;
|
||||
void OnWindowEnterFullScreen() override;
|
||||
void OnWindowLeaveFullScreen() override;
|
||||
void OnWindowEnterHtmlFullScreen() override;
|
||||
@@ -110,7 +109,6 @@ class Window : public mate::TrackableObject<Window>,
|
||||
std::vector<int> GetMinimumSize();
|
||||
void SetMaximumSize(int width, int height);
|
||||
std::vector<int> GetMaximumSize();
|
||||
void SetSheetOffset(double offset);
|
||||
void SetResizable(bool resizable);
|
||||
bool IsResizable();
|
||||
void SetMovable(bool movable);
|
||||
|
||||
@@ -54,7 +54,7 @@ void FrameSubscriber::OnFrameDelivered(const FrameCaptureCallback& callback,
|
||||
return;
|
||||
|
||||
bitmap.copyPixelsTo(
|
||||
reinterpret_cast<uint8_t*>(node::Buffer::Data(buffer.ToLocalChecked())),
|
||||
reinterpret_cast<uint8*>(node::Buffer::Data(buffer.ToLocalChecked())),
|
||||
rgb_arr_size);
|
||||
|
||||
callback_.Run(buffer.ToLocalChecked());
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include <shlobj.h>
|
||||
#endif
|
||||
|
||||
#include "atom/browser/api/atom_api_app.h"
|
||||
#include "atom/browser/atom_access_token_store.h"
|
||||
#include "atom/browser/atom_browser_context.h"
|
||||
#include "atom/browser/atom_browser_main_parts.h"
|
||||
@@ -37,6 +36,7 @@
|
||||
#include "content/public/browser/site_instance.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/common/web_preferences.h"
|
||||
#include "net/cert/x509_certificate.h"
|
||||
#include "net/ssl/ssl_cert_request_info.h"
|
||||
#include "ppapi/host/ppapi_host.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
@@ -46,6 +46,11 @@ namespace atom {
|
||||
|
||||
namespace {
|
||||
|
||||
// The default routing id of WebContents.
|
||||
// In Electron each RenderProcessHost only has one WebContents, so this ID is
|
||||
// same for every WebContents.
|
||||
int kDefaultRoutingID = 2;
|
||||
|
||||
// Next navigation should not restart renderer process.
|
||||
bool g_suppress_renderer_process_restart = false;
|
||||
|
||||
@@ -54,6 +59,26 @@ std::string g_custom_schemes = "";
|
||||
// Custom schemes to be registered to handle service worker.
|
||||
std::string g_custom_service_worker_schemes = "";
|
||||
|
||||
scoped_refptr<net::X509Certificate> ImportCertFromFile(
|
||||
const base::FilePath& path) {
|
||||
if (path.empty())
|
||||
return nullptr;
|
||||
|
||||
std::string cert_data;
|
||||
if (!base::ReadFileToString(path, &cert_data))
|
||||
return nullptr;
|
||||
|
||||
net::CertificateList certs =
|
||||
net::X509Certificate::CreateCertificateListFromBytes(
|
||||
cert_data.data(), cert_data.size(),
|
||||
net::X509Certificate::FORMAT_AUTO);
|
||||
|
||||
if (certs.empty())
|
||||
return nullptr;
|
||||
|
||||
return certs[0];
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
@@ -176,10 +201,16 @@ void AtomBrowserClient::AppendExtraCommandLineSwitches(
|
||||
if (ContainsKey(pending_processes_, process_id))
|
||||
process_id = pending_processes_[process_id];
|
||||
|
||||
|
||||
// Certain render process will be created with no associated render view,
|
||||
// for example: ServiceWorker.
|
||||
auto rvh = content::RenderViewHost::FromID(process_id, kDefaultRoutingID);
|
||||
if (!rvh)
|
||||
return;
|
||||
|
||||
// Get the WebContents of the render process.
|
||||
content::WebContents* web_contents =
|
||||
WebContentsPreferences::GetWebContentsFromProcessID(process_id);
|
||||
content::WebContents::FromRenderViewHost(rvh);
|
||||
if (!web_contents)
|
||||
return;
|
||||
|
||||
@@ -199,7 +230,8 @@ content::QuotaPermissionContext*
|
||||
}
|
||||
|
||||
void AtomBrowserClient::AllowCertificateError(
|
||||
content::WebContents* web_contents,
|
||||
int render_process_id,
|
||||
int render_frame_id,
|
||||
int cert_error,
|
||||
const net::SSLInfo& ssl_info,
|
||||
const GURL& request_url,
|
||||
@@ -211,7 +243,7 @@ void AtomBrowserClient::AllowCertificateError(
|
||||
content::CertificateRequestResultType* request) {
|
||||
if (delegate_) {
|
||||
delegate_->AllowCertificateError(
|
||||
web_contents, cert_error, ssl_info, request_url,
|
||||
render_process_id, render_frame_id, cert_error, ssl_info, request_url,
|
||||
resource_type, overridable, strict_enforcement,
|
||||
expired_previous_decision, callback, request);
|
||||
}
|
||||
@@ -221,9 +253,19 @@ void AtomBrowserClient::SelectClientCertificate(
|
||||
content::WebContents* web_contents,
|
||||
net::SSLCertRequestInfo* cert_request_info,
|
||||
scoped_ptr<content::ClientCertificateDelegate> delegate) {
|
||||
// --client-certificate=`path`
|
||||
auto cmd = base::CommandLine::ForCurrentProcess();
|
||||
if (cmd->HasSwitch(switches::kClientCertificate)) {
|
||||
auto cert_path = cmd->GetSwitchValuePath(switches::kClientCertificate);
|
||||
auto certificate = ImportCertFromFile(cert_path);
|
||||
if (certificate.get())
|
||||
delegate->ContinueWithCertificate(certificate.get());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!cert_request_info->client_certs.empty() && delegate_) {
|
||||
delegate_->SelectClientCertificate(
|
||||
web_contents, cert_request_info, std::move(delegate));
|
||||
web_contents, cert_request_info, delegate.Pass());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,39 +276,6 @@ void AtomBrowserClient::ResourceDispatcherHostCreated() {
|
||||
resource_dispatcher_host_delegate_.get());
|
||||
}
|
||||
|
||||
bool AtomBrowserClient::CanCreateWindow(
|
||||
const GURL& opener_url,
|
||||
const GURL& opener_top_level_frame_url,
|
||||
const GURL& source_origin,
|
||||
WindowContainerType container_type,
|
||||
const std::string& frame_name,
|
||||
const GURL& target_url,
|
||||
const content::Referrer& referrer,
|
||||
WindowOpenDisposition disposition,
|
||||
const blink::WebWindowFeatures& features,
|
||||
bool user_gesture,
|
||||
bool opener_suppressed,
|
||||
content::ResourceContext* context,
|
||||
int render_process_id,
|
||||
int opener_render_view_id,
|
||||
int opener_render_frame_id,
|
||||
bool* no_javascript_access) {
|
||||
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
|
||||
|
||||
if (delegate_) {
|
||||
content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
|
||||
base::Bind(&api::App::OnCreateWindow,
|
||||
base::Unretained(static_cast<api::App*>(delegate_)),
|
||||
target_url,
|
||||
frame_name,
|
||||
disposition,
|
||||
render_process_id,
|
||||
opener_render_frame_id));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
brightray::BrowserMainParts* AtomBrowserClient::OverrideCreateBrowserMainParts(
|
||||
const content::MainFunctionParams&) {
|
||||
v8::V8::Initialize(); // Init V8 before creating main parts.
|
||||
@@ -276,8 +285,8 @@ brightray::BrowserMainParts* AtomBrowserClient::OverrideCreateBrowserMainParts(
|
||||
void AtomBrowserClient::WebNotificationAllowed(
|
||||
int render_process_id,
|
||||
const base::Callback<void(bool)>& callback) {
|
||||
content::WebContents* web_contents =
|
||||
WebContentsPreferences::GetWebContentsFromProcessID(render_process_id);
|
||||
content::WebContents* web_contents = content::WebContents::FromRenderViewHost(
|
||||
content::RenderViewHost::FromID(render_process_id, kDefaultRoutingID));
|
||||
if (!web_contents) {
|
||||
callback.Run(false);
|
||||
return;
|
||||
|
||||
@@ -61,7 +61,8 @@ class AtomBrowserClient : public brightray::BrowserClient,
|
||||
void DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host) override;
|
||||
content::QuotaPermissionContext* CreateQuotaPermissionContext() override;
|
||||
void AllowCertificateError(
|
||||
content::WebContents* web_contents,
|
||||
int render_process_id,
|
||||
int render_frame_id,
|
||||
int cert_error,
|
||||
const net::SSLInfo& ssl_info,
|
||||
const GURL& request_url,
|
||||
@@ -76,22 +77,6 @@ class AtomBrowserClient : public brightray::BrowserClient,
|
||||
net::SSLCertRequestInfo* cert_request_info,
|
||||
scoped_ptr<content::ClientCertificateDelegate> delegate) override;
|
||||
void ResourceDispatcherHostCreated() override;
|
||||
bool CanCreateWindow(const GURL& opener_url,
|
||||
const GURL& opener_top_level_frame_url,
|
||||
const GURL& source_origin,
|
||||
WindowContainerType container_type,
|
||||
const std::string& frame_name,
|
||||
const GURL& target_url,
|
||||
const content::Referrer& referrer,
|
||||
WindowOpenDisposition disposition,
|
||||
const blink::WebWindowFeatures& features,
|
||||
bool user_gesture,
|
||||
bool opener_suppressed,
|
||||
content::ResourceContext* context,
|
||||
int render_process_id,
|
||||
int opener_render_view_id,
|
||||
int opener_render_frame_id,
|
||||
bool* no_javascript_access) override;
|
||||
|
||||
// brightray::BrowserClient:
|
||||
brightray::BrowserMainParts* OverrideCreateBrowserMainParts(
|
||||
|
||||
@@ -65,7 +65,7 @@ std::string RemoveWhitespace(const std::string& str) {
|
||||
AtomBrowserContext::AtomBrowserContext(const std::string& partition,
|
||||
bool in_memory)
|
||||
: brightray::BrowserContext(partition, in_memory),
|
||||
cert_verifier_(new AtomCertVerifier),
|
||||
cert_verifier_(nullptr),
|
||||
job_factory_(new AtomURLRequestJobFactory),
|
||||
network_delegate_(new AtomNetworkDelegate),
|
||||
allow_ntlm_everywhere_(false) {
|
||||
@@ -134,15 +134,14 @@ AtomBrowserContext::CreateURLRequestJobFactory(
|
||||
new net::FtpNetworkLayer(host_resolver))));
|
||||
|
||||
// Set up interceptors in the reverse order.
|
||||
scoped_ptr<net::URLRequestJobFactory> top_job_factory =
|
||||
std::move(job_factory);
|
||||
scoped_ptr<net::URLRequestJobFactory> top_job_factory = job_factory.Pass();
|
||||
content::URLRequestInterceptorScopedVector::reverse_iterator it;
|
||||
for (it = interceptors->rbegin(); it != interceptors->rend(); ++it)
|
||||
top_job_factory.reset(new net::URLRequestInterceptingJobFactory(
|
||||
std::move(top_job_factory), make_scoped_ptr(*it)));
|
||||
top_job_factory.Pass(), make_scoped_ptr(*it)));
|
||||
interceptors->weak_clear();
|
||||
|
||||
return top_job_factory;
|
||||
return top_job_factory.Pass();
|
||||
}
|
||||
|
||||
net::HttpCache::BackendFactory*
|
||||
@@ -178,6 +177,8 @@ content::PermissionManager* AtomBrowserContext::GetPermissionManager() {
|
||||
}
|
||||
|
||||
scoped_ptr<net::CertVerifier> AtomBrowserContext::CreateCertVerifier() {
|
||||
DCHECK(!cert_verifier_);
|
||||
cert_verifier_ = new AtomCertVerifier;
|
||||
return make_scoped_ptr(cert_verifier_);
|
||||
}
|
||||
|
||||
@@ -192,7 +193,6 @@ void AtomBrowserContext::RegisterPrefs(PrefRegistrySimple* pref_registry) {
|
||||
PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS, &download_dir);
|
||||
pref_registry->RegisterFilePathPref(prefs::kDownloadDefaultDirectory,
|
||||
download_dir);
|
||||
pref_registry->RegisterDictionaryPref(prefs::kDevToolsFileSystemPaths);
|
||||
}
|
||||
|
||||
bool AtomBrowserContext::AllowNTLMCredentialsForDomain(const GURL& origin) {
|
||||
|
||||
@@ -46,14 +46,6 @@ AtomBrowserMainParts::AtomBrowserMainParts()
|
||||
}
|
||||
|
||||
AtomBrowserMainParts::~AtomBrowserMainParts() {
|
||||
// Leak the JavascriptEnvironment on exit.
|
||||
// This is to work around the bug that V8 would be waiting for background
|
||||
// tasks to finish on exit, while somehow it waits forever in Electron, more
|
||||
// about this can be found at https://github.com/electron/electron/issues/4767.
|
||||
// On the other handle there is actually no need to gracefully shutdown V8
|
||||
// on exit in the main process, we already ensured all necessary resources get
|
||||
// cleaned up, and it would make quitting faster.
|
||||
ignore_result(js_env_.release());
|
||||
}
|
||||
|
||||
// static
|
||||
@@ -106,21 +98,17 @@ void AtomBrowserMainParts::PostEarlyInitialization() {
|
||||
node_debugger_.reset(new NodeDebugger(js_env_->isolate()));
|
||||
|
||||
// Create the global environment.
|
||||
node::Environment* env =
|
||||
node_bindings_->CreateEnvironment(js_env_->context());
|
||||
global_env = node_bindings_->CreateEnvironment(js_env_->context());
|
||||
|
||||
// Make sure node can get correct environment when debugging.
|
||||
if (node_debugger_->IsRunning())
|
||||
env->AssignToContext(v8::Debug::GetDebugContext());
|
||||
global_env->AssignToContext(v8::Debug::GetDebugContext());
|
||||
|
||||
// Add atom-shell extended APIs.
|
||||
atom_bindings_->BindTo(js_env_->isolate(), env->process_object());
|
||||
atom_bindings_->BindTo(js_env_->isolate(), global_env->process_object());
|
||||
|
||||
// Load everything.
|
||||
node_bindings_->LoadEnvironment(env);
|
||||
|
||||
// Wrap the uv loop with global env.
|
||||
node_bindings_->set_uv_env(env);
|
||||
node_bindings_->LoadEnvironment(global_env);
|
||||
}
|
||||
|
||||
void AtomBrowserMainParts::PreMainMessageLoopRun() {
|
||||
@@ -136,8 +124,9 @@ void AtomBrowserMainParts::PreMainMessageLoopRun() {
|
||||
// Start idle gc.
|
||||
gc_timer_.Start(
|
||||
FROM_HERE, base::TimeDelta::FromMinutes(1),
|
||||
base::Bind(&v8::Isolate::LowMemoryNotification,
|
||||
base::Unretained(js_env_->isolate())));
|
||||
base::Bind(base::IgnoreResult(&v8::Isolate::IdleNotification),
|
||||
base::Unretained(js_env_->isolate()),
|
||||
1000));
|
||||
|
||||
brightray::BrowserMainParts::PreMainMessageLoopRun();
|
||||
bridge_task_runner_->MessageLoopIsReady();
|
||||
@@ -183,6 +172,14 @@ void AtomBrowserMainParts::PostMainMessageLoopRun() {
|
||||
++iter;
|
||||
callback.Run();
|
||||
}
|
||||
|
||||
// Destroy JavaScript environment immediately after running destruction
|
||||
// callbacks.
|
||||
gc_timer_.Stop();
|
||||
node_debugger_.reset();
|
||||
atom_bindings_.reset();
|
||||
node_bindings_.reset();
|
||||
js_env_.reset();
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
||||
@@ -60,7 +60,7 @@ void AtomDownloadManagerDelegate::CreateDownloadPath(
|
||||
}
|
||||
|
||||
void AtomDownloadManagerDelegate::OnDownloadPathGenerated(
|
||||
uint32_t download_id,
|
||||
uint32 download_id,
|
||||
const content::DownloadTargetCallback& callback,
|
||||
const base::FilePath& default_path) {
|
||||
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
||||
@@ -160,7 +160,7 @@ bool AtomDownloadManagerDelegate::ShouldOpenDownload(
|
||||
|
||||
void AtomDownloadManagerDelegate::GetNextId(
|
||||
const content::DownloadIdCallback& callback) {
|
||||
static uint32_t next_id = content::DownloadItem::kInvalidId + 1;
|
||||
static uint32 next_id = content::DownloadItem::kInvalidId + 1;
|
||||
callback.Run(next_id++);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ class AtomDownloadManagerDelegate : public content::DownloadManagerDelegate {
|
||||
const std::string& mime_type,
|
||||
const base::FilePath& path,
|
||||
const CreateDownloadPathCallback& callback);
|
||||
void OnDownloadPathGenerated(uint32_t download_id,
|
||||
void OnDownloadPathGenerated(uint32 download_id,
|
||||
const content::DownloadTargetCallback& callback,
|
||||
const base::FilePath& default_path);
|
||||
|
||||
|
||||
@@ -4,9 +4,6 @@
|
||||
|
||||
#include "atom/browser/atom_permission_manager.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "atom/browser/web_contents_preferences.h"
|
||||
#include "content/public/browser/child_process_security_policy.h"
|
||||
#include "content/public/browser/permission_type.h"
|
||||
#include "content/public/browser/render_frame_host.h"
|
||||
@@ -18,12 +15,17 @@ namespace atom {
|
||||
|
||||
namespace {
|
||||
|
||||
// Must be kept in sync with atom_browser_client.cc
|
||||
int kDefaultRoutingID = 2;
|
||||
|
||||
bool WebContentsDestroyed(int process_id) {
|
||||
auto contents =
|
||||
WebContentsPreferences::GetWebContentsFromProcessID(process_id);
|
||||
if (!contents)
|
||||
return true;
|
||||
return contents->IsBeingDestroyed();
|
||||
auto rvh = content::RenderViewHost::FromID(process_id, kDefaultRoutingID);
|
||||
if (rvh) {
|
||||
auto contents = content::WebContents::FromRenderViewHost(rvh);
|
||||
return contents->IsBeingDestroyed();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -78,26 +80,6 @@ int AtomPermissionManager::RequestPermission(
|
||||
return kNoPendingOperation;
|
||||
}
|
||||
|
||||
int AtomPermissionManager::RequestPermissions(
|
||||
const std::vector<content::PermissionType>& permissions,
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const GURL& requesting_origin,
|
||||
bool user_gesture,
|
||||
const base::Callback<void(
|
||||
const std::vector<content::PermissionStatus>&)>& callback) {
|
||||
// FIXME(zcbenz): Just ignore multiple permissions request for now.
|
||||
std::vector<content::PermissionStatus> permissionStatuses;
|
||||
for (auto permission : permissions) {
|
||||
if (permission == content::PermissionType::MIDI_SYSEX) {
|
||||
content::ChildProcessSecurityPolicy::GetInstance()->
|
||||
GrantSendMidiSysExMessage(render_frame_host->GetProcess()->GetID());
|
||||
}
|
||||
permissionStatuses.push_back(content::PERMISSION_STATUS_GRANTED);
|
||||
}
|
||||
callback.Run(permissionStatuses);
|
||||
return kNoPendingOperation;
|
||||
}
|
||||
|
||||
void AtomPermissionManager::OnPermissionResponse(
|
||||
int request_id,
|
||||
const GURL& origin,
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#define ATOM_BROWSER_ATOM_PERMISSION_MANAGER_H_
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include "base/callback.h"
|
||||
#include "content/public/browser/permission_manager.h"
|
||||
@@ -39,13 +38,6 @@ class AtomPermissionManager : public content::PermissionManager {
|
||||
const GURL& requesting_origin,
|
||||
bool user_gesture,
|
||||
const ResponseCallback& callback) override;
|
||||
int RequestPermissions(
|
||||
const std::vector<content::PermissionType>& permissions,
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const GURL& requesting_origin,
|
||||
bool user_gesture,
|
||||
const base::Callback<void(
|
||||
const std::vector<content::PermissionStatus>&)>& callback) override;
|
||||
|
||||
protected:
|
||||
void OnPermissionResponse(int request_id,
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "atom/browser/atom_resource_dispatcher_host_delegate.h"
|
||||
|
||||
#include "atom/browser/login_handler.h"
|
||||
#include "atom/browser/web_contents_permission_helper.h"
|
||||
#include "atom/common/platform_util.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "net/base/escape.h"
|
||||
@@ -15,46 +14,20 @@ using content::BrowserThread;
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace {
|
||||
|
||||
void OnOpenExternal(const GURL& escaped_url,
|
||||
bool allowed) {
|
||||
if (allowed)
|
||||
platform_util::OpenExternal(escaped_url, true);
|
||||
}
|
||||
|
||||
void HandleExternalProtocolInUI(
|
||||
const GURL& url,
|
||||
const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter,
|
||||
bool has_user_gesture) {
|
||||
content::WebContents* web_contents = web_contents_getter.Run();
|
||||
if (!web_contents)
|
||||
return;
|
||||
|
||||
GURL escaped_url(net::EscapeExternalHandlerValue(url.spec()));
|
||||
auto callback = base::Bind(&OnOpenExternal, escaped_url);
|
||||
auto permission_helper =
|
||||
WebContentsPermissionHelper::FromWebContents(web_contents);
|
||||
permission_helper->RequestOpenExternalPermission(callback, has_user_gesture);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
AtomResourceDispatcherHostDelegate::AtomResourceDispatcherHostDelegate() {
|
||||
}
|
||||
|
||||
bool AtomResourceDispatcherHostDelegate::HandleExternalProtocol(
|
||||
const GURL& url,
|
||||
int child_id,
|
||||
const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter,
|
||||
int render_process_id,
|
||||
int render_view_id,
|
||||
bool is_main_frame,
|
||||
ui::PageTransition transition,
|
||||
bool has_user_gesture) {
|
||||
GURL escaped_url(net::EscapeExternalHandlerValue(url.spec()));
|
||||
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
|
||||
base::Bind(&HandleExternalProtocolInUI,
|
||||
url,
|
||||
web_contents_getter,
|
||||
has_user_gesture));
|
||||
base::Bind(
|
||||
base::IgnoreResult(platform_util::OpenExternal), escaped_url, true));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,13 +15,12 @@ class AtomResourceDispatcherHostDelegate
|
||||
AtomResourceDispatcherHostDelegate();
|
||||
|
||||
// content::ResourceDispatcherHostDelegate:
|
||||
bool HandleExternalProtocol(
|
||||
const GURL& url,
|
||||
int child_id,
|
||||
const content::ResourceRequestInfo::WebContentsGetter&,
|
||||
bool is_main_frame,
|
||||
ui::PageTransition transition,
|
||||
bool has_user_gesture) override;
|
||||
bool HandleExternalProtocol(const GURL& url,
|
||||
int render_process_id,
|
||||
int render_view_id,
|
||||
bool is_main_frame,
|
||||
ui::PageTransition transition,
|
||||
bool has_user_gesture) override;
|
||||
content::ResourceDispatcherHostLoginDelegate* CreateLoginDelegate(
|
||||
net::AuthChallengeInfo* auth_info,
|
||||
net::URLRequest* request) override;
|
||||
|
||||
@@ -1,105 +0,0 @@
|
||||
// Copyright (c) 2016 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/browser/atom_security_state_model_client.h"
|
||||
|
||||
#include "content/public/browser/cert_store.h"
|
||||
#include "content/public/browser/navigation_entry.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/common/origin_util.h"
|
||||
#include "content/public/common/ssl_status.h"
|
||||
#include "net/cert/x509_certificate.h"
|
||||
|
||||
DEFINE_WEB_CONTENTS_USER_DATA_KEY(atom::AtomSecurityStateModelClient);
|
||||
|
||||
using security_state::SecurityStateModel;
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace {
|
||||
|
||||
SecurityStateModel::SecurityLevel GetSecurityLevelForSecurityStyle(
|
||||
content::SecurityStyle style) {
|
||||
switch (style) {
|
||||
case content::SECURITY_STYLE_UNKNOWN:
|
||||
return SecurityStateModel::NONE;
|
||||
case content::SECURITY_STYLE_UNAUTHENTICATED:
|
||||
return SecurityStateModel::NONE;
|
||||
case content::SECURITY_STYLE_AUTHENTICATION_BROKEN:
|
||||
return SecurityStateModel::SECURITY_ERROR;
|
||||
case content::SECURITY_STYLE_WARNING:
|
||||
return SecurityStateModel::SECURITY_WARNING;
|
||||
case content::SECURITY_STYLE_AUTHENTICATED:
|
||||
return SecurityStateModel::SECURE;
|
||||
}
|
||||
return SecurityStateModel::NONE;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
AtomSecurityStateModelClient::AtomSecurityStateModelClient(
|
||||
content::WebContents* web_contents)
|
||||
: web_contents_(web_contents),
|
||||
security_state_model_(new SecurityStateModel()) {
|
||||
security_state_model_->SetClient(this);
|
||||
}
|
||||
|
||||
AtomSecurityStateModelClient::~AtomSecurityStateModelClient() {
|
||||
}
|
||||
|
||||
const SecurityStateModel::SecurityInfo&
|
||||
AtomSecurityStateModelClient::GetSecurityInfo() const {
|
||||
return security_state_model_->GetSecurityInfo();
|
||||
}
|
||||
|
||||
bool AtomSecurityStateModelClient::RetrieveCert(
|
||||
scoped_refptr<net::X509Certificate>* cert) {
|
||||
content::NavigationEntry* entry =
|
||||
web_contents_->GetController().GetVisibleEntry();
|
||||
if (!entry)
|
||||
return false;
|
||||
return content::CertStore::GetInstance()->RetrieveCert(
|
||||
entry->GetSSL().cert_id, cert);
|
||||
}
|
||||
|
||||
bool AtomSecurityStateModelClient::UsedPolicyInstalledCertificate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AtomSecurityStateModelClient::IsOriginSecure(const GURL& url) {
|
||||
return content::IsOriginSecure(url);
|
||||
}
|
||||
|
||||
void AtomSecurityStateModelClient::GetVisibleSecurityState(
|
||||
SecurityStateModel::VisibleSecurityState* state) {
|
||||
content::NavigationEntry* entry =
|
||||
web_contents_->GetController().GetVisibleEntry();
|
||||
if (!entry ||
|
||||
entry->GetSSL().security_style == content::SECURITY_STYLE_UNKNOWN) {
|
||||
*state = SecurityStateModel::VisibleSecurityState();
|
||||
return;
|
||||
}
|
||||
|
||||
state->initialized = true;
|
||||
state->url = entry->GetURL();
|
||||
const content::SSLStatus& ssl = entry->GetSSL();
|
||||
state->initial_security_level =
|
||||
GetSecurityLevelForSecurityStyle(ssl.security_style);
|
||||
state->cert_id = ssl.cert_id;
|
||||
state->cert_status = ssl.cert_status;
|
||||
state->connection_status = ssl.connection_status;
|
||||
state->security_bits = ssl.security_bits;
|
||||
state->sct_verify_statuses.clear();
|
||||
for (const auto& sct : ssl.signed_certificate_timestamp_ids)
|
||||
state->sct_verify_statuses.push_back(sct.status);
|
||||
state->displayed_mixed_content =
|
||||
(ssl.content_status & content::SSLStatus::DISPLAYED_INSECURE_CONTENT)
|
||||
? true
|
||||
: false;
|
||||
state->ran_mixed_content =
|
||||
(ssl.content_status & content::SSLStatus::RAN_INSECURE_CONTENT) ? true
|
||||
: false;
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
@@ -1,42 +0,0 @@
|
||||
// Copyright (c) 2016 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_BROWSER_ATOM_SECURITY_STATE_MODEL_CLIENT_H_
|
||||
#define ATOM_BROWSER_ATOM_SECURITY_STATE_MODEL_CLIENT_H_
|
||||
|
||||
#include "components/security_state/security_state_model.h"
|
||||
#include "components/security_state/security_state_model_client.h"
|
||||
#include "content/public/browser/web_contents_user_data.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
class AtomSecurityStateModelClient
|
||||
: public security_state::SecurityStateModelClient,
|
||||
public content::WebContentsUserData<AtomSecurityStateModelClient> {
|
||||
public:
|
||||
~AtomSecurityStateModelClient() override;
|
||||
|
||||
const security_state::SecurityStateModel::SecurityInfo&
|
||||
GetSecurityInfo() const;
|
||||
|
||||
// security_state::SecurityStateModelClient:
|
||||
void GetVisibleSecurityState(
|
||||
security_state::SecurityStateModel::VisibleSecurityState* state) override;
|
||||
bool RetrieveCert(scoped_refptr<net::X509Certificate>* cert) override;
|
||||
bool UsedPolicyInstalledCertificate() override;
|
||||
bool IsOriginSecure(const GURL& url) override;
|
||||
|
||||
private:
|
||||
explicit AtomSecurityStateModelClient(content::WebContents* web_contents);
|
||||
friend class content::WebContentsUserData<AtomSecurityStateModelClient>;
|
||||
|
||||
content::WebContents* web_contents_;
|
||||
scoped_ptr<security_state::SecurityStateModel> security_state_model_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomSecurityStateModelClient);
|
||||
};
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_BROWSER_ATOM_SECURITY_STATE_MODEL_CLIENT_H_
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "content/public/browser/speech_recognition_event_listener.h"
|
||||
#include "content/public/browser/speech_recognition_manager_delegate.h"
|
||||
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "build/build_config.h"
|
||||
#include "base/basictypes.h"
|
||||
|
||||
namespace base {
|
||||
class Time;
|
||||
|
||||
@@ -15,7 +15,6 @@ namespace atom {
|
||||
|
||||
Browser::Browser()
|
||||
: is_quiting_(false),
|
||||
is_exiting_(false),
|
||||
is_ready_(false),
|
||||
is_shutdown_(false) {
|
||||
WindowList::AddObserver(this);
|
||||
@@ -50,12 +49,9 @@ void Browser::Exit(int code) {
|
||||
// Message loop is not ready, quit directly.
|
||||
exit(code);
|
||||
} else {
|
||||
// Prepare to quit when all windows have been closed.
|
||||
// Prepare to quit when all windows have been closed..
|
||||
is_quiting_ = true;
|
||||
|
||||
// Remember this caller so that we don't emit unrelated events.
|
||||
is_exiting_ = true;
|
||||
|
||||
// Must destroy windows before quitting, otherwise bad things can happen.
|
||||
atom::WindowList* window_list = atom::WindowList::GetInstance();
|
||||
if (window_list->size() == 0) {
|
||||
@@ -179,9 +175,7 @@ void Browser::OnWindowCloseCancelled(NativeWindow* window) {
|
||||
}
|
||||
|
||||
void Browser::OnWindowAllClosed() {
|
||||
if (is_exiting_)
|
||||
Shutdown();
|
||||
else if (is_quiting_)
|
||||
if (is_quiting_)
|
||||
NotifyAndShutdown();
|
||||
else
|
||||
FOR_EACH_OBSERVER(BrowserObserver, observers_, OnWindowAllClosed());
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "base/basictypes.h"
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/observer_list.h"
|
||||
#include "base/strings/string16.h"
|
||||
@@ -76,12 +76,6 @@ class Browser : public WindowListObserver {
|
||||
// Set the application user model ID.
|
||||
void SetAppUserModelID(const base::string16& name);
|
||||
|
||||
// Remove the default protocol handler registry key
|
||||
bool RemoveAsDefaultProtocolClient(const std::string& protocol);
|
||||
|
||||
// Set as default handler for a protocol.
|
||||
bool SetAsDefaultProtocolClient(const std::string& protocol);
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
// Hide the application.
|
||||
void Hide();
|
||||
@@ -189,13 +183,10 @@ class Browser : public WindowListObserver {
|
||||
// Observers of the browser.
|
||||
base::ObserverList<BrowserObserver> observers_;
|
||||
|
||||
// Whether `app.exit()` has been called
|
||||
bool is_exiting_;
|
||||
|
||||
// Whether "ready" event has been emitted.
|
||||
bool is_ready_;
|
||||
|
||||
// The browser is being shutdown.
|
||||
// The browse is being shutdown.
|
||||
bool is_shutdown_;
|
||||
|
||||
std::string version_override_;
|
||||
|
||||
@@ -34,14 +34,6 @@ void Browser::ClearRecentDocuments() {
|
||||
void Browser::SetAppUserModelID(const base::string16& name) {
|
||||
}
|
||||
|
||||
bool Browser::RemoveAsDefaultProtocolClient(const std::string& protocol) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Browser::SetAsDefaultProtocolClient(const std::string& protocol) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string Browser::GetExecutableFileVersion() const {
|
||||
return brightray::GetApplicationVersion();
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include "atom/browser/mac/atom_application_delegate.h"
|
||||
#include "atom/browser/native_window.h"
|
||||
#include "atom/browser/window_list.h"
|
||||
#include "base/mac/bundle_locations.h"
|
||||
#include "base/mac/foundation_util.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "brightray/common/application_info.h"
|
||||
@@ -46,25 +45,6 @@ void Browser::ClearRecentDocuments() {
|
||||
[[NSDocumentController sharedDocumentController] clearRecentDocuments:nil];
|
||||
}
|
||||
|
||||
bool Browser::RemoveAsDefaultProtocolClient(const std::string& protocol) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Browser::SetAsDefaultProtocolClient(const std::string& protocol) {
|
||||
if (protocol.empty())
|
||||
return false;
|
||||
|
||||
NSString* identifier = [base::mac::MainBundle() bundleIdentifier];
|
||||
if (!identifier)
|
||||
return false;
|
||||
|
||||
NSString* protocol_ns = [NSString stringWithUTF8String:protocol.c_str()];
|
||||
OSStatus return_code =
|
||||
LSSetDefaultHandlerForURLScheme(base::mac::NSToCFCast(protocol_ns),
|
||||
base::mac::NSToCFCast(identifier));
|
||||
return return_code == noErr;
|
||||
}
|
||||
|
||||
void Browser::SetAppUserModelID(const base::string16& name) {
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/win/win_util.h"
|
||||
#include "base/win/registry.h"
|
||||
#include "base/win/windows_version.h"
|
||||
#include "atom/common/atom_version.h"
|
||||
|
||||
@@ -126,105 +125,6 @@ void Browser::SetUserTasks(const std::vector<UserTask>& tasks) {
|
||||
destinations->CommitList();
|
||||
}
|
||||
|
||||
bool Browser::RemoveAsDefaultProtocolClient(const std::string& protocol) {
|
||||
if (protocol.empty())
|
||||
return false;
|
||||
|
||||
base::FilePath path;
|
||||
if (!PathService::Get(base::FILE_EXE, &path)) {
|
||||
LOG(ERROR) << "Error getting app exe path";
|
||||
return false;
|
||||
}
|
||||
|
||||
// Main Registry Key
|
||||
HKEY root = HKEY_CURRENT_USER;
|
||||
std::string keyPathStr = "Software\\Classes\\" + protocol;
|
||||
std::wstring keyPath = std::wstring(keyPathStr.begin(), keyPathStr.end());
|
||||
|
||||
// Command Key
|
||||
std::string cmdPathStr = keyPathStr + "\\shell\\open\\command";
|
||||
std::wstring cmdPath = std::wstring(cmdPathStr.begin(), cmdPathStr.end());
|
||||
|
||||
base::win::RegKey key;
|
||||
base::win::RegKey commandKey;
|
||||
if (FAILED(key.Open(root, keyPath.c_str(), KEY_ALL_ACCESS)))
|
||||
// Key doesn't even exist, we can confirm that it is not set
|
||||
return true;
|
||||
|
||||
if (FAILED(commandKey.Open(root, cmdPath.c_str(), KEY_ALL_ACCESS)))
|
||||
// Key doesn't even exist, we can confirm that it is not set
|
||||
return true;
|
||||
|
||||
std::wstring keyVal;
|
||||
if (FAILED(commandKey.ReadValue(L"", &keyVal)))
|
||||
// Default value not set, we can confirm that it is not set
|
||||
return true;
|
||||
|
||||
std::wstring exePath(path.value());
|
||||
std::wstring exe = L"\"" + exePath + L"\" \"%1\"";
|
||||
if (keyVal == exe) {
|
||||
// Let's kill the key
|
||||
if (FAILED(key.DeleteKey(L"shell")))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool Browser::SetAsDefaultProtocolClient(const std::string& protocol) {
|
||||
// HKEY_CLASSES_ROOT
|
||||
// $PROTOCOL
|
||||
// (Default) = "URL:$NAME"
|
||||
// URL Protocol = ""
|
||||
// shell
|
||||
// open
|
||||
// command
|
||||
// (Default) = "$COMMAND" "%1"
|
||||
//
|
||||
// However, the "HKEY_CLASSES_ROOT" key can only be written by the
|
||||
// Administrator user. So, we instead write to "HKEY_CURRENT_USER\
|
||||
// Software\Classes", which is inherited by "HKEY_CLASSES_ROOT"
|
||||
// anyway, and can be written by unprivileged users.
|
||||
|
||||
if (protocol.empty())
|
||||
return false;
|
||||
|
||||
base::FilePath path;
|
||||
if (!PathService::Get(base::FILE_EXE, &path)) {
|
||||
LOG(ERROR) << "Error getting app exe path";
|
||||
return false;
|
||||
}
|
||||
|
||||
// Main Registry Key
|
||||
HKEY root = HKEY_CURRENT_USER;
|
||||
std::string keyPathStr = "Software\\Classes\\" + protocol;
|
||||
std::wstring keyPath = std::wstring(keyPathStr.begin(), keyPathStr.end());
|
||||
std::string urlDeclStr = "URL:" + protocol;
|
||||
std::wstring urlDecl = std::wstring(urlDeclStr.begin(), urlDeclStr.end());
|
||||
|
||||
// Command Key
|
||||
std::string cmdPathStr = keyPathStr + "\\shell\\open\\command";
|
||||
std::wstring cmdPath = std::wstring(cmdPathStr.begin(), cmdPathStr.end());
|
||||
|
||||
// Executable Path
|
||||
std::wstring exePath(path.value());
|
||||
std::wstring exe = L"\"" + exePath + L"\" \"%1\"";
|
||||
|
||||
// Write information to registry
|
||||
base::win::RegKey key(root, keyPath.c_str(), KEY_ALL_ACCESS);
|
||||
if (FAILED(key.WriteValue(L"URL Protocol", L"")) ||
|
||||
FAILED(key.WriteValue(L"", urlDecl.c_str())))
|
||||
return false;
|
||||
|
||||
base::win::RegKey commandKey(root, cmdPath.c_str(), KEY_ALL_ACCESS);
|
||||
if (FAILED(commandKey.WriteValue(L"", exe.c_str())))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
PCWSTR Browser::GetAppUserModelID() {
|
||||
if (app_user_model_id_.empty()) {
|
||||
SetAppUserModelID(base::ReplaceStringPlaceholders(
|
||||
|
||||
@@ -4,31 +4,21 @@
|
||||
|
||||
#include "atom/browser/common_web_contents_delegate.h"
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "atom/browser/atom_browser_context.h"
|
||||
#include "atom/browser/atom_javascript_dialog_manager.h"
|
||||
#include "atom/browser/atom_security_state_model_client.h"
|
||||
#include "atom/browser/native_window.h"
|
||||
#include "atom/browser/ui/file_dialog.h"
|
||||
#include "atom/browser/web_dialog_helper.h"
|
||||
#include "atom/common/atom_constants.h"
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/prefs/pref_service.h"
|
||||
#include "base/prefs/scoped_user_pref_update.h"
|
||||
#include "chrome/browser/printing/print_preview_message_handler.h"
|
||||
#include "chrome/browser/printing/print_view_manager_basic.h"
|
||||
#include "chrome/browser/ui/browser_dialogs.h"
|
||||
#include "chrome/common/pref_names.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/child_process_security_policy.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
#include "content/public/browser/render_widget_host.h"
|
||||
#include "content/public/browser/security_style_explanation.h"
|
||||
#include "content/public/browser/security_style_explanations.h"
|
||||
#include "storage/browser/fileapi/isolated_context.h"
|
||||
|
||||
#if defined(TOOLKIT_VIEWS)
|
||||
@@ -40,14 +30,11 @@
|
||||
#endif
|
||||
|
||||
using content::BrowserThread;
|
||||
using security_state::SecurityStateModel;
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace {
|
||||
|
||||
const char kRootName[] = "<root>";
|
||||
|
||||
struct FileSystem {
|
||||
FileSystem() {
|
||||
}
|
||||
@@ -65,14 +52,14 @@ struct FileSystem {
|
||||
};
|
||||
|
||||
std::string RegisterFileSystem(content::WebContents* web_contents,
|
||||
const base::FilePath& path) {
|
||||
const base::FilePath& path,
|
||||
std::string* registered_name) {
|
||||
auto isolated_context = storage::IsolatedContext::GetInstance();
|
||||
std::string root_name(kRootName);
|
||||
std::string file_system_id = isolated_context->RegisterFileSystemForPath(
|
||||
storage::kFileSystemTypeNativeLocal,
|
||||
std::string(),
|
||||
path,
|
||||
&root_name);
|
||||
registered_name);
|
||||
|
||||
content::ChildProcessSecurityPolicy* policy =
|
||||
content::ChildProcessSecurityPolicy::GetInstance();
|
||||
@@ -92,12 +79,13 @@ std::string RegisterFileSystem(content::WebContents* web_contents,
|
||||
FileSystem CreateFileSystemStruct(
|
||||
content::WebContents* web_contents,
|
||||
const std::string& file_system_id,
|
||||
const std::string& registered_name,
|
||||
const std::string& file_system_path) {
|
||||
const GURL origin = web_contents->GetURL().GetOrigin();
|
||||
std::string file_system_name =
|
||||
storage::GetIsolatedFileSystemName(origin, file_system_id);
|
||||
std::string root_url = storage::GetIsolatedFileSystemRootURIString(
|
||||
origin, file_system_id, kRootName);
|
||||
origin, file_system_id, registered_name);
|
||||
return FileSystem(file_system_name, root_url, file_system_path);
|
||||
}
|
||||
|
||||
@@ -125,44 +113,6 @@ void AppendToFile(const base::FilePath& path,
|
||||
base::AppendToFile(path, content.data(), content.size());
|
||||
}
|
||||
|
||||
PrefService* GetPrefService(content::WebContents* web_contents) {
|
||||
auto context = web_contents->GetBrowserContext();
|
||||
return static_cast<atom::AtomBrowserContext*>(context)->prefs();
|
||||
}
|
||||
|
||||
std::set<std::string> GetAddedFileSystemPaths(
|
||||
content::WebContents* web_contents) {
|
||||
auto pref_service = GetPrefService(web_contents);
|
||||
const base::DictionaryValue* file_system_paths_value =
|
||||
pref_service->GetDictionary(prefs::kDevToolsFileSystemPaths);
|
||||
std::set<std::string> result;
|
||||
if (file_system_paths_value) {
|
||||
base::DictionaryValue::Iterator it(*file_system_paths_value);
|
||||
for (; !it.IsAtEnd(); it.Advance()) {
|
||||
result.insert(it.key());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
content::SecurityStyle SecurityLevelToSecurityStyle(
|
||||
SecurityStateModel::SecurityLevel security_level) {
|
||||
switch (security_level) {
|
||||
case SecurityStateModel::NONE:
|
||||
return content::SECURITY_STYLE_UNAUTHENTICATED;
|
||||
case SecurityStateModel::SECURITY_WARNING:
|
||||
case SecurityStateModel::SECURITY_POLICY_WARNING:
|
||||
return content::SECURITY_STYLE_WARNING;
|
||||
case SecurityStateModel::EV_SECURE:
|
||||
case SecurityStateModel::SECURE:
|
||||
return content::SECURITY_STYLE_AUTHENTICATED;
|
||||
case SecurityStateModel::SECURITY_ERROR:
|
||||
return content::SECURITY_STYLE_AUTHENTICATION_BROKEN;
|
||||
}
|
||||
|
||||
return content::SECURITY_STYLE_UNKNOWN;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
CommonWebContentsDelegate::CommonWebContentsDelegate()
|
||||
@@ -223,6 +173,8 @@ content::WebContents* CommonWebContentsDelegate::OpenURLFromTab(
|
||||
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;
|
||||
load_url_params.should_clear_history_list = true;
|
||||
|
||||
source->GetController().LoadURLWithParams(load_url_params);
|
||||
@@ -271,7 +223,7 @@ void CommonWebContentsDelegate::EnterFullscreenModeForTab(
|
||||
return;
|
||||
SetHtmlApiFullscreen(true);
|
||||
owner_window_->NotifyWindowEnterHtmlFullScreen();
|
||||
source->GetRenderViewHost()->GetWidget()->WasResized();
|
||||
source->GetRenderViewHost()->WasResized();
|
||||
}
|
||||
|
||||
void CommonWebContentsDelegate::ExitFullscreenModeForTab(
|
||||
@@ -280,7 +232,7 @@ void CommonWebContentsDelegate::ExitFullscreenModeForTab(
|
||||
return;
|
||||
SetHtmlApiFullscreen(false);
|
||||
owner_window_->NotifyWindowLeaveHtmlFullScreen();
|
||||
source->GetRenderViewHost()->GetWidget()->WasResized();
|
||||
source->GetRenderViewHost()->WasResized();
|
||||
}
|
||||
|
||||
bool CommonWebContentsDelegate::IsFullscreenForTabOrPending(
|
||||
@@ -288,90 +240,6 @@ bool CommonWebContentsDelegate::IsFullscreenForTabOrPending(
|
||||
return html_fullscreen_;
|
||||
}
|
||||
|
||||
content::SecurityStyle CommonWebContentsDelegate::GetSecurityStyle(
|
||||
content::WebContents* web_contents,
|
||||
content::SecurityStyleExplanations* explanations) {
|
||||
auto model_client =
|
||||
AtomSecurityStateModelClient::FromWebContents(web_contents);
|
||||
|
||||
const SecurityStateModel::SecurityInfo& security_info =
|
||||
model_client->GetSecurityInfo();
|
||||
|
||||
const content::SecurityStyle security_style =
|
||||
SecurityLevelToSecurityStyle(security_info.security_level);
|
||||
|
||||
explanations->ran_insecure_content_style =
|
||||
SecurityLevelToSecurityStyle(
|
||||
SecurityStateModel::kRanInsecureContentLevel);
|
||||
explanations->displayed_insecure_content_style =
|
||||
SecurityLevelToSecurityStyle(
|
||||
SecurityStateModel::kDisplayedInsecureContentLevel);
|
||||
|
||||
explanations->scheme_is_cryptographic = security_info.scheme_is_cryptographic;
|
||||
if (!security_info.scheme_is_cryptographic)
|
||||
return security_style;
|
||||
|
||||
if (security_info.sha1_deprecation_status ==
|
||||
SecurityStateModel::DEPRECATED_SHA1_MAJOR) {
|
||||
explanations->broken_explanations.push_back(
|
||||
content::SecurityStyleExplanation(
|
||||
kSHA1Certificate,
|
||||
kSHA1MajorDescription,
|
||||
security_info.cert_id));
|
||||
} else if (security_info.sha1_deprecation_status ==
|
||||
SecurityStateModel::DEPRECATED_SHA1_MINOR) {
|
||||
explanations->unauthenticated_explanations.push_back(
|
||||
content::SecurityStyleExplanation(
|
||||
kSHA1Certificate,
|
||||
kSHA1MinorDescription,
|
||||
security_info.cert_id));
|
||||
}
|
||||
|
||||
explanations->ran_insecure_content =
|
||||
security_info.mixed_content_status ==
|
||||
SecurityStateModel::RAN_MIXED_CONTENT ||
|
||||
security_info.mixed_content_status ==
|
||||
SecurityStateModel::RAN_AND_DISPLAYED_MIXED_CONTENT;
|
||||
explanations->displayed_insecure_content =
|
||||
security_info.mixed_content_status ==
|
||||
SecurityStateModel::DISPLAYED_MIXED_CONTENT ||
|
||||
security_info.mixed_content_status ==
|
||||
SecurityStateModel::RAN_AND_DISPLAYED_MIXED_CONTENT;
|
||||
|
||||
if (net::IsCertStatusError(security_info.cert_status)) {
|
||||
std::string error_string = net::ErrorToString(
|
||||
net::MapCertStatusToNetError(security_info.cert_status));
|
||||
|
||||
content::SecurityStyleExplanation explanation(
|
||||
kCertificateError,
|
||||
"There are issues with the site's certificate chain " + error_string,
|
||||
security_info.cert_id);
|
||||
|
||||
if (net::IsCertStatusMinorError(security_info.cert_status))
|
||||
explanations->unauthenticated_explanations.push_back(explanation);
|
||||
else
|
||||
explanations->broken_explanations.push_back(explanation);
|
||||
} else {
|
||||
if (security_info.sha1_deprecation_status ==
|
||||
SecurityStateModel::NO_DEPRECATED_SHA1) {
|
||||
explanations->secure_explanations.push_back(
|
||||
content::SecurityStyleExplanation(
|
||||
kValidCertificate,
|
||||
kValidCertificateDescription,
|
||||
security_info.cert_id));
|
||||
}
|
||||
}
|
||||
|
||||
if (security_info.is_secure_protocol_and_ciphersuite) {
|
||||
explanations->secure_explanations.push_back(
|
||||
content::SecurityStyleExplanation(
|
||||
kSecureProtocol,
|
||||
kSecureProtocolDescription));
|
||||
}
|
||||
|
||||
return security_style;
|
||||
}
|
||||
|
||||
void CommonWebContentsDelegate::DevToolsSaveToFile(
|
||||
const std::string& url, const std::string& content, bool save_as) {
|
||||
base::FilePath path;
|
||||
@@ -411,34 +279,6 @@ void CommonWebContentsDelegate::DevToolsAppendToFile(
|
||||
base::Unretained(this), url));
|
||||
}
|
||||
|
||||
void CommonWebContentsDelegate::DevToolsRequestFileSystems() {
|
||||
auto file_system_paths = GetAddedFileSystemPaths(GetDevToolsWebContents());
|
||||
if (file_system_paths.empty()) {
|
||||
base::ListValue empty_file_system_value;
|
||||
web_contents_->CallClientFunction("DevToolsAPI.fileSystemsLoaded",
|
||||
&empty_file_system_value,
|
||||
nullptr, nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<FileSystem> file_systems;
|
||||
for (auto file_system_path : file_system_paths) {
|
||||
base::FilePath path = base::FilePath::FromUTF8Unsafe(file_system_path);
|
||||
std::string file_system_id = RegisterFileSystem(GetDevToolsWebContents(),
|
||||
path);
|
||||
FileSystem file_system = CreateFileSystemStruct(GetDevToolsWebContents(),
|
||||
file_system_id,
|
||||
file_system_path);
|
||||
file_systems.push_back(file_system);
|
||||
}
|
||||
|
||||
base::ListValue file_system_value;
|
||||
for (size_t i = 0; i < file_systems.size(); ++i)
|
||||
file_system_value.Append(CreateFileSystemValue(file_systems[i]));
|
||||
web_contents_->CallClientFunction("DevToolsAPI.fileSystemsLoaded",
|
||||
&file_system_value, nullptr, nullptr);
|
||||
}
|
||||
|
||||
void CommonWebContentsDelegate::DevToolsAddFileSystem(
|
||||
const base::FilePath& file_system_path) {
|
||||
base::FilePath path = file_system_path;
|
||||
@@ -454,26 +294,32 @@ void CommonWebContentsDelegate::DevToolsAddFileSystem(
|
||||
path = paths[0];
|
||||
}
|
||||
|
||||
std::string registered_name;
|
||||
std::string file_system_id = RegisterFileSystem(GetDevToolsWebContents(),
|
||||
path);
|
||||
auto file_system_paths = GetAddedFileSystemPaths(GetDevToolsWebContents());
|
||||
if (file_system_paths.find(path.AsUTF8Unsafe()) != file_system_paths.end())
|
||||
path,
|
||||
®istered_name);
|
||||
|
||||
WorkspaceMap::iterator it = saved_paths_.find(file_system_id);
|
||||
if (it != saved_paths_.end())
|
||||
return;
|
||||
|
||||
saved_paths_[file_system_id] = path;
|
||||
|
||||
FileSystem file_system = CreateFileSystemStruct(GetDevToolsWebContents(),
|
||||
file_system_id,
|
||||
path.AsUTF8Unsafe());
|
||||
scoped_ptr<base::DictionaryValue> file_system_value(
|
||||
CreateFileSystemValue(file_system));
|
||||
file_system_id,
|
||||
registered_name,
|
||||
path.AsUTF8Unsafe());
|
||||
|
||||
auto pref_service = GetPrefService(GetDevToolsWebContents());
|
||||
DictionaryPrefUpdate update(pref_service, prefs::kDevToolsFileSystemPaths);
|
||||
update.Get()->SetWithoutPathExpansion(
|
||||
path.AsUTF8Unsafe(), base::Value::CreateNullValue());
|
||||
|
||||
web_contents_->CallClientFunction("DevToolsAPI.fileSystemAdded",
|
||||
file_system_value.get(),
|
||||
nullptr, nullptr);
|
||||
scoped_ptr<base::StringValue> error_string_value(
|
||||
new base::StringValue(std::string()));
|
||||
scoped_ptr<base::DictionaryValue> file_system_value;
|
||||
if (!file_system.file_system_path.empty())
|
||||
file_system_value.reset(CreateFileSystemValue(file_system));
|
||||
web_contents_->CallClientFunction(
|
||||
"DevToolsAPI.fileSystemAdded",
|
||||
error_string_value.get(),
|
||||
file_system_value.get(),
|
||||
nullptr);
|
||||
}
|
||||
|
||||
void CommonWebContentsDelegate::DevToolsRemoveFileSystem(
|
||||
@@ -481,18 +327,21 @@ void CommonWebContentsDelegate::DevToolsRemoveFileSystem(
|
||||
if (!web_contents_)
|
||||
return;
|
||||
|
||||
std::string path = file_system_path.AsUTF8Unsafe();
|
||||
storage::IsolatedContext::GetInstance()->
|
||||
RevokeFileSystemByPath(file_system_path);
|
||||
|
||||
auto pref_service = GetPrefService(GetDevToolsWebContents());
|
||||
DictionaryPrefUpdate update(pref_service, prefs::kDevToolsFileSystemPaths);
|
||||
update.Get()->RemoveWithoutPathExpansion(path, nullptr);
|
||||
for (auto it = saved_paths_.begin(); it != saved_paths_.end(); ++it)
|
||||
if (it->second == file_system_path) {
|
||||
saved_paths_.erase(it);
|
||||
break;
|
||||
}
|
||||
|
||||
base::StringValue file_system_path_value(path);
|
||||
web_contents_->CallClientFunction("DevToolsAPI.fileSystemRemoved",
|
||||
&file_system_path_value,
|
||||
nullptr, nullptr);
|
||||
base::StringValue file_system_path_value(file_system_path.AsUTF8Unsafe());
|
||||
web_contents_->CallClientFunction(
|
||||
"DevToolsAPI.fileSystemRemoved",
|
||||
&file_system_path_value,
|
||||
nullptr,
|
||||
nullptr);
|
||||
}
|
||||
|
||||
void CommonWebContentsDelegate::OnDevToolsSaveToFile(
|
||||
|
||||
@@ -76,9 +76,6 @@ class CommonWebContentsDelegate
|
||||
void ExitFullscreenModeForTab(content::WebContents* source) override;
|
||||
bool IsFullscreenForTabOrPending(
|
||||
const content::WebContents* source) const override;
|
||||
content::SecurityStyle GetSecurityStyle(
|
||||
content::WebContents* web_contents,
|
||||
content::SecurityStyleExplanations* explanations) override;
|
||||
|
||||
// brightray::InspectableWebContentsDelegate:
|
||||
void DevToolsSaveToFile(const std::string& url,
|
||||
@@ -86,7 +83,6 @@ class CommonWebContentsDelegate
|
||||
bool save_as) override;
|
||||
void DevToolsAppendToFile(const std::string& url,
|
||||
const std::string& content) override;
|
||||
void DevToolsRequestFileSystems() override;
|
||||
void DevToolsAddFileSystem(const base::FilePath& path) override;
|
||||
void DevToolsRemoveFileSystem(
|
||||
const base::FilePath& file_system_path) override;
|
||||
@@ -132,6 +128,11 @@ class CommonWebContentsDelegate
|
||||
typedef std::map<std::string, base::FilePath> PathsMap;
|
||||
PathsMap saved_files_;
|
||||
|
||||
// Maps file system id to file path, used by the file system requests
|
||||
// sent from devtools.
|
||||
typedef std::map<std::string, base::FilePath> WorkspaceMap;
|
||||
WorkspaceMap saved_paths_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(CommonWebContentsDelegate);
|
||||
};
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@ bool JavascriptEnvironment::Initialize() {
|
||||
v8::V8::SetFlagsFromString(js_flags.c_str(), js_flags.size());
|
||||
|
||||
gin::IsolateHolder::Initialize(gin::IsolateHolder::kNonStrictMode,
|
||||
gin::IsolateHolder::kStableV8Extras,
|
||||
gin::ArrayBufferAllocator::SharedInstance());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#ifndef ATOM_BROWSER_JAVASCRIPT_ENVIRONMENT_H_
|
||||
#define ATOM_BROWSER_JAVASCRIPT_ENVIRONMENT_H_
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "base/basictypes.h"
|
||||
#include "gin/public/isolate_holder.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
#include "content/public/browser/plugin_service.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
#include "content/public/browser/render_widget_host.h"
|
||||
#include "content/public/browser/render_widget_host_view.h"
|
||||
#include "content/public/common/content_switches.h"
|
||||
#include "ipc/ipc_message_macros.h"
|
||||
@@ -54,7 +53,6 @@ NativeWindow::NativeWindow(
|
||||
enable_larger_than_screen_(false),
|
||||
is_closed_(false),
|
||||
has_dialog_attached_(false),
|
||||
sheet_offset_(0.0),
|
||||
aspect_ratio_(0.0),
|
||||
inspectable_web_contents_(inspectable_web_contents),
|
||||
weak_factory_(this) {
|
||||
@@ -163,9 +161,6 @@ void NativeWindow::InitFromOptions(const mate::Dictionary& options) {
|
||||
std::string color;
|
||||
if (options.Get(options::kBackgroundColor, &color)) {
|
||||
SetBackgroundColor(color);
|
||||
} else if (!transparent()) {
|
||||
// For normal window, use white as default background.
|
||||
SetBackgroundColor("#FFFF");
|
||||
}
|
||||
std::string title("Electron");
|
||||
options.Get(options::kTitle, &title);
|
||||
@@ -255,14 +250,6 @@ gfx::Size NativeWindow::GetMaximumSize() {
|
||||
return GetSizeConstraints().GetMaximumSize();
|
||||
}
|
||||
|
||||
void NativeWindow::SetSheetOffset(const double offset) {
|
||||
sheet_offset_ = offset;
|
||||
}
|
||||
|
||||
double NativeWindow::GetSheetOffset() {
|
||||
return sheet_offset_;
|
||||
}
|
||||
|
||||
void NativeWindow::SetRepresentedFilename(const std::string& filename) {
|
||||
}
|
||||
|
||||
@@ -288,15 +275,15 @@ bool NativeWindow::HasModalDialog() {
|
||||
}
|
||||
|
||||
void NativeWindow::FocusOnWebView() {
|
||||
web_contents()->GetRenderViewHost()->GetWidget()->Focus();
|
||||
web_contents()->GetRenderViewHost()->Focus();
|
||||
}
|
||||
|
||||
void NativeWindow::BlurWebView() {
|
||||
web_contents()->GetRenderViewHost()->GetWidget()->Blur();
|
||||
web_contents()->GetRenderViewHost()->Blur();
|
||||
}
|
||||
|
||||
bool NativeWindow::IsWebViewFocused() {
|
||||
auto host_view = web_contents()->GetRenderViewHost()->GetWidget()->GetView();
|
||||
auto host_view = web_contents()->GetRenderViewHost()->GetView();
|
||||
return host_view && host_view->HasFocus();
|
||||
}
|
||||
|
||||
@@ -492,11 +479,6 @@ void NativeWindow::NotifyWindowScrollTouchEnd() {
|
||||
OnWindowScrollTouchEnd());
|
||||
}
|
||||
|
||||
void NativeWindow::NotifyWindowSwipe(const std::string& direction) {
|
||||
FOR_EACH_OBSERVER(NativeWindowObserver, observers_,
|
||||
OnWindowSwipe(direction));
|
||||
}
|
||||
|
||||
void NativeWindow::NotifyWindowLeaveFullScreen() {
|
||||
FOR_EACH_OBSERVER(NativeWindowObserver, observers_,
|
||||
OnWindowLeaveFullScreen());
|
||||
@@ -537,7 +519,7 @@ scoped_ptr<SkRegion> NativeWindow::DraggableRegionsToSkRegion(
|
||||
region.bounds.bottom(),
|
||||
region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op);
|
||||
}
|
||||
return sk_region;
|
||||
return sk_region.Pass();
|
||||
}
|
||||
|
||||
void NativeWindow::RenderViewCreated(
|
||||
@@ -606,4 +588,27 @@ void NativeWindow::OnCapturePageDone(const CapturePageCallback& callback,
|
||||
callback.Run(bitmap);
|
||||
}
|
||||
|
||||
SkColor NativeWindow::ParseHexColor(const std::string& name) {
|
||||
auto color = name.substr(1);
|
||||
unsigned length = color.size();
|
||||
SkColor result = (length != 8 ? 0xFF000000 : 0x00000000);
|
||||
unsigned value = 0;
|
||||
if (length != 3 && length != 6 && length != 8)
|
||||
return result;
|
||||
for (unsigned i = 0; i < length; ++i) {
|
||||
if (!base::IsHexDigit(color[i]))
|
||||
return result;
|
||||
value <<= 4;
|
||||
value |= (color[i] < 'A' ? color[i] - '0' : (color[i] - 'A' + 10) & 0xF);
|
||||
}
|
||||
if (length == 6 || length == 8) {
|
||||
result |= value;
|
||||
return result;
|
||||
}
|
||||
result |= (value & 0xF00) << 12 | (value & 0xF00) << 8
|
||||
| (value & 0xF0) << 8 | (value & 0xF0) << 4
|
||||
| (value & 0xF) << 4 | (value & 0xF);
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
||||
@@ -123,8 +123,6 @@ class NativeWindow : public base::SupportsUserData,
|
||||
virtual gfx::Size GetMinimumSize();
|
||||
virtual void SetMaximumSize(const gfx::Size& size);
|
||||
virtual gfx::Size GetMaximumSize();
|
||||
virtual void SetSheetOffset(const double offset);
|
||||
virtual double GetSheetOffset();
|
||||
virtual void SetResizable(bool resizable) = 0;
|
||||
virtual bool IsResizable() = 0;
|
||||
virtual void SetMovable(bool movable) = 0;
|
||||
@@ -223,7 +221,6 @@ class NativeWindow : public base::SupportsUserData,
|
||||
void NotifyWindowMoved();
|
||||
void NotifyWindowScrollTouchBegin();
|
||||
void NotifyWindowScrollTouchEnd();
|
||||
void NotifyWindowSwipe(const std::string& direction);
|
||||
void NotifyWindowEnterFullScreen();
|
||||
void NotifyWindowLeaveFullScreen();
|
||||
void NotifyWindowEnterHtmlFullScreen();
|
||||
@@ -284,6 +281,9 @@ class NativeWindow : public base::SupportsUserData,
|
||||
void BeforeUnloadDialogCancelled() override;
|
||||
bool OnMessageReceived(const IPC::Message& message) override;
|
||||
|
||||
// Parse hex color like "#FFF" or "#EFEFEF"
|
||||
SkColor ParseHexColor(const std::string& name);
|
||||
|
||||
private:
|
||||
// Schedule a notification unresponsive event.
|
||||
void ScheduleUnresponsiveEvent(int ms);
|
||||
@@ -328,9 +328,6 @@ class NativeWindow : public base::SupportsUserData,
|
||||
// it should be cancelled when we can prove that the window is responsive.
|
||||
base::CancelableClosure window_unresposive_closure_;
|
||||
|
||||
// Used to display sheets at the appropriate vertical offset
|
||||
double sheet_offset_;
|
||||
|
||||
// Used to maintain the aspect ratio of a view which is inside of the
|
||||
// content view.
|
||||
double aspect_ratio_;
|
||||
|
||||
@@ -6,11 +6,9 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "atom/common/color_util.h"
|
||||
#include "atom/common/draggable_region.h"
|
||||
#include "atom/common/options_switches.h"
|
||||
#include "base/mac/mac_util.h"
|
||||
#include "base/mac/scoped_cftyperef.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "brightray/browser/inspectable_web_contents.h"
|
||||
#include "brightray/browser/inspectable_web_contents_view.h"
|
||||
@@ -20,7 +18,6 @@
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
#include "content/public/browser/render_widget_host_view.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "skia/ext/skia_utils_mac.h"
|
||||
#include "ui/gfx/skia_util.h"
|
||||
|
||||
namespace {
|
||||
@@ -243,13 +240,6 @@ bool ScopedDisableResize::disable_resize_ = false;
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (NSRect)window:(NSWindow*)window
|
||||
willPositionSheet:(NSWindow*)sheet usingRect:(NSRect)rect {
|
||||
NSView* view = window.contentView;
|
||||
rect.origin.y = view.frame.size.height - shell_->GetSheetOffset();
|
||||
return rect;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface AtomNSWindow : NSWindow {
|
||||
@@ -277,18 +267,6 @@ bool ScopedDisableResize::disable_resize_ = false;
|
||||
|
||||
// NSWindow overrides.
|
||||
|
||||
- (void)swipeWithEvent:(NSEvent *)event {
|
||||
if (event.deltaY == 1.0) {
|
||||
shell_->NotifyWindowSwipe("up");
|
||||
} else if (event.deltaX == -1.0) {
|
||||
shell_->NotifyWindowSwipe("right");
|
||||
} else if (event.deltaY == -1.0) {
|
||||
shell_->NotifyWindowSwipe("down");
|
||||
} else if (event.deltaX == 1.0) {
|
||||
shell_->NotifyWindowSwipe("left");
|
||||
}
|
||||
}
|
||||
|
||||
- (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen*)screen {
|
||||
// Resizing is disabled.
|
||||
if (ScopedDisableResize::IsResizeDisabled())
|
||||
@@ -814,14 +792,12 @@ bool NativeWindowMac::IsKiosk() {
|
||||
}
|
||||
|
||||
void NativeWindowMac::SetBackgroundColor(const std::string& color_name) {
|
||||
SkColor color = ParseHexColor(color_name);
|
||||
base::ScopedCFTypeRef<CGColorRef> cgcolor =
|
||||
skia::CGColorCreateFromSkColor(color);
|
||||
[[[window_ contentView] layer] setBackgroundColor:cgcolor];
|
||||
|
||||
const auto view = web_contents()->GetRenderWidgetHostView();
|
||||
if (view)
|
||||
view->SetBackgroundColor(color);
|
||||
SkColor background_color = NativeWindow::ParseHexColor(color_name);
|
||||
NSColor *color = [NSColor colorWithCalibratedRed:SkColorGetR(background_color)
|
||||
green:SkColorGetG(background_color)
|
||||
blue:SkColorGetB(background_color)
|
||||
alpha:SkColorGetA(background_color)/255.0f];
|
||||
[window_ setBackgroundColor:color];
|
||||
}
|
||||
|
||||
void NativeWindowMac::SetHasShadow(bool has_shadow) {
|
||||
|
||||
@@ -58,7 +58,6 @@ class NativeWindowObserver {
|
||||
virtual void OnWindowMoved() {}
|
||||
virtual void OnWindowScrollTouchBegin() {}
|
||||
virtual void OnWindowScrollTouchEnd() {}
|
||||
virtual void OnWindowSwipe(const std::string& direction) {}
|
||||
virtual void OnWindowEnterFullScreen() {}
|
||||
virtual void OnWindowLeaveFullScreen() {}
|
||||
virtual void OnWindowEnterHtmlFullScreen() {}
|
||||
|
||||
@@ -9,13 +9,11 @@
|
||||
|
||||
#include "atom/browser/ui/views/menu_bar.h"
|
||||
#include "atom/browser/ui/views/menu_layout.h"
|
||||
#include "atom/common/color_util.h"
|
||||
#include "atom/common/draggable_region.h"
|
||||
#include "atom/common/options_switches.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "brightray/browser/inspectable_web_contents.h"
|
||||
#include "brightray/browser/inspectable_web_contents_view.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/native_web_keyboard_event.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "ui/aura/window_tree_host.h"
|
||||
@@ -616,7 +614,7 @@ bool NativeWindowViews::IsKiosk() {
|
||||
|
||||
void NativeWindowViews::SetBackgroundColor(const std::string& color_name) {
|
||||
// web views' background color.
|
||||
SkColor background_color = ParseHexColor(color_name);
|
||||
SkColor background_color = NativeWindow::ParseHexColor(color_name);
|
||||
set_background(views::Background::CreateSolidBackground(background_color));
|
||||
|
||||
#if defined(OS_WIN)
|
||||
@@ -781,12 +779,10 @@ void NativeWindowViews::OnWidgetActivationChanged(
|
||||
if (widget != window_.get())
|
||||
return;
|
||||
|
||||
// Post the notification to next tick.
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::UI, FROM_HERE,
|
||||
base::Bind(active ? &NativeWindow::NotifyWindowFocus :
|
||||
&NativeWindow::NotifyWindowBlur,
|
||||
GetWeakPtr()));
|
||||
if (active)
|
||||
NotifyWindowFocus();
|
||||
else
|
||||
NotifyWindowBlur();
|
||||
|
||||
if (active && inspectable_web_contents() &&
|
||||
!inspectable_web_contents()->IsDevToolsViewShowing())
|
||||
|
||||
@@ -199,10 +199,6 @@ class NativeWindowViews : public NativeWindow,
|
||||
|
||||
// In charge of running taskbar related APIs.
|
||||
TaskbarHost taskbar_host_;
|
||||
|
||||
// If true we have enabled a11y
|
||||
bool enabled_a11y_support_;
|
||||
|
||||
#endif
|
||||
|
||||
// Handles unhandled keyboard messages coming back from the renderer process.
|
||||
|
||||
@@ -84,25 +84,6 @@ bool NativeWindowViews::PreHandleMSG(
|
||||
NotifyWindowMessage(message, w_param, l_param);
|
||||
|
||||
switch (message) {
|
||||
// Screen readers send WM_GETOBJECT in order to get the accessibility
|
||||
// object, so take this opportunity to push Chromium into accessible
|
||||
// mode if it isn't already, always say we didn't handle the message
|
||||
// because we still want Chromium to handle returning the actual
|
||||
// accessibility object.
|
||||
case WM_GETOBJECT: {
|
||||
const DWORD obj_id = static_cast<DWORD>(l_param);
|
||||
if (enabled_a11y_support_) return false;
|
||||
|
||||
if (obj_id == OBJID_CLIENT) {
|
||||
const auto axState = content::BrowserAccessibilityState::GetInstance();
|
||||
if (axState && !axState->IsAccessibleBrowser()) {
|
||||
axState->OnScreenReaderDetected();
|
||||
enabled_a11y_support_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
case WM_COMMAND:
|
||||
// Handle thumbar button click message.
|
||||
if (HIWORD(w_param) == THBN_CLICKED)
|
||||
|
||||
@@ -44,7 +44,6 @@ URLRequestAsarJob::URLRequestAsarJob(
|
||||
: net::URLRequestJob(request, network_delegate),
|
||||
type_(TYPE_ERROR),
|
||||
remaining_bytes_(0),
|
||||
range_parse_result_(net::OK),
|
||||
weak_ptr_factory_(this) {}
|
||||
|
||||
URLRequestAsarJob::~URLRequestAsarJob() {}
|
||||
@@ -100,7 +99,7 @@ void URLRequestAsarJob::InitializeFileJob(
|
||||
|
||||
void URLRequestAsarJob::Start() {
|
||||
if (type_ == TYPE_ASAR) {
|
||||
remaining_bytes_ = static_cast<int64_t>(file_info_.size);
|
||||
remaining_bytes_ = static_cast<int64>(file_info_.size);
|
||||
|
||||
int flags = base::File::FLAG_OPEN |
|
||||
base::File::FLAG_READ |
|
||||
@@ -132,14 +131,18 @@ void URLRequestAsarJob::Kill() {
|
||||
URLRequestJob::Kill();
|
||||
}
|
||||
|
||||
int URLRequestAsarJob::ReadRawData(net::IOBuffer* dest, int dest_size) {
|
||||
bool URLRequestAsarJob::ReadRawData(net::IOBuffer* dest,
|
||||
int dest_size,
|
||||
int* bytes_read) {
|
||||
if (remaining_bytes_ < dest_size)
|
||||
dest_size = static_cast<int>(remaining_bytes_);
|
||||
|
||||
// If we should copy zero bytes because |remaining_bytes_| is zero, short
|
||||
// circuit here.
|
||||
if (!dest_size)
|
||||
return 0;
|
||||
if (!dest_size) {
|
||||
*bytes_read = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
int rv = stream_->Read(dest,
|
||||
dest_size,
|
||||
@@ -147,11 +150,20 @@ int URLRequestAsarJob::ReadRawData(net::IOBuffer* dest, int dest_size) {
|
||||
weak_ptr_factory_.GetWeakPtr(),
|
||||
make_scoped_refptr(dest)));
|
||||
if (rv >= 0) {
|
||||
// Data is immediately available.
|
||||
*bytes_read = rv;
|
||||
remaining_bytes_ -= rv;
|
||||
DCHECK_GE(remaining_bytes_, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
return rv;
|
||||
// Otherwise, a read error occured. We may just need to wait...
|
||||
if (rv == net::ERR_IO_PENDING) {
|
||||
SetStatus(net::URLRequestStatus(net::URLRequestStatus::IO_PENDING, 0));
|
||||
} else {
|
||||
NotifyDone(net::URLRequestStatus(net::URLRequestStatus::FAILED, rv));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool URLRequestAsarJob::IsRedirectResponse(GURL* location,
|
||||
@@ -202,16 +214,15 @@ void URLRequestAsarJob::SetExtraRequestHeaders(
|
||||
const net::HttpRequestHeaders& headers) {
|
||||
std::string range_header;
|
||||
if (headers.GetHeader(net::HttpRequestHeaders::kRange, &range_header)) {
|
||||
// This job only cares about the Range header. This method stashes the value
|
||||
// for later use in DidOpen(), which is responsible for some of the range
|
||||
// validation as well. NotifyStartError is not legal to call here since
|
||||
// the job has not started.
|
||||
// We only care about "Range" header here.
|
||||
std::vector<net::HttpByteRange> ranges;
|
||||
if (net::HttpUtil::ParseRangeHeader(range_header, &ranges)) {
|
||||
if (ranges.size() == 1) {
|
||||
byte_range_ = ranges[0];
|
||||
} else {
|
||||
range_parse_result_ = net::ERR_REQUEST_RANGE_NOT_SATISFIABLE;
|
||||
NotifyDone(net::URLRequestStatus(
|
||||
net::URLRequestStatus::FAILED,
|
||||
net::ERR_REQUEST_RANGE_NOT_SATISFIABLE));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -263,14 +274,7 @@ void URLRequestAsarJob::DidFetchMetaInfo(const FileMetaInfo* meta_info) {
|
||||
|
||||
void URLRequestAsarJob::DidOpen(int result) {
|
||||
if (result != net::OK) {
|
||||
NotifyStartError(net::URLRequestStatus(net::URLRequestStatus::FAILED,
|
||||
result));
|
||||
return;
|
||||
}
|
||||
|
||||
if (range_parse_result_ != net::OK) {
|
||||
NotifyStartError(net::URLRequestStatus(net::URLRequestStatus::FAILED,
|
||||
range_parse_result_));
|
||||
NotifyDone(net::URLRequestStatus(net::URLRequestStatus::FAILED, result));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -285,9 +289,8 @@ void URLRequestAsarJob::DidOpen(int result) {
|
||||
}
|
||||
} else {
|
||||
if (!byte_range_.ComputeBounds(meta_info_.file_size)) {
|
||||
NotifyStartError(
|
||||
net::URLRequestStatus(net::URLRequestStatus::FAILED,
|
||||
net::ERR_REQUEST_RANGE_NOT_SATISFIABLE));
|
||||
NotifyDone(net::URLRequestStatus(net::URLRequestStatus::FAILED,
|
||||
net::ERR_REQUEST_RANGE_NOT_SATISFIABLE));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -312,19 +315,17 @@ void URLRequestAsarJob::DidOpen(int result) {
|
||||
}
|
||||
}
|
||||
|
||||
void URLRequestAsarJob::DidSeek(int64_t result) {
|
||||
void URLRequestAsarJob::DidSeek(int64 result) {
|
||||
if (type_ == TYPE_ASAR) {
|
||||
if (result != static_cast<int64_t>(file_info_.offset)) {
|
||||
NotifyStartError(
|
||||
net::URLRequestStatus(net::URLRequestStatus::FAILED,
|
||||
net::ERR_REQUEST_RANGE_NOT_SATISFIABLE));
|
||||
if (result != static_cast<int64>(file_info_.offset)) {
|
||||
NotifyDone(net::URLRequestStatus(net::URLRequestStatus::FAILED,
|
||||
net::ERR_REQUEST_RANGE_NOT_SATISFIABLE));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (result != byte_range_.first_byte_position()) {
|
||||
NotifyStartError(
|
||||
net::URLRequestStatus(net::URLRequestStatus::FAILED,
|
||||
net::ERR_REQUEST_RANGE_NOT_SATISFIABLE));
|
||||
NotifyDone(net::URLRequestStatus(net::URLRequestStatus::FAILED,
|
||||
net::ERR_REQUEST_RANGE_NOT_SATISFIABLE));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -333,14 +334,21 @@ void URLRequestAsarJob::DidSeek(int64_t result) {
|
||||
}
|
||||
|
||||
void URLRequestAsarJob::DidRead(scoped_refptr<net::IOBuffer> buf, int result) {
|
||||
if (result >= 0) {
|
||||
if (result > 0) {
|
||||
SetStatus(net::URLRequestStatus()); // Clear the IO_PENDING status
|
||||
remaining_bytes_ -= result;
|
||||
DCHECK_GE(remaining_bytes_, 0);
|
||||
}
|
||||
|
||||
buf = NULL;
|
||||
|
||||
ReadRawDataComplete(result);
|
||||
if (result == 0) {
|
||||
NotifyDone(net::URLRequestStatus());
|
||||
} else if (result < 0) {
|
||||
NotifyDone(net::URLRequestStatus(net::URLRequestStatus::FAILED, result));
|
||||
}
|
||||
|
||||
NotifyReadComplete(result);
|
||||
}
|
||||
|
||||
} // namespace asar
|
||||
|
||||
@@ -54,7 +54,9 @@ class URLRequestAsarJob : public net::URLRequestJob {
|
||||
// net::URLRequestJob:
|
||||
void Start() override;
|
||||
void Kill() override;
|
||||
int ReadRawData(net::IOBuffer* buf, int buf_size) override;
|
||||
bool ReadRawData(net::IOBuffer* buf,
|
||||
int buf_size,
|
||||
int* bytes_read) override;
|
||||
bool IsRedirectResponse(GURL* location, int* http_status_code) override;
|
||||
net::Filter* SetupFilter() const override;
|
||||
bool GetMimeType(std::string* mime_type) const override;
|
||||
@@ -70,7 +72,7 @@ class URLRequestAsarJob : public net::URLRequestJob {
|
||||
FileMetaInfo();
|
||||
|
||||
// Size of the file.
|
||||
int64_t file_size;
|
||||
int64 file_size;
|
||||
// Mime type associated with the file.
|
||||
std::string mime_type;
|
||||
// Result returned from GetMimeTypeFromFile(), i.e. flag showing whether
|
||||
@@ -95,7 +97,7 @@ class URLRequestAsarJob : public net::URLRequestJob {
|
||||
|
||||
// Callback after seeking to the beginning of |byte_range_| in the file
|
||||
// on a background thread.
|
||||
void DidSeek(int64_t result);
|
||||
void DidSeek(int64 result);
|
||||
|
||||
// Callback after data is asynchronously read from the file into |buf|.
|
||||
void DidRead(scoped_refptr<net::IOBuffer> buf, int result);
|
||||
@@ -117,9 +119,7 @@ class URLRequestAsarJob : public net::URLRequestJob {
|
||||
scoped_refptr<base::TaskRunner> file_task_runner_;
|
||||
|
||||
net::HttpByteRange byte_range_;
|
||||
int64_t remaining_bytes_;
|
||||
|
||||
net::Error range_parse_result_;
|
||||
int64 remaining_bytes_;
|
||||
|
||||
base::WeakPtrFactory<URLRequestAsarJob> weak_ptr_factory_;
|
||||
|
||||
|
||||
@@ -4,20 +4,21 @@
|
||||
|
||||
#include "atom/browser/net/atom_network_delegate.h"
|
||||
|
||||
#include <utility>
|
||||
#include <string>
|
||||
|
||||
#include "atom/common/native_mate_converters/net_converter.h"
|
||||
#include "base/stl_util.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "brightray/browser/net/devtools_network_transaction.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/resource_request_info.h"
|
||||
#include "net/url_request/url_request.h"
|
||||
|
||||
using brightray::DevToolsNetworkTransaction;
|
||||
using content::BrowserThread;
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace {
|
||||
|
||||
const char* ResourceTypeToString(content::ResourceType type) {
|
||||
switch (type) {
|
||||
case content::RESOURCE_TYPE_MAIN_FRAME:
|
||||
@@ -39,11 +40,6 @@ const char* ResourceTypeToString(content::ResourceType type) {
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
using ResponseHeadersContainer =
|
||||
std::pair<scoped_refptr<net::HttpResponseHeaders>*, const std::string&>;
|
||||
|
||||
void RunSimpleListener(const AtomNetworkDelegate::SimpleListener& listener,
|
||||
scoped_ptr<base::DictionaryValue> details) {
|
||||
return listener.Run(*(details.get()));
|
||||
@@ -82,7 +78,7 @@ void ToDictionary(base::DictionaryValue* details, net::URLRequest* request) {
|
||||
scoped_ptr<base::ListValue> list(new base::ListValue);
|
||||
GetUploadData(list.get(), request);
|
||||
if (!list->empty())
|
||||
details->Set("uploadData", std::move(list));
|
||||
details->Set("uploadData", list.Pass());
|
||||
}
|
||||
|
||||
void ToDictionary(base::DictionaryValue* details,
|
||||
@@ -91,7 +87,7 @@ void ToDictionary(base::DictionaryValue* details,
|
||||
net::HttpRequestHeaders::Iterator it(headers);
|
||||
while (it.GetNext())
|
||||
dict->SetString(it.name(), it.value());
|
||||
details->Set("requestHeaders", std::move(dict));
|
||||
details->Set("requestHeaders", dict.Pass());
|
||||
}
|
||||
|
||||
void ToDictionary(base::DictionaryValue* details,
|
||||
@@ -111,10 +107,10 @@ void ToDictionary(base::DictionaryValue* details,
|
||||
} else {
|
||||
scoped_ptr<base::ListValue> values(new base::ListValue);
|
||||
values->AppendString(value);
|
||||
dict->Set(key, std::move(values));
|
||||
dict->Set(key, values.Pass());
|
||||
}
|
||||
}
|
||||
details->Set("responseHeaders", std::move(dict));
|
||||
details->Set("responseHeaders", dict.Pass());
|
||||
details->SetString("statusLine", headers->GetStatusLine());
|
||||
details->SetInteger("statusCode", headers->response_code());
|
||||
}
|
||||
@@ -174,15 +170,10 @@ void ReadFromResponseObject(const base::DictionaryValue& response,
|
||||
}
|
||||
|
||||
void ReadFromResponseObject(const base::DictionaryValue& response,
|
||||
const ResponseHeadersContainer& container) {
|
||||
scoped_refptr<net::HttpResponseHeaders>* headers) {
|
||||
const base::DictionaryValue* dict;
|
||||
std::string status_line;
|
||||
if (!response.GetString("statusLine", &status_line))
|
||||
status_line = container.second;
|
||||
if (response.GetDictionary("responseHeaders", &dict)) {
|
||||
auto headers = container.first;
|
||||
*headers = new net::HttpResponseHeaders("");
|
||||
(*headers)->ReplaceStatusLine(status_line);
|
||||
for (base::DictionaryValue::Iterator it(*dict);
|
||||
!it.IsAtEnd();
|
||||
it.Advance()) {
|
||||
@@ -227,12 +218,6 @@ void AtomNetworkDelegate::SetResponseListenerInIO(
|
||||
response_listeners_[type] = { patterns, callback };
|
||||
}
|
||||
|
||||
void AtomNetworkDelegate::SetDevToolsNetworkEmulationClientId(
|
||||
const std::string& client_id) {
|
||||
base::AutoLock auto_lock(lock_);
|
||||
client_id_ = client_id;
|
||||
}
|
||||
|
||||
int AtomNetworkDelegate::OnBeforeURLRequest(
|
||||
net::URLRequest* request,
|
||||
const net::CompletionCallback& callback,
|
||||
@@ -248,16 +233,6 @@ int AtomNetworkDelegate::OnBeforeSendHeaders(
|
||||
net::URLRequest* request,
|
||||
const net::CompletionCallback& callback,
|
||||
net::HttpRequestHeaders* headers) {
|
||||
std::string client_id;
|
||||
{
|
||||
base::AutoLock auto_lock(lock_);
|
||||
client_id = client_id_;
|
||||
}
|
||||
|
||||
if (!client_id.empty())
|
||||
headers->SetHeader(
|
||||
DevToolsNetworkTransaction::kDevToolsEmulateNetworkConditionsClientId,
|
||||
client_id);
|
||||
if (!ContainsKey(response_listeners_, kOnBeforeSendHeaders))
|
||||
return brightray::NetworkDelegate::OnBeforeSendHeaders(
|
||||
request, callback, headers);
|
||||
@@ -288,8 +263,7 @@ int AtomNetworkDelegate::OnHeadersReceived(
|
||||
request, callback, original, override, allowed);
|
||||
|
||||
return HandleResponseEvent(
|
||||
kOnHeadersReceived, request, callback,
|
||||
std::make_pair(override, original->GetStatusLine()), original);
|
||||
kOnHeadersReceived, request, callback, override, original);
|
||||
}
|
||||
|
||||
void AtomNetworkDelegate::OnBeforeRedirect(net::URLRequest* request,
|
||||
|
||||
@@ -7,17 +7,14 @@
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
#include "brightray/browser/network_delegate.h"
|
||||
#include "base/callback.h"
|
||||
#include "base/synchronization/lock.h"
|
||||
#include "base/values.h"
|
||||
#include "extensions/common/url_pattern.h"
|
||||
#include "net/base/net_errors.h"
|
||||
#include "net/http/http_request_headers.h"
|
||||
#include "net/http/http_response_headers.h"
|
||||
#include "content/public/browser/resource_request_info.h"
|
||||
|
||||
namespace extensions {
|
||||
class URLPattern;
|
||||
@@ -27,8 +24,6 @@ namespace atom {
|
||||
|
||||
using URLPatterns = std::set<extensions::URLPattern>;
|
||||
|
||||
const char* ResourceTypeToString(content::ResourceType type);
|
||||
|
||||
class AtomNetworkDelegate : public brightray::NetworkDelegate {
|
||||
public:
|
||||
using ResponseCallback = base::Callback<void(const base::DictionaryValue&)>;
|
||||
@@ -70,8 +65,6 @@ class AtomNetworkDelegate : public brightray::NetworkDelegate {
|
||||
const URLPatterns& patterns,
|
||||
const ResponseListener& callback);
|
||||
|
||||
void SetDevToolsNetworkEmulationClientId(const std::string& client_id);
|
||||
|
||||
protected:
|
||||
// net::NetworkDelegate:
|
||||
int OnBeforeURLRequest(net::URLRequest* request,
|
||||
@@ -120,11 +113,6 @@ class AtomNetworkDelegate : public brightray::NetworkDelegate {
|
||||
std::map<ResponseEvent, ResponseListenerInfo> response_listeners_;
|
||||
std::map<uint64_t, net::CompletionCallback> callbacks_;
|
||||
|
||||
base::Lock lock_;
|
||||
|
||||
// Client id for devtools network emulation.
|
||||
std::string client_id_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomNetworkDelegate);
|
||||
};
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@ namespace atom {
|
||||
|
||||
namespace {
|
||||
|
||||
uint16_t GetSSLProtocolVersion(const std::string& version_string) {
|
||||
uint16_t version = 0; // Invalid
|
||||
uint16 GetSSLProtocolVersion(const std::string& version_string) {
|
||||
uint16 version = 0; // Invalid
|
||||
if (version_string == "tls1")
|
||||
version = net::SSL_PROTOCOL_VERSION_TLS1;
|
||||
else if (version_string == "tls1.1")
|
||||
@@ -29,13 +29,13 @@ uint16_t GetSSLProtocolVersion(const std::string& version_string) {
|
||||
return version;
|
||||
}
|
||||
|
||||
std::vector<uint16_t> ParseCipherSuites(
|
||||
std::vector<uint16> ParseCipherSuites(
|
||||
const std::vector<std::string>& cipher_strings) {
|
||||
std::vector<uint16_t> cipher_suites;
|
||||
std::vector<uint16> cipher_suites;
|
||||
cipher_suites.reserve(cipher_strings.size());
|
||||
|
||||
for (auto& cipher_string : cipher_strings) {
|
||||
uint16_t cipher_suite = 0;
|
||||
uint16 cipher_suite = 0;
|
||||
if (!net::ParseSSLCipherString(cipher_string, &cipher_suite)) {
|
||||
LOG(ERROR) << "Ignoring unrecognised cipher suite : "
|
||||
<< cipher_string;
|
||||
|
||||
@@ -16,9 +16,7 @@ namespace internal {
|
||||
namespace {
|
||||
|
||||
// The callback which is passed to |handler|.
|
||||
void HandlerCallback(const BeforeStartCallback& before_start,
|
||||
const ResponseCallback& callback,
|
||||
mate::Arguments* args) {
|
||||
void HandlerCallback(const ResponseCallback& callback, mate::Arguments* args) {
|
||||
// If there is no argument passed then we failed.
|
||||
v8::Local<v8::Value> value;
|
||||
if (!args->GetNext(&value)) {
|
||||
@@ -28,9 +26,6 @@ void HandlerCallback(const BeforeStartCallback& before_start,
|
||||
return;
|
||||
}
|
||||
|
||||
// Give the job a chance to parse V8 value.
|
||||
before_start.Run(args->isolate(), value);
|
||||
|
||||
// Pass whatever user passed to the actaul request job.
|
||||
V8ValueConverter converter;
|
||||
v8::Local<v8::Context> context = args->isolate()->GetCurrentContext();
|
||||
@@ -45,17 +40,15 @@ void HandlerCallback(const BeforeStartCallback& before_start,
|
||||
void AskForOptions(v8::Isolate* isolate,
|
||||
const JavaScriptHandler& handler,
|
||||
net::URLRequest* request,
|
||||
const BeforeStartCallback& before_start,
|
||||
const ResponseCallback& callback) {
|
||||
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
||||
v8::Locker locker(isolate);
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
v8::Local<v8::Context> context = isolate->GetCurrentContext();
|
||||
v8::Context::Scope context_scope(context);
|
||||
handler.Run(
|
||||
request,
|
||||
mate::ConvertToV8(isolate,
|
||||
base::Bind(&HandlerCallback, before_start, callback)));
|
||||
handler.Run(request,
|
||||
mate::ConvertToV8(isolate,
|
||||
base::Bind(&HandlerCallback, callback)));
|
||||
}
|
||||
|
||||
bool IsErrorOptions(base::Value* value, int* error) {
|
||||
|
||||
@@ -23,8 +23,6 @@ using JavaScriptHandler =
|
||||
|
||||
namespace internal {
|
||||
|
||||
using BeforeStartCallback =
|
||||
base::Callback<void(v8::Isolate*, v8::Local<v8::Value>)>;
|
||||
using ResponseCallback =
|
||||
base::Callback<void(bool, scoped_ptr<base::Value> options)>;
|
||||
|
||||
@@ -32,7 +30,6 @@ using ResponseCallback =
|
||||
void AskForOptions(v8::Isolate* isolate,
|
||||
const JavaScriptHandler& handler,
|
||||
net::URLRequest* request,
|
||||
const BeforeStartCallback& before_start,
|
||||
const ResponseCallback& callback);
|
||||
|
||||
// Test whether the |options| means an error.
|
||||
@@ -57,7 +54,6 @@ class JsAsker : public RequestJob {
|
||||
}
|
||||
|
||||
// Subclass should do initailze work here.
|
||||
virtual void BeforeStartInUI(v8::Isolate*, v8::Local<v8::Value>) {}
|
||||
virtual void StartAsync(scoped_ptr<base::Value> options) = 0;
|
||||
|
||||
net::URLRequestContextGetter* request_context_getter() const {
|
||||
@@ -73,8 +69,6 @@ class JsAsker : public RequestJob {
|
||||
isolate_,
|
||||
handler_,
|
||||
RequestJob::request(),
|
||||
base::Bind(&JsAsker::BeforeStartInUI,
|
||||
weak_factory_.GetWeakPtr()),
|
||||
base::Bind(&JsAsker::OnResponse,
|
||||
weak_factory_.GetWeakPtr())));
|
||||
}
|
||||
@@ -87,7 +81,7 @@ class JsAsker : public RequestJob {
|
||||
void OnResponse(bool success, scoped_ptr<base::Value> value) {
|
||||
int error = net::ERR_NOT_IMPLEMENTED;
|
||||
if (success && value && !internal::IsErrorOptions(value.get(), &error)) {
|
||||
StartAsync(std::move(value));
|
||||
StartAsync(value.Pass());
|
||||
} else {
|
||||
RequestJob::NotifyStartError(
|
||||
net::URLRequestStatus(net::URLRequestStatus::FAILED, error));
|
||||
|
||||
@@ -8,14 +8,15 @@
|
||||
#include <string>
|
||||
|
||||
#include "base/strings/string_util.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "base/thread_task_runner_handle.h"
|
||||
#include "net/base/io_buffer.h"
|
||||
#include "net/base/net_errors.h"
|
||||
#include "net/http/http_response_headers.h"
|
||||
#include "net/url_request/url_fetcher.h"
|
||||
#include "net/url_request/url_fetcher_response_writer.h"
|
||||
|
||||
using content::BrowserThread;
|
||||
#include "net/url_request/url_request_context.h"
|
||||
#include "net/url_request/url_request_context_builder.h"
|
||||
#include "net/url_request/url_request_status.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
@@ -80,25 +81,6 @@ URLRequestFetchJob::URLRequestFetchJob(
|
||||
pending_buffer_size_(0) {
|
||||
}
|
||||
|
||||
void URLRequestFetchJob::BeforeStartInUI(
|
||||
v8::Isolate* isolate, v8::Local<v8::Value> value) {
|
||||
mate::Dictionary options;
|
||||
if (!mate::ConvertFromV8(isolate, value, &options))
|
||||
return;
|
||||
|
||||
// When |session| is set to |null| we use a new request context for fetch job.
|
||||
// TODO(zcbenz): Handle the case when it is not null.
|
||||
v8::Local<v8::Value> session;
|
||||
if (options.Get("session", &session) && session->IsNull()) {
|
||||
// We have to create the URLRequestContextGetter on UI thread.
|
||||
url_request_context_getter_ = new brightray::URLRequestContextGetter(
|
||||
this, nullptr, nullptr, base::FilePath(), true,
|
||||
BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO),
|
||||
BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::FILE),
|
||||
nullptr, content::URLRequestInterceptorScopedVector());
|
||||
}
|
||||
}
|
||||
|
||||
void URLRequestFetchJob::StartAsync(scoped_ptr<base::Value> options) {
|
||||
if (!options->IsType(base::Value::TYPE_DICTIONARY)) {
|
||||
NotifyStartError(net::URLRequestStatus(
|
||||
@@ -107,12 +89,14 @@ void URLRequestFetchJob::StartAsync(scoped_ptr<base::Value> options) {
|
||||
}
|
||||
|
||||
std::string url, method, referrer;
|
||||
base::Value* session = nullptr;
|
||||
base::DictionaryValue* upload_data = nullptr;
|
||||
base::DictionaryValue* dict =
|
||||
static_cast<base::DictionaryValue*>(options.get());
|
||||
dict->GetString("url", &url);
|
||||
dict->GetString("method", &method);
|
||||
dict->GetString("referrer", &referrer);
|
||||
dict->Get("session", &session);
|
||||
dict->GetDictionary("uploadData", &upload_data);
|
||||
|
||||
// Check if URL is valid.
|
||||
@@ -133,9 +117,9 @@ void URLRequestFetchJob::StartAsync(scoped_ptr<base::Value> options) {
|
||||
fetcher_ = net::URLFetcher::Create(formated_url, request_type, this);
|
||||
fetcher_->SaveResponseWithWriter(make_scoped_ptr(new ResponsePiper(this)));
|
||||
|
||||
// A request context getter is passed by the user.
|
||||
if (url_request_context_getter_)
|
||||
fetcher_->SetRequestContext(url_request_context_getter_.get());
|
||||
// When |session| is set to |null| we use a new request context for fetch job.
|
||||
if (session && session->IsType(base::Value::TYPE_NULL))
|
||||
fetcher_->SetRequestContext(CreateRequestContext());
|
||||
else
|
||||
fetcher_->SetRequestContext(request_context_getter());
|
||||
|
||||
@@ -160,6 +144,18 @@ void URLRequestFetchJob::StartAsync(scoped_ptr<base::Value> options) {
|
||||
fetcher_->Start();
|
||||
}
|
||||
|
||||
net::URLRequestContextGetter* URLRequestFetchJob::CreateRequestContext() {
|
||||
if (!url_request_context_getter_.get()) {
|
||||
auto task_runner = base::ThreadTaskRunnerHandle::Get();
|
||||
net::URLRequestContextBuilder builder;
|
||||
builder.set_proxy_service(net::ProxyService::CreateDirect());
|
||||
request_context_ = builder.Build();
|
||||
url_request_context_getter_ = new net::TrivialURLRequestContextGetter(
|
||||
request_context_.get(), task_runner);
|
||||
}
|
||||
return url_request_context_getter_.get();
|
||||
}
|
||||
|
||||
void URLRequestFetchJob::HeadersCompleted() {
|
||||
response_info_.reset(new net::HttpResponseInfo);
|
||||
response_info_->headers = fetcher_->GetResponseHeaders();
|
||||
@@ -167,6 +163,8 @@ void URLRequestFetchJob::HeadersCompleted() {
|
||||
}
|
||||
|
||||
int URLRequestFetchJob::DataAvailable(net::IOBuffer* buffer, int num_bytes) {
|
||||
// Clear the IO_PENDING status.
|
||||
SetStatus(net::URLRequestStatus());
|
||||
// Do nothing if pending_buffer_ is empty, i.e. there's no ReadRawData()
|
||||
// operation waiting for IO completion.
|
||||
if (!pending_buffer_.get())
|
||||
@@ -174,6 +172,7 @@ int URLRequestFetchJob::DataAvailable(net::IOBuffer* buffer, int num_bytes) {
|
||||
|
||||
// pending_buffer_ is set to the IOBuffer instance provided to ReadRawData()
|
||||
// by URLRequestJob.
|
||||
|
||||
int bytes_read = std::min(num_bytes, pending_buffer_size_);
|
||||
memcpy(pending_buffer_->data(), buffer->data(), bytes_read);
|
||||
|
||||
@@ -182,7 +181,7 @@ int URLRequestFetchJob::DataAvailable(net::IOBuffer* buffer, int num_bytes) {
|
||||
pending_buffer_ = nullptr;
|
||||
pending_buffer_size_ = 0;
|
||||
|
||||
ReadRawDataComplete(bytes_read);
|
||||
NotifyReadComplete(bytes_read);
|
||||
return bytes_read;
|
||||
}
|
||||
|
||||
@@ -191,14 +190,18 @@ void URLRequestFetchJob::Kill() {
|
||||
fetcher_.reset();
|
||||
}
|
||||
|
||||
int URLRequestFetchJob::ReadRawData(net::IOBuffer* dest, int dest_size) {
|
||||
bool URLRequestFetchJob::ReadRawData(net::IOBuffer* dest,
|
||||
int dest_size,
|
||||
int* bytes_read) {
|
||||
if (GetResponseCode() == 204) {
|
||||
*bytes_read = 0;
|
||||
request()->set_received_response_content_length(prefilter_bytes_read());
|
||||
return net::OK;
|
||||
return true;
|
||||
}
|
||||
pending_buffer_ = dest;
|
||||
pending_buffer_size_ = dest_size;
|
||||
return net::ERR_IO_PENDING;
|
||||
SetStatus(net::URLRequestStatus(net::URLRequestStatus::IO_PENDING, 0));
|
||||
return false;
|
||||
}
|
||||
|
||||
bool URLRequestFetchJob::GetMimeType(std::string* mime_type) const {
|
||||
@@ -231,10 +234,9 @@ void URLRequestFetchJob::OnURLFetchComplete(const net::URLFetcher* source) {
|
||||
|
||||
pending_buffer_ = nullptr;
|
||||
pending_buffer_size_ = 0;
|
||||
NotifyDone(fetcher_->GetStatus());
|
||||
if (fetcher_->GetStatus().is_success())
|
||||
ReadRawDataComplete(0);
|
||||
else
|
||||
NotifyStartError(fetcher_->GetStatus());
|
||||
NotifyReadComplete(0);
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include <string>
|
||||
|
||||
#include "atom/browser/net/js_asker.h"
|
||||
#include "browser/url_request_context_getter.h"
|
||||
#include "net/url_request/url_request_context_getter.h"
|
||||
#include "net/url_request/url_fetcher_delegate.h"
|
||||
#include "net/url_request/url_request_job.h"
|
||||
@@ -18,8 +17,7 @@ namespace atom {
|
||||
class AtomBrowserContext;
|
||||
|
||||
class URLRequestFetchJob : public JsAsker<net::URLRequestJob>,
|
||||
public net::URLFetcherDelegate,
|
||||
public brightray::URLRequestContextGetter::Delegate {
|
||||
public net::URLFetcherDelegate {
|
||||
public:
|
||||
URLRequestFetchJob(net::URLRequest*, net::NetworkDelegate*);
|
||||
|
||||
@@ -29,12 +27,13 @@ class URLRequestFetchJob : public JsAsker<net::URLRequestJob>,
|
||||
|
||||
protected:
|
||||
// JsAsker:
|
||||
void BeforeStartInUI(v8::Isolate*, v8::Local<v8::Value>) override;
|
||||
void StartAsync(scoped_ptr<base::Value> options) override;
|
||||
|
||||
// net::URLRequestJob:
|
||||
void Kill() override;
|
||||
int ReadRawData(net::IOBuffer* buf, int buf_size) override;
|
||||
bool ReadRawData(net::IOBuffer* buf,
|
||||
int buf_size,
|
||||
int* bytes_read) override;
|
||||
bool GetMimeType(std::string* mime_type) const override;
|
||||
void GetResponseInfo(net::HttpResponseInfo* info) override;
|
||||
int GetResponseCode() const override;
|
||||
@@ -43,6 +42,10 @@ class URLRequestFetchJob : public JsAsker<net::URLRequestJob>,
|
||||
void OnURLFetchComplete(const net::URLFetcher* source) override;
|
||||
|
||||
private:
|
||||
// Create a independent request context.
|
||||
net::URLRequestContextGetter* CreateRequestContext();
|
||||
|
||||
scoped_ptr<net::URLRequestContext> request_context_;
|
||||
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
|
||||
scoped_ptr<net::URLFetcher> fetcher_;
|
||||
scoped_refptr<net::IOBuffer> pending_buffer_;
|
||||
|
||||
@@ -152,7 +152,7 @@ void NodeDebugger::DidAccept(
|
||||
return;
|
||||
}
|
||||
|
||||
accepted_socket_ = std::move(socket);
|
||||
accepted_socket_ = socket.Pass();
|
||||
SendConnectMessage();
|
||||
}
|
||||
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>electron.icns</string>
|
||||
<string>atom.icns</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>0.37.7</string>
|
||||
<string>0.36.12</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>0.37.7</string>
|
||||
<string>0.36.12</string>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
<string>public.app-category.developer-tools</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
|
||||
@@ -56,8 +56,8 @@ END
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 0,37,7,0
|
||||
PRODUCTVERSION 0,37,7,0
|
||||
FILEVERSION 0,36,12,0
|
||||
PRODUCTVERSION 0,36,12,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
@@ -74,12 +74,12 @@ BEGIN
|
||||
BEGIN
|
||||
VALUE "CompanyName", "GitHub, Inc."
|
||||
VALUE "FileDescription", "Electron"
|
||||
VALUE "FileVersion", "0.37.7"
|
||||
VALUE "FileVersion", "0.36.12"
|
||||
VALUE "InternalName", "electron.exe"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2015 GitHub, Inc. All rights reserved."
|
||||
VALUE "OriginalFilename", "electron.exe"
|
||||
VALUE "ProductName", "Electron"
|
||||
VALUE "ProductVersion", "0.37.7"
|
||||
VALUE "ProductVersion", "0.36.12"
|
||||
VALUE "SquirrelAwareVersion", "1"
|
||||
END
|
||||
END
|
||||
|
||||
@@ -28,7 +28,7 @@ void SetPlatformAccelerator(ui::Accelerator* accelerator) {
|
||||
|
||||
scoped_ptr<ui::PlatformAccelerator> platform_accelerator(
|
||||
new ui::PlatformAcceleratorCocoa(characters, modifiers));
|
||||
accelerator->set_platform_accelerator(std::move(platform_accelerator));
|
||||
accelerator->set_platform_accelerator(platform_accelerator.Pass());
|
||||
}
|
||||
|
||||
} // namespace accelerator_util
|
||||
|
||||
@@ -39,8 +39,7 @@ class FileChooserDialog {
|
||||
const std::string& title,
|
||||
const base::FilePath& default_path,
|
||||
const Filters& filters)
|
||||
: dialog_scope_(parent_window),
|
||||
filters_(filters) {
|
||||
: dialog_scope_(parent_window) {
|
||||
const char* confirm_text = GTK_STOCK_OK;
|
||||
if (action == GTK_FILE_CHOOSER_ACTION_SAVE)
|
||||
confirm_text = GTK_STOCK_SAVE;
|
||||
@@ -112,7 +111,7 @@ class FileChooserDialog {
|
||||
|
||||
base::FilePath GetFileName() const {
|
||||
gchar* filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog_));
|
||||
base::FilePath path = AddExtensionForFilename(filename);
|
||||
base::FilePath path(filename);
|
||||
g_free(filename);
|
||||
return path;
|
||||
}
|
||||
@@ -122,8 +121,7 @@ class FileChooserDialog {
|
||||
GSList* filenames = gtk_file_chooser_get_filenames(
|
||||
GTK_FILE_CHOOSER(dialog_));
|
||||
for (GSList* iter = filenames; iter != NULL; iter = g_slist_next(iter)) {
|
||||
base::FilePath path = AddExtensionForFilename(
|
||||
static_cast<char*>(iter->data));
|
||||
base::FilePath path(static_cast<char*>(iter->data));
|
||||
g_free(iter->data);
|
||||
paths.push_back(path);
|
||||
}
|
||||
@@ -137,13 +135,11 @@ class FileChooserDialog {
|
||||
|
||||
private:
|
||||
void AddFilters(const Filters& filters);
|
||||
base::FilePath AddExtensionForFilename(const gchar* filename) const;
|
||||
|
||||
atom::NativeWindow::DialogScope dialog_scope_;
|
||||
|
||||
GtkWidget* dialog_;
|
||||
|
||||
Filters filters_;
|
||||
SaveDialogCallback save_callback_;
|
||||
OpenDialogCallback open_callback_;
|
||||
|
||||
@@ -188,30 +184,6 @@ void FileChooserDialog::AddFilters(const Filters& filters) {
|
||||
}
|
||||
}
|
||||
|
||||
base::FilePath FileChooserDialog::AddExtensionForFilename(
|
||||
const gchar* filename) const {
|
||||
base::FilePath path(filename);
|
||||
GtkFileFilter* selected_filter =
|
||||
gtk_file_chooser_get_filter(GTK_FILE_CHOOSER(dialog_));
|
||||
if (!selected_filter)
|
||||
return path;
|
||||
|
||||
GSList* filters = gtk_file_chooser_list_filters(GTK_FILE_CHOOSER(dialog_));
|
||||
int i = g_slist_index(filters, selected_filter);
|
||||
g_slist_free(filters);
|
||||
if (i >= filters_.size())
|
||||
return path;
|
||||
|
||||
const auto& extensions = filters_[i].second;
|
||||
for (const auto& extension : extensions) {
|
||||
if (extension == "*" || path.MatchesExtension("." + extension))
|
||||
return path;
|
||||
}
|
||||
|
||||
return path.ReplaceExtension(extensions[0]);
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
bool ShowOpenDialog(atom::NativeWindow* parent_window,
|
||||
|
||||
@@ -96,7 +96,7 @@ NSAlert* CreateNSAlert(NativeWindow* parent_window,
|
||||
}
|
||||
|
||||
if (!icon.isNull()) {
|
||||
NSImage* image = skia::SkBitmapToNSImageWithColorSpace(
|
||||
NSImage* image = gfx::SkBitmapToNSImageWithColorSpace(
|
||||
*icon.bitmap(), base::mac::GetGenericRGBColorSpace());
|
||||
[alert setIcon:image];
|
||||
}
|
||||
|
||||
@@ -102,9 +102,9 @@ int ShowMessageBoxUTF16(HWND parent,
|
||||
|
||||
base::win::ScopedHICON hicon;
|
||||
if (!icon.isNull()) {
|
||||
hicon = IconUtil::CreateHICONFromSkBitmap(*icon.bitmap());
|
||||
hicon.Set(IconUtil::CreateHICONFromSkBitmap(*icon.bitmap()));
|
||||
config.dwFlags |= TDF_USE_HICON_MAIN;
|
||||
config.hMainIcon = hicon.get();
|
||||
config.hMainIcon = hicon.Get();
|
||||
} else {
|
||||
// Show icon according to dialog's type.
|
||||
switch (type) {
|
||||
|
||||
@@ -27,6 +27,7 @@ const CGFloat kVerticalTitleMargin = 2;
|
||||
BOOL inMouseEventSequence_;
|
||||
base::scoped_nsobject<NSImage> image_;
|
||||
base::scoped_nsobject<NSImage> alternateImage_;
|
||||
base::scoped_nsobject<NSImageView> image_view_;
|
||||
base::scoped_nsobject<NSString> title_;
|
||||
base::scoped_nsobject<NSStatusItem> statusItem_;
|
||||
}
|
||||
@@ -43,6 +44,15 @@ const CGFloat kVerticalTitleMargin = 2;
|
||||
inMouseEventSequence_ = NO;
|
||||
|
||||
if ((self = [super initWithFrame: CGRectZero])) {
|
||||
// Setup the image view.
|
||||
image_view_.reset([[NSImageView alloc] initWithFrame: CGRectZero]);
|
||||
[image_view_ setImageScaling:NSImageScaleNone];
|
||||
[image_view_ setImageAlignment:NSImageAlignCenter];
|
||||
[self addSubview:image_view_];
|
||||
|
||||
// Unregister image_view_ as a dragged destination, allows its parent view
|
||||
// (StatusItemView) handle dragging events.
|
||||
[image_view_ unregisterDraggedTypes];
|
||||
[self registerForDraggedTypes: @[NSFilenamesPboardType]];
|
||||
|
||||
// Create the status item.
|
||||
@@ -59,6 +69,7 @@ const CGFloat kVerticalTitleMargin = 2;
|
||||
|
||||
- (void)updateDimensions {
|
||||
NSStatusBar * bar = [NSStatusBar systemStatusBar];
|
||||
[image_view_ setFrame: NSMakeRect(0, 0, [self iconWidth], [bar thickness])];
|
||||
[self setFrame: NSMakeRect(0, 0, [self fullWidth], [bar thickness])];
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
@@ -74,44 +85,28 @@ const CGFloat kVerticalTitleMargin = 2;
|
||||
// | icon | title |
|
||||
/// ----------------
|
||||
|
||||
// Draw background.
|
||||
BOOL highlight = [self shouldHighlight];
|
||||
BOOL highlightContent = highlight | [self isDarkMode];
|
||||
CGFloat thickness = [[statusItem_ statusBar] thickness];
|
||||
|
||||
// Draw the system bar background.
|
||||
[statusItem_ drawStatusBarBackgroundInRect:self.bounds withHighlight:highlight];
|
||||
|
||||
// Determine which image to use.
|
||||
NSImage* image = image_.get();
|
||||
if (inMouseEventSequence_ && alternateImage_) {
|
||||
image = alternateImage_.get();
|
||||
// Make use of NSImageView to draw the image, which can correctly draw
|
||||
// template image under dark menu bar.
|
||||
if (inMouseEventSequence_ && alternateImage_ &&
|
||||
[image_view_ image] != alternateImage_.get()) {
|
||||
[image_view_ setImage:alternateImage_];
|
||||
} else if ([image_view_ image] != image_.get()) {
|
||||
[image_view_ setImage:image_];
|
||||
}
|
||||
// Apply the higlight color if the image is a template image. When this moves
|
||||
// to using the new [NSStatusItem button] API, this should work automagically.
|
||||
if ([image isTemplate] == YES) {
|
||||
NSImage* imageWithColor = [[image copy] autorelease];
|
||||
[imageWithColor lockFocus];
|
||||
[[self colorWithHighlight: highlightContent] set];
|
||||
CGRect imageBounds = CGRectMake(0,0, image.size.width, image.size.height);
|
||||
NSRectFillUsingOperation(imageBounds, NSCompositeSourceAtop);
|
||||
[imageWithColor unlockFocus];
|
||||
image = imageWithColor;
|
||||
}
|
||||
|
||||
// Draw the image
|
||||
[image drawInRect: CGRectMake(
|
||||
roundf(([self iconWidth] - image.size.width) / 2),
|
||||
roundf((thickness - image.size.height) / 2),
|
||||
image.size.width,
|
||||
image.size.height
|
||||
)];
|
||||
|
||||
if (title_) {
|
||||
// Highlight the text when icon is highlighted or in dark mode.
|
||||
highlight |= [self isDarkMode];
|
||||
// Draw title.
|
||||
NSRect titleDrawRect = NSMakeRect(
|
||||
[self iconWidth], -kVerticalTitleMargin, [self titleWidth], thickness);
|
||||
[title_ drawInRect:titleDrawRect
|
||||
withAttributes:[self titleAttributesWithHighlight:highlightContent]];
|
||||
withAttributes:[self titleAttributesWithHighlight:highlight]];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,16 +157,14 @@ const CGFloat kVerticalTitleMargin = 2;
|
||||
return [attributes size].width;
|
||||
}
|
||||
|
||||
- (NSColor*)colorWithHighlight:(BOOL)highlight {
|
||||
return highlight ?
|
||||
- (NSDictionary*)titleAttributesWithHighlight:(BOOL)highlight {
|
||||
NSFont* font = [NSFont menuBarFontOfSize:0];
|
||||
NSColor* foregroundColor = highlight ?
|
||||
[NSColor whiteColor] :
|
||||
[NSColor colorWithRed:0.265625 green:0.25390625 blue:0.234375 alpha:1.0];
|
||||
}
|
||||
|
||||
- (NSDictionary*)titleAttributesWithHighlight:(BOOL)highlight {
|
||||
return @{
|
||||
NSFontAttributeName:[NSFont menuBarFontOfSize:0],
|
||||
NSForegroundColorAttributeName:[self colorWithHighlight: highlight]
|
||||
NSFontAttributeName: font,
|
||||
NSForegroundColorAttributeName: foregroundColor
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "base/basictypes.h"
|
||||
#include "base/compiler_specific.h"
|
||||
#include "ui/base/glib/glib_signal.h"
|
||||
#include "ui/gfx/native_widget_types.h"
|
||||
|
||||
@@ -37,7 +37,7 @@ SubmenuButton::SubmenuButton(views::ButtonListener* listener,
|
||||
underline_color_(SK_ColorBLACK) {
|
||||
#if defined(OS_LINUX)
|
||||
// Dont' use native style border.
|
||||
SetBorder(std::move(CreateDefaultBorder()));
|
||||
SetBorder(CreateDefaultBorder().Pass());
|
||||
#endif
|
||||
|
||||
if (GetUnderlinePosition(title, &accelerator_, &underline_start_,
|
||||
|
||||
@@ -80,7 +80,7 @@ void NotifyIcon::ResetIcon() {
|
||||
InitIconData(&icon_data);
|
||||
icon_data.uFlags |= NIF_MESSAGE;
|
||||
icon_data.uCallbackMessage = message_id_;
|
||||
icon_data.hIcon = icon_.get();
|
||||
icon_data.hIcon = icon_.Get();
|
||||
// If we have an image, then set the NIF_ICON flag, which tells
|
||||
// Shell_NotifyIcon() to set the image for the status icon it creates.
|
||||
if (icon_data.hIcon)
|
||||
@@ -96,8 +96,8 @@ void NotifyIcon::SetImage(const gfx::Image& image) {
|
||||
NOTIFYICONDATA icon_data;
|
||||
InitIconData(&icon_data);
|
||||
icon_data.uFlags |= NIF_ICON;
|
||||
icon_ = IconUtil::CreateHICONFromSkBitmap(image.AsBitmap());
|
||||
icon_data.hIcon = icon_.get();
|
||||
icon_.Set(IconUtil::CreateHICONFromSkBitmap(image.AsBitmap()));
|
||||
icon_data.hIcon = icon_.Get();
|
||||
BOOL result = Shell_NotifyIcon(NIM_MODIFY, &icon_data);
|
||||
if (!result)
|
||||
LOG(WARNING) << "Error setting status tray icon image";
|
||||
@@ -132,8 +132,8 @@ void NotifyIcon::DisplayBalloon(const gfx::Image& icon,
|
||||
|
||||
base::win::Version win_version = base::win::GetVersion();
|
||||
if (!icon.IsEmpty() && win_version != base::win::VERSION_PRE_XP) {
|
||||
balloon_icon_ = IconUtil::CreateHICONFromSkBitmap(icon.AsBitmap());
|
||||
icon_data.hBalloonIcon = balloon_icon_.get();
|
||||
balloon_icon_.Set(IconUtil::CreateHICONFromSkBitmap(icon.AsBitmap()));
|
||||
icon_data.hBalloonIcon = balloon_icon_.Get();
|
||||
icon_data.dwInfoFlags = NIIF_USER | NIIF_LARGE_ICON;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "atom/browser/ui/tray_icon.h"
|
||||
#include "base/macros.h"
|
||||
#include "base/basictypes.h"
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "base/win/scoped_gdi_object.h"
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#include "base/win/win_util.h"
|
||||
#include "base/win/wrapped_window_proc.h"
|
||||
#include "ui/events/event_constants.h"
|
||||
#include "ui/events/win/system_event_state_lookup.h"
|
||||
#include "ui/gfx/win/hwnd_util.h"
|
||||
|
||||
namespace atom {
|
||||
@@ -36,11 +35,11 @@ bool IsWinPressed() {
|
||||
|
||||
int GetKeyboardModifers() {
|
||||
int modifiers = ui::EF_NONE;
|
||||
if (ui::win::IsShiftPressed())
|
||||
if (base::win::IsShiftPressed())
|
||||
modifiers |= ui::EF_SHIFT_DOWN;
|
||||
if (ui::win::IsCtrlPressed())
|
||||
if (base::win::IsCtrlPressed())
|
||||
modifiers |= ui::EF_CONTROL_DOWN;
|
||||
if (ui::win::IsAltPressed())
|
||||
if (base::win::IsAltPressed())
|
||||
modifiers |= ui::EF_ALT_DOWN;
|
||||
if (IsWinPressed())
|
||||
modifiers |= ui::EF_COMMAND_DOWN;
|
||||
|
||||
@@ -91,7 +91,7 @@ bool TaskbarHost::SetThumbarButtons(
|
||||
if (!button.icon.IsEmpty()) {
|
||||
thumb_button.dwMask |= THB_ICON;
|
||||
icons[i] = IconUtil::CreateHICONFromSkBitmap(button.icon.AsBitmap());
|
||||
thumb_button.hIcon = icons[i].get();
|
||||
thumb_button.hIcon = icons[i].Get();
|
||||
}
|
||||
|
||||
// Set tooltip.
|
||||
@@ -138,8 +138,8 @@ bool TaskbarHost::SetOverlayIcon(
|
||||
|
||||
base::win::ScopedHICON icon(
|
||||
IconUtil::CreateHICONFromSkBitmap(overlay.AsBitmap()));
|
||||
return SUCCEEDED(taskbar_->SetOverlayIcon(
|
||||
window, icon.get(), base::UTF8ToUTF16(text).c_str()));
|
||||
return SUCCEEDED(
|
||||
taskbar_->SetOverlayIcon(window, icon, base::UTF8ToUTF16(text).c_str()));
|
||||
}
|
||||
|
||||
bool TaskbarHost::HandleThumbarButtonEvent(int button_id) {
|
||||
|
||||
@@ -91,12 +91,4 @@ void WebContentsPermissionHelper::RequestPointerLockPermission(
|
||||
user_gesture);
|
||||
}
|
||||
|
||||
void WebContentsPermissionHelper::RequestOpenExternalPermission(
|
||||
const base::Callback<void(bool)>& callback,
|
||||
bool user_gesture) {
|
||||
RequestPermission((content::PermissionType)(PermissionType::OPEN_EXTERNAL),
|
||||
callback,
|
||||
user_gesture);
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
||||
@@ -19,8 +19,7 @@ class WebContentsPermissionHelper
|
||||
|
||||
enum class PermissionType {
|
||||
POINTER_LOCK = static_cast<int>(content::PermissionType::NUM) + 1,
|
||||
FULLSCREEN,
|
||||
OPEN_EXTERNAL,
|
||||
FULLSCREEN
|
||||
};
|
||||
|
||||
void RequestFullscreenPermission(
|
||||
@@ -31,9 +30,6 @@ class WebContentsPermissionHelper
|
||||
void RequestWebNotificationPermission(
|
||||
const base::Callback<void(bool)>& callback);
|
||||
void RequestPointerLockPermission(bool user_gesture);
|
||||
void RequestOpenExternalPermission(
|
||||
const base::Callback<void(bool)>& callback,
|
||||
bool user_gesture);
|
||||
|
||||
private:
|
||||
explicit WebContentsPermissionHelper(content::WebContents* web_contents);
|
||||
|
||||
@@ -4,16 +4,12 @@
|
||||
|
||||
#include "atom/browser/web_contents_preferences.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "atom/browser/native_window.h"
|
||||
#include "atom/common/native_mate_converters/value_converter.h"
|
||||
#include "atom/common/options_switches.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "content/public/common/content_switches.h"
|
||||
#include "content/public/common/web_preferences.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
@@ -27,13 +23,9 @@ DEFINE_WEB_CONTENTS_USER_DATA_KEY(atom::WebContentsPreferences);
|
||||
|
||||
namespace atom {
|
||||
|
||||
// static
|
||||
std::vector<WebContentsPreferences*> WebContentsPreferences::instances_;
|
||||
|
||||
WebContentsPreferences::WebContentsPreferences(
|
||||
content::WebContents* web_contents,
|
||||
const mate::Dictionary& web_preferences)
|
||||
: web_contents_(web_contents) {
|
||||
const mate::Dictionary& web_preferences) {
|
||||
v8::Isolate* isolate = web_preferences.isolate();
|
||||
mate::Dictionary copied(isolate, web_preferences.GetHandle()->Clone());
|
||||
// Following fields should not be stored.
|
||||
@@ -43,31 +35,15 @@ WebContentsPreferences::WebContentsPreferences(
|
||||
|
||||
mate::ConvertFromV8(isolate, copied.GetHandle(), &web_preferences_);
|
||||
web_contents->SetUserData(UserDataKey(), this);
|
||||
|
||||
instances_.push_back(this);
|
||||
}
|
||||
|
||||
WebContentsPreferences::~WebContentsPreferences() {
|
||||
instances_.erase(
|
||||
std::remove(instances_.begin(), instances_.end(), this),
|
||||
instances_.end());
|
||||
}
|
||||
|
||||
void WebContentsPreferences::Merge(const base::DictionaryValue& extend) {
|
||||
web_preferences_.MergeDictionary(&extend);
|
||||
}
|
||||
|
||||
// static
|
||||
content::WebContents* WebContentsPreferences::GetWebContentsFromProcessID(
|
||||
int process_id) {
|
||||
for (WebContentsPreferences* preferences : instances_) {
|
||||
content::WebContents* web_contents = preferences->web_contents_;
|
||||
if (web_contents->GetRenderProcessHost()->GetID() == process_id)
|
||||
return web_contents;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// static
|
||||
void WebContentsPreferences::AppendExtraCommandLineSwitches(
|
||||
content::WebContents* web_contents, base::CommandLine* command_line) {
|
||||
@@ -98,6 +74,11 @@ void WebContentsPreferences::AppendExtraCommandLineSwitches(
|
||||
// Check if we have node integration specified.
|
||||
bool node_integration = true;
|
||||
web_preferences.GetBoolean(options::kNodeIntegration, &node_integration);
|
||||
// Be compatible with old API of "node-integration" option.
|
||||
std::string old_token;
|
||||
if (web_preferences.GetString(options::kNodeIntegration, &old_token) &&
|
||||
old_token != "disable")
|
||||
node_integration = true;
|
||||
command_line->AppendSwitchASCII(switches::kNodeIntegration,
|
||||
node_integration ? "true" : "false");
|
||||
|
||||
@@ -117,11 +98,6 @@ void WebContentsPreferences::AppendExtraCommandLineSwitches(
|
||||
LOG(ERROR) << "preload url must be file:// protocol.";
|
||||
}
|
||||
|
||||
// --background-color.
|
||||
std::string color;
|
||||
if (web_preferences.GetString(options::kBackgroundColor, &color))
|
||||
command_line->AppendSwitchASCII(switches::kBackgroundColor, color);
|
||||
|
||||
// The zoom factor.
|
||||
double zoom_factor = 1.0;
|
||||
if (web_preferences.GetDouble(options::kZoomFactor, &zoom_factor) &&
|
||||
@@ -132,28 +108,20 @@ void WebContentsPreferences::AppendExtraCommandLineSwitches(
|
||||
// --guest-instance-id, which is used to identify guest WebContents.
|
||||
int guest_instance_id;
|
||||
if (web_preferences.GetInteger(options::kGuestInstanceID, &guest_instance_id))
|
||||
command_line->AppendSwitchASCII(switches::kGuestInstanceID,
|
||||
base::IntToString(guest_instance_id));
|
||||
command_line->AppendSwitchASCII(switches::kGuestInstanceID,
|
||||
base::IntToString(guest_instance_id));
|
||||
|
||||
// Pass the opener's window id.
|
||||
int opener_id;
|
||||
if (web_preferences.GetInteger(options::kOpenerID, &opener_id))
|
||||
command_line->AppendSwitchASCII(switches::kOpenerID,
|
||||
base::IntToString(opener_id));
|
||||
command_line->AppendSwitchASCII(switches::kOpenerID,
|
||||
base::IntToString(opener_id));
|
||||
|
||||
// Enable blink features.
|
||||
std::string blink_features;
|
||||
if (web_preferences.GetString(options::kBlinkFeatures, &blink_features))
|
||||
command_line->AppendSwitchASCII(::switches::kEnableBlinkFeatures,
|
||||
blink_features);
|
||||
|
||||
// The initial visibility state.
|
||||
NativeWindow* window = NativeWindow::FromWebContents(web_contents);
|
||||
if (window) {
|
||||
bool visible = window->IsVisible() && !window->IsMinimized();
|
||||
if (!visible) // Default state is visible.
|
||||
command_line->AppendSwitch("hidden-page");
|
||||
}
|
||||
command_line->AppendSwitchASCII(::switches::kEnableBlinkFeatures,
|
||||
blink_features);
|
||||
}
|
||||
|
||||
// static
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
#ifndef ATOM_BROWSER_WEB_CONTENTS_PREFERENCES_H_
|
||||
#define ATOM_BROWSER_WEB_CONTENTS_PREFERENCES_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "base/values.h"
|
||||
#include "content/public/browser/web_contents_user_data.h"
|
||||
|
||||
@@ -28,9 +26,6 @@ namespace atom {
|
||||
class WebContentsPreferences
|
||||
: public content::WebContentsUserData<WebContentsPreferences> {
|
||||
public:
|
||||
// Get WebContents according to process ID.
|
||||
static content::WebContents* GetWebContentsFromProcessID(int process_id);
|
||||
|
||||
// Append command paramters according to |web_contents|'s preferences.
|
||||
static void AppendExtraCommandLineSwitches(
|
||||
content::WebContents* web_contents, base::CommandLine* command_line);
|
||||
@@ -52,9 +47,6 @@ class WebContentsPreferences
|
||||
private:
|
||||
friend class content::WebContentsUserData<WebContentsPreferences>;
|
||||
|
||||
static std::vector<WebContentsPreferences*> instances_;
|
||||
|
||||
content::WebContents* web_contents_;
|
||||
base::DictionaryValue web_preferences_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(WebContentsPreferences);
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include "content/public/browser/guest_host.h"
|
||||
#include "content/public/browser/render_frame_host.h"
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
#include "content/public/browser/render_widget_host.h"
|
||||
#include "content/public/browser/render_widget_host_view.h"
|
||||
|
||||
namespace atom {
|
||||
@@ -22,7 +21,8 @@ const int kDefaultHeight = 300;
|
||||
} // namespace
|
||||
|
||||
WebViewGuestDelegate::WebViewGuestDelegate()
|
||||
: guest_host_(nullptr),
|
||||
: guest_opaque_(true),
|
||||
guest_host_(nullptr),
|
||||
auto_size_enabled_(false),
|
||||
is_full_page_plugin_(false),
|
||||
api_web_contents_(nullptr) {
|
||||
@@ -95,6 +95,22 @@ void WebViewGuestDelegate::SetSize(const SetSizeParams& params) {
|
||||
auto_size_enabled_ = enable_auto_size;
|
||||
}
|
||||
|
||||
void WebViewGuestDelegate::SetAllowTransparency(bool allow) {
|
||||
if (guest_opaque_ != allow)
|
||||
return;
|
||||
|
||||
auto render_view_host = web_contents()->GetRenderViewHost();
|
||||
guest_opaque_ = !allow;
|
||||
if (!render_view_host->GetView())
|
||||
return;
|
||||
|
||||
if (guest_opaque_) {
|
||||
render_view_host->GetView()->SetBackgroundColorToDefault();
|
||||
} else {
|
||||
render_view_host->GetView()->SetBackgroundColor(SK_ColorTRANSPARENT);
|
||||
}
|
||||
}
|
||||
|
||||
void WebViewGuestDelegate::HandleKeyboardEvent(
|
||||
content::WebContents* source,
|
||||
const content::NativeWebKeyboardEvent& event) {
|
||||
@@ -102,6 +118,18 @@ void WebViewGuestDelegate::HandleKeyboardEvent(
|
||||
embedder_web_contents_->GetDelegate()->HandleKeyboardEvent(source, event);
|
||||
}
|
||||
|
||||
void WebViewGuestDelegate::RenderViewReady() {
|
||||
// We don't want to accidentally set the opacity of an interstitial page.
|
||||
// WebContents::GetRenderWidgetHostView will return the RWHV of an
|
||||
// interstitial page if one is showing at this time. We only want opacity
|
||||
// to apply to web pages.
|
||||
auto render_view_host_view = web_contents()->GetRenderViewHost()->GetView();
|
||||
if (guest_opaque_)
|
||||
render_view_host_view->SetBackgroundColorToDefault();
|
||||
else
|
||||
render_view_host_view->SetBackgroundColor(SK_ColorTRANSPARENT);
|
||||
}
|
||||
|
||||
void WebViewGuestDelegate::DidCommitProvisionalLoadForFrame(
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const GURL& url, ui::PageTransition transition_type) {
|
||||
|
||||
@@ -49,12 +49,16 @@ class WebViewGuestDelegate : public content::BrowserPluginGuestDelegate,
|
||||
// and normal sizes.
|
||||
void SetSize(const SetSizeParams& params);
|
||||
|
||||
// Sets the transparency of the guest.
|
||||
void SetAllowTransparency(bool allow);
|
||||
|
||||
// Transfer the keyboard event to embedder.
|
||||
void HandleKeyboardEvent(content::WebContents* source,
|
||||
const content::NativeWebKeyboardEvent& event);
|
||||
|
||||
protected:
|
||||
// content::WebContentsObserver:
|
||||
void RenderViewReady() override;
|
||||
void DidCommitProvisionalLoadForFrame(
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const GURL& url, ui::PageTransition transition_type) override;
|
||||
@@ -81,6 +85,9 @@ class WebViewGuestDelegate : public content::BrowserPluginGuestDelegate,
|
||||
// Returns the default size of the guestview.
|
||||
gfx::Size GetDefaultSize() const;
|
||||
|
||||
// Stores whether the contents of the guest can be transparent.
|
||||
bool guest_opaque_;
|
||||
|
||||
// The WebContents that attaches this guest view.
|
||||
content::WebContents* embedder_web_contents_;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "base/basictypes.h"
|
||||
#include "base/lazy_instance.h"
|
||||
#include "base/observer_list.h"
|
||||
|
||||
|
||||
@@ -27,12 +27,12 @@ class Archive : public mate::Wrappable {
|
||||
scoped_ptr<asar::Archive> archive(new asar::Archive(path));
|
||||
if (!archive->Init())
|
||||
return v8::False(isolate);
|
||||
return (new Archive(std::move(archive)))->GetWrapper(isolate);
|
||||
return (new Archive(archive.Pass()))->GetWrapper(isolate);
|
||||
}
|
||||
|
||||
protected:
|
||||
explicit Archive(scoped_ptr<asar::Archive> archive)
|
||||
: archive_(std::move(archive)) {}
|
||||
: archive_(archive.Pass()) {}
|
||||
|
||||
// Reads the offset and size of file.
|
||||
v8::Local<v8::Value> GetFileInfo(v8::Isolate* isolate,
|
||||
@@ -129,11 +129,9 @@ void InitAsarSupport(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> process,
|
||||
v8::Local<v8::Value> require) {
|
||||
// Evaluate asar_init.coffee.
|
||||
const char* asar_init_native = reinterpret_cast<const char*>(
|
||||
static_cast<const unsigned char*>(node::asar_init_native));
|
||||
v8::Local<v8::Script> asar_init = v8::Script::Compile(v8::String::NewFromUtf8(
|
||||
isolate,
|
||||
asar_init_native,
|
||||
node::asar_init_native,
|
||||
v8::String::kNormalString,
|
||||
sizeof(node::asar_init_native) -1));
|
||||
v8::Local<v8::Value> result = asar_init->Run();
|
||||
@@ -143,11 +141,9 @@ void InitAsarSupport(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value>,
|
||||
std::string)> init;
|
||||
if (mate::ConvertFromV8(isolate, result, &init)) {
|
||||
const char* asar_native = reinterpret_cast<const char*>(
|
||||
static_cast<const unsigned char*>(node::asar_native));
|
||||
init.Run(process,
|
||||
require,
|
||||
std::string(asar_native, sizeof(node::asar_native) - 1));
|
||||
std::string(node::asar_native, sizeof(node::asar_native) - 1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -109,8 +109,8 @@ base::string16 ReadHtml(mate::Arguments* args) {
|
||||
base::string16 data;
|
||||
base::string16 html;
|
||||
std::string url;
|
||||
uint32_t start;
|
||||
uint32_t end;
|
||||
uint32 start;
|
||||
uint32 end;
|
||||
ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
|
||||
clipboard->ReadHTML(GetClipboardType(args), &html, &url, &start, &end);
|
||||
data = html.substr(start, end - start);
|
||||
|
||||
@@ -158,11 +158,11 @@ bool ReadImageSkiaFromICO(gfx::ImageSkia* image, const base::FilePath& path) {
|
||||
base::win::ScopedHICON icon(static_cast<HICON>(
|
||||
LoadImage(NULL, image_path.value().c_str(), IMAGE_ICON, 0, 0,
|
||||
LR_DEFAULTSIZE | LR_LOADFROMFILE)));
|
||||
if (!icon.get())
|
||||
if (!icon)
|
||||
return false;
|
||||
|
||||
// Convert the icon from the Windows specific HICON to gfx::ImageSkia.
|
||||
scoped_ptr<SkBitmap> bitmap(IconUtil:: CreateSkBitmapFromHICON(icon.get()));
|
||||
scoped_ptr<SkBitmap> bitmap(IconUtil::CreateSkBitmapFromHICON(icon));
|
||||
image->AddRepresentation(gfx::ImageSkiaRep(*bitmap, 1.0f));
|
||||
return true;
|
||||
}
|
||||
@@ -184,7 +184,6 @@ mate::ObjectTemplateBuilder NativeImage::GetObjectTemplateBuilder(
|
||||
template_.Reset(isolate, mate::ObjectTemplateBuilder(isolate)
|
||||
.SetMethod("toPng", &NativeImage::ToPNG)
|
||||
.SetMethod("toJpeg", &NativeImage::ToJPEG)
|
||||
.SetMethod("getNativeHandle", &NativeImage::GetNativeHandle)
|
||||
.SetMethod("toDataURL", &NativeImage::ToDataURL)
|
||||
.SetMethod("toDataUrl", &NativeImage::ToDataURL) // deprecated.
|
||||
.SetMethod("isEmpty", &NativeImage::IsEmpty)
|
||||
@@ -222,20 +221,6 @@ std::string NativeImage::ToDataURL() {
|
||||
return data_url;
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> NativeImage::GetNativeHandle(v8::Isolate* isolate,
|
||||
mate::Arguments* args) {
|
||||
#if defined(OS_MACOSX)
|
||||
NSImage* ptr = image_.AsNSImage();
|
||||
return node::Buffer::Copy(
|
||||
isolate,
|
||||
reinterpret_cast<char*>(ptr),
|
||||
sizeof(void*)).ToLocalChecked();
|
||||
#else
|
||||
args->ThrowError("Not implemented");
|
||||
return v8::Undefined(isolate);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool NativeImage::IsEmpty() {
|
||||
return image_.IsEmpty();
|
||||
}
|
||||
|
||||
@@ -61,9 +61,6 @@ class NativeImage : public mate::Wrappable {
|
||||
private:
|
||||
v8::Local<v8::Value> ToPNG(v8::Isolate* isolate);
|
||||
v8::Local<v8::Value> ToJPEG(v8::Isolate* isolate, int quality);
|
||||
v8::Local<v8::Value> GetNativeHandle(
|
||||
v8::Isolate* isolate,
|
||||
mate::Arguments* args);
|
||||
std::string ToDataURL();
|
||||
bool IsEmpty();
|
||||
gfx::Size GetSize();
|
||||
|
||||
@@ -11,40 +11,20 @@
|
||||
|
||||
namespace {
|
||||
|
||||
v8::Local<v8::Value> GetHiddenValue(v8::Isolate* isolate,
|
||||
v8::Local<v8::Object> object,
|
||||
v8::Local<v8::Value> GetHiddenValue(v8::Local<v8::Object> object,
|
||||
v8::Local<v8::String> key) {
|
||||
v8::Local<v8::Context> context = isolate->GetCurrentContext();
|
||||
v8::Local<v8::Private> privateKey = v8::Private::ForApi(isolate, key);
|
||||
v8::Local<v8::Value> value;
|
||||
v8::Maybe<bool> result = object->HasPrivate(context, privateKey);
|
||||
if (!(result.IsJust() && result.FromJust()))
|
||||
return v8::Local<v8::Value>();
|
||||
if (object->GetPrivate(context, privateKey).ToLocal(&value))
|
||||
return value;
|
||||
return v8::Local<v8::Value>();
|
||||
return object->GetHiddenValue(key);
|
||||
}
|
||||
|
||||
void SetHiddenValue(v8::Isolate* isolate,
|
||||
v8::Local<v8::Object> object,
|
||||
void SetHiddenValue(v8::Local<v8::Object> object,
|
||||
v8::Local<v8::String> key,
|
||||
v8::Local<v8::Value> value) {
|
||||
if (value.IsEmpty())
|
||||
return;
|
||||
v8::Local<v8::Context> context = isolate->GetCurrentContext();
|
||||
v8::Local<v8::Private> privateKey = v8::Private::ForApi(isolate, key);
|
||||
object->SetPrivate(context, privateKey, value);
|
||||
object->SetHiddenValue(key, value);
|
||||
}
|
||||
|
||||
void DeleteHiddenValue(v8::Isolate* isolate,
|
||||
v8::Local<v8::Object> object,
|
||||
void DeleteHiddenValue(v8::Local<v8::Object> object,
|
||||
v8::Local<v8::String> key) {
|
||||
v8::Local<v8::Context> context = isolate->GetCurrentContext();
|
||||
v8::Local<v8::Private> privateKey = v8::Private::ForApi(isolate, key);
|
||||
// Actually deleting the value would make force the object into
|
||||
// dictionary mode which is unnecessarily slow. Instead, we replace
|
||||
// the hidden value with "undefined".
|
||||
object->SetPrivate(context, privateKey, v8::Undefined(isolate));
|
||||
object->DeleteHiddenValue(key);
|
||||
}
|
||||
|
||||
int32_t GetObjectHash(v8::Local<v8::Object> object) {
|
||||
|
||||
@@ -98,17 +98,24 @@ void AtomBindings::OnCallNextTick(uv_async_t* handle) {
|
||||
self->pending_next_ticks_.begin();
|
||||
it != self->pending_next_ticks_.end(); ++it) {
|
||||
node::Environment* env = *it;
|
||||
// KickNextTick, copied from node.cc:
|
||||
node::Environment::AsyncCallbackScope callback_scope(env);
|
||||
if (callback_scope.in_makecallback())
|
||||
continue;
|
||||
node::Environment::TickInfo* tick_info = env->tick_info();
|
||||
if (tick_info->length() == 0)
|
||||
|
||||
v8::Context::Scope context_scope(env->context());
|
||||
if (tick_info->in_tick())
|
||||
continue;
|
||||
|
||||
if (tick_info->length() == 0) {
|
||||
env->isolate()->RunMicrotasks();
|
||||
v8::Local<v8::Object> process = env->process_object();
|
||||
if (tick_info->length() == 0)
|
||||
}
|
||||
|
||||
if (tick_info->length() == 0) {
|
||||
tick_info->set_index(0);
|
||||
env->tick_callback_function()->Call(process, 0, nullptr).IsEmpty();
|
||||
continue;
|
||||
}
|
||||
|
||||
tick_info->set_in_tick(true);
|
||||
env->tick_callback_function()->Call(env->process_object(), 0, NULL);
|
||||
tick_info->set_in_tick(false);
|
||||
}
|
||||
|
||||
self->pending_next_ticks_.clear();
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
#include <list>
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "base/strings/string16.h"
|
||||
#include "v8/include/v8.h"
|
||||
#include "vendor/node/deps/uv/include/uv.h"
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#ifndef ATOM_COMMON_API_OBJECT_LIFE_MONITOR_H_
|
||||
#define ATOM_COMMON_API_OBJECT_LIFE_MONITOR_H_
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "base/basictypes.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "v8/include/v8.h"
|
||||
|
||||
|
||||
@@ -90,12 +90,12 @@ bool GetNodeFromPath(std::string path,
|
||||
}
|
||||
|
||||
bool FillFileInfoWithNode(Archive::FileInfo* info,
|
||||
uint32_t header_size,
|
||||
uint32 header_size,
|
||||
const base::DictionaryValue* node) {
|
||||
int size;
|
||||
if (!node->GetInteger("size", &size))
|
||||
return false;
|
||||
info->size = static_cast<uint32_t>(size);
|
||||
info->size = static_cast<uint32>(size);
|
||||
|
||||
if (node->GetBoolean("unpacked", &info->unpacked) && info->unpacked)
|
||||
return true;
|
||||
@@ -157,7 +157,7 @@ bool Archive::Init() {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t size;
|
||||
uint32 size;
|
||||
if (!base::PickleIterator(base::Pickle(buf.data(), buf.size())).ReadUInt32(
|
||||
&size)) {
|
||||
LOG(ERROR) << "Failed to parse header size from " << path_.value();
|
||||
@@ -296,7 +296,7 @@ bool Archive::CopyFileOut(const base::FilePath& path, base::FilePath* out) {
|
||||
#endif
|
||||
|
||||
*out = temp_file->path();
|
||||
external_files_.set(path, std::move(temp_file));
|
||||
external_files_.set(path, temp_file.Pass());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@ class Archive {
|
||||
FileInfo() : unpacked(false), executable(false), size(0), offset(0) {}
|
||||
bool unpacked;
|
||||
bool executable;
|
||||
uint32_t size;
|
||||
uint64_t offset;
|
||||
uint32 size;
|
||||
uint64 offset;
|
||||
};
|
||||
|
||||
struct Stats : public FileInfo {
|
||||
@@ -71,7 +71,7 @@ class Archive {
|
||||
base::FilePath path_;
|
||||
base::File file_;
|
||||
int fd_;
|
||||
uint32_t header_size_;
|
||||
uint32 header_size_;
|
||||
scoped_ptr<base::DictionaryValue> header_;
|
||||
|
||||
// Cached external temporary files.
|
||||
|
||||
@@ -51,7 +51,7 @@ bool ScopedTemporaryFile::Init(const base::FilePath::StringType& ext) {
|
||||
|
||||
bool ScopedTemporaryFile::InitFromFile(base::File* src,
|
||||
const base::FilePath::StringType& ext,
|
||||
uint64_t offset, uint64_t size) {
|
||||
uint64 offset, uint64 size) {
|
||||
if (!src->IsValid())
|
||||
return false;
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ class ScopedTemporaryFile {
|
||||
// Init an temporary file and fill it with content of |path|.
|
||||
bool InitFromFile(base::File* src,
|
||||
const base::FilePath::StringType& ext,
|
||||
uint64_t offset, uint64_t size);
|
||||
uint64 offset, uint64 size);
|
||||
|
||||
base::FilePath path() const { return path_; }
|
||||
|
||||
|
||||
@@ -8,8 +8,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "build/build_config.h"
|
||||
#include "base/basictypes.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user