atom_api_web_frame.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 "atom/renderer/guest_view_container.h"
  9. #include "native_mate/handle.h"
  10. #include "native_mate/wrappable.h"
  11. #include "third_party/WebKit/public/web/WebCache.h"
  12. namespace blink {
  13. class WebLocalFrame;
  14. }
  15. namespace mate {
  16. class Arguments;
  17. }
  18. namespace atom {
  19. namespace api {
  20. class SpellCheckClient;
  21. class WebFrame : public mate::Wrappable<WebFrame> {
  22. public:
  23. static mate::Handle<WebFrame> Create(v8::Isolate* isolate);
  24. static void BuildPrototype(v8::Isolate* isolate,
  25. v8::Local<v8::FunctionTemplate> prototype);
  26. private:
  27. explicit WebFrame(v8::Isolate* isolate);
  28. ~WebFrame() override;
  29. void SetName(const std::string& name);
  30. double SetZoomLevel(double level);
  31. double GetZoomLevel() const;
  32. double SetZoomFactor(double factor);
  33. double GetZoomFactor() const;
  34. void SetVisualZoomLevelLimits(double min_level, double max_level);
  35. void SetLayoutZoomLevelLimits(double min_level, double max_level);
  36. v8::Local<v8::Value> RegisterEmbedderCustomElement(
  37. const base::string16& name, v8::Local<v8::Object> options);
  38. void RegisterElementResizeCallback(
  39. int element_instance_id,
  40. const GuestViewContainer::ResizeCallback& callback);
  41. void AttachGuest(int element_instance_id);
  42. // Set the provider that will be used by SpellCheckClient for spell check.
  43. void SetSpellCheckProvider(mate::Arguments* args,
  44. const std::string& language,
  45. bool auto_spell_correct_turned_on,
  46. v8::Local<v8::Object> provider);
  47. void RegisterURLSchemeAsSecure(const std::string& scheme);
  48. void RegisterURLSchemeAsBypassingCSP(const std::string& scheme);
  49. void RegisterURLSchemeAsPrivileged(const std::string& scheme);
  50. // Editing.
  51. void InsertText(const std::string& text);
  52. // Excecuting scripts.
  53. void ExecuteJavaScript(const base::string16& code, mate::Arguments* args);
  54. // Resource related methods
  55. blink::WebCache::ResourceTypeStats GetResourceUsage(v8::Isolate* isolate);
  56. void ClearCache(v8::Isolate* isolate);
  57. std::unique_ptr<SpellCheckClient> spell_check_client_;
  58. blink::WebLocalFrame* web_frame_;
  59. DISALLOW_COPY_AND_ASSIGN(WebFrame);
  60. };
  61. } // namespace api
  62. } // namespace atom
  63. #endif // ATOM_RENDERER_API_ATOM_API_WEB_FRAME_H_