inspectable_web_contents_view_mac.mm 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #include "brightray/browser/inspectable_web_contents_view_mac.h"
  2. #import <AppKit/AppKit.h>
  3. #include "base/strings/sys_string_conversions.h"
  4. #include "brightray/browser/inspectable_web_contents.h"
  5. #include "brightray/browser/inspectable_web_contents_view_delegate.h"
  6. #import "brightray/browser/mac/bry_inspectable_web_contents_view.h"
  7. namespace brightray {
  8. InspectableWebContentsView* CreateInspectableContentsView(
  9. InspectableWebContentsImpl* inspectable_web_contents) {
  10. return new InspectableWebContentsViewMac(inspectable_web_contents);
  11. }
  12. InspectableWebContentsViewMac::InspectableWebContentsViewMac(
  13. InspectableWebContentsImpl* inspectable_web_contents)
  14. : inspectable_web_contents_(inspectable_web_contents),
  15. view_([[BRYInspectableWebContentsView alloc]
  16. initWithInspectableWebContentsViewMac:this]) {}
  17. InspectableWebContentsViewMac::~InspectableWebContentsViewMac() {
  18. [view_ removeObservers];
  19. CloseDevTools();
  20. }
  21. gfx::NativeView InspectableWebContentsViewMac::GetNativeView() const {
  22. return view_.get();
  23. }
  24. void InspectableWebContentsViewMac::ShowDevTools() {
  25. [view_ setDevToolsVisible:YES];
  26. }
  27. void InspectableWebContentsViewMac::CloseDevTools() {
  28. [view_ setDevToolsVisible:NO];
  29. }
  30. bool InspectableWebContentsViewMac::IsDevToolsViewShowing() {
  31. return [view_ isDevToolsVisible];
  32. }
  33. bool InspectableWebContentsViewMac::IsDevToolsViewFocused() {
  34. return [view_ isDevToolsFocused];
  35. }
  36. void InspectableWebContentsViewMac::SetIsDocked(bool docked) {
  37. [view_ setIsDocked:docked];
  38. }
  39. void InspectableWebContentsViewMac::SetContentsResizingStrategy(
  40. const DevToolsContentsResizingStrategy& strategy) {
  41. [view_ setContentsResizingStrategy:strategy];
  42. }
  43. void InspectableWebContentsViewMac::SetTitle(const base::string16& title) {
  44. [view_ setTitle:base::SysUTF16ToNSString(title)];
  45. }
  46. } // namespace brightray