2014-10-31 11:17:05 -07:00
|
|
|
// Copyright (c) 2014 GitHub, Inc.
|
2014-06-16 14:27:57 +08:00
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2014-10-24 18:24:12 +08:00
|
|
|
#ifndef ATOM_RENDERER_API_ATOM_API_WEB_FRAME_H_
|
|
|
|
#define ATOM_RENDERER_API_ATOM_API_WEB_FRAME_H_
|
2014-06-16 14:27:57 +08:00
|
|
|
|
2016-07-04 15:08:55 +09:00
|
|
|
#include <memory>
|
2014-10-24 18:44:15 +08:00
|
|
|
#include <string>
|
2017-08-30 23:31:21 +02:00
|
|
|
#include <vector>
|
2014-10-24 18:44:15 +08:00
|
|
|
|
2015-05-29 13:47:09 +08:00
|
|
|
#include "atom/renderer/guest_view_container.h"
|
2014-06-16 14:27:57 +08:00
|
|
|
#include "native_mate/handle.h"
|
|
|
|
#include "native_mate/wrappable.h"
|
2017-04-05 18:02:06 +09:00
|
|
|
#include "third_party/WebKit/public/platform/WebCache.h"
|
2014-06-16 14:27:57 +08:00
|
|
|
|
2014-06-28 22:33:00 +08:00
|
|
|
namespace blink {
|
2014-10-24 18:24:12 +08:00
|
|
|
class WebLocalFrame;
|
2014-06-16 14:27:57 +08:00
|
|
|
}
|
|
|
|
|
2014-12-19 20:42:19 -08:00
|
|
|
namespace mate {
|
2017-11-15 11:14:41 +01:00
|
|
|
class Dictionary;
|
2014-12-19 20:42:19 -08:00
|
|
|
class Arguments;
|
|
|
|
}
|
|
|
|
|
2014-06-16 14:27:57 +08:00
|
|
|
namespace atom {
|
|
|
|
|
|
|
|
namespace api {
|
|
|
|
|
2014-12-18 13:54:01 -08:00
|
|
|
class SpellCheckClient;
|
|
|
|
|
2016-04-25 10:17:54 +09:00
|
|
|
class WebFrame : public mate::Wrappable<WebFrame> {
|
2014-06-16 14:27:57 +08:00
|
|
|
public:
|
2014-10-24 18:24:12 +08:00
|
|
|
static mate::Handle<WebFrame> Create(v8::Isolate* isolate);
|
2014-06-16 14:27:57 +08:00
|
|
|
|
2016-04-25 10:17:54 +09:00
|
|
|
static void BuildPrototype(v8::Isolate* isolate,
|
2016-08-02 18:08:12 +09:00
|
|
|
v8::Local<v8::FunctionTemplate> prototype);
|
2016-04-25 10:17:54 +09:00
|
|
|
|
2014-06-16 14:27:57 +08:00
|
|
|
private:
|
2016-04-25 10:17:54 +09:00
|
|
|
explicit WebFrame(v8::Isolate* isolate);
|
2018-01-09 14:41:40 -05:00
|
|
|
explicit WebFrame(v8::Isolate* isolate, blink::WebLocalFrame* blink_frame);
|
2016-04-25 10:17:54 +09:00
|
|
|
~WebFrame() override;
|
2014-06-16 14:27:57 +08:00
|
|
|
|
2014-10-24 18:44:15 +08:00
|
|
|
void SetName(const std::string& name);
|
|
|
|
|
2014-06-16 14:39:29 +08:00
|
|
|
double SetZoomLevel(double level);
|
2014-06-16 14:27:57 +08:00
|
|
|
double GetZoomLevel() const;
|
2014-06-16 14:39:29 +08:00
|
|
|
double SetZoomFactor(double factor);
|
|
|
|
double GetZoomFactor() const;
|
2014-06-16 14:27:57 +08:00
|
|
|
|
2016-11-22 07:53:02 -08:00
|
|
|
void SetVisualZoomLevelLimits(double min_level, double max_level);
|
2016-11-21 14:59:27 -05:00
|
|
|
void SetLayoutZoomLevelLimits(double min_level, double max_level);
|
2015-08-27 22:08:25 +08:00
|
|
|
|
2015-05-22 19:11:22 +08:00
|
|
|
v8::Local<v8::Value> RegisterEmbedderCustomElement(
|
|
|
|
const base::string16& name, v8::Local<v8::Object> options);
|
2015-05-29 13:47:09 +08:00
|
|
|
void RegisterElementResizeCallback(
|
|
|
|
int element_instance_id,
|
|
|
|
const GuestViewContainer::ResizeCallback& callback);
|
2014-12-08 08:05:34 -08:00
|
|
|
void AttachGuest(int element_instance_id);
|
2016-09-08 10:01:01 -07:00
|
|
|
void DetachGuest(int element_instance_id);
|
2014-10-22 21:01:12 +08:00
|
|
|
|
2014-12-18 13:54:01 -08:00
|
|
|
// Set the provider that will be used by SpellCheckClient for spell check.
|
2014-12-19 20:42:19 -08:00
|
|
|
void SetSpellCheckProvider(mate::Arguments* args,
|
|
|
|
const std::string& language,
|
2014-12-19 21:01:47 -08:00
|
|
|
bool auto_spell_correct_turned_on,
|
2015-05-22 19:11:22 +08:00
|
|
|
v8::Local<v8::Object> provider);
|
2014-12-18 13:54:01 -08:00
|
|
|
|
2015-07-29 16:50:50 +05:30
|
|
|
void RegisterURLSchemeAsSecure(const std::string& scheme);
|
2015-11-13 16:03:40 +08:00
|
|
|
void RegisterURLSchemeAsBypassingCSP(const std::string& scheme);
|
2016-10-24 16:27:54 +09:00
|
|
|
void RegisterURLSchemeAsPrivileged(const std::string& scheme,
|
|
|
|
mate::Arguments* args);
|
2015-07-29 16:50:50 +05:30
|
|
|
|
2016-01-13 11:21:16 +08:00
|
|
|
// Editing.
|
|
|
|
void InsertText(const std::string& text);
|
2016-12-19 15:50:47 -08:00
|
|
|
void InsertCSS(const std::string& css);
|
2016-01-13 11:21:16 +08:00
|
|
|
|
2017-11-15 11:14:41 +01:00
|
|
|
// Executing scripts.
|
2016-01-13 12:17:56 +08:00
|
|
|
void ExecuteJavaScript(const base::string16& code, mate::Arguments* args);
|
2017-11-15 11:14:41 +01:00
|
|
|
void ExecuteJavaScriptInIsolatedWorld(
|
|
|
|
int world_id,
|
|
|
|
const std::vector<mate::Dictionary>& scripts,
|
|
|
|
mate::Arguments* args);
|
|
|
|
|
|
|
|
// Isolated world related methods
|
|
|
|
void SetIsolatedWorldSecurityOrigin(int world_id,
|
|
|
|
const std::string& origin_url);
|
|
|
|
void SetIsolatedWorldContentSecurityPolicy(
|
|
|
|
int world_id,
|
|
|
|
const std::string& security_policy);
|
2017-11-15 10:35:04 +01:00
|
|
|
void SetIsolatedWorldHumanReadableName(int world_id,
|
|
|
|
const std::string& name);
|
|
|
|
|
2016-05-12 13:56:46 -07:00
|
|
|
// Resource related methods
|
2016-05-13 10:43:08 -07:00
|
|
|
blink::WebCache::ResourceTypeStats GetResourceUsage(v8::Isolate* isolate);
|
2016-05-14 22:48:25 +09:00
|
|
|
void ClearCache(v8::Isolate* isolate);
|
2016-05-12 13:56:46 -07:00
|
|
|
|
2018-01-09 14:41:40 -05:00
|
|
|
// Frame navigation
|
|
|
|
v8::Local<v8::Value> Opener() const;
|
|
|
|
v8::Local<v8::Value> Parent() const;
|
|
|
|
v8::Local<v8::Value> Top() const;
|
|
|
|
v8::Local<v8::Value> FirstChild() const;
|
|
|
|
v8::Local<v8::Value> NextSibling() const;
|
|
|
|
v8::Local<v8::Value> GetFrameForSelector(const std::string& selector) const;
|
|
|
|
v8::Local<v8::Value> FindFrameByName(const std::string& name) const;
|
|
|
|
|
2016-05-23 10:59:39 +09:00
|
|
|
std::unique_ptr<SpellCheckClient> spell_check_client_;
|
2014-12-18 13:54:01 -08:00
|
|
|
|
2014-10-24 18:24:12 +08:00
|
|
|
blink::WebLocalFrame* web_frame_;
|
2014-06-16 14:27:57 +08:00
|
|
|
|
2014-10-24 18:24:12 +08:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(WebFrame);
|
2014-06-16 14:27:57 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace api
|
|
|
|
|
|
|
|
} // namespace atom
|
|
|
|
|
2014-10-24 18:24:12 +08:00
|
|
|
#endif // ATOM_RENDERER_API_ATOM_API_WEB_FRAME_H_
|