Move the converters for blink structures to another file
It makes the api::WebContents smaller.
This commit is contained in:
parent
96d35ec29e
commit
7dc7ee1c41
5 changed files with 120 additions and 71 deletions
|
@ -15,6 +15,7 @@
|
|||
#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/native_mate_converters/blink_converter.h"
|
||||
#include "atom/common/native_mate_converters/callback.h"
|
||||
#include "atom/common/native_mate_converters/file_path_converter.h"
|
||||
#include "atom/common/native_mate_converters/gfx_converter.h"
|
||||
|
@ -45,7 +46,6 @@
|
|||
#include "net/http/http_response_headers.h"
|
||||
#include "net/url_request/static_http_user_agent_settings.h"
|
||||
#include "net/url_request/url_request_context.h"
|
||||
#include "third_party/WebKit/public/web/WebDeviceEmulationParams.h"
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
|
||||
|
@ -642,78 +642,11 @@ bool WebContents::IsDevToolsOpened() {
|
|||
return managed_web_contents()->IsDevToolsViewShowing();
|
||||
}
|
||||
|
||||
void WebContents::EnableDeviceEmulation(const base::DictionaryValue& dict) {
|
||||
void WebContents::EnableDeviceEmulation(
|
||||
const blink::WebDeviceEmulationParams& params) {
|
||||
if (type_ == REMOTE)
|
||||
return;
|
||||
|
||||
blink::WebDeviceEmulationParams params;
|
||||
|
||||
if (dict.HasKey("screenPosition")) {
|
||||
std::string screen_position;
|
||||
if (!dict.GetString("screenPosition", &screen_position))
|
||||
return;
|
||||
|
||||
screen_position = base::StringToLowerASCII(screen_position);
|
||||
|
||||
if (screen_position == "mobile") {
|
||||
params.screenPosition = blink::WebDeviceEmulationParams::Mobile;
|
||||
} else if (screen_position == "desktop") {
|
||||
params.screenPosition = blink::WebDeviceEmulationParams::Desktop;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (dict.HasKey("screenSize")) {
|
||||
if (!dict.GetInteger("screenSize.width", ¶ms.screenSize.width))
|
||||
return;
|
||||
if (!dict.GetInteger("screenSize.height", ¶ms.screenSize.height))
|
||||
return;
|
||||
}
|
||||
|
||||
if (dict.HasKey("viewPosition")) {
|
||||
if (!dict.GetInteger("viewPosition.x", ¶ms.viewPosition.x))
|
||||
return;
|
||||
if (!dict.GetInteger("viewPosition.y", ¶ms.viewPosition.y))
|
||||
return;
|
||||
}
|
||||
|
||||
if (dict.HasKey("deviceScaleFactor")) {
|
||||
double device_scale_factor;
|
||||
if (!dict.GetDouble("deviceScaleFactor", &device_scale_factor))
|
||||
return;
|
||||
params.deviceScaleFactor = static_cast<float>(device_scale_factor);
|
||||
}
|
||||
|
||||
if (dict.HasKey("viewSize")) {
|
||||
if (!dict.GetInteger("viewSize.width", ¶ms.viewSize.width))
|
||||
return;
|
||||
if (!dict.GetInteger("viewSize.height", ¶ms.viewSize.height))
|
||||
return;
|
||||
}
|
||||
|
||||
if (dict.HasKey("fitToView")) {
|
||||
if (!dict.GetBoolean("fitToView", ¶ms.fitToView))
|
||||
return;
|
||||
}
|
||||
|
||||
if (dict.HasKey("offset")) {
|
||||
double x, y;
|
||||
if (!dict.GetDouble("offset.x", &x))
|
||||
return;
|
||||
if (!dict.GetDouble("offset.y", &y))
|
||||
return;
|
||||
params.offset.x = static_cast<float>(x);
|
||||
params.offset.y = static_cast<float>(y);
|
||||
}
|
||||
|
||||
if (dict.HasKey("scale")) {
|
||||
double scale;
|
||||
if (!dict.GetDouble("scale", &scale))
|
||||
return;
|
||||
params.scale = static_cast<float>(scale);
|
||||
}
|
||||
|
||||
Send(new ViewMsg_EnableDeviceEmulation(routing_id(), params));
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,10 @@
|
|||
#include "native_mate/handle.h"
|
||||
#include "ui/gfx/image/image.h"
|
||||
|
||||
namespace blink {
|
||||
struct WebDeviceEmulationParams;
|
||||
}
|
||||
|
||||
namespace brightray {
|
||||
class InspectableWebContents;
|
||||
}
|
||||
|
@ -74,7 +78,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
|||
void CloseDevTools();
|
||||
bool IsDevToolsOpened();
|
||||
void ToggleDevTools();
|
||||
void EnableDeviceEmulation(const base::DictionaryValue&);
|
||||
void EnableDeviceEmulation(const blink::WebDeviceEmulationParams& params);
|
||||
void DisableDeviceEmulation();
|
||||
void InspectElement(int x, int y);
|
||||
void InspectServiceWorker();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue