Skip to content

Commit

Permalink
Merge pull request #3 from electron/master
Browse files Browse the repository at this point in the history
update from electron
  • Loading branch information
Stone-Jay committed Apr 19, 2016
2 parents 7d788cf + 1c87acb commit ace235b
Show file tree
Hide file tree
Showing 18 changed files with 197 additions and 51 deletions.
26 changes: 9 additions & 17 deletions atom/browser/api/atom_api_session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@
#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.h"
#include "brightray/browser/net/devtools_network_controller_handle.h"
#include "chrome/common/pref_names.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
Expand Down Expand Up @@ -288,7 +289,8 @@ void ClearHostResolverCacheInIO(
} // namespace

Session::Session(AtomBrowserContext* browser_context)
: browser_context_(browser_context) {
: devtools_network_emulation_client_id_(base::GenerateGUID()),
browser_context_(browser_context) {
AttachAsUserData(browser_context);

// Observe DownloadManger to get download notifications.
Expand Down Expand Up @@ -381,25 +383,15 @@ void Session::EnableNetworkEmulation(const mate::Dictionary& options) {
download_throughput,
upload_throughput));
}
auto controller = browser_context_->GetDevToolsNetworkController();

BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
base::Bind(&brightray::DevToolsNetworkController::SetNetworkState,
base::Unretained(controller),
std::string(),
base::Passed(&conditions)));
browser_context_->network_controller_handle()->SetNetworkState(
devtools_network_emulation_client_id_, std::move(conditions));
}

void Session::DisableNetworkEmulation() {
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)));
scoped_ptr<brightray::DevToolsNetworkConditions> conditions;
browser_context_->network_controller_handle()->SetNetworkState(
devtools_network_emulation_client_id_, std::move(conditions));
}

void Session::SetCertVerifyProc(v8::Local<v8::Value> val,
Expand Down
3 changes: 3 additions & 0 deletions atom/browser/api/atom_api_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ 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);
Expand Down
1 change: 1 addition & 0 deletions atom/browser/api/atom_api_web_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ content::ServiceWorkerContext* GetServiceWorkerContext(

WebContents::WebContents(content::WebContents* web_contents)
: content::WebContentsObserver(web_contents),
embedder_(nullptr),
type_(REMOTE),
request_id_(0),
background_throttling_(true) {
Expand Down
4 changes: 2 additions & 2 deletions atom/browser/resources/mac/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
<key>CFBundleIconFile</key>
<string>electron.icns</string>
<key>CFBundleVersion</key>
<string>0.37.5</string>
<string>0.37.6</string>
<key>CFBundleShortVersionString</key>
<string>0.37.5</string>
<string>0.37.6</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.developer-tools</string>
<key>LSMinimumSystemVersion</key>
Expand Down
8 changes: 4 additions & 4 deletions atom/browser/resources/win/atom.rc
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ END
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,37,5,0
PRODUCTVERSION 0,37,5,0
FILEVERSION 0,37,6,0
PRODUCTVERSION 0,37,6,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -74,12 +74,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "GitHub, Inc."
VALUE "FileDescription", "Electron"
VALUE "FileVersion", "0.37.5"
VALUE "FileVersion", "0.37.6"
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.5"
VALUE "ProductVersion", "0.37.6"
VALUE "SquirrelAwareVersion", "1"
END
END
Expand Down
2 changes: 1 addition & 1 deletion atom/common/atom_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#define ATOM_MAJOR_VERSION 0
#define ATOM_MINOR_VERSION 37
#define ATOM_PATCH_VERSION 5
#define ATOM_PATCH_VERSION 6

#define ATOM_VERSION_IS_RELEASE 1

Expand Down
12 changes: 6 additions & 6 deletions docs-translations/es/tutorial/application-packaging.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ $ asar pack your-app app.asar

## Utilizando los paquetes `asar`

En Electron existen dos tipos de APIs: las APIs de Node, proveídas por Node.js,
y las APIs Web, proveídas por Chromium. Ambas APIs soportan la lecutra de paquetes `asar`.
En Electron existen dos tipos de APIs: las APIs de Node, provistas por Node.js,
y las APIs Web, provistas por Chromium. Ambas APIs soportan la lectura de paquetes `asar`.

### API Node

Expand Down Expand Up @@ -92,7 +92,7 @@ $.get('file:///path/to/example.asar/file.txt', function(data) {
### Utilizando un paquete `asar` como un archivo normal

En algunas situaciones necesitaremos acceder al paquete `asar` como archivo, por ejemplo,
si necesitaramos verificar la integridad del archivo con un checksum.
si necesitáramos verificar la integridad del archivo con un checksum.
Para casos así es posible utilizar el módulo `original-fs`, que provee la API `fs` original:

```javascript
Expand Down Expand Up @@ -127,7 +127,7 @@ Las APIs que requieren el desempaquetamiento adicional son:
* `child_process.execFile`
* `fs.open`
* `fs.openSync`
* `process.dlopen` - Utilizado po `require` en los módulos nativos
* `process.dlopen` - Utilizado por `require` en los módulos nativos

### Información falsa en `fs.stat`

Expand All @@ -143,8 +143,8 @@ Como se menciona arriba, algunas APIs de Node desempaquetarán archivos cuando e
que los referencie, además de los problemas de rendimiento que esto podría ocasionar, también
podría accionar alertas falsas en software antivirus.

Para lidiar con esto, puedes desempaquetar algunos archivos utilizando la opción `--unpack`,
a continuación un ejemplo que excluye las librerías compartidas de los módulos nativos:
Para lidiar con esto, puedes desempaquetar algunos archivos utilizando la opción `--unpack`.
A continuación, un ejemplo que excluye las librerías compartidas de los módulos nativos:

```bash
$ asar pack app app.asar --unpack *.node
Expand Down
3 changes: 3 additions & 0 deletions docs-translations/ko-KR/api/session.md
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,9 @@ HTTP 요청을 보내기 전 요청 헤더를 사용할 수 있을 때 `listener
* `cancel` Boolean
* `responseHeaders` Object (optional) - 이 속성이 제공되면 서버는 이 헤더와
함께 응답합니다.
* `statusLine` String (optional) - `responseHeaders`를 덮어쓸 땐, 헤더의 상태를
변경하기 위해 반드시 지정되어야 합니다. 그렇지 않은 경우, 기존의 응답 헤더의 상태가
사용됩니다.

#### `ses.webRequest.onResponseStarted([filter, ]listener)`

Expand Down
18 changes: 14 additions & 4 deletions docs-translations/ko-KR/development/coding-style.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,19 @@ C++ 코드는 많은 Chromium의 추상화와 타입을 사용합니다. 따라
* [Template literals](https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Template_literals)
`+`로 문자열을 합치는 대신 사용합니다.

## API 이름
## 이름 짓기

새로운 API를 만들 땐 getter, setter스타일 대신 jQuery의 one-function 스타일을
사용해야 합니다. 예를 들어 `.getText()``.setText(text)`대신에 `.text([text])`
형식으로 설계하면 됩니다. 포럼에 이 문제에 대한 [논의](https://github.com/electron/electron/issues/46)
Electron API는 Node.js와 비슷한 명명법을 사용합니다:

- `BrowserWindow`와 같은 모듈 자체를 뜻하는 이름은, `CamelCase`를 사용합니다.
- `globalShortcut`과 같은 API의 세트일 땐, `mixedCase`를 사용합니다.
- API가 객체의 속성일 경우, 그리고 `win.webContents`와 같이 충분히 복잡하고 분리된
부분일 경우, `mixedCase`를 사용합니다.
- 다른 모듈이 아닌 API를 구현할 땐, `<webview> Tag` 또는 `Process Object`와 같이
단순하고 자연스러운 제목을 사용합니다.

새로운 API를 만들 땐 jQuery의 one-function 스타일 대신 getter, setter스타일을
사용해야 합니다. 예를 들어 `.text([text])` 대신 `.getText()``.setText(text)`
형식으로 함수를 설계하면 됩니다. 포럼에서 이 문제에 대한
[논의](https://github.com/electron/electron/issues/46)
진행되고 있습니다.
4 changes: 2 additions & 2 deletions docs-translations/zh-CN/api/browser-window.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ win.show();
* `zoomFactor` Number - 界面默认缩放值, `3.0` 表示
`300%`. 默认 `1.0`.
* `javascript` Boolean - 开启javascript支持. 默认为`true`.
* `webSecurity` Boolean - 当设置为 `false`, 它将禁用相同地方的规则 (通常测试服), 并且如果有2个非用户设置的参数,就设置
* `webSecurity` Boolean - 当设置为 `false`, 它将禁用同源策略 (通常用来测试网站), 并且如果有2个非用户设置的参数,就设置
`allowDisplayingInsecureContent``allowRunningInsecureContent` 的值为
`true`. 默认为 `true`.
* `allowDisplayingInsecureContent` Boolean -允许一个使用 https的界面来展示由 http URLs 传过来的资源. 默认`false`.
Expand Down Expand Up @@ -758,4 +758,4 @@ windows上句柄类型为 `HWND` ,OS X `NSView*` , Linux `Window`.

忽略窗口的所有鼠标事件.

[blink-feature-string]: https://code.google.com/p/chromium/codesearch#chromium/src/out/Debug/gen/blink/platform/RuntimeEnabledFeatures.cpp&sq=package:chromium&type=cs&l=527
[blink-feature-string]: https://code.google.com/p/chromium/codesearch#chromium/src/out/Debug/gen/blink/platform/RuntimeEnabledFeatures.cpp&sq=package:chromium&type=cs&l=527
87 changes: 87 additions & 0 deletions docs-translations/zh-CN/api/frameless-window.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# 无边框窗口

无边框窗口指的是不包含除页面本身以外任何其它可视部分的窗口([chrome](https://developer.mozilla.org/en-US/docs/Glossary/Chrome))。
像工具栏,是窗口的一部分,但并不属于页面。这些是[`BrowserWindow`](browser-window.md) 类的选项。

## 创建无边框窗口

为了创建一个无边框窗口,你需要设置[BrowserWindow](browser-window.md)`frame``false`:



```javascript
const BrowserWindow = require('electron').BrowserWindow;
var win = new BrowserWindow({ width: 800, height: 600, frame: false });
```

### OS X上的替代方案

在Mac OS X 10.10 Yosemite或者更新的版本中,有一个替代方案去生成一个无边框窗口。
不同于设置`frame``false`会隐藏标题栏以及失去对窗口的控制,你可能想隐藏标题栏使你的页面内容显示在整个窗口上
,同时又想保持对窗口的控制("traffic lights")。你可以通过指定`titleBarStyle`这一新选项达到目标:

```javascript
var win = new BrowserWindow({ 'titleBarStyle': 'hidden' });
```

## 透明窗口

通过设置`transparent` 选项为 `true`,你能使无边框窗口透明:

```javascript
var win = new BrowserWindow({ transparent: true, frame: false });
```

### 限制

* 你无法点击透明的区域。我们正在采用一个新的API去设置窗口的外形以解决这个问题,
详见[our issue](https://github.com/electron/electron/issues/1335)
* 透明窗口是不可调整大小的。在某些平台上,设置`resizable``true`也许会造成这个透明窗口停止工作。
* `blur`滤光器器只适用于网页,所以没法将模糊效果用于窗口之下(i.e. 其它在用户的系统中打开的应用)。
* 在Windows系统中,当DWM被禁用时透明窗口不会工作。
* Linux用户需要在命令行中输入`--enable-transparent-visuals --disable-gpu`
去禁用GPU以及允许ARGB去渲染透明窗口,这是由于一个Linux上的上游bug[alpha channel doesn't work on some
NVidia drivers](https://code.google.com/p/chromium/issues/detail?id=369209)造成的
* 在Mac上,透明窗口的阴影不会显示出来.

## 可拖动区域

默认情况下,无边框窗口是不可拖动的。应用在CSS中设置`-webkit-app-region: drag`
告诉Electron哪个区域是可拖动的(比如系统标准的标题栏),应用也可以设置`-webkit-app-region: no-drag`
在可拖动区域中排除不可拖动的区域。需要注意的是,目前只支持矩形区域。

为了让整个窗口可拖动,你可以在`body`的样式中添加`-webkit-app-region: drag`:

```html
<body style="-webkit-app-region: drag">
</body>
```

另外需要注意的是,如果你设置了整个窗口可拖动,你必须标记按钮为不可拖动的(non-draggable),
否则用户不能点击它们:

```css
button {
-webkit-app-region: no-drag;
}
```

如果你设置一个自定义的标题栏可拖动,你同样需要设置标题栏中所有的按钮为不可拖动(non-draggable)。

## 文本选择

在一个无边框窗口中,拖动动作会与文本选择发生冲突。比如,当你拖动标题栏,偶尔会选中标题栏上的文本。
为了防止这种情况发生,你需要向下面这样在一个可拖动区域中禁用文本选择:

```css
.titlebar {
-webkit-user-select: none;
-webkit-app-region: drag;
}
```

## 上下文菜单

在一些平台上,可拖动区域会被认为是非客户端框架(non-client frame),所有当你点击右键时,一个系统菜单会弹出。
为了保证上下文菜单在所有平台下正确的显示,你不应该在可拖动区域使用自定义上下文菜单。

2 changes: 1 addition & 1 deletion docs/api/browser-window.md
Original file line number Diff line number Diff line change
Expand Up @@ -912,4 +912,4 @@ Returns whether the window is visible on all workspaces.

Ignore all moused events that happened in the window.

[blink-feature-string]: https://code.google.com/p/chromium/codesearch#chromium/src/out/Debug/gen/blink/platform/RuntimeEnabledFeatures.cpp&sq=package:chromium&type=cs&l=527
[blink-feature-string]: https://code.google.com/p/chromium/codesearch#chromium/src/out/Debug/gen/blink/platform/RuntimeEnabledFeatures.cpp&sq=package:chromium&type=cs&l=576
2 changes: 1 addition & 1 deletion docs/api/menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ var template = [
})(),
click: function(item, focusedWindow) {
if (focusedWindow)
focusedWindow.toggleDevTools();
focusedWindow.webContents.toggleDevTools();
}
},
]
Expand Down
40 changes: 35 additions & 5 deletions docs/api/web-view-tag.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ control the appearance of the `webview` container:
```html
<webview id="foo" src="https://www.github.com/" style="display:inline-flex; width:640px; height:480px"></webview>
```
Please note that the `webview` tag's style uses `display:flex;` internally to
ensure the child `object` element fills the full height and width of its `webview`
container when used with traditional and flexbox layouts (since v0.36.11). Please
do not overwrite the default `display:flex;` CSS property, unless specifying
`display:inline-flex;` for inline layout.

If you want to control the guest content in any way, you can write JavaScript
that listens for `webview` events and responds to those events using the
Expand All @@ -50,6 +45,36 @@ and displays a "loading..." message during the load time:
</script>
```

## CSS Styling Notes

Please note that the `webview` tag's style uses `display:flex;` internally to
ensure the child `object` element fills the full height and width of its `webview`
container when used with traditional and flexbox layouts (since v0.36.11). Please
do not overwrite the default `display:flex;` CSS property, unless specifying
`display:inline-flex;` for inline layout.

`webview` has issues being hidden using the `hidden` attribute or using `display: none;`.
It can cause unusual rendering behaviour within its child `browserplugin` object
and the web page is reloaded, when the `webview` is un-hidden, as opposed to just
becoming visible again. The recommended approach is to hide the `webview` using
CSS by zeroing the `width` & `height` and allowing the element to shrink to the 0px
dimensions via `flex`.

```html
<style>
webview {
display:inline-flex;
width:640px;
height:480px;
}
webview.hide {
flex: 0 1;
width: 0px;
height: 0px;
}
</style>
```

## Tag Attributes

The `webview` tag has the following attributes:
Expand Down Expand Up @@ -479,6 +504,7 @@ Returns:
* `errorCode` Integer
* `errorDescription` String
* `validatedURL` String
* `isMainFrame` Boolean

This event is like `did-finish-load`, but fired when the load failed or was
cancelled, e.g. `window.stop()` is invoked.
Expand Down Expand Up @@ -737,6 +763,10 @@ Emitted when media is paused or done playing.

### Event: 'did-change-theme-color'

Returns:

* `themeColor` String

Emitted when a page's theme color changes. This is usually due to encountering a meta tag:

```html
Expand Down
2 changes: 1 addition & 1 deletion electron.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
'product_name%': 'Electron',
'company_name%': 'GitHub, Inc',
'company_abbr%': 'github',
'version%': '0.37.5',
'version%': '0.37.6',
},
'includes': [
'filenames.gypi',
Expand Down
Loading

0 comments on commit ace235b

Please sign in to comment.