native_window.cc 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  1. // Copyright (c) 2013 GitHub, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #include "shell/browser/native_window.h"
  5. #include <algorithm>
  6. #include <string>
  7. #include <utility>
  8. #include <vector>
  9. #include "base/memory/ptr_util.h"
  10. #include "base/strings/utf_string_conversions.h"
  11. #include "shell/browser/browser.h"
  12. #include "shell/browser/window_list.h"
  13. #include "shell/common/color_util.h"
  14. #include "shell/common/gin_helper/dictionary.h"
  15. #include "shell/common/gin_helper/persistent_dictionary.h"
  16. #include "shell/common/options_switches.h"
  17. #include "ui/views/widget/widget.h"
  18. #if defined(OS_WIN)
  19. #include "ui/base/win/shell.h"
  20. #include "ui/display/win/screen_win.h"
  21. #endif
  22. namespace electron {
  23. namespace {
  24. #if defined(OS_WIN)
  25. gfx::Size GetExpandedWindowSize(const NativeWindow* window, gfx::Size size) {
  26. if (!window->transparent() || !ui::win::IsAeroGlassEnabled())
  27. return size;
  28. gfx::Size min_size = display::win::ScreenWin::ScreenToDIPSize(
  29. window->GetAcceleratedWidget(), gfx::Size(64, 64));
  30. // Some AMD drivers can't display windows that are less than 64x64 pixels,
  31. // so expand them to be at least that size. http://crbug.com/286609
  32. gfx::Size expanded(std::max(size.width(), min_size.width()),
  33. std::max(size.height(), min_size.height()));
  34. return expanded;
  35. }
  36. #endif
  37. } // namespace
  38. NativeWindow::NativeWindow(const gin_helper::Dictionary& options,
  39. NativeWindow* parent)
  40. : widget_(new views::Widget), parent_(parent), weak_factory_(this) {
  41. ++next_id_;
  42. options.Get(options::kFrame, &has_frame_);
  43. options.Get(options::kTransparent, &transparent_);
  44. options.Get(options::kEnableLargerThanScreen, &enable_larger_than_screen_);
  45. if (parent)
  46. options.Get("modal", &is_modal_);
  47. WindowList::AddWindow(this);
  48. }
  49. NativeWindow::~NativeWindow() {
  50. // It's possible that the windows gets destroyed before it's closed, in that
  51. // case we need to ensure the Widget delegate gets destroyed and
  52. // OnWindowClosed message is still notified.
  53. if (widget_->widget_delegate())
  54. widget_->OnNativeWidgetDestroyed();
  55. NotifyWindowClosed();
  56. }
  57. void NativeWindow::InitFromOptions(const gin_helper::Dictionary& options) {
  58. // Setup window from options.
  59. int x = -1, y = -1;
  60. bool center;
  61. if (options.Get(options::kX, &x) && options.Get(options::kY, &y)) {
  62. SetPosition(gfx::Point(x, y));
  63. #if defined(OS_WIN)
  64. // FIXME(felixrieseberg): Dirty, dirty workaround for
  65. // https://github.com/electron/electron/issues/10862
  66. // Somehow, we need to call `SetBounds` twice to get
  67. // usable results. The root cause is still unknown.
  68. SetPosition(gfx::Point(x, y));
  69. #endif
  70. } else if (options.Get(options::kCenter, &center) && center) {
  71. Center();
  72. }
  73. bool use_content_size = false;
  74. options.Get(options::kUseContentSize, &use_content_size);
  75. // On Linux and Window we may already have maximum size defined.
  76. extensions::SizeConstraints size_constraints(
  77. use_content_size ? GetContentSizeConstraints() : GetSizeConstraints());
  78. int min_height = 0, min_width = 0;
  79. if (options.Get(options::kMinHeight, &min_height) |
  80. options.Get(options::kMinWidth, &min_width)) {
  81. size_constraints.set_minimum_size(gfx::Size(min_width, min_height));
  82. }
  83. int max_height = INT_MAX, max_width = INT_MAX;
  84. if (options.Get(options::kMaxHeight, &max_height) |
  85. options.Get(options::kMaxWidth, &max_width)) {
  86. size_constraints.set_maximum_size(gfx::Size(max_width, max_height));
  87. }
  88. if (use_content_size) {
  89. SetContentSizeConstraints(size_constraints);
  90. } else {
  91. SetSizeConstraints(size_constraints);
  92. }
  93. #if defined(OS_WIN) || defined(USE_X11)
  94. bool resizable;
  95. if (options.Get(options::kResizable, &resizable)) {
  96. SetResizable(resizable);
  97. }
  98. bool closable;
  99. if (options.Get(options::kClosable, &closable)) {
  100. SetClosable(closable);
  101. }
  102. #endif
  103. bool movable;
  104. if (options.Get(options::kMovable, &movable)) {
  105. SetMovable(movable);
  106. }
  107. bool has_shadow;
  108. if (options.Get(options::kHasShadow, &has_shadow)) {
  109. SetHasShadow(has_shadow);
  110. }
  111. double opacity;
  112. if (options.Get(options::kOpacity, &opacity)) {
  113. SetOpacity(opacity);
  114. }
  115. bool top;
  116. if (options.Get(options::kAlwaysOnTop, &top) && top) {
  117. SetAlwaysOnTop(ui::ZOrderLevel::kFloatingWindow);
  118. }
  119. bool fullscreenable = true;
  120. bool fullscreen = false;
  121. if (options.Get(options::kFullscreen, &fullscreen) && !fullscreen) {
  122. // Disable fullscreen button if 'fullscreen' is specified to false.
  123. #if defined(OS_MAC)
  124. fullscreenable = false;
  125. #endif
  126. }
  127. // Overridden by 'fullscreenable'.
  128. options.Get(options::kFullScreenable, &fullscreenable);
  129. SetFullScreenable(fullscreenable);
  130. if (fullscreen) {
  131. SetFullScreen(true);
  132. }
  133. bool skip;
  134. if (options.Get(options::kSkipTaskbar, &skip)) {
  135. SetSkipTaskbar(skip);
  136. }
  137. bool kiosk;
  138. if (options.Get(options::kKiosk, &kiosk) && kiosk) {
  139. SetKiosk(kiosk);
  140. }
  141. #if defined(OS_MAC)
  142. std::string type;
  143. if (options.Get(options::kVibrancyType, &type)) {
  144. SetVibrancy(type);
  145. }
  146. #endif
  147. std::string color;
  148. if (options.Get(options::kBackgroundColor, &color)) {
  149. SetBackgroundColor(ParseHexColor(color));
  150. } else if (!transparent()) {
  151. // For normal window, use white as default background.
  152. SetBackgroundColor(SK_ColorWHITE);
  153. }
  154. std::string title(Browser::Get()->GetName());
  155. options.Get(options::kTitle, &title);
  156. SetTitle(title);
  157. // Then show it.
  158. bool show = true;
  159. options.Get(options::kShow, &show);
  160. if (show)
  161. Show();
  162. }
  163. bool NativeWindow::IsClosed() const {
  164. return is_closed_;
  165. }
  166. void NativeWindow::SetSize(const gfx::Size& size, bool animate) {
  167. SetBounds(gfx::Rect(GetPosition(), size), animate);
  168. }
  169. gfx::Size NativeWindow::GetSize() {
  170. return GetBounds().size();
  171. }
  172. void NativeWindow::SetPosition(const gfx::Point& position, bool animate) {
  173. SetBounds(gfx::Rect(position, GetSize()), animate);
  174. }
  175. gfx::Point NativeWindow::GetPosition() {
  176. return GetBounds().origin();
  177. }
  178. void NativeWindow::SetContentSize(const gfx::Size& size, bool animate) {
  179. SetSize(ContentBoundsToWindowBounds(gfx::Rect(size)).size(), animate);
  180. }
  181. gfx::Size NativeWindow::GetContentSize() {
  182. return GetContentBounds().size();
  183. }
  184. void NativeWindow::SetContentBounds(const gfx::Rect& bounds, bool animate) {
  185. SetBounds(ContentBoundsToWindowBounds(bounds), animate);
  186. }
  187. gfx::Rect NativeWindow::GetContentBounds() {
  188. return WindowBoundsToContentBounds(GetBounds());
  189. }
  190. bool NativeWindow::IsNormal() {
  191. return !IsMinimized() && !IsMaximized() && !IsFullscreen();
  192. }
  193. void NativeWindow::SetSizeConstraints(
  194. const extensions::SizeConstraints& window_constraints) {
  195. extensions::SizeConstraints content_constraints(GetContentSizeConstraints());
  196. if (window_constraints.HasMaximumSize()) {
  197. gfx::Rect max_bounds = WindowBoundsToContentBounds(
  198. gfx::Rect(window_constraints.GetMaximumSize()));
  199. content_constraints.set_maximum_size(max_bounds.size());
  200. }
  201. if (window_constraints.HasMinimumSize()) {
  202. gfx::Rect min_bounds = WindowBoundsToContentBounds(
  203. gfx::Rect(window_constraints.GetMinimumSize()));
  204. content_constraints.set_minimum_size(min_bounds.size());
  205. }
  206. SetContentSizeConstraints(content_constraints);
  207. }
  208. extensions::SizeConstraints NativeWindow::GetSizeConstraints() const {
  209. extensions::SizeConstraints content_constraints = GetContentSizeConstraints();
  210. extensions::SizeConstraints window_constraints;
  211. if (content_constraints.HasMaximumSize()) {
  212. gfx::Rect max_bounds = ContentBoundsToWindowBounds(
  213. gfx::Rect(content_constraints.GetMaximumSize()));
  214. window_constraints.set_maximum_size(max_bounds.size());
  215. }
  216. if (content_constraints.HasMinimumSize()) {
  217. gfx::Rect min_bounds = ContentBoundsToWindowBounds(
  218. gfx::Rect(content_constraints.GetMinimumSize()));
  219. window_constraints.set_minimum_size(min_bounds.size());
  220. }
  221. return window_constraints;
  222. }
  223. void NativeWindow::SetContentSizeConstraints(
  224. const extensions::SizeConstraints& size_constraints) {
  225. size_constraints_ = size_constraints;
  226. }
  227. extensions::SizeConstraints NativeWindow::GetContentSizeConstraints() const {
  228. return size_constraints_;
  229. }
  230. void NativeWindow::SetMinimumSize(const gfx::Size& size) {
  231. extensions::SizeConstraints size_constraints;
  232. size_constraints.set_minimum_size(size);
  233. SetSizeConstraints(size_constraints);
  234. }
  235. gfx::Size NativeWindow::GetMinimumSize() const {
  236. return GetSizeConstraints().GetMinimumSize();
  237. }
  238. void NativeWindow::SetMaximumSize(const gfx::Size& size) {
  239. extensions::SizeConstraints size_constraints;
  240. size_constraints.set_maximum_size(size);
  241. SetSizeConstraints(size_constraints);
  242. }
  243. gfx::Size NativeWindow::GetMaximumSize() const {
  244. return GetSizeConstraints().GetMaximumSize();
  245. }
  246. gfx::Size NativeWindow::GetContentMinimumSize() const {
  247. return GetContentSizeConstraints().GetMinimumSize();
  248. }
  249. gfx::Size NativeWindow::GetContentMaximumSize() const {
  250. gfx::Size maximum_size = GetContentSizeConstraints().GetMaximumSize();
  251. #if defined(OS_WIN)
  252. return GetContentSizeConstraints().HasMaximumSize()
  253. ? GetExpandedWindowSize(this, maximum_size)
  254. : maximum_size;
  255. #else
  256. return maximum_size;
  257. #endif
  258. }
  259. void NativeWindow::SetSheetOffset(const double offsetX, const double offsetY) {
  260. sheet_offset_x_ = offsetX;
  261. sheet_offset_y_ = offsetY;
  262. }
  263. double NativeWindow::GetSheetOffsetX() {
  264. return sheet_offset_x_;
  265. }
  266. double NativeWindow::GetSheetOffsetY() {
  267. return sheet_offset_y_;
  268. }
  269. void NativeWindow::SetRepresentedFilename(const std::string& filename) {}
  270. std::string NativeWindow::GetRepresentedFilename() {
  271. return "";
  272. }
  273. void NativeWindow::SetDocumentEdited(bool edited) {}
  274. bool NativeWindow::IsDocumentEdited() {
  275. return false;
  276. }
  277. void NativeWindow::SetFocusable(bool focusable) {}
  278. void NativeWindow::SetMenu(ElectronMenuModel* menu) {}
  279. void NativeWindow::SetParentWindow(NativeWindow* parent) {
  280. parent_ = parent;
  281. }
  282. void NativeWindow::SetAutoHideCursor(bool auto_hide) {}
  283. void NativeWindow::SelectPreviousTab() {}
  284. void NativeWindow::SelectNextTab() {}
  285. void NativeWindow::MergeAllWindows() {}
  286. void NativeWindow::MoveTabToNewWindow() {}
  287. void NativeWindow::ToggleTabBar() {}
  288. bool NativeWindow::AddTabbedWindow(NativeWindow* window) {
  289. return true; // for non-Mac platforms
  290. }
  291. void NativeWindow::SetVibrancy(const std::string& filename) {}
  292. void NativeWindow::SetTouchBar(
  293. std::vector<gin_helper::PersistentDictionary> items) {}
  294. void NativeWindow::RefreshTouchBarItem(const std::string& item_id) {}
  295. void NativeWindow::SetEscapeTouchBarItem(
  296. gin_helper::PersistentDictionary item) {}
  297. void NativeWindow::SetAutoHideMenuBar(bool auto_hide) {}
  298. bool NativeWindow::IsMenuBarAutoHide() {
  299. return false;
  300. }
  301. void NativeWindow::SetMenuBarVisibility(bool visible) {}
  302. bool NativeWindow::IsMenuBarVisible() {
  303. return true;
  304. }
  305. bool NativeWindow::SetWindowButtonVisibility(bool visible) {
  306. return false;
  307. }
  308. double NativeWindow::GetAspectRatio() {
  309. return aspect_ratio_;
  310. }
  311. gfx::Size NativeWindow::GetAspectRatioExtraSize() {
  312. return aspect_ratio_extraSize_;
  313. }
  314. void NativeWindow::SetAspectRatio(double aspect_ratio,
  315. const gfx::Size& extra_size) {
  316. aspect_ratio_ = aspect_ratio;
  317. aspect_ratio_extraSize_ = extra_size;
  318. }
  319. void NativeWindow::PreviewFile(const std::string& path,
  320. const std::string& display_name) {}
  321. void NativeWindow::CloseFilePreview() {}
  322. void NativeWindow::NotifyWindowRequestPreferredWith(int* width) {
  323. for (NativeWindowObserver& observer : observers_)
  324. observer.RequestPreferredWidth(width);
  325. }
  326. void NativeWindow::NotifyWindowCloseButtonClicked() {
  327. // First ask the observers whether we want to close.
  328. bool prevent_default = false;
  329. for (NativeWindowObserver& observer : observers_)
  330. observer.WillCloseWindow(&prevent_default);
  331. if (prevent_default) {
  332. WindowList::WindowCloseCancelled(this);
  333. return;
  334. }
  335. // Then ask the observers how should we close the window.
  336. for (NativeWindowObserver& observer : observers_)
  337. observer.OnCloseButtonClicked(&prevent_default);
  338. if (prevent_default)
  339. return;
  340. CloseImmediately();
  341. }
  342. void NativeWindow::NotifyWindowClosed() {
  343. if (is_closed_)
  344. return;
  345. is_closed_ = true;
  346. for (NativeWindowObserver& observer : observers_)
  347. observer.OnWindowClosed();
  348. WindowList::RemoveWindow(this);
  349. }
  350. void NativeWindow::NotifyWindowEndSession() {
  351. for (NativeWindowObserver& observer : observers_)
  352. observer.OnWindowEndSession();
  353. }
  354. void NativeWindow::NotifyWindowBlur() {
  355. for (NativeWindowObserver& observer : observers_)
  356. observer.OnWindowBlur();
  357. }
  358. void NativeWindow::NotifyWindowFocus() {
  359. for (NativeWindowObserver& observer : observers_)
  360. observer.OnWindowFocus();
  361. }
  362. void NativeWindow::NotifyWindowIsKeyChanged(bool is_key) {
  363. for (NativeWindowObserver& observer : observers_)
  364. observer.OnWindowIsKeyChanged(is_key);
  365. }
  366. void NativeWindow::NotifyWindowShow() {
  367. for (NativeWindowObserver& observer : observers_)
  368. observer.OnWindowShow();
  369. }
  370. void NativeWindow::NotifyWindowHide() {
  371. for (NativeWindowObserver& observer : observers_)
  372. observer.OnWindowHide();
  373. }
  374. void NativeWindow::NotifyWindowMaximize() {
  375. for (NativeWindowObserver& observer : observers_)
  376. observer.OnWindowMaximize();
  377. }
  378. void NativeWindow::NotifyWindowUnmaximize() {
  379. for (NativeWindowObserver& observer : observers_)
  380. observer.OnWindowUnmaximize();
  381. }
  382. void NativeWindow::NotifyWindowMinimize() {
  383. for (NativeWindowObserver& observer : observers_)
  384. observer.OnWindowMinimize();
  385. }
  386. void NativeWindow::NotifyWindowRestore() {
  387. for (NativeWindowObserver& observer : observers_)
  388. observer.OnWindowRestore();
  389. }
  390. void NativeWindow::NotifyWindowWillResize(const gfx::Rect& new_bounds,
  391. bool* prevent_default) {
  392. for (NativeWindowObserver& observer : observers_)
  393. observer.OnWindowWillResize(new_bounds, prevent_default);
  394. }
  395. void NativeWindow::NotifyWindowWillMove(const gfx::Rect& new_bounds,
  396. bool* prevent_default) {
  397. for (NativeWindowObserver& observer : observers_)
  398. observer.OnWindowWillMove(new_bounds, prevent_default);
  399. }
  400. void NativeWindow::NotifyWindowResize() {
  401. for (NativeWindowObserver& observer : observers_)
  402. observer.OnWindowResize();
  403. }
  404. void NativeWindow::NotifyWindowResized() {
  405. for (NativeWindowObserver& observer : observers_)
  406. observer.OnWindowResized();
  407. }
  408. void NativeWindow::NotifyWindowMove() {
  409. for (NativeWindowObserver& observer : observers_)
  410. observer.OnWindowMove();
  411. }
  412. void NativeWindow::NotifyWindowMoved() {
  413. for (NativeWindowObserver& observer : observers_)
  414. observer.OnWindowMoved();
  415. }
  416. void NativeWindow::NotifyWindowEnterFullScreen() {
  417. for (NativeWindowObserver& observer : observers_)
  418. observer.OnWindowEnterFullScreen();
  419. }
  420. void NativeWindow::NotifyWindowScrollTouchBegin() {
  421. for (NativeWindowObserver& observer : observers_)
  422. observer.OnWindowScrollTouchBegin();
  423. }
  424. void NativeWindow::NotifyWindowScrollTouchEnd() {
  425. for (NativeWindowObserver& observer : observers_)
  426. observer.OnWindowScrollTouchEnd();
  427. }
  428. void NativeWindow::NotifyWindowSwipe(const std::string& direction) {
  429. for (NativeWindowObserver& observer : observers_)
  430. observer.OnWindowSwipe(direction);
  431. }
  432. void NativeWindow::NotifyWindowRotateGesture(float rotation) {
  433. for (NativeWindowObserver& observer : observers_)
  434. observer.OnWindowRotateGesture(rotation);
  435. }
  436. void NativeWindow::NotifyWindowSheetBegin() {
  437. for (NativeWindowObserver& observer : observers_)
  438. observer.OnWindowSheetBegin();
  439. }
  440. void NativeWindow::NotifyWindowSheetEnd() {
  441. for (NativeWindowObserver& observer : observers_)
  442. observer.OnWindowSheetEnd();
  443. }
  444. void NativeWindow::NotifyWindowLeaveFullScreen() {
  445. for (NativeWindowObserver& observer : observers_)
  446. observer.OnWindowLeaveFullScreen();
  447. }
  448. void NativeWindow::NotifyWindowEnterHtmlFullScreen() {
  449. for (NativeWindowObserver& observer : observers_)
  450. observer.OnWindowEnterHtmlFullScreen();
  451. }
  452. void NativeWindow::NotifyWindowLeaveHtmlFullScreen() {
  453. for (NativeWindowObserver& observer : observers_)
  454. observer.OnWindowLeaveHtmlFullScreen();
  455. }
  456. void NativeWindow::NotifyWindowAlwaysOnTopChanged() {
  457. for (NativeWindowObserver& observer : observers_)
  458. observer.OnWindowAlwaysOnTopChanged();
  459. }
  460. void NativeWindow::NotifyWindowExecuteAppCommand(const std::string& command) {
  461. for (NativeWindowObserver& observer : observers_)
  462. observer.OnExecuteAppCommand(command);
  463. }
  464. void NativeWindow::NotifyTouchBarItemInteraction(
  465. const std::string& item_id,
  466. const base::DictionaryValue& details) {
  467. for (NativeWindowObserver& observer : observers_)
  468. observer.OnTouchBarItemResult(item_id, details);
  469. }
  470. void NativeWindow::NotifyNewWindowForTab() {
  471. for (NativeWindowObserver& observer : observers_)
  472. observer.OnNewWindowForTab();
  473. }
  474. void NativeWindow::NotifyWindowSystemContextMenu(int x,
  475. int y,
  476. bool* prevent_default) {
  477. for (NativeWindowObserver& observer : observers_)
  478. observer.OnSystemContextMenu(x, y, prevent_default);
  479. }
  480. #if defined(OS_WIN)
  481. void NativeWindow::NotifyWindowMessage(UINT message,
  482. WPARAM w_param,
  483. LPARAM l_param) {
  484. for (NativeWindowObserver& observer : observers_)
  485. observer.OnWindowMessage(message, w_param, l_param);
  486. }
  487. #endif
  488. views::Widget* NativeWindow::GetWidget() {
  489. return widget();
  490. }
  491. const views::Widget* NativeWindow::GetWidget() const {
  492. return widget();
  493. }
  494. base::string16 NativeWindow::GetAccessibleWindowTitle() const {
  495. if (accessible_title_.empty()) {
  496. return views::WidgetDelegate::GetAccessibleWindowTitle();
  497. }
  498. return accessible_title_;
  499. }
  500. void NativeWindow::SetAccessibleTitle(const std::string& title) {
  501. accessible_title_ = base::UTF8ToUTF16(title);
  502. }
  503. std::string NativeWindow::GetAccessibleTitle() {
  504. return base::UTF16ToUTF8(accessible_title_);
  505. }
  506. // static
  507. int32_t NativeWindow::next_id_ = 0;
  508. // static
  509. void NativeWindowRelay::CreateForWebContents(
  510. content::WebContents* web_contents,
  511. base::WeakPtr<NativeWindow> window) {
  512. DCHECK(web_contents);
  513. if (!web_contents->GetUserData(UserDataKey())) {
  514. web_contents->SetUserData(UserDataKey(),
  515. base::WrapUnique(new NativeWindowRelay(window)));
  516. }
  517. }
  518. NativeWindowRelay::NativeWindowRelay(base::WeakPtr<NativeWindow> window)
  519. : native_window_(window) {}
  520. NativeWindowRelay::~NativeWindowRelay() = default;
  521. WEB_CONTENTS_USER_DATA_KEY_IMPL(NativeWindowRelay)
  522. } // namespace electron