Merge pull request #351 from atom/custom-web-preferences
Enable custom web preferences
This commit is contained in:
commit
890448d5fa
7 changed files with 69 additions and 0 deletions
|
@ -31,6 +31,7 @@
|
|||
#include "content/public/browser/notification_details.h"
|
||||
#include "content/public/browser/notification_source.h"
|
||||
#include "content/public/browser/notification_types.h"
|
||||
#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_view.h"
|
||||
|
@ -76,6 +77,11 @@ NativeWindow::NativeWindow(content::WebContents* web_contents,
|
|||
// Read iframe security before any navigation.
|
||||
options->GetString(switches::kNodeIntegration, &node_integration_);
|
||||
|
||||
// Read the web preferences.
|
||||
base::DictionaryValue* web_preferences;
|
||||
if (options->GetDictionary(switches::kWebPreferences, &web_preferences))
|
||||
web_preferences_.reset(web_preferences->DeepCopy());
|
||||
|
||||
web_contents->SetDelegate(this);
|
||||
inspectable_web_contents()->SetDelegate(this);
|
||||
|
||||
|
@ -348,6 +354,37 @@ void NativeWindow::OverrideWebkitPrefs(const GURL& url, WebPreferences* prefs) {
|
|||
// FIXME Disable accelerated composition in frameless window.
|
||||
if (!has_frame_)
|
||||
prefs->accelerated_compositing_enabled = false;
|
||||
|
||||
bool b;
|
||||
base::ListValue* list;
|
||||
if (!web_preferences_)
|
||||
return;
|
||||
if (web_preferences_->GetBoolean("javascript", &b))
|
||||
prefs->javascript_enabled = b;
|
||||
if (web_preferences_->GetBoolean("web-security", &b))
|
||||
prefs->web_security_enabled = b;
|
||||
if (web_preferences_->GetBoolean("images", &b))
|
||||
prefs->images_enabled = b;
|
||||
if (web_preferences_->GetBoolean("java", &b))
|
||||
prefs->java_enabled = b;
|
||||
if (web_preferences_->GetBoolean("text-areas-are-resizable", &b))
|
||||
prefs->text_areas_are_resizable = b;
|
||||
if (web_preferences_->GetBoolean("webgl", &b))
|
||||
prefs->experimental_webgl_enabled = b;
|
||||
if (web_preferences_->GetBoolean("webaudio", &b))
|
||||
prefs->webaudio_enabled = b;
|
||||
if (web_preferences_->GetBoolean("accelerated-compositing", &b))
|
||||
prefs->accelerated_compositing_enabled = b;
|
||||
if (web_preferences_->GetBoolean("plugins", &b))
|
||||
prefs->plugins_enabled = b;
|
||||
if (web_preferences_->GetList("extra-plugin-dirs", &list))
|
||||
for (size_t i = 0; i < list->GetSize(); ++i) {
|
||||
base::FilePath::StringType path_string;
|
||||
if (list->GetString(i, &path_string)) {
|
||||
base::FilePath path(path_string);
|
||||
content::PluginService::GetInstance()->AddExtraPluginDir(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NativeWindow::NotifyWindowClosed() {
|
||||
|
|
|
@ -291,6 +291,9 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
|||
// it should be cancelled when we can prove that the window is responsive.
|
||||
base::CancelableClosure window_unresposive_closure_;
|
||||
|
||||
// web preferences.
|
||||
scoped_ptr<base::DictionaryValue> web_preferences_;
|
||||
|
||||
base::WeakPtrFactory<NativeWindow> weak_factory_;
|
||||
|
||||
base::WeakPtr<NativeWindow> devtools_window_;
|
||||
|
|
|
@ -39,6 +39,9 @@ const char kAcceptFirstMouse[] = "accept-first-mouse";
|
|||
// Whether window size should include window frame.
|
||||
const char kUseContentSize[] = "use-content-size";
|
||||
|
||||
// The WebPreferences.
|
||||
const char kWebPreferences[] = "web-preferences";
|
||||
|
||||
} // namespace switches
|
||||
|
||||
} // namespace atom
|
||||
|
|
|
@ -29,6 +29,7 @@ extern const char kAlwaysOnTop[];
|
|||
extern const char kNodeIntegration[];
|
||||
extern const char kAcceptFirstMouse[];
|
||||
extern const char kUseContentSize[];
|
||||
extern const char kWebPreferences[];
|
||||
|
||||
} // namespace switches
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
## API references
|
||||
|
||||
* [Synopsis](api/synopsis.md)
|
||||
* [Process object](api/process.md)
|
||||
|
||||
Modules for browser side:
|
||||
|
||||
|
|
|
@ -51,6 +51,22 @@ You can also create a window without chrome by using
|
|||
`manual-enable-iframe` or `disable`.
|
||||
* `accept-first-mouse` Boolean - Whether the web view accepts a single
|
||||
mouse-down event that simultaneously activates the window
|
||||
* `web-preferences` Object - Settings of web page's features
|
||||
* `javascript` Boolean
|
||||
* `web-security` Boolean
|
||||
* `images` Boolean
|
||||
* `java` Boolean
|
||||
* `text-areas-are-resizable` Boolean
|
||||
* `webgl` Boolean
|
||||
* `webaudio` Boolean
|
||||
* `accelerated-compositing` Boolean
|
||||
* `plugins` Boolean - Whether plugins should be enabled, currently only
|
||||
`NPAPI` plugins are supported.
|
||||
* `extra-plugin-dirs` Array - Array of paths that would be searched for
|
||||
plugins. Note that if you want to add a directory under your app, you
|
||||
should use `__dirname` or `process.resourcesPath` to join the paths to
|
||||
make them absolute, using relative paths would make atom-shell search
|
||||
under current working directory.
|
||||
|
||||
Creates a new `BrowserWindow` with native properties set by the `options`.
|
||||
Usually you only need to set the `width` and `height`, other properties will
|
||||
|
|
8
docs/api/process.md
Normal file
8
docs/api/process.md
Normal file
|
@ -0,0 +1,8 @@
|
|||
# Process object
|
||||
|
||||
The `process` object in atom-shell has following differences between the one in
|
||||
upstream node:
|
||||
|
||||
* `process.type` String - Process's type, can be `browser` or `renderer`.
|
||||
* `process.versions['atom-shell']` String - Version of atom-shell.
|
||||
* `process.resourcesPath` String - Path to JavaScript source codes.
|
Loading…
Reference in a new issue