Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
|
mfomitchev
2015/11/04 23:21:14
It would be easier to review/use as a reference la
bshe
2015/11/11 00:38:28
Done.
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ui/views/widget/android/native_widget_android.h" | |
| 6 | |
| 7 #include "ui/aura/client/default_capture_client.h" | |
| 8 #include "ui/aura/client/window_tree_client.h" | |
| 9 #include "ui/aura/window.h" | |
| 10 #include "ui/aura/window_tree_host.h" | |
| 11 #include "ui/views/widget/android/android_focus_rules.h" | |
| 12 #include "ui/views/widget/native_widget_delegate.h" | |
| 13 #include "ui/wm/core/default_activation_client.h" | |
| 14 #include "ui/wm/core/focus_controller.h" | |
| 15 | |
| 16 namespace { | |
| 17 | |
| 18 class NativeWidgetAndroidWindowTreeClient | |
| 19 : public aura::client::WindowTreeClient { | |
| 20 public: | |
| 21 explicit NativeWidgetAndroidWindowTreeClient(aura::Window* root_window) | |
| 22 : root_window_(root_window) { | |
| 23 aura::client::SetWindowTreeClient(root_window_, this); | |
| 24 } | |
| 25 ~NativeWidgetAndroidWindowTreeClient() override { | |
| 26 aura::client::SetWindowTreeClient(root_window_, NULL); | |
| 27 } | |
| 28 | |
| 29 // Overridden from client::WindowTreeClient: | |
| 30 aura::Window* GetDefaultParent(aura::Window* context, | |
| 31 aura::Window* window, | |
| 32 const gfx::Rect& bounds) override { | |
| 33 return root_window_; | |
| 34 } | |
| 35 | |
| 36 private: | |
| 37 aura::Window* root_window_; | |
| 38 | |
| 39 DISALLOW_COPY_AND_ASSIGN(NativeWidgetAndroidWindowTreeClient); | |
| 40 }; | |
| 41 | |
| 42 } // namespace | |
| 43 | |
| 44 namespace views { | |
| 45 | |
| 46 NativeWidgetAndroid::NativeWidgetAndroid( | |
| 47 internal::NativeWidgetDelegate* delegate) | |
| 48 : delegate_(delegate) {} | |
| 49 NativeWidgetAndroid::~NativeWidgetAndroid() {} | |
|
sadrul
2015/11/04 19:00:53
new line
bshe
2015/11/11 00:38:29
Done.
| |
| 50 | |
| 51 //////////////////////////////////////////////////////////////////////////////// | |
| 52 // NativeWidgetAndroid, internal::NativeWidgetPrivate implementation: | |
| 53 | |
| 54 void NativeWidgetAndroid::InitNativeWidget(const Widget::InitParams& params) { | |
| 55 // TODO(bshe): Get rid of the hard coded size. Uses screen size instead. | |
|
mfomitchev
2015/11/04 23:21:13
Can you reference a crbug here? (Either use one of
bshe
2015/11/11 00:38:29
Done.
| |
| 56 host_.reset(aura::WindowTreeHost::Create(gfx::Rect(0, 0, 800, 600))); | |
| 57 host_->InitHost(); | |
| 58 | |
| 59 window_tree_client_.reset( | |
| 60 new NativeWidgetAndroidWindowTreeClient(host_->window())); | |
| 61 | |
| 62 focus_client_.reset(new wm::FocusController(new AndroidFocusRules)); | |
| 63 aura::client::SetFocusClient(host_->window(), focus_client_.get()); | |
| 64 | |
| 65 host_->window()->AddPreTargetHandler(focus_client_.get()); | |
| 66 | |
| 67 new wm::DefaultActivationClient(host_->window()); | |
| 68 | |
| 69 capture_client_.reset( | |
| 70 new aura::client::DefaultCaptureClient(host_->window())); | |
| 71 } | |
|
mfomitchev
2015/11/04 23:21:13
What about screen position client?
bshe
2015/11/11 00:38:29
Done.
| |
| 72 | |
| 73 NonClientFrameView* NativeWidgetAndroid::CreateNonClientFrameView() { | |
| 74 NOTIMPLEMENTED(); | |
| 75 return nullptr; | |
| 76 } | |
| 77 | |
| 78 bool NativeWidgetAndroid::ShouldUseNativeFrame() const { | |
| 79 NOTIMPLEMENTED(); | |
| 80 // There is only one frame type for aura. | |
| 81 return false; | |
| 82 } | |
| 83 | |
| 84 bool NativeWidgetAndroid::ShouldWindowContentsBeTransparent() const { | |
| 85 NOTIMPLEMENTED(); | |
| 86 return false; | |
| 87 } | |
| 88 | |
| 89 void NativeWidgetAndroid::FrameTypeChanged() { | |
| 90 NOTIMPLEMENTED(); | |
| 91 } | |
| 92 | |
| 93 Widget* NativeWidgetAndroid::GetWidget() { | |
| 94 return delegate_->AsWidget(); | |
| 95 } | |
| 96 | |
| 97 const Widget* NativeWidgetAndroid::GetWidget() const { | |
| 98 return delegate_->AsWidget(); | |
| 99 } | |
| 100 | |
| 101 gfx::NativeView NativeWidgetAndroid::GetNativeView() const { | |
| 102 return host_->window(); | |
| 103 } | |
| 104 | |
| 105 gfx::NativeWindow NativeWidgetAndroid::GetNativeWindow() const { | |
| 106 return host_->window(); | |
| 107 } | |
| 108 | |
| 109 Widget* NativeWidgetAndroid::GetTopLevelWidget() { | |
| 110 NOTIMPLEMENTED(); | |
| 111 return nullptr; | |
| 112 } | |
| 113 | |
| 114 const ui::Compositor* NativeWidgetAndroid::GetCompositor() const { | |
| 115 return host_->window()->layer()->GetCompositor(); | |
|
sadrul
2015/11/04 19:00:53
Just host_->compositor()?
bshe
2015/11/11 00:38:29
Done.
| |
| 116 } | |
| 117 | |
| 118 const ui::Layer* NativeWidgetAndroid::GetLayer() const { | |
| 119 return host_->window() ? host_->window()->layer() : nullptr; | |
|
sadrul
2015/11/04 19:00:53
When can this be null? Can this just be:
return
bshe
2015/11/11 00:38:29
Done.
| |
| 120 } | |
| 121 | |
| 122 void NativeWidgetAndroid::ReorderNativeViews() { | |
| 123 NOTIMPLEMENTED(); | |
|
mfomitchev
2015/11/04 23:21:13
Is it tricky to use Aura's impl here? If so, can w
bshe
2015/11/11 00:38:29
Done.
| |
| 124 } | |
| 125 | |
| 126 void NativeWidgetAndroid::ViewRemoved(View* view) { | |
| 127 NOTIMPLEMENTED(); | |
| 128 } | |
| 129 | |
| 130 void NativeWidgetAndroid::SetNativeWindowProperty(const char* name, | |
| 131 void* value) { | |
| 132 if (host_->window()) | |
| 133 host_->window()->SetNativeWindowProperty(name, value); | |
| 134 } | |
| 135 | |
| 136 void* NativeWidgetAndroid::GetNativeWindowProperty(const char* name) const { | |
| 137 return host_->window() ? host_->window()->GetNativeWindowProperty(name) | |
| 138 : nullptr; | |
| 139 } | |
| 140 | |
| 141 TooltipManager* NativeWidgetAndroid::GetTooltipManager() const { | |
| 142 NOTIMPLEMENTED(); | |
|
mfomitchev
2015/11/04 23:21:13
Is it tricky to use Aura's impl here? If so, can w
bshe
2015/11/11 00:38:29
Done.
| |
| 143 return nullptr; | |
| 144 } | |
| 145 | |
| 146 void NativeWidgetAndroid::SetCapture() { | |
| 147 if (host_->window()) | |
| 148 host_->window()->SetCapture(); | |
| 149 } | |
| 150 | |
| 151 void NativeWidgetAndroid::ReleaseCapture() { | |
| 152 if (host_->window()) | |
| 153 host_->window()->ReleaseCapture(); | |
| 154 } | |
| 155 | |
| 156 bool NativeWidgetAndroid::HasCapture() const { | |
| 157 return host_->window() && host_->window()->HasCapture(); | |
| 158 } | |
| 159 | |
| 160 ui::InputMethod* NativeWidgetAndroid::GetInputMethod() { | |
| 161 if (!host_->window()) | |
| 162 return nullptr; | |
| 163 aura::Window* root_window = host_->window()->GetRootWindow(); | |
| 164 return root_window ? root_window->GetHost()->GetInputMethod() : nullptr; | |
| 165 } | |
| 166 | |
| 167 void NativeWidgetAndroid::CenterWindow(const gfx::Size& size) { | |
|
mfomitchev
2015/11/04 23:21:13
Can you add one TODO referencing a crbug for all t
bshe
2015/11/11 00:38:29
Done.
| |
| 168 NOTIMPLEMENTED(); | |
| 169 } | |
| 170 | |
| 171 void NativeWidgetAndroid::GetWindowPlacement( | |
| 172 gfx::Rect* bounds, | |
| 173 ui::WindowShowState* show_state) const { | |
| 174 NOTIMPLEMENTED(); | |
| 175 } | |
| 176 | |
| 177 bool NativeWidgetAndroid::SetWindowTitle(const base::string16& title) { | |
| 178 NOTIMPLEMENTED(); | |
|
mfomitchev
2015/11/04 23:21:13
Why not use Aura's impl?
bshe
2015/11/11 00:38:29
Done.
| |
| 179 return true; | |
| 180 } | |
| 181 | |
| 182 void NativeWidgetAndroid::SetWindowIcons(const gfx::ImageSkia& window_icon, | |
| 183 const gfx::ImageSkia& app_icon) { | |
| 184 NOTIMPLEMENTED(); | |
| 185 } | |
| 186 | |
| 187 void NativeWidgetAndroid::InitModalType(ui::ModalType modal_type) { | |
| 188 NOTIMPLEMENTED(); | |
|
mfomitchev
2015/11/04 23:21:13
Why not use Aura's impl?
bshe
2015/11/11 00:38:29
Done.
| |
| 189 } | |
| 190 | |
| 191 gfx::Rect NativeWidgetAndroid::GetWindowBoundsInScreen() const { | |
| 192 return host_->window() ? host_->window()->GetBoundsInScreen() : gfx::Rect(); | |
| 193 } | |
| 194 | |
| 195 gfx::Rect NativeWidgetAndroid::GetClientAreaBoundsInScreen() const { | |
| 196 // View-to-screen coordinate system transformations depend on this returning | |
| 197 // the full window bounds, for example View::ConvertPointToScreen(). | |
| 198 return host_->window() ? host_->window()->GetBoundsInScreen() : gfx::Rect(); | |
| 199 } | |
| 200 | |
| 201 gfx::Rect NativeWidgetAndroid::GetRestoredBounds() const { | |
| 202 NOTIMPLEMENTED(); | |
| 203 return gfx::Rect(); | |
| 204 } | |
| 205 | |
| 206 void NativeWidgetAndroid::SetBounds(const gfx::Rect& bounds) { | |
| 207 if (!host_->window()) | |
| 208 return; | |
| 209 | |
| 210 host_->window()->SetBounds(bounds); | |
| 211 } | |
| 212 | |
| 213 void NativeWidgetAndroid::SetSize(const gfx::Size& size) { | |
| 214 if (host_->window()) | |
| 215 host_->window()->SetBounds( | |
| 216 gfx::Rect(host_->window()->bounds().origin(), size)); | |
| 217 } | |
| 218 | |
| 219 void NativeWidgetAndroid::StackAbove(gfx::NativeView native_view) { | |
| 220 NOTIMPLEMENTED(); | |
| 221 } | |
| 222 | |
| 223 void NativeWidgetAndroid::StackAtTop() { | |
| 224 NOTIMPLEMENTED(); | |
| 225 } | |
| 226 | |
| 227 void NativeWidgetAndroid::StackBelow(gfx::NativeView native_view) { | |
| 228 NOTIMPLEMENTED(); | |
| 229 } | |
| 230 | |
| 231 void NativeWidgetAndroid::SetShape(SkRegion* region) { | |
| 232 NOTIMPLEMENTED(); | |
| 233 } | |
| 234 | |
| 235 void NativeWidgetAndroid::Close() { | |
| 236 NOTIMPLEMENTED(); | |
| 237 } | |
| 238 | |
| 239 void NativeWidgetAndroid::CloseNow() { | |
| 240 delete host_->window(); | |
|
sadrul
2015/11/04 19:00:53
Why not host_.reset() instead?
bshe
2015/11/11 00:38:29
Done.
| |
| 241 } | |
| 242 | |
| 243 void NativeWidgetAndroid::Show() { | |
| 244 ShowWithWindowState(ui::SHOW_STATE_MAXIMIZED); | |
| 245 } | |
| 246 | |
| 247 void NativeWidgetAndroid::Hide() { | |
| 248 if (host_->window()) | |
| 249 host_->window()->Hide(); | |
| 250 } | |
| 251 | |
| 252 void NativeWidgetAndroid::ShowMaximizedWithBounds( | |
| 253 const gfx::Rect& restored_bounds) { | |
| 254 ShowWithWindowState(ui::SHOW_STATE_MAXIMIZED); | |
| 255 } | |
| 256 | |
| 257 void NativeWidgetAndroid::ShowWithWindowState(ui::WindowShowState state) { | |
| 258 NOTIMPLEMENTED(); | |
| 259 } | |
| 260 | |
| 261 bool NativeWidgetAndroid::IsVisible() const { | |
| 262 return host_->window() && host_->window()->IsVisible(); | |
| 263 } | |
| 264 | |
| 265 void NativeWidgetAndroid::Activate() { | |
| 266 if (!host_->window()) | |
| 267 return; | |
| 268 | |
| 269 // We don't necessarily have a root window yet. This can happen with | |
| 270 // constrained windows. | |
| 271 if (host_->window()->GetRootWindow()) { | |
| 272 aura::client::GetActivationClient(host_->window()->GetRootWindow()) | |
| 273 ->ActivateWindow(host_->window()); | |
| 274 } | |
| 275 } | |
| 276 | |
| 277 void NativeWidgetAndroid::Deactivate() { | |
| 278 if (!host_->window()) | |
| 279 return; | |
| 280 aura::client::GetActivationClient(host_->window()->GetRootWindow()) | |
| 281 ->DeactivateWindow(host_->window()); | |
| 282 } | |
| 283 | |
| 284 bool NativeWidgetAndroid::IsActive() const { | |
| 285 NOTIMPLEMENTED(); | |
| 286 return true; | |
| 287 } | |
| 288 | |
| 289 void NativeWidgetAndroid::SetAlwaysOnTop(bool on_top) { | |
| 290 NOTIMPLEMENTED(); | |
| 291 } | |
| 292 | |
| 293 bool NativeWidgetAndroid::IsAlwaysOnTop() const { | |
| 294 NOTIMPLEMENTED(); | |
| 295 return false; | |
| 296 } | |
| 297 | |
| 298 void NativeWidgetAndroid::SetVisibleOnAllWorkspaces(bool always_visible) { | |
| 299 NOTIMPLEMENTED(); | |
| 300 } | |
| 301 | |
| 302 void NativeWidgetAndroid::Maximize() { | |
| 303 NOTIMPLEMENTED(); | |
| 304 } | |
| 305 | |
| 306 void NativeWidgetAndroid::Minimize() { | |
| 307 NOTIMPLEMENTED(); | |
| 308 } | |
| 309 | |
| 310 bool NativeWidgetAndroid::IsMaximized() const { | |
| 311 NOTIMPLEMENTED(); | |
| 312 return true; | |
| 313 } | |
| 314 | |
| 315 bool NativeWidgetAndroid::IsMinimized() const { | |
| 316 NOTIMPLEMENTED(); | |
| 317 return false; | |
| 318 } | |
| 319 | |
| 320 void NativeWidgetAndroid::Restore() { | |
| 321 NOTIMPLEMENTED(); | |
| 322 } | |
| 323 | |
| 324 void NativeWidgetAndroid::SetFullscreen(bool fullscreen) { | |
| 325 NOTIMPLEMENTED(); | |
| 326 } | |
| 327 | |
| 328 bool NativeWidgetAndroid::IsFullscreen() const { | |
| 329 NOTIMPLEMENTED(); | |
| 330 return true; | |
| 331 } | |
| 332 | |
| 333 void NativeWidgetAndroid::SetOpacity(unsigned char opacity) { | |
| 334 if (host_->window()) | |
| 335 host_->window()->layer()->SetOpacity(opacity / 255.0); | |
|
sadrul
2015/11/04 19:00:53
GetLayer()->SetOpacity()
bshe
2015/11/11 00:38:29
GetLayer() returns a const ref. Unless we want to
| |
| 336 } | |
| 337 | |
| 338 void NativeWidgetAndroid::SetUseDragFrame(bool use_drag_frame) { | |
| 339 NOTIMPLEMENTED(); | |
| 340 } | |
| 341 | |
| 342 void NativeWidgetAndroid::FlashFrame(bool flash) { | |
| 343 NOTIMPLEMENTED(); | |
| 344 } | |
| 345 | |
| 346 void NativeWidgetAndroid::RunShellDrag( | |
| 347 View* view, | |
| 348 const ui::OSExchangeData& data, | |
| 349 const gfx::Point& location, | |
| 350 int operation, | |
| 351 ui::DragDropTypes::DragEventSource source) { | |
| 352 NOTIMPLEMENTED(); | |
| 353 } | |
| 354 | |
| 355 void NativeWidgetAndroid::SchedulePaintInRect(const gfx::Rect& rect) { | |
| 356 NOTIMPLEMENTED(); | |
|
mfomitchev
2015/11/04 23:21:13
Sorry, why is this NOTIMPLEMENTED()?
Why not host-
bshe
2015/11/11 00:38:29
Done.
| |
| 357 } | |
| 358 | |
| 359 void NativeWidgetAndroid::SetCursor(gfx::NativeCursor cursor) { | |
|
mfomitchev
2015/11/04 23:21:13
TODO/crbug for cursor?
bshe
2015/11/11 00:38:28
Used NativeWidgetAura implementation
| |
| 360 NOTIMPLEMENTED(); | |
| 361 } | |
| 362 | |
| 363 bool NativeWidgetAndroid::IsMouseEventsEnabled() const { | |
| 364 NOTIMPLEMENTED(); | |
| 365 return true; | |
| 366 } | |
| 367 | |
| 368 void NativeWidgetAndroid::ClearNativeFocus() { | |
| 369 NOTIMPLEMENTED(); | |
|
mfomitchev
2015/11/04 23:21:13
Why can't we use NativeWidgetAura's implementation
bshe
2015/11/11 00:38:29
Done.
| |
| 370 } | |
| 371 | |
| 372 gfx::Rect NativeWidgetAndroid::GetWorkAreaBoundsInScreen() const { | |
| 373 NOTIMPLEMENTED(); | |
|
mfomitchev
2015/11/04 23:21:13
TODO/crbug? maybe the same one we use for initiali
bshe
2015/11/11 00:38:29
Done.
| |
| 374 return gfx::Rect(); | |
| 375 } | |
| 376 | |
| 377 Widget::MoveLoopResult NativeWidgetAndroid::RunMoveLoop( | |
| 378 const gfx::Vector2d& drag_offset, | |
| 379 Widget::MoveLoopSource source, | |
| 380 Widget::MoveLoopEscapeBehavior escape_behavior) { | |
| 381 NOTIMPLEMENTED(); | |
| 382 return Widget::MOVE_LOOP_SUCCESSFUL; | |
| 383 } | |
| 384 | |
| 385 void NativeWidgetAndroid::EndMoveLoop() { | |
| 386 NOTIMPLEMENTED(); | |
| 387 } | |
| 388 | |
| 389 void NativeWidgetAndroid::SetVisibilityChangedAnimationsEnabled(bool value) { | |
| 390 NOTIMPLEMENTED(); | |
|
mfomitchev
2015/11/04 23:21:13
Why not use Aura's impl?
bshe
2015/11/11 00:38:29
Done.
| |
| 391 } | |
| 392 | |
| 393 void NativeWidgetAndroid::SetVisibilityAnimationDuration( | |
| 394 const base::TimeDelta& duration) { | |
| 395 NOTIMPLEMENTED(); | |
|
mfomitchev
2015/11/04 23:21:13
ditto
bshe
2015/11/11 00:38:29
Done.
| |
| 396 } | |
| 397 | |
| 398 void NativeWidgetAndroid::SetVisibilityAnimationTransition( | |
| 399 Widget::VisibilityTransition transition) { | |
| 400 NOTIMPLEMENTED(); | |
|
mfomitchev
2015/11/04 23:21:13
ditto
bshe
2015/11/11 00:38:29
Done.
| |
| 401 } | |
| 402 | |
| 403 ui::NativeTheme* NativeWidgetAndroid::GetNativeTheme() const { | |
| 404 NOTIMPLEMENTED(); | |
| 405 return nullptr; | |
| 406 } | |
| 407 | |
| 408 void NativeWidgetAndroid::OnRootViewLayout() { | |
| 409 NOTIMPLEMENTED(); | |
| 410 } | |
| 411 | |
| 412 bool NativeWidgetAndroid::IsTranslucentWindowOpacitySupported() const { | |
| 413 NOTIMPLEMENTED(); | |
| 414 return true; | |
| 415 } | |
| 416 | |
| 417 void NativeWidgetAndroid::OnSizeConstraintsChanged() { | |
| 418 NOTIMPLEMENTED(); | |
|
mfomitchev
2015/11/04 23:21:13
ditto
bshe
2015/11/11 00:38:29
Done.
| |
| 419 } | |
| 420 | |
| 421 void NativeWidgetAndroid::RepostNativeEvent(gfx::NativeEvent native_event) { | |
| 422 NOTIMPLEMENTED(); | |
| 423 } | |
| 424 | |
| 425 } // namespace views | |
| OLD | NEW |