Allow setting default zoom factor.
This commit is contained in:
parent
0bc8251e1b
commit
05f079fa5b
6 changed files with 34 additions and 1 deletions
|
@ -22,6 +22,7 @@
|
||||||
#include "base/json/json_writer.h"
|
#include "base/json/json_writer.h"
|
||||||
#include "base/prefs/pref_service.h"
|
#include "base/prefs/pref_service.h"
|
||||||
#include "base/message_loop/message_loop.h"
|
#include "base/message_loop/message_loop.h"
|
||||||
|
#include "base/strings/string_number_conversions.h"
|
||||||
#include "base/strings/stringprintf.h"
|
#include "base/strings/stringprintf.h"
|
||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
#include "base/values.h"
|
#include "base/values.h"
|
||||||
|
@ -58,6 +59,7 @@ NativeWindow::NativeWindow(content::WebContents* web_contents,
|
||||||
is_closed_(false),
|
is_closed_(false),
|
||||||
node_integration_("except-iframe"),
|
node_integration_("except-iframe"),
|
||||||
has_dialog_attached_(false),
|
has_dialog_attached_(false),
|
||||||
|
zoom_factor_(1.0),
|
||||||
weak_factory_(this),
|
weak_factory_(this),
|
||||||
inspectable_web_contents_(
|
inspectable_web_contents_(
|
||||||
brightray::InspectableWebContents::Create(web_contents)) {
|
brightray::InspectableWebContents::Create(web_contents)) {
|
||||||
|
@ -82,6 +84,9 @@ NativeWindow::NativeWindow(content::WebContents* web_contents,
|
||||||
if (options->GetDictionary(switches::kWebPreferences, &web_preferences))
|
if (options->GetDictionary(switches::kWebPreferences, &web_preferences))
|
||||||
web_preferences_.reset(web_preferences->DeepCopy());
|
web_preferences_.reset(web_preferences->DeepCopy());
|
||||||
|
|
||||||
|
// Read the zoom factor before any navigation.
|
||||||
|
options->GetDouble(switches::kZoomFactor, &zoom_factor_);
|
||||||
|
|
||||||
web_contents->SetDelegate(this);
|
web_contents->SetDelegate(this);
|
||||||
inspectable_web_contents()->SetDelegate(this);
|
inspectable_web_contents()->SetDelegate(this);
|
||||||
|
|
||||||
|
@ -358,6 +363,11 @@ void NativeWindow::AppendExtraCommandLineSwitches(CommandLine* command_line,
|
||||||
// Append --node-integration to renderer process.
|
// Append --node-integration to renderer process.
|
||||||
command_line->AppendSwitchASCII(switches::kNodeIntegration,
|
command_line->AppendSwitchASCII(switches::kNodeIntegration,
|
||||||
node_integration_);
|
node_integration_);
|
||||||
|
|
||||||
|
// Append --zoom-factor.
|
||||||
|
if (zoom_factor_ != 1.0)
|
||||||
|
command_line->AppendSwitchASCII(switches::kZoomFactor,
|
||||||
|
base::DoubleToString(zoom_factor_));
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindow::OverrideWebkitPrefs(const GURL& url, WebPreferences* prefs) {
|
void NativeWindow::OverrideWebkitPrefs(const GURL& url, WebPreferences* prefs) {
|
||||||
|
|
|
@ -294,9 +294,12 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
||||||
// it should be cancelled when we can prove that the window is responsive.
|
// it should be cancelled when we can prove that the window is responsive.
|
||||||
base::CancelableClosure window_unresposive_closure_;
|
base::CancelableClosure window_unresposive_closure_;
|
||||||
|
|
||||||
// web preferences.
|
// Web preferences.
|
||||||
scoped_ptr<base::DictionaryValue> web_preferences_;
|
scoped_ptr<base::DictionaryValue> web_preferences_;
|
||||||
|
|
||||||
|
// Page's default zoom factor.
|
||||||
|
double zoom_factor_;
|
||||||
|
|
||||||
base::WeakPtrFactory<NativeWindow> weak_factory_;
|
base::WeakPtrFactory<NativeWindow> weak_factory_;
|
||||||
|
|
||||||
base::WeakPtr<NativeWindow> devtools_window_;
|
base::WeakPtr<NativeWindow> devtools_window_;
|
||||||
|
|
|
@ -45,6 +45,9 @@ const char kUseContentSize[] = "use-content-size";
|
||||||
// The WebPreferences.
|
// The WebPreferences.
|
||||||
const char kWebPreferences[] = "web-preferences";
|
const char kWebPreferences[] = "web-preferences";
|
||||||
|
|
||||||
|
// The factor of which page should be zoomed.
|
||||||
|
const char kZoomFactor[] = "zoom-factor";
|
||||||
|
|
||||||
} // namespace switches
|
} // namespace switches
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
|
@ -31,6 +31,7 @@ extern const char kNodeIntegration[];
|
||||||
extern const char kAcceptFirstMouse[];
|
extern const char kAcceptFirstMouse[];
|
||||||
extern const char kUseContentSize[];
|
extern const char kUseContentSize[];
|
||||||
extern const char kWebPreferences[];
|
extern const char kWebPreferences[];
|
||||||
|
extern const char kZoomFactor[];
|
||||||
|
|
||||||
} // namespace switches
|
} // namespace switches
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,11 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "atom/common/api/api_messages.h"
|
#include "atom/common/api/api_messages.h"
|
||||||
|
#include "atom/common/options_switches.h"
|
||||||
#include "atom/renderer/api/atom_renderer_bindings.h"
|
#include "atom/renderer/api/atom_renderer_bindings.h"
|
||||||
#include "atom/renderer/atom_renderer_client.h"
|
#include "atom/renderer/atom_renderer_client.h"
|
||||||
|
#include "base/command_line.h"
|
||||||
|
#include "base/strings/string_number_conversions.h"
|
||||||
#include "content/public/renderer/render_view.h"
|
#include "content/public/renderer/render_view.h"
|
||||||
#include "ipc/ipc_message_macros.h"
|
#include "ipc/ipc_message_macros.h"
|
||||||
#include "third_party/WebKit/public/web/WebDraggableRegion.h"
|
#include "third_party/WebKit/public/web/WebDraggableRegion.h"
|
||||||
|
@ -32,6 +35,18 @@ AtomRenderViewObserver::AtomRenderViewObserver(
|
||||||
AtomRenderViewObserver::~AtomRenderViewObserver() {
|
AtomRenderViewObserver::~AtomRenderViewObserver() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AtomRenderViewObserver::DidCreateDocumentElement(WebKit::WebFrame* frame) {
|
||||||
|
std::string zoom_factor_str = CommandLine::ForCurrentProcess()->
|
||||||
|
GetSwitchValueASCII(switches::kZoomFactor);;
|
||||||
|
if (zoom_factor_str.empty())
|
||||||
|
return;
|
||||||
|
double zoom_factor;
|
||||||
|
if (!base::StringToDouble(zoom_factor_str, &zoom_factor))
|
||||||
|
return;
|
||||||
|
double zoom_level = WebKit::WebView::zoomFactorToZoomLevel(zoom_factor);
|
||||||
|
frame->view()->setZoomLevel(zoom_level);
|
||||||
|
}
|
||||||
|
|
||||||
void AtomRenderViewObserver::DraggableRegionsChanged(WebKit::WebFrame* frame) {
|
void AtomRenderViewObserver::DraggableRegionsChanged(WebKit::WebFrame* frame) {
|
||||||
WebKit::WebVector<WebKit::WebDraggableRegion> webregions =
|
WebKit::WebVector<WebKit::WebDraggableRegion> webregions =
|
||||||
frame->document().draggableRegions();
|
frame->document().draggableRegions();
|
||||||
|
|
|
@ -25,6 +25,7 @@ class AtomRenderViewObserver : public content::RenderViewObserver {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// content::RenderViewObserver implementation.
|
// content::RenderViewObserver implementation.
|
||||||
|
virtual void DidCreateDocumentElement(WebKit::WebFrame* frame) OVERRIDE;
|
||||||
virtual void DraggableRegionsChanged(WebKit::WebFrame* frame) OVERRIDE;
|
virtual void DraggableRegionsChanged(WebKit::WebFrame* frame) OVERRIDE;
|
||||||
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
|
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue