atom_api_web_frame.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. // Copyright (c) 2014 GitHub, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #ifndef ATOM_RENDERER_API_ATOM_API_WEB_FRAME_H_
  5. #define ATOM_RENDERER_API_ATOM_API_WEB_FRAME_H_
  6. #include <memory>
  7. #include <string>
  8. #include <vector>
  9. #include "atom/renderer/guest_view_container.h"
  10. #include "native_mate/handle.h"
  11. #include "native_mate/wrappable.h"
  12. #include "third_party/WebKit/public/platform/WebCache.h"
  13. namespace blink {
  14. class WebLocalFrame;
  15. }
  16. namespace mate {
  17. class Dictionary;
  18. class Arguments;
  19. } // namespace mate
  20. namespace atom {
  21. namespace api {
  22. class SpellCheckClient;
  23. class WebFrame : public mate::Wrappable<WebFrame> {
  24. public:
  25. static mate::Handle<WebFrame> Create(v8::Isolate* isolate);
  26. static void BuildPrototype(v8::Isolate* isolate,
  27. v8::Local<v8::FunctionTemplate> prototype);
  28. private:
  29. explicit WebFrame(v8::Isolate* isolate);
  30. explicit WebFrame(v8::Isolate* isolate, blink::WebLocalFrame* blink_frame);
  31. ~WebFrame() override;
  32. void SetName(const std::string& name);
  33. double SetZoomLevel(double level);
  34. double GetZoomLevel() const;
  35. double SetZoomFactor(double factor);
  36. double GetZoomFactor() const;
  37. void SetVisualZoomLevelLimits(double min_level, double max_level);
  38. void SetLayoutZoomLevelLimits(double min_level, double max_level);
  39. v8::Local<v8::Value> RegisterEmbedderCustomElement(
  40. const base::string16& name,
  41. v8::Local<v8::Object> options);
  42. void RegisterElementResizeCallback(
  43. int element_instance_id,
  44. const GuestViewContainer::ResizeCallback& callback);
  45. void AttachGuest(int element_instance_id);
  46. void DetachGuest(int element_instance_id);
  47. // Set the provider that will be used by SpellCheckClient for spell check.
  48. void SetSpellCheckProvider(mate::Arguments* args,
  49. const std::string& language,
  50. bool auto_spell_correct_turned_on,
  51. v8::Local<v8::Object> provider);
  52. void RegisterURLSchemeAsBypassingCSP(const std::string& scheme);
  53. void RegisterURLSchemeAsPrivileged(const std::string& scheme,
  54. mate::Arguments* args);
  55. // Editing.
  56. void InsertText(const std::string& text);
  57. void InsertCSS(const std::string& css);
  58. // Executing scripts.
  59. void ExecuteJavaScript(const base::string16& code, mate::Arguments* args);
  60. void ExecuteJavaScriptInIsolatedWorld(
  61. int world_id,
  62. const std::vector<mate::Dictionary>& scripts,
  63. mate::Arguments* args);
  64. // Isolated world related methods
  65. void SetIsolatedWorldSecurityOrigin(int world_id,
  66. const std::string& origin_url);
  67. void SetIsolatedWorldContentSecurityPolicy(
  68. int world_id,
  69. const std::string& security_policy);
  70. void SetIsolatedWorldHumanReadableName(int world_id, const std::string& name);
  71. // Resource related methods
  72. blink::WebCache::ResourceTypeStats GetResourceUsage(v8::Isolate* isolate);
  73. void ClearCache(v8::Isolate* isolate);
  74. // Frame navigation
  75. v8::Local<v8::Value> Opener() const;
  76. v8::Local<v8::Value> Parent() const;
  77. v8::Local<v8::Value> Top() const;
  78. v8::Local<v8::Value> FirstChild() const;
  79. v8::Local<v8::Value> NextSibling() const;
  80. v8::Local<v8::Value> GetFrameForSelector(const std::string& selector) const;
  81. v8::Local<v8::Value> FindFrameByName(const std::string& name) const;
  82. v8::Local<v8::Value> FindFrameByRoutingId(int routing_id) const;
  83. v8::Local<v8::Value> RoutingId() const;
  84. std::unique_ptr<SpellCheckClient> spell_check_client_;
  85. blink::WebLocalFrame* web_frame_;
  86. DISALLOW_COPY_AND_ASSIGN(WebFrame);
  87. };
  88. } // namespace api
  89. } // namespace atom
  90. #endif // ATOM_RENDERER_API_ATOM_API_WEB_FRAME_H_