Avoid adding a new option to webPreferences

This commit is contained in:
Cheng Zhao 2016-04-14 10:50:07 +09:00
Родитель 8f0e594007
Коммит 31eb793fb0
8 изменённых файлов: 8 добавлений и 28 удалений

Просмотреть файл

@ -1127,12 +1127,6 @@ bool WebContents::IsGuest() const {
return type_ == WEB_VIEW;
}
void WebContents::MergeWebPreferences(const base::DictionaryValue& extend) {
WebContentsPreferences* web_preferences =
WebContentsPreferences::FromWebContents(web_contents());
web_preferences->Merge(extend);
}
v8::Local<v8::Value> WebContents::GetWebPreferences(v8::Isolate* isolate) {
WebContentsPreferences* web_preferences =
WebContentsPreferences::FromWebContents(web_contents());
@ -1227,7 +1221,6 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
.SetMethod("endFrameSubscription", &WebContents::EndFrameSubscription)
.SetMethod("setSize", &WebContents::SetSize)
.SetMethod("isGuest", &WebContents::IsGuest)
.SetMethod("mergeWebPreferences", &WebContents::MergeWebPreferences)
.SetMethod("getWebPreferences", &WebContents::GetWebPreferences)
.SetMethod("getOwnerBrowserWindow", &WebContents::GetOwnerBrowserWindow)
.SetMethod("hasServiceWorker", &WebContents::HasServiceWorker)

Просмотреть файл

@ -144,7 +144,6 @@ class WebContents : public mate::TrackableObject<WebContents>,
WindowOpenDisposition disposition);
// Returns the web preferences of current WebContents.
void MergeWebPreferences(const base::DictionaryValue& extend);
v8::Local<v8::Value> GetWebPreferences(v8::Isolate* isolate);
// Returns the owner window.

Просмотреть файл

@ -8,6 +8,7 @@
#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"
@ -147,9 +148,12 @@ void WebContentsPreferences::AppendExtraCommandLineSwitches(
blink_features);
// The initial visibility state.
std::string visibility;
if (web_preferences.GetString(options::kVisibilityState, &visibility))
command_line->AppendSwitchASCII(switches::kVisibilityState, visibility);
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");
}
}
// static

Просмотреть файл

@ -106,9 +106,6 @@ const char kOpenerID[] = "openerId";
// Enable blink features.
const char kBlinkFeatures[] = "blinkFeatures";
// The initiali visibility state.
const char kVisibilityState[] = "visibilityState";
} // namespace options
namespace switches {
@ -152,7 +149,6 @@ const char kPreloadURL[] = "preload-url";
const char kNodeIntegration[] = "node-integration";
const char kGuestInstanceID[] = "guest-instance-id";
const char kOpenerID[] = "opener-id";
const char kVisibilityState[] = "visibility-state";
// Widevine options
// Path to Widevine CDM binaries.

Просмотреть файл

@ -56,7 +56,6 @@ extern const char kGuestInstanceID[];
extern const char kExperimentalFeatures[];
extern const char kExperimentalCanvasFeatures[];
extern const char kOpenerID[];
extern const char kVisibilityState[];
extern const char kBlinkFeatures[];
} // namespace options
@ -84,7 +83,6 @@ extern const char kPreloadURL[];
extern const char kNodeIntegration[];
extern const char kGuestInstanceID[];
extern const char kOpenerID[];
extern const char kVisibilityState[];
extern const char kWidevineCdmPath[];
extern const char kWidevineCdmVersion[];

Просмотреть файл

@ -93,11 +93,6 @@ BrowserWindow.prototype._init = function () {
this.on('restore', visibilityChanged)
this.on('maximize', visibilityChanged)
// Make renderer process have correct initial state.
if (!isVisible) {
this.webContents.mergeWebPreferences({visibilityState: 'hidden'})
}
// Notify the creation of the window.
app.emit('browser-window-created', {}, this)

Просмотреть файл

@ -58,8 +58,6 @@ for (let arg of process.argv) {
nodeIntegration = arg.substr(arg.indexOf('=') + 1)
} else if (arg.indexOf('--preload=') === 0) {
preloadScript = arg.substr(arg.indexOf('=') + 1)
} else if (arg.indexOf('--visibility-state=') === 0) {
process.visibilityState = arg.substr(arg.indexOf('=') + 1)
}
}

Просмотреть файл

@ -225,10 +225,7 @@ Object.defineProperty(window.history, 'length', {
})
// The initial visibilityState.
let cachedVisibilityState = 'visible'
if (process.visibilityState) {
cachedVisibilityState = process.visibilityState
}
let cachedVisibilityState = process.argv.includes('--hidden-page') ? 'hidden' : 'visible'
// Subscribe to visibilityState changes.
ipcRenderer.on('ELECTRON_RENDERER_WINDOW_VISIBILITY_CHANGE', function (event, visibilityState) {