1// Copyright 2018 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5module remote_cocoa.mojom; 6 7import "mojo/public/mojom/base/string16.mojom"; 8import "ui/base/accelerators/mojom/accelerator.mojom"; 9import "ui/base/mojom/ui_base_types.mojom"; 10import "ui/base/mojom/window_open_disposition.mojom"; 11import "ui/display/mojom/display.mojom"; 12import "ui/events/mojom/event.mojom"; 13import "ui/gfx/geometry/mojom/geometry.mojom"; 14import "ui/gfx/mojom/ca_layer_params.mojom"; 15 16struct ValidateUserInterfaceItemResult { 17 // Whether or not the specified sender should be enabled. 18 bool enable; 19 20 // If true, then the item should be disabled if there exists no key equivalent 21 // for the item. 22 bool disable_if_has_no_key_equivalent; 23 24 // The new title to set for the item (unset if the title is not to be 25 // changed). 26 mojo_base.mojom.String16? new_title; 27 28 // Whether or not to change the hidden state for the item, and the new hidden 29 // state to set. 30 bool set_hidden_state; 31 bool new_hidden_state; 32 33 // Whether or not to change the toggled state for the item, and the new toggle 34 // state to set. 35 bool set_toggle_state; 36 bool new_toggle_state; 37}; 38 39// The interface through which an NSWindow (possibly in a process separate from 40// the browser process) may interact with a NativeWidgetMac. 41interface NativeWidgetNSWindowHost { 42 // Update the views::Widget, ui::Compositor and ui::Layer's visibility. 43 OnVisibilityChanged(bool visible); 44 45 // Called when the window's native theme changes. 46 OnWindowNativeThemeChanged(); 47 48 // Resize the underlying views::View to |new_size| in response to the NSView's 49 // frame changing size. Note that this will not necessarily match the content 50 // bounds from OnWindowGeometryChanged. 51 OnViewSizeChanged(gfx.mojom.Size new_size); 52 53 // The vertical position from which sheets should be anchored, from the top 54 // of the content view. 55 [Sync] 56 GetSheetOffsetY() => (int32 offset_y); 57 58 // Indicate if full keyboard accessibility is needed and update focus if 59 // needed. 60 SetKeyboardAccessible(bool enabled); 61 62 // Indicate if the NSView for this widget is the first responder for the 63 // NSWindow for this widget. 64 OnIsFirstResponderChanged(bool is_first_responder); 65 66 // Indicate if mouse capture is active. 67 OnMouseCaptureActiveChanged(bool capture_is_active); 68 69 // Handle events. Note that whether or not the event is actually handled is 70 // not returned. 71 OnScrollEvent(ui.mojom.Event event); 72 OnMouseEvent(ui.mojom.Event event); 73 OnGestureEvent(ui.mojom.Event event); 74 75 // Synchronously dispatch a key event and return in |event_handled| whether 76 // or not the event was handled. This method is to be used only via the 77 // NativeWidgetNSWindowHostHelper interface. 78 [Sync] 79 DispatchKeyEventRemote(ui.mojom.Event event) => (bool event_handled); 80 81 // Synchronously dispatch a key event to the current menu controller (if one 82 // exists and is owned by the widget for this). Return in |event_swallowed| 83 // whether or not the event was swallowed (that is, if the menu's dispatch 84 // returned POST_DISPATCH_NONE). Return in |event_handled| whether or not the 85 // event was handled (that is, if the event in the caller's scope should be 86 // marked as handled). This method is to be used only via the 87 // NativeWidgetNSWindowHostHelper interface. 88 [Sync] 89 DispatchKeyEventToMenuControllerRemote(ui.mojom.Event event) => 90 (bool event_swallowed, bool event_handled); 91 92 // Synchronously return in |has_menu_controller| whether or not a menu 93 // controller exists for this widget. 94 [Sync] 95 GetHasMenuController() => (bool has_menu_controller); 96 97 // Synchronously query if |location_in_content| is a draggable background. 98 [Sync] 99 GetIsDraggableBackgroundAt(gfx.mojom.Point location_in_content) => 100 (bool is_draggable_background); 101 102 // Synchronously query the tooltip text for |location_in_content|. 103 [Sync] 104 GetTooltipTextAt(gfx.mojom.Point location_in_content) => 105 (mojo_base.mojom.String16 new_tooltip_text); 106 107 // Synchronously query the value of IsModal for this widget and store it in 108 // |widget_is_modal|. 109 [Sync] 110 GetWidgetIsModal() => (bool widget_is_modal); 111 112 // Synchronously return in |is_textual| whether or not the focused view 113 // contains text that can be selected and copied. 114 [Sync] 115 GetIsFocusedViewTextual() => (bool is_textual); 116 117 // Called whenever the NSWindow's size or position changes. 118 OnWindowGeometryChanged( 119 gfx.mojom.Rect window_bounds_in_screen_dips, 120 gfx.mojom.Rect content_bounds_in_screen_dips); 121 122 // Called when the window begins transitioning to or from being fullscreen. 123 OnWindowFullscreenTransitionStart( 124 bool target_fullscreen_state); 125 126 // Called when the window has completed its transition to or from being 127 // fullscreen. Note that if there are multiple consecutive transitions 128 // (because a new transition was initiated before the previous one completed) 129 // then this will only be called when all transitions have competed. 130 OnWindowFullscreenTransitionComplete(bool is_fullscreen); 131 132 // Called when the window is miniaturized or deminiaturized. 133 OnWindowMiniaturizedChanged(bool miniaturized); 134 135 // Called when the current display or the properties of the current display 136 // change. 137 OnWindowDisplayChanged(display.mojom.Display display); 138 139 // Called before the NSWindow is closed and destroyed. 140 OnWindowWillClose(); 141 142 // Called after the NSWindow has been closed and destroyed. 143 OnWindowHasClosed(); 144 145 // Called when the NSWindow becomes key or resigns from being key. Additional 146 // state required for the transition include whether or not the content NSView 147 // is the first responder for the NSWindow in |is_content_first_responder| and 148 // whether or not the NSApp's full keyboard access is enabled in 149 // |full_keyboard_access_enabled|. 150 OnWindowKeyStatusChanged(bool is_key, 151 bool is_content_first_responder, 152 bool full_keyboard_access_enabled); 153 154 // Called when the blob of data that represents the NSWindow's restorable 155 // state has changed. 156 OnWindowStateRestorationDataChanged(array<uint8> data); 157 158 // Accept or cancel the current dialog window (depending on the value of 159 // |button|), if a current dialog exists. 160 DoDialogButtonAction(ui.mojom.DialogButton button); 161 162 // Synchronously determine if the specified button exists in the current 163 // dialog (if any), along with its label, whether or not it is enabled, and 164 // whether or not it is the default button.. 165 [Sync] 166 GetDialogButtonInfo(ui.mojom.DialogButton button) => (bool button_exists, 167 mojo_base.mojom.String16 title, 168 bool is_button_enabled, 169 bool is_button_default); 170 171 // Synchronously return in |buttons_exist| whether or not any buttons exist 172 // for the current dialog. 173 [Sync] 174 GetDoDialogButtonsExist() => (bool buttons_exist); 175 176 // Synchronously query if the NSWindow should display its title. 177 [Sync] 178 GetShouldShowWindowTitle() => (bool should_show_window_title); 179 180 // Synchronously query if the NSWindow can become key (activate, in views 181 // terminology). 182 [Sync] 183 GetCanWindowBecomeKey() => (bool can_window_become_key); 184 185 // Synchronously query if the NSWindow should always render as if it is 186 // the key window (is active, in views terminology). 187 [Sync] 188 GetAlwaysRenderWindowAsKey() => (bool always_render_as_key); 189 190 // Synchronously query if the NSWindow should always render as if it is 191 // the key window (is active, in views terminology). 192 [Sync] 193 GetCanWindowClose() => (bool can_window_close); 194 195 // Synchronously query if the NSWindow's theme frame overrides the titlebar 196 // height, and, if so, what the overridden height is. 197 [Sync] 198 GetWindowFrameTitlebarHeight() => (bool override_titlebar_height, 199 float titlebar_height); 200 201 // Handle "Move focus to the window toolbar" shortcut. 202 OnFocusWindowToolbar(); 203 204 // Send the token for the NSWindow and NSView for this widget. 205 SetRemoteAccessibilityTokens( 206 array<uint8> window_token, array<uint8> view_token); 207 208 // Return in |element_token| the token for the root views AX node for this 209 // view and in |host_pid| the pid for the host process. 210 [Sync] 211 GetRootViewAccessibilityToken() => 212 (int64 host_pid, array<uint8> element_token); 213 214 // Return the result for -[NSUserInterfaceValidations 215 // validateUserInterfaceItem] for a given command, along with any state for 216 // that item that should be updated. 217 [Sync] 218 ValidateUserInterfaceItem(int32 command) => 219 (ValidateUserInterfaceItemResult result); 220 221 // Execute the chrome command |command| with |window_open_disposition|. If 222 // |is_before_first_responder| then only call ExecuteCommand if the command 223 // is reserved and extension shortcut handling is not suspended. Returns in 224 // |was_executed| whether or not ExecuteCommand was called (regardless of what 225 // the return value for ExecuteCommand was). 226 [Sync] 227 ExecuteCommand(int32 command, 228 ui.mojom.WindowOpenDisposition window_open_disposition, 229 bool is_before_first_responder) => (bool was_executed); 230 231 // Give the widget's FocusManager a chance to to handle the specified 232 // accelerator. If |require_priority_handler| is true, the only send the 233 // accelerator to the FocusManager if the FocusManager has a priority handler 234 // for the specified accelerator. 235 [Sync] 236 HandleAccelerator(ui.mojom.Accelerator accelerator, 237 bool require_priority_handler) => 238 (bool was_handled); 239}; 240