Avi Drissman | 4e1b7bc3 | 2022-09-15 14:03:50 | [diff] [blame] | 1 | // Copyright 2018 The Chromium Authors |
Christopher Cameron | ec34e18 | 2018-12-06 05:45:54 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Christopher Cameron | a5ff657 | 2019-05-07 01:41:27 | [diff] [blame] | 5 | #ifndef CONTENT_APP_SHIM_REMOTE_COCOA_WEB_CONTENTS_VIEW_COCOA_H_ |
| 6 | #define CONTENT_APP_SHIM_REMOTE_COCOA_WEB_CONTENTS_VIEW_COCOA_H_ |
Christopher Cameron | ec34e18 | 2018-12-06 05:45:54 | [diff] [blame] | 7 | |
Keishi Hattori | 7c3c718 | 2022-06-24 22:18:14 | [diff] [blame] | 8 | #include "base/memory/raw_ptr.h" |
Christopher Cameron | ec34e18 | 2018-12-06 05:45:54 | [diff] [blame] | 9 | #include "content/common/content_export.h" |
Jayson Adams | 1a3f08d6 | 2022-01-07 04:36:24 | [diff] [blame] | 10 | #include "content/common/web_contents_ns_view_bridge.mojom.h" |
Christopher Cameron | ec34e18 | 2018-12-06 05:45:54 | [diff] [blame] | 11 | #import "ui/base/cocoa/base_view.h" |
| 12 | #import "ui/base/cocoa/views_hostable.h" |
| 13 | |
| 14 | namespace content { |
| 15 | struct DropData; |
Christopher Cameron | ec34e18 | 2018-12-06 05:45:54 | [diff] [blame] | 16 | } // namespace content |
| 17 | |
Avi Drissman | 5ddd9c17 | 2023-07-06 14:47:43 | [diff] [blame] | 18 | namespace remote_cocoa::mojom { |
Christopher Cameron | f0bdd12b | 2019-06-01 18:10:29 | [diff] [blame] | 19 | class WebContentsNSViewHost; |
Avi Drissman | 5ddd9c17 | 2023-07-06 14:47:43 | [diff] [blame] | 20 | } // namespace remote_cocoa::mojom |
Christopher Cameron | f0bdd12b | 2019-06-01 18:10:29 | [diff] [blame] | 21 | |
Daniel Cheng | 2cb89f9 | 2023-09-28 00:46:54 | [diff] [blame] | 22 | namespace url { |
| 23 | class Origin; |
| 24 | } |
| 25 | |
Christopher Cameron | ec34e18 | 2018-12-06 05:45:54 | [diff] [blame] | 26 | @class WebDragSource; |
| 27 | |
| 28 | CONTENT_EXPORT |
Avi Drissman | 8628f89 | 2022-12-20 16:11:18 | [diff] [blame] | 29 | @interface WebContentsViewCocoa |
Avi Drissman | 5ddd9c17 | 2023-07-06 14:47:43 | [diff] [blame] | 30 | : BaseView <ViewsHostable, NSDraggingSource, NSDraggingDestination> |
Christopher Cameron | ec34e18 | 2018-12-06 05:45:54 | [diff] [blame] | 31 | |
Christopher Cameron | 02e5964f | 2019-03-05 22:23:16 | [diff] [blame] | 32 | // Set or un-set the mojo interface through which to communicate with the |
| 33 | // browser process. |
Christopher Cameron | f0bdd12b | 2019-06-01 18:10:29 | [diff] [blame] | 34 | - (void)setHost:(remote_cocoa::mojom::WebContentsNSViewHost*)host; |
Christopher Cameron | e30928e | 2019-01-23 20:12:32 | [diff] [blame] | 35 | |
Christopher Cameron | ec34e18 | 2018-12-06 05:45:54 | [diff] [blame] | 36 | - (void)setMouseDownCanMoveWindow:(BOOL)canMove; |
| 37 | |
Christopher Cameron | 0d876497 | 2021-07-13 20:15:10 | [diff] [blame] | 38 | // Enable the workaround for https://crbug.com/1148078. This is called by |
| 39 | // in-PWA-process instances, to limit the workaround's effect to just PWAs. |
| 40 | - (void)enableDroppedScreenShotCopier; |
| 41 | |
Christopher Cameron | ec34e18 | 2018-12-06 05:45:54 | [diff] [blame] | 42 | // Private interface. |
| 43 | // TODO(ccameron): Document these functions. |
Leonard Grey | 2f55fb9 | 2021-05-14 20:42:43 | [diff] [blame] | 44 | - (instancetype)initWithViewsHostableView:(ui::ViewsHostableView*)v; |
Christopher Cameron | ec34e18 | 2018-12-06 05:45:54 | [diff] [blame] | 45 | - (void)registerDragTypes; |
Christopher Cameron | ec34e18 | 2018-12-06 05:45:54 | [diff] [blame] | 46 | - (void)startDragWithDropData:(const content::DropData&)dropData |
Daniel Cheng | 2cb89f9 | 2023-09-28 00:46:54 | [diff] [blame] | 47 | sourceOrigin:(const url::Origin&)sourceOrigin |
Christopher Cameron | ec34e18 | 2018-12-06 05:45:54 | [diff] [blame] | 48 | dragOperationMask:(NSDragOperation)operationMask |
| 49 | image:(NSImage*)image |
Avi Drissman | 905fa88 | 2023-02-13 17:49:49 | [diff] [blame] | 50 | offset:(NSPoint)offset |
| 51 | isPrivileged:(BOOL)isPrivileged; |
Christopher Cameron | 02e5964f | 2019-03-05 22:23:16 | [diff] [blame] | 52 | - (void)clearViewsHostableView; |
Christopher Cameron | ec34e18 | 2018-12-06 05:45:54 | [diff] [blame] | 53 | - (void)viewDidBecomeFirstResponder:(NSNotification*)notification; |
Jayson Adams | ef4af89ba | 2022-06-13 20:07:54 | [diff] [blame] | 54 | |
| 55 | // API exposed for testing. |
| 56 | |
| 57 | // Used to set the web contents's visibility status to occluded after a delay. |
| 58 | - (void)performDelayedSetWebContentsOccluded; |
| 59 | |
| 60 | // Returns YES if the WCVC is scheduled to set its web contents's to the |
| 61 | // occluded state. |
| 62 | - (BOOL)willSetWebContentsOccludedAfterDelayForTesting; |
| 63 | |
| 64 | // Updates the WCVC's web contents's visibility state. The update may occur |
| 65 | // immediately or in the near future. |
| 66 | - (void)updateWebContentsVisibility:(remote_cocoa::mojom::Visibility)visibility; |
| 67 | |
Marijn Kruisselbrink | 61cdd4d | 2023-01-26 02:47:48 | [diff] [blame] | 68 | - (void)updateWindowControlsOverlay:(const gfx::Rect&)boundingRect; |
| 69 | |
Christopher Cameron | ec34e18 | 2018-12-06 05:45:54 | [diff] [blame] | 70 | @end |
| 71 | |
Jayson Adams | 1a3f08d6 | 2022-01-07 04:36:24 | [diff] [blame] | 72 | @interface NSWindow (WebContentsViewCocoa) |
| 73 | // Returns all the WebContentsViewCocoas in the window. |
| 74 | - (NSArray<WebContentsViewCocoa*>*)webContentsViewCocoa; |
Jayson Adams | ef4af89ba | 2022-06-13 20:07:54 | [diff] [blame] | 75 | // Returns YES if the window contains at least one WebContentsViewCocoa. |
| 76 | - (BOOL)containsWebContentsViewCocoa; |
Jayson Adams | 1a3f08d6 | 2022-01-07 04:36:24 | [diff] [blame] | 77 | @end |
| 78 | |
Christopher Cameron | a5ff657 | 2019-05-07 01:41:27 | [diff] [blame] | 79 | #endif // CONTENT_APP_SHIM_REMOTE_COCOA_WEB_CONTENTS_VIEW_COCOA_H_ |