Index: ui/views/widget/android/native_widget_android.cc |
diff --git a/ui/views/widget/android/native_widget_android.cc b/ui/views/widget/android/native_widget_android.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..678e0c7abbd3d52fd4a6122c69bcb676df4214c9 |
--- /dev/null |
+++ b/ui/views/widget/android/native_widget_android.cc |
@@ -0,0 +1,425 @@ |
+// 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.
|
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "ui/views/widget/android/native_widget_android.h" |
+ |
+#include "ui/aura/client/default_capture_client.h" |
+#include "ui/aura/client/window_tree_client.h" |
+#include "ui/aura/window.h" |
+#include "ui/aura/window_tree_host.h" |
+#include "ui/views/widget/android/android_focus_rules.h" |
+#include "ui/views/widget/native_widget_delegate.h" |
+#include "ui/wm/core/default_activation_client.h" |
+#include "ui/wm/core/focus_controller.h" |
+ |
+namespace { |
+ |
+class NativeWidgetAndroidWindowTreeClient |
+ : public aura::client::WindowTreeClient { |
+ public: |
+ explicit NativeWidgetAndroidWindowTreeClient(aura::Window* root_window) |
+ : root_window_(root_window) { |
+ aura::client::SetWindowTreeClient(root_window_, this); |
+ } |
+ ~NativeWidgetAndroidWindowTreeClient() override { |
+ aura::client::SetWindowTreeClient(root_window_, NULL); |
+ } |
+ |
+ // Overridden from client::WindowTreeClient: |
+ aura::Window* GetDefaultParent(aura::Window* context, |
+ aura::Window* window, |
+ const gfx::Rect& bounds) override { |
+ return root_window_; |
+ } |
+ |
+ private: |
+ aura::Window* root_window_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(NativeWidgetAndroidWindowTreeClient); |
+}; |
+ |
+} // namespace |
+ |
+namespace views { |
+ |
+NativeWidgetAndroid::NativeWidgetAndroid( |
+ internal::NativeWidgetDelegate* delegate) |
+ : delegate_(delegate) {} |
+NativeWidgetAndroid::~NativeWidgetAndroid() {} |
sadrul
2015/11/04 19:00:53
new line
bshe
2015/11/11 00:38:29
Done.
|
+ |
+//////////////////////////////////////////////////////////////////////////////// |
+// NativeWidgetAndroid, internal::NativeWidgetPrivate implementation: |
+ |
+void NativeWidgetAndroid::InitNativeWidget(const Widget::InitParams& params) { |
+ // 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.
|
+ host_.reset(aura::WindowTreeHost::Create(gfx::Rect(0, 0, 800, 600))); |
+ host_->InitHost(); |
+ |
+ window_tree_client_.reset( |
+ new NativeWidgetAndroidWindowTreeClient(host_->window())); |
+ |
+ focus_client_.reset(new wm::FocusController(new AndroidFocusRules)); |
+ aura::client::SetFocusClient(host_->window(), focus_client_.get()); |
+ |
+ host_->window()->AddPreTargetHandler(focus_client_.get()); |
+ |
+ new wm::DefaultActivationClient(host_->window()); |
+ |
+ capture_client_.reset( |
+ new aura::client::DefaultCaptureClient(host_->window())); |
+} |
mfomitchev
2015/11/04 23:21:13
What about screen position client?
bshe
2015/11/11 00:38:29
Done.
|
+ |
+NonClientFrameView* NativeWidgetAndroid::CreateNonClientFrameView() { |
+ NOTIMPLEMENTED(); |
+ return nullptr; |
+} |
+ |
+bool NativeWidgetAndroid::ShouldUseNativeFrame() const { |
+ NOTIMPLEMENTED(); |
+ // There is only one frame type for aura. |
+ return false; |
+} |
+ |
+bool NativeWidgetAndroid::ShouldWindowContentsBeTransparent() const { |
+ NOTIMPLEMENTED(); |
+ return false; |
+} |
+ |
+void NativeWidgetAndroid::FrameTypeChanged() { |
+ NOTIMPLEMENTED(); |
+} |
+ |
+Widget* NativeWidgetAndroid::GetWidget() { |
+ return delegate_->AsWidget(); |
+} |
+ |
+const Widget* NativeWidgetAndroid::GetWidget() const { |
+ return delegate_->AsWidget(); |
+} |
+ |
+gfx::NativeView NativeWidgetAndroid::GetNativeView() const { |
+ return host_->window(); |
+} |
+ |
+gfx::NativeWindow NativeWidgetAndroid::GetNativeWindow() const { |
+ return host_->window(); |
+} |
+ |
+Widget* NativeWidgetAndroid::GetTopLevelWidget() { |
+ NOTIMPLEMENTED(); |
+ return nullptr; |
+} |
+ |
+const ui::Compositor* NativeWidgetAndroid::GetCompositor() const { |
+ return host_->window()->layer()->GetCompositor(); |
sadrul
2015/11/04 19:00:53
Just host_->compositor()?
bshe
2015/11/11 00:38:29
Done.
|
+} |
+ |
+const ui::Layer* NativeWidgetAndroid::GetLayer() const { |
+ 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.
|
+} |
+ |
+void NativeWidgetAndroid::ReorderNativeViews() { |
+ 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.
|
+} |
+ |
+void NativeWidgetAndroid::ViewRemoved(View* view) { |
+ NOTIMPLEMENTED(); |
+} |
+ |
+void NativeWidgetAndroid::SetNativeWindowProperty(const char* name, |
+ void* value) { |
+ if (host_->window()) |
+ host_->window()->SetNativeWindowProperty(name, value); |
+} |
+ |
+void* NativeWidgetAndroid::GetNativeWindowProperty(const char* name) const { |
+ return host_->window() ? host_->window()->GetNativeWindowProperty(name) |
+ : nullptr; |
+} |
+ |
+TooltipManager* NativeWidgetAndroid::GetTooltipManager() const { |
+ 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.
|
+ return nullptr; |
+} |
+ |
+void NativeWidgetAndroid::SetCapture() { |
+ if (host_->window()) |
+ host_->window()->SetCapture(); |
+} |
+ |
+void NativeWidgetAndroid::ReleaseCapture() { |
+ if (host_->window()) |
+ host_->window()->ReleaseCapture(); |
+} |
+ |
+bool NativeWidgetAndroid::HasCapture() const { |
+ return host_->window() && host_->window()->HasCapture(); |
+} |
+ |
+ui::InputMethod* NativeWidgetAndroid::GetInputMethod() { |
+ if (!host_->window()) |
+ return nullptr; |
+ aura::Window* root_window = host_->window()->GetRootWindow(); |
+ return root_window ? root_window->GetHost()->GetInputMethod() : nullptr; |
+} |
+ |
+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.
|
+ NOTIMPLEMENTED(); |
+} |
+ |
+void NativeWidgetAndroid::GetWindowPlacement( |
+ gfx::Rect* bounds, |
+ ui::WindowShowState* show_state) const { |
+ NOTIMPLEMENTED(); |
+} |
+ |
+bool NativeWidgetAndroid::SetWindowTitle(const base::string16& title) { |
+ NOTIMPLEMENTED(); |
mfomitchev
2015/11/04 23:21:13
Why not use Aura's impl?
bshe
2015/11/11 00:38:29
Done.
|
+ return true; |
+} |
+ |
+void NativeWidgetAndroid::SetWindowIcons(const gfx::ImageSkia& window_icon, |
+ const gfx::ImageSkia& app_icon) { |
+ NOTIMPLEMENTED(); |
+} |
+ |
+void NativeWidgetAndroid::InitModalType(ui::ModalType modal_type) { |
+ NOTIMPLEMENTED(); |
mfomitchev
2015/11/04 23:21:13
Why not use Aura's impl?
bshe
2015/11/11 00:38:29
Done.
|
+} |
+ |
+gfx::Rect NativeWidgetAndroid::GetWindowBoundsInScreen() const { |
+ return host_->window() ? host_->window()->GetBoundsInScreen() : gfx::Rect(); |
+} |
+ |
+gfx::Rect NativeWidgetAndroid::GetClientAreaBoundsInScreen() const { |
+ // View-to-screen coordinate system transformations depend on this returning |
+ // the full window bounds, for example View::ConvertPointToScreen(). |
+ return host_->window() ? host_->window()->GetBoundsInScreen() : gfx::Rect(); |
+} |
+ |
+gfx::Rect NativeWidgetAndroid::GetRestoredBounds() const { |
+ NOTIMPLEMENTED(); |
+ return gfx::Rect(); |
+} |
+ |
+void NativeWidgetAndroid::SetBounds(const gfx::Rect& bounds) { |
+ if (!host_->window()) |
+ return; |
+ |
+ host_->window()->SetBounds(bounds); |
+} |
+ |
+void NativeWidgetAndroid::SetSize(const gfx::Size& size) { |
+ if (host_->window()) |
+ host_->window()->SetBounds( |
+ gfx::Rect(host_->window()->bounds().origin(), size)); |
+} |
+ |
+void NativeWidgetAndroid::StackAbove(gfx::NativeView native_view) { |
+ NOTIMPLEMENTED(); |
+} |
+ |
+void NativeWidgetAndroid::StackAtTop() { |
+ NOTIMPLEMENTED(); |
+} |
+ |
+void NativeWidgetAndroid::StackBelow(gfx::NativeView native_view) { |
+ NOTIMPLEMENTED(); |
+} |
+ |
+void NativeWidgetAndroid::SetShape(SkRegion* region) { |
+ NOTIMPLEMENTED(); |
+} |
+ |
+void NativeWidgetAndroid::Close() { |
+ NOTIMPLEMENTED(); |
+} |
+ |
+void NativeWidgetAndroid::CloseNow() { |
+ delete host_->window(); |
sadrul
2015/11/04 19:00:53
Why not host_.reset() instead?
bshe
2015/11/11 00:38:29
Done.
|
+} |
+ |
+void NativeWidgetAndroid::Show() { |
+ ShowWithWindowState(ui::SHOW_STATE_MAXIMIZED); |
+} |
+ |
+void NativeWidgetAndroid::Hide() { |
+ if (host_->window()) |
+ host_->window()->Hide(); |
+} |
+ |
+void NativeWidgetAndroid::ShowMaximizedWithBounds( |
+ const gfx::Rect& restored_bounds) { |
+ ShowWithWindowState(ui::SHOW_STATE_MAXIMIZED); |
+} |
+ |
+void NativeWidgetAndroid::ShowWithWindowState(ui::WindowShowState state) { |
+ NOTIMPLEMENTED(); |
+} |
+ |
+bool NativeWidgetAndroid::IsVisible() const { |
+ return host_->window() && host_->window()->IsVisible(); |
+} |
+ |
+void NativeWidgetAndroid::Activate() { |
+ if (!host_->window()) |
+ return; |
+ |
+ // We don't necessarily have a root window yet. This can happen with |
+ // constrained windows. |
+ if (host_->window()->GetRootWindow()) { |
+ aura::client::GetActivationClient(host_->window()->GetRootWindow()) |
+ ->ActivateWindow(host_->window()); |
+ } |
+} |
+ |
+void NativeWidgetAndroid::Deactivate() { |
+ if (!host_->window()) |
+ return; |
+ aura::client::GetActivationClient(host_->window()->GetRootWindow()) |
+ ->DeactivateWindow(host_->window()); |
+} |
+ |
+bool NativeWidgetAndroid::IsActive() const { |
+ NOTIMPLEMENTED(); |
+ return true; |
+} |
+ |
+void NativeWidgetAndroid::SetAlwaysOnTop(bool on_top) { |
+ NOTIMPLEMENTED(); |
+} |
+ |
+bool NativeWidgetAndroid::IsAlwaysOnTop() const { |
+ NOTIMPLEMENTED(); |
+ return false; |
+} |
+ |
+void NativeWidgetAndroid::SetVisibleOnAllWorkspaces(bool always_visible) { |
+ NOTIMPLEMENTED(); |
+} |
+ |
+void NativeWidgetAndroid::Maximize() { |
+ NOTIMPLEMENTED(); |
+} |
+ |
+void NativeWidgetAndroid::Minimize() { |
+ NOTIMPLEMENTED(); |
+} |
+ |
+bool NativeWidgetAndroid::IsMaximized() const { |
+ NOTIMPLEMENTED(); |
+ return true; |
+} |
+ |
+bool NativeWidgetAndroid::IsMinimized() const { |
+ NOTIMPLEMENTED(); |
+ return false; |
+} |
+ |
+void NativeWidgetAndroid::Restore() { |
+ NOTIMPLEMENTED(); |
+} |
+ |
+void NativeWidgetAndroid::SetFullscreen(bool fullscreen) { |
+ NOTIMPLEMENTED(); |
+} |
+ |
+bool NativeWidgetAndroid::IsFullscreen() const { |
+ NOTIMPLEMENTED(); |
+ return true; |
+} |
+ |
+void NativeWidgetAndroid::SetOpacity(unsigned char opacity) { |
+ if (host_->window()) |
+ 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
|
+} |
+ |
+void NativeWidgetAndroid::SetUseDragFrame(bool use_drag_frame) { |
+ NOTIMPLEMENTED(); |
+} |
+ |
+void NativeWidgetAndroid::FlashFrame(bool flash) { |
+ NOTIMPLEMENTED(); |
+} |
+ |
+void NativeWidgetAndroid::RunShellDrag( |
+ View* view, |
+ const ui::OSExchangeData& data, |
+ const gfx::Point& location, |
+ int operation, |
+ ui::DragDropTypes::DragEventSource source) { |
+ NOTIMPLEMENTED(); |
+} |
+ |
+void NativeWidgetAndroid::SchedulePaintInRect(const gfx::Rect& rect) { |
+ NOTIMPLEMENTED(); |
mfomitchev
2015/11/04 23:21:13
Sorry, why is this NOTIMPLEMENTED()?
Why not host-
bshe
2015/11/11 00:38:29
Done.
|
+} |
+ |
+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
|
+ NOTIMPLEMENTED(); |
+} |
+ |
+bool NativeWidgetAndroid::IsMouseEventsEnabled() const { |
+ NOTIMPLEMENTED(); |
+ return true; |
+} |
+ |
+void NativeWidgetAndroid::ClearNativeFocus() { |
+ NOTIMPLEMENTED(); |
mfomitchev
2015/11/04 23:21:13
Why can't we use NativeWidgetAura's implementation
bshe
2015/11/11 00:38:29
Done.
|
+} |
+ |
+gfx::Rect NativeWidgetAndroid::GetWorkAreaBoundsInScreen() const { |
+ 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.
|
+ return gfx::Rect(); |
+} |
+ |
+Widget::MoveLoopResult NativeWidgetAndroid::RunMoveLoop( |
+ const gfx::Vector2d& drag_offset, |
+ Widget::MoveLoopSource source, |
+ Widget::MoveLoopEscapeBehavior escape_behavior) { |
+ NOTIMPLEMENTED(); |
+ return Widget::MOVE_LOOP_SUCCESSFUL; |
+} |
+ |
+void NativeWidgetAndroid::EndMoveLoop() { |
+ NOTIMPLEMENTED(); |
+} |
+ |
+void NativeWidgetAndroid::SetVisibilityChangedAnimationsEnabled(bool value) { |
+ NOTIMPLEMENTED(); |
mfomitchev
2015/11/04 23:21:13
Why not use Aura's impl?
bshe
2015/11/11 00:38:29
Done.
|
+} |
+ |
+void NativeWidgetAndroid::SetVisibilityAnimationDuration( |
+ const base::TimeDelta& duration) { |
+ NOTIMPLEMENTED(); |
mfomitchev
2015/11/04 23:21:13
ditto
bshe
2015/11/11 00:38:29
Done.
|
+} |
+ |
+void NativeWidgetAndroid::SetVisibilityAnimationTransition( |
+ Widget::VisibilityTransition transition) { |
+ NOTIMPLEMENTED(); |
mfomitchev
2015/11/04 23:21:13
ditto
bshe
2015/11/11 00:38:29
Done.
|
+} |
+ |
+ui::NativeTheme* NativeWidgetAndroid::GetNativeTheme() const { |
+ NOTIMPLEMENTED(); |
+ return nullptr; |
+} |
+ |
+void NativeWidgetAndroid::OnRootViewLayout() { |
+ NOTIMPLEMENTED(); |
+} |
+ |
+bool NativeWidgetAndroid::IsTranslucentWindowOpacitySupported() const { |
+ NOTIMPLEMENTED(); |
+ return true; |
+} |
+ |
+void NativeWidgetAndroid::OnSizeConstraintsChanged() { |
+ NOTIMPLEMENTED(); |
mfomitchev
2015/11/04 23:21:13
ditto
bshe
2015/11/11 00:38:29
Done.
|
+} |
+ |
+void NativeWidgetAndroid::RepostNativeEvent(gfx::NativeEvent native_event) { |
+ NOTIMPLEMENTED(); |
+} |
+ |
+} // namespace views |