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