Chromium Code Reviews| Index: ui/views/widget/android/native_widget_android.cc |
| diff --git a/ui/views/widget/native_widget_aura.cc b/ui/views/widget/android/native_widget_android.cc |
| similarity index 58% |
| copy from ui/views/widget/native_widget_aura.cc |
| copy to ui/views/widget/android/native_widget_android.cc |
| index 8099626710db18abf5751e2c015403307ec4ff92..6cd7c908c6e201d77b97384e2c9b465f1252a8b6 100644 |
| --- a/ui/views/widget/native_widget_aura.cc |
| +++ b/ui/views/widget/android/native_widget_android.cc |
| @@ -1,14 +1,16 @@ |
| -// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#include "ui/views/widget/native_widget_aura.h" |
| +#include "ui/views/widget/android/native_widget_android.h" |
| #include "base/bind.h" |
| +#include "base/run_loop.h" |
| #include "base/strings/string_util.h" |
| #include "third_party/skia/include/core/SkRegion.h" |
| #include "ui/aura/client/aura_constants.h" |
| #include "ui/aura/client/cursor_client.h" |
| +#include "ui/aura/client/default_capture_client.h" |
| #include "ui/aura/client/focus_client.h" |
| #include "ui/aura/client/screen_position_client.h" |
| #include "ui/aura/client/window_tree_client.h" |
| @@ -27,38 +29,29 @@ |
| #include "ui/native_theme/native_theme_aura.h" |
| #include "ui/views/drag_utils.h" |
| #include "ui/views/views_delegate.h" |
| +#include "ui/views/widget/android/android_focus_rules.h" |
| #include "ui/views/widget/drop_helper.h" |
| +#include "ui/views/widget/native_widget_aura.h" |
| #include "ui/views/widget/native_widget_delegate.h" |
| #include "ui/views/widget/root_view.h" |
| #include "ui/views/widget/tooltip_manager_aura.h" |
| #include "ui/views/widget/widget_aura_utils.h" |
| #include "ui/views/widget/widget_delegate.h" |
| #include "ui/views/widget/window_reorderer.h" |
| +#include "ui/wm/core/default_activation_client.h" |
| +#include "ui/wm/core/default_screen_position_client.h" |
| +#include "ui/wm/core/focus_controller.h" |
| #include "ui/wm/core/shadow_types.h" |
| #include "ui/wm/core/window_animations.h" |
| #include "ui/wm/core/window_util.h" |
| #include "ui/wm/public/activation_client.h" |
| +#include "ui/wm/public/dispatcher_client.h" |
| #include "ui/wm/public/drag_drop_client.h" |
| #include "ui/wm/public/window_move_client.h" |
| #include "ui/wm/public/window_types.h" |
| -#if defined(OS_WIN) |
| -#include "base/win/scoped_gdi_object.h" |
| -#include "base/win/win_util.h" |
| -#include "ui/base/l10n/l10n_util_win.h" |
| -#include "ui/views/widget/desktop_aura/desktop_window_tree_host_win.h" |
| -#endif |
| - |
| -#if defined(USE_X11) && !defined(OS_CHROMEOS) |
| -#include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" |
| -#endif |
| - |
| -#if !defined(OS_CHROMEOS) |
| -#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
| -#include "ui/views/widget/desktop_aura/desktop_window_tree_host.h" |
| -#endif |
| - |
| -namespace views { |
| +// TODO(bshe): Most of the code is copied from NativeWidgetAura. There will be |
| +// more differences overtime. For upstreaming purpose, keep the change minimal. |
| namespace { |
| @@ -66,12 +59,72 @@ void SetRestoreBounds(aura::Window* window, const gfx::Rect& bounds) { |
| window->SetProperty(aura::client::kRestoreBoundsKey, new gfx::Rect(bounds)); |
| } |
| +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); |
| +}; |
| + |
| +class AndroidDispatcherClient : public aura::client::DispatcherClient { |
|
mfomitchev
2015/11/06 16:45:50
We are trying to get rid of nested msg loops, so h
bshe
2015/11/11 00:38:30
Done.
|
| + public: |
| + AndroidDispatcherClient() : dispatcher_(nullptr) {} |
| + ~AndroidDispatcherClient() override {} |
| + |
| + base::MessagePumpDispatcher* dispatcher() { return dispatcher_; } |
| + |
| + // aura::client::DispatcherClient: |
| + void PrepareNestedLoopClosures(base::MessagePumpDispatcher* dispatcher, |
| + base::Closure* run_closure, |
| + base::Closure* quit_closure) override { |
| + scoped_ptr<base::RunLoop> run_loop(new base::RunLoop()); |
| + *quit_closure = run_loop->QuitClosure(); |
| + *run_closure = |
| + base::Bind(&AndroidDispatcherClient::RunNestedDispatcher, |
| + base::Unretained(this), base::Passed(&run_loop), dispatcher); |
| + } |
| + |
| + private: |
| + void RunNestedDispatcher(scoped_ptr<base::RunLoop> run_loop, |
| + base::MessagePumpDispatcher* dispatcher) { |
| + base::AutoReset<base::MessagePumpDispatcher*> reset_dispatcher(&dispatcher_, |
| + dispatcher); |
| + base::MessageLoopForUI* loop = base::MessageLoopForUI::current(); |
| + base::MessageLoop::ScopedNestableTaskAllower allow(loop); |
| + run_loop->Run(); |
| + } |
| + |
| + base::MessagePumpDispatcher* dispatcher_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(AndroidDispatcherClient); |
| +}; |
| + |
| } // namespace |
| +namespace views { |
| + |
| //////////////////////////////////////////////////////////////////////////////// |
| -// NativeWidgetAura, public: |
| +// NativeWidgetAndroid, public |
| -NativeWidgetAura::NativeWidgetAura(internal::NativeWidgetDelegate* delegate) |
| +NativeWidgetAndroid::NativeWidgetAndroid( |
| + internal::NativeWidgetDelegate* delegate) |
| : delegate_(delegate), |
| window_(new aura::Window(this)), |
| ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), |
| @@ -83,30 +136,46 @@ NativeWidgetAura::NativeWidgetAura(internal::NativeWidgetDelegate* delegate) |
| aura::client::SetActivationChangeObserver(window_, this); |
| } |
| -// static |
| -void NativeWidgetAura::RegisterNativeWidgetForWindow( |
| - internal::NativeWidgetPrivate* native_widget, |
| - aura::Window* window) { |
| - window->set_user_data(native_widget); |
| -} |
| - |
| //////////////////////////////////////////////////////////////////////////////// |
| -// NativeWidgetAura, internal::NativeWidgetPrivate implementation: |
| +// NativeWidgetAndroid, NativeWidgetAndroid implementation: |
| + |
| +void NativeWidgetAndroid::InitNativeWidget(const Widget::InitParams& params) { |
| + // TODO(bshe): Get rid of the hard coded size. Tracked in crbug.com/551923. |
| + host_.reset(aura::WindowTreeHost::Create(gfx::Rect(0, 0, 800, 600))); |
| + host_->InitHost(); |
| + host_->Show(); |
| + |
| + 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())); |
| + |
| + screen_position_client_.reset(new wm::DefaultScreenPositionClient); |
| + aura::client::SetScreenPositionClient(host_->window(), |
| + screen_position_client_.get()); |
| + dispatcher_client_.reset(new AndroidDispatcherClient); |
| + aura::client::SetDispatcherClient(host_->window(), dispatcher_client_.get()); |
| -void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) { |
| // Aura needs to know which desktop (Ash or regular) will manage this widget. |
| // See Widget::InitParams::context for details. |
| DCHECK(params.parent || params.context); |
|
mfomitchev
2015/11/06 16:45:50
This seems wrong? This is top-level...
bshe
2015/11/11 00:38:30
removed.
|
| ownership_ = params.ownership; |
| - RegisterNativeWidgetForWindow(this, window_); |
| + NativeWidgetAura::RegisterNativeWidgetForWindow(this, window_); |
| window_->SetType(GetAuraWindowTypeForWidgetType(params.type)); |
| window_->SetProperty(aura::client::kShowStateKey, params.show_state); |
| if (params.type == Widget::InitParams::TYPE_BUBBLE) |
| aura::client::SetHideOnDeactivate(window_, true); |
| - window_->SetTransparent( |
| - params.opacity == Widget::InitParams::TRANSLUCENT_WINDOW); |
| + window_->SetTransparent(params.opacity == |
| + Widget::InitParams::TRANSLUCENT_WINDOW); |
| window_->Init(params.layer_type); |
| if (params.shadow_type == Widget::InitParams::SHADOW_TYPE_NONE) |
| SetShadowType(window_, wm::SHADOW_TYPE_NONE); |
| @@ -136,8 +205,9 @@ void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) { |
| // If a parent is specified but no bounds are given, |
| // use the origin of the parent's display so that the widget |
| // will be added to the same display as the parent. |
| - gfx::Rect bounds = gfx::Screen::GetScreenFor(parent)-> |
| - GetDisplayNearestWindow(parent).bounds(); |
| + gfx::Rect bounds = gfx::Screen::GetScreenFor(parent) |
| + ->GetDisplayNearestWindow(parent) |
| + .bounds(); |
| window_bounds.set_origin(bounds.origin()); |
| } |
| } |
| @@ -149,8 +219,8 @@ void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) { |
| if (parent) { |
| parent->AddChild(window_); |
| } else { |
| - aura::client::ParentWindowWithContext( |
| - window_, context->GetRootWindow(), window_bounds); |
| + aura::client::ParentWindowWithContext(window_, context->GetRootWindow(), |
| + window_bounds); |
| } |
| // Start observing property changes. |
| @@ -176,103 +246,104 @@ void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) { |
| aura::client::SetActivationDelegate(window_, this); |
| - window_reorderer_.reset(new WindowReorderer(window_, |
| - GetWidget()->GetRootView())); |
| + window_reorderer_.reset( |
| + new WindowReorderer(window_, GetWidget()->GetRootView())); |
| } |
| -NonClientFrameView* NativeWidgetAura::CreateNonClientFrameView() { |
| +NonClientFrameView* NativeWidgetAndroid::CreateNonClientFrameView() { |
| return NULL; |
|
mfomitchev
2015/11/06 16:45:50
previous impl was better IMHO
bshe
2015/11/11 00:38:30
Done.
|
| } |
| -bool NativeWidgetAura::ShouldUseNativeFrame() const { |
| +bool NativeWidgetAndroid::ShouldUseNativeFrame() const { |
| // There is only one frame type for aura. |
|
mfomitchev
2015/11/06 16:45:50
ditto
bshe
2015/11/11 00:38:30
Done.
|
| return false; |
| } |
| -bool NativeWidgetAura::ShouldWindowContentsBeTransparent() const { |
| +bool NativeWidgetAndroid::ShouldWindowContentsBeTransparent() const { |
| return false; |
|
mfomitchev
2015/11/06 16:45:51
ditto
bshe
2015/11/11 00:38:30
Done.
|
| } |
| -void NativeWidgetAura::FrameTypeChanged() { |
| +void NativeWidgetAndroid::FrameTypeChanged() { |
| // This is called when the Theme has changed; forward the event to the root |
| // widget. |
| GetWidget()->ThemeChanged(); |
|
mfomitchev
2015/11/06 16:45:51
We don't have themes.. maybe just leave NOTIMPLEME
bshe
2015/11/11 00:38:30
Done.
|
| GetWidget()->GetRootView()->SchedulePaint(); |
| } |
| -Widget* NativeWidgetAura::GetWidget() { |
| +Widget* NativeWidgetAndroid::GetWidget() { |
| return delegate_->AsWidget(); |
| } |
| -const Widget* NativeWidgetAura::GetWidget() const { |
| +const Widget* NativeWidgetAndroid::GetWidget() const { |
| return delegate_->AsWidget(); |
| } |
| -gfx::NativeView NativeWidgetAura::GetNativeView() const { |
| +gfx::NativeView NativeWidgetAndroid::GetNativeView() const { |
| return window_; |
| } |
| -gfx::NativeWindow NativeWidgetAura::GetNativeWindow() const { |
| +gfx::NativeWindow NativeWidgetAndroid::GetNativeWindow() const { |
| return window_; |
| } |
| -Widget* NativeWidgetAura::GetTopLevelWidget() { |
| +Widget* NativeWidgetAndroid::GetTopLevelWidget() { |
| NativeWidgetPrivate* native_widget = GetTopLevelNativeWidget(GetNativeView()); |
|
mfomitchev
2015/11/06 16:45:51
We are the top-level widget... use DNWA's impl?
bshe
2015/11/11 00:38:30
Done.
|
| return native_widget ? native_widget->GetWidget() : NULL; |
| } |
| -const ui::Compositor* NativeWidgetAura::GetCompositor() const { |
| +const ui::Compositor* NativeWidgetAndroid::GetCompositor() const { |
| return window_ ? window_->layer()->GetCompositor() : NULL; |
|
mfomitchev
2015/11/06 16:45:51
Sadrul suggested host_->compositor()
bshe
2015/11/11 00:38:30
Done.
|
| } |
| -const ui::Layer* NativeWidgetAura::GetLayer() const { |
| +const ui::Layer* NativeWidgetAndroid::GetLayer() const { |
| return window_ ? window_->layer() : NULL; |
|
mfomitchev
2015/11/06 16:45:51
See Sadrul's comment
bshe
2015/11/11 00:38:29
Done.
|
| } |
| -void NativeWidgetAura::ReorderNativeViews() { |
| +void NativeWidgetAndroid::ReorderNativeViews() { |
| window_reorderer_->ReorderChildWindows(); |
| } |
| -void NativeWidgetAura::ViewRemoved(View* view) { |
| +void NativeWidgetAndroid::ViewRemoved(View* view) { |
| DCHECK(drop_helper_.get() != NULL); |
|
mfomitchev
2015/11/06 16:45:50
We don't support DND, so NOTIMPLEMENTED() makes se
bshe
2015/11/11 00:38:30
Done.
|
| drop_helper_->ResetTargetViewIfEquals(view); |
| } |
| -void NativeWidgetAura::SetNativeWindowProperty(const char* name, void* value) { |
| +void NativeWidgetAndroid::SetNativeWindowProperty(const char* name, |
| + void* value) { |
| if (window_) |
| window_->SetNativeWindowProperty(name, value); |
| } |
| -void* NativeWidgetAura::GetNativeWindowProperty(const char* name) const { |
| +void* NativeWidgetAndroid::GetNativeWindowProperty(const char* name) const { |
| return window_ ? window_->GetNativeWindowProperty(name) : NULL; |
| } |
| -TooltipManager* NativeWidgetAura::GetTooltipManager() const { |
| +TooltipManager* NativeWidgetAndroid::GetTooltipManager() const { |
| return tooltip_manager_.get(); |
| } |
| -void NativeWidgetAura::SetCapture() { |
| +void NativeWidgetAndroid::SetCapture() { |
| if (window_) |
| window_->SetCapture(); |
| } |
| -void NativeWidgetAura::ReleaseCapture() { |
| +void NativeWidgetAndroid::ReleaseCapture() { |
| if (window_) |
| window_->ReleaseCapture(); |
| } |
| -bool NativeWidgetAura::HasCapture() const { |
| +bool NativeWidgetAndroid::HasCapture() const { |
| return window_ && window_->HasCapture(); |
| } |
| -ui::InputMethod* NativeWidgetAura::GetInputMethod() { |
| +ui::InputMethod* NativeWidgetAndroid::GetInputMethod() { |
| if (!window_) |
| return nullptr; |
| aura::Window* root_window = window_->GetRootWindow(); |
| return root_window ? root_window->GetHost()->GetInputMethod() : nullptr; |
| } |
| -void NativeWidgetAura::CenterWindow(const gfx::Size& size) { |
| +void NativeWidgetAndroid::CenterWindow(const gfx::Size& size) { |
|
mfomitchev
2015/11/06 16:45:51
See my previous comment - not sure this makes sens
bshe
2015/11/11 00:38:30
Left a TODO and used NOTIMPLEMENTED for now.
|
| if (!window_) |
| return; |
| @@ -280,8 +351,9 @@ void NativeWidgetAura::CenterWindow(const gfx::Size& size) { |
| // When centering window, we take the intersection of the host and |
| // the parent. We assume the root window represents the visible |
| // rect of a single screen. |
| - gfx::Rect work_area = gfx::Screen::GetScreenFor(window_)-> |
| - GetDisplayNearestWindow(window_).work_area(); |
| + gfx::Rect work_area = gfx::Screen::GetScreenFor(window_) |
| + ->GetDisplayNearestWindow(window_) |
| + .work_area(); |
| aura::client::ScreenPositionClient* screen_position_client = |
| aura::client::GetScreenPositionClient(window_->GetRootWindow()); |
| @@ -308,8 +380,7 @@ void NativeWidgetAura::CenterWindow(const gfx::Size& size) { |
| gfx::Rect window_bounds( |
| parent_bounds.x() + (parent_bounds.width() - size.width()) / 2, |
| parent_bounds.y() + (parent_bounds.height() - size.height()) / 2, |
| - size.width(), |
| - size.height()); |
| + size.width(), size.height()); |
| // Don't size the window bigger than the parent, otherwise the user may not be |
| // able to close or move it. |
| window_bounds.AdjustToFit(parent_bounds); |
| @@ -317,21 +388,21 @@ void NativeWidgetAura::CenterWindow(const gfx::Size& size) { |
| // Convert the bounds back relative to the parent. |
| gfx::Point origin = window_bounds.origin(); |
| aura::Window::ConvertPointToTarget(window_->GetRootWindow(), |
| - window_->parent(), &origin); |
| + window_->parent(), &origin); |
| window_bounds.set_origin(origin); |
| window_->SetBounds(window_bounds); |
| } |
| -void NativeWidgetAura::GetWindowPlacement( |
| +void NativeWidgetAndroid::GetWindowPlacement( |
| gfx::Rect* bounds, |
| ui::WindowShowState* show_state) const { |
| // The interface specifies returning restored bounds, not current bounds. |
|
mfomitchev
2015/11/06 16:45:51
ditto
bshe
2015/11/11 00:38:30
Done.
|
| *bounds = GetRestoredBounds(); |
| - *show_state = window_ ? window_->GetProperty(aura::client::kShowStateKey) : |
| - ui::SHOW_STATE_DEFAULT; |
| + *show_state = window_ ? window_->GetProperty(aura::client::kShowStateKey) |
| + : ui::SHOW_STATE_DEFAULT; |
| } |
| -bool NativeWidgetAura::SetWindowTitle(const base::string16& title) { |
| +bool NativeWidgetAndroid::SetWindowTitle(const base::string16& title) { |
| if (!window_) |
|
mfomitchev
2015/11/06 16:45:51
window_ can't be null?
bshe
2015/11/11 00:38:30
Done.
|
| return false; |
| if (window_->title() == title) |
| @@ -340,27 +411,27 @@ bool NativeWidgetAura::SetWindowTitle(const base::string16& title) { |
| return true; |
| } |
| -void NativeWidgetAura::SetWindowIcons(const gfx::ImageSkia& window_icon, |
| - const gfx::ImageSkia& app_icon) { |
| +void NativeWidgetAndroid::SetWindowIcons(const gfx::ImageSkia& window_icon, |
| + const gfx::ImageSkia& app_icon) { |
| // Aura doesn't have window icons. |
|
mfomitchev
2015/11/06 16:45:50
DesktopNativeWidgetAura has something for this, so
bshe
2015/11/11 00:38:30
Done.
|
| } |
| -void NativeWidgetAura::InitModalType(ui::ModalType modal_type) { |
| +void NativeWidgetAndroid::InitModalType(ui::ModalType modal_type) { |
| if (modal_type != ui::MODAL_TYPE_NONE) |
| window_->SetProperty(aura::client::kModalKey, modal_type); |
| } |
| -gfx::Rect NativeWidgetAura::GetWindowBoundsInScreen() const { |
| +gfx::Rect NativeWidgetAndroid::GetWindowBoundsInScreen() const { |
| return window_ ? window_->GetBoundsInScreen() : gfx::Rect(); |
| } |
| -gfx::Rect NativeWidgetAura::GetClientAreaBoundsInScreen() const { |
| +gfx::Rect NativeWidgetAndroid::GetClientAreaBoundsInScreen() const { |
| // View-to-screen coordinate system transformations depend on this returning |
| // the full window bounds, for example View::ConvertPointToScreen(). |
| return window_ ? window_->GetBoundsInScreen() : gfx::Rect(); |
| } |
| -gfx::Rect NativeWidgetAura::GetRestoredBounds() const { |
| +gfx::Rect NativeWidgetAndroid::GetRestoredBounds() const { |
| if (!window_) |
|
mfomitchev
2015/11/06 16:45:50
Same as CenterWindow and other top-level sizing/po
bshe
2015/11/11 00:38:30
Done.
|
| return gfx::Rect(); |
| @@ -391,7 +462,7 @@ gfx::Rect NativeWidgetAura::GetRestoredBounds() const { |
| return bounds; |
| } |
| -void NativeWidgetAura::SetBounds(const gfx::Rect& bounds) { |
| +void NativeWidgetAndroid::SetBounds(const gfx::Rect& bounds) { |
| if (!window_) |
| return; |
| @@ -409,36 +480,36 @@ void NativeWidgetAura::SetBounds(const gfx::Rect& bounds) { |
| window_->SetBounds(bounds); |
| } |
| -void NativeWidgetAura::SetSize(const gfx::Size& size) { |
| +void NativeWidgetAndroid::SetSize(const gfx::Size& size) { |
| if (window_) |
| window_->SetBounds(gfx::Rect(window_->bounds().origin(), size)); |
| } |
| -void NativeWidgetAura::StackAbove(gfx::NativeView native_view) { |
| +void NativeWidgetAndroid::StackAbove(gfx::NativeView native_view) { |
| if (window_ && window_->parent() && |
| window_->parent() == native_view->parent()) |
| window_->parent()->StackChildAbove(window_, native_view); |
| } |
| -void NativeWidgetAura::StackAtTop() { |
| +void NativeWidgetAndroid::StackAtTop() { |
| if (window_) |
| window_->parent()->StackChildAtTop(window_); |
| } |
| -void NativeWidgetAura::StackBelow(gfx::NativeView native_view) { |
| +void NativeWidgetAndroid::StackBelow(gfx::NativeView native_view) { |
| if (window_ && window_->parent() && |
| window_->parent() == native_view->parent()) |
| window_->parent()->StackChildBelow(window_, native_view); |
| } |
| -void NativeWidgetAura::SetShape(SkRegion* region) { |
| +void NativeWidgetAndroid::SetShape(SkRegion* region) { |
| if (window_) |
| window_->layer()->SetAlphaShape(make_scoped_ptr(region)); |
| else |
| delete region; |
| } |
| -void NativeWidgetAura::Close() { |
| +void NativeWidgetAndroid::Close() { |
| // |window_| may already be deleted by parent window. This can happen |
| // when this widget is child widget or has transient parent |
| // and ownership is WIDGET_OWNS_NATIVE_WIDGET. |
| @@ -452,32 +523,31 @@ void NativeWidgetAura::Close() { |
| if (!close_widget_factory_.HasWeakPtrs()) { |
| base::MessageLoop::current()->PostTask( |
| - FROM_HERE, |
| - base::Bind(&NativeWidgetAura::CloseNow, |
| - close_widget_factory_.GetWeakPtr())); |
| + FROM_HERE, base::Bind(&NativeWidgetAndroid::CloseNow, |
| + close_widget_factory_.GetWeakPtr())); |
| } |
| } |
| -void NativeWidgetAura::CloseNow() { |
| +void NativeWidgetAndroid::CloseNow() { |
| delete window_; |
|
mfomitchev
2015/11/06 16:45:51
see Sadrul's comment
bshe
2015/11/11 00:38:30
Done.
|
| } |
| -void NativeWidgetAura::Show() { |
| +void NativeWidgetAndroid::Show() { |
| ShowWithWindowState(ui::SHOW_STATE_NORMAL); |
| } |
| -void NativeWidgetAura::Hide() { |
| +void NativeWidgetAndroid::Hide() { |
| if (window_) |
| window_->Hide(); |
| } |
| -void NativeWidgetAura::ShowMaximizedWithBounds( |
| +void NativeWidgetAndroid::ShowMaximizedWithBounds( |
| const gfx::Rect& restored_bounds) { |
| SetRestoreBounds(window_, restored_bounds); |
| ShowWithWindowState(ui::SHOW_STATE_MAXIMIZED); |
| } |
| -void NativeWidgetAura::ShowWithWindowState(ui::WindowShowState state) { |
| +void NativeWidgetAndroid::ShowWithWindowState(ui::WindowShowState state) { |
| if (!window_) |
| return; |
| @@ -496,74 +566,76 @@ void NativeWidgetAura::ShowWithWindowState(ui::WindowShowState state) { |
| } |
| } |
| -bool NativeWidgetAura::IsVisible() const { |
| +bool NativeWidgetAndroid::IsVisible() const { |
| return window_ && window_->IsVisible(); |
| } |
| -void NativeWidgetAura::Activate() { |
| +void NativeWidgetAndroid::Activate() { |
| if (!window_) |
| return; |
| // We don't necessarily have a root window yet. This can happen with |
| // constrained windows. |
| if (window_->GetRootWindow()) { |
| - aura::client::GetActivationClient(window_->GetRootWindow())->ActivateWindow( |
| - window_); |
| + aura::client::GetActivationClient(window_->GetRootWindow()) |
| + ->ActivateWindow(window_); |
| } |
| if (window_->GetProperty(aura::client::kDrawAttentionKey)) |
| window_->SetProperty(aura::client::kDrawAttentionKey, false); |
| } |
| -void NativeWidgetAura::Deactivate() { |
| +void NativeWidgetAndroid::Deactivate() { |
| if (!window_) |
| return; |
| - aura::client::GetActivationClient(window_->GetRootWindow())->DeactivateWindow( |
| - window_); |
| + aura::client::GetActivationClient(window_->GetRootWindow()) |
| + ->DeactivateWindow(window_); |
| } |
| -bool NativeWidgetAura::IsActive() const { |
| +bool NativeWidgetAndroid::IsActive() const { |
| return window_ && wm::IsActiveWindow(window_); |
| } |
| -void NativeWidgetAura::SetAlwaysOnTop(bool on_top) { |
| +void NativeWidgetAndroid::SetAlwaysOnTop(bool on_top) { |
| if (window_) |
| window_->SetProperty(aura::client::kAlwaysOnTopKey, on_top); |
| } |
| -bool NativeWidgetAura::IsAlwaysOnTop() const { |
| +bool NativeWidgetAndroid::IsAlwaysOnTop() const { |
| return window_ && window_->GetProperty(aura::client::kAlwaysOnTopKey); |
| } |
| -void NativeWidgetAura::SetVisibleOnAllWorkspaces(bool always_visible) { |
| +void NativeWidgetAndroid::SetVisibleOnAllWorkspaces(bool always_visible) { |
| // Not implemented on chromeos or for child widgets. |
| } |
| -void NativeWidgetAura::Maximize() { |
| +void NativeWidgetAndroid::Maximize() { |
| if (window_) |
| window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| } |
| -void NativeWidgetAura::Minimize() { |
| +void NativeWidgetAndroid::Minimize() { |
| if (window_) |
| window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); |
| } |
| -bool NativeWidgetAura::IsMaximized() const { |
| - return window_ && window_->GetProperty(aura::client::kShowStateKey) == |
| - ui::SHOW_STATE_MAXIMIZED; |
| +bool NativeWidgetAndroid::IsMaximized() const { |
| + return window_ && |
| + window_->GetProperty(aura::client::kShowStateKey) == |
| + ui::SHOW_STATE_MAXIMIZED; |
| } |
| -bool NativeWidgetAura::IsMinimized() const { |
| - return window_ && window_->GetProperty(aura::client::kShowStateKey) == |
| - ui::SHOW_STATE_MINIMIZED; |
| +bool NativeWidgetAndroid::IsMinimized() const { |
| + return window_ && |
| + window_->GetProperty(aura::client::kShowStateKey) == |
| + ui::SHOW_STATE_MINIMIZED; |
| } |
| -void NativeWidgetAura::Restore() { |
| +void NativeWidgetAndroid::Restore() { |
| if (window_) |
| window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
| } |
| -void NativeWidgetAura::SetFullscreen(bool fullscreen) { |
| +void NativeWidgetAndroid::SetFullscreen(bool fullscreen) { |
| if (!window_ || IsFullscreen() == fullscreen) |
| return; // Nothing to do. |
| @@ -577,40 +649,42 @@ void NativeWidgetAura::SetFullscreen(bool fullscreen) { |
| fullscreen ? ui::SHOW_STATE_FULLSCREEN : saved_window_state_); |
| } |
| -bool NativeWidgetAura::IsFullscreen() const { |
| - return window_ && window_->GetProperty(aura::client::kShowStateKey) == |
| - ui::SHOW_STATE_FULLSCREEN; |
| +bool NativeWidgetAndroid::IsFullscreen() const { |
| + return window_ && |
| + window_->GetProperty(aura::client::kShowStateKey) == |
| + ui::SHOW_STATE_FULLSCREEN; |
| } |
| -void NativeWidgetAura::SetOpacity(unsigned char opacity) { |
| +void NativeWidgetAndroid::SetOpacity(unsigned char opacity) { |
| if (window_) |
| window_->layer()->SetOpacity(opacity / 255.0); |
| } |
| -void NativeWidgetAura::SetUseDragFrame(bool use_drag_frame) { |
| +void NativeWidgetAndroid::SetUseDragFrame(bool use_drag_frame) { |
| NOTIMPLEMENTED(); |
| } |
| -void NativeWidgetAura::FlashFrame(bool flash) { |
| +void NativeWidgetAndroid::FlashFrame(bool flash) { |
| if (window_) |
| window_->SetProperty(aura::client::kDrawAttentionKey, flash); |
| } |
| -void NativeWidgetAura::RunShellDrag(View* view, |
| - const ui::OSExchangeData& data, |
| - const gfx::Point& location, |
| - int operation, |
| - ui::DragDropTypes::DragEventSource source) { |
| +void NativeWidgetAndroid::RunShellDrag( |
| + View* view, |
| + const ui::OSExchangeData& data, |
| + const gfx::Point& location, |
| + int operation, |
| + ui::DragDropTypes::DragEventSource source) { |
| if (window_) |
| views::RunShellDrag(window_, data, location, operation, source); |
| } |
| -void NativeWidgetAura::SchedulePaintInRect(const gfx::Rect& rect) { |
| +void NativeWidgetAndroid::SchedulePaintInRect(const gfx::Rect& rect) { |
| if (window_) |
| window_->SchedulePaintInRect(rect); |
| } |
| -void NativeWidgetAura::SetCursor(gfx::NativeCursor cursor) { |
| +void NativeWidgetAndroid::SetCursor(gfx::NativeCursor cursor) { |
| cursor_ = cursor; |
| aura::client::CursorClient* cursor_client = |
| aura::client::GetCursorClient(window_->GetRootWindow()); |
| @@ -618,7 +692,7 @@ void NativeWidgetAura::SetCursor(gfx::NativeCursor cursor) { |
| cursor_client->SetCursor(cursor); |
| } |
| -bool NativeWidgetAura::IsMouseEventsEnabled() const { |
| +bool NativeWidgetAndroid::IsMouseEventsEnabled() const { |
| if (!window_) |
| return false; |
| aura::client::CursorClient* cursor_client = |
| @@ -626,20 +700,21 @@ bool NativeWidgetAura::IsMouseEventsEnabled() const { |
| return cursor_client ? cursor_client->IsMouseEventsEnabled() : true; |
| } |
| -void NativeWidgetAura::ClearNativeFocus() { |
| +void NativeWidgetAndroid::ClearNativeFocus() { |
| aura::client::FocusClient* client = aura::client::GetFocusClient(window_); |
| if (window_ && client && window_->Contains(client->GetFocusedWindow())) |
| client->ResetFocusWithinActiveWindow(window_); |
| } |
| -gfx::Rect NativeWidgetAura::GetWorkAreaBoundsInScreen() const { |
| +gfx::Rect NativeWidgetAndroid::GetWorkAreaBoundsInScreen() const { |
| if (!window_) |
| return gfx::Rect(); |
| - return gfx::Screen::GetScreenFor(window_)-> |
| - GetDisplayNearestWindow(window_).work_area(); |
| + return gfx::Screen::GetScreenFor(window_) |
| + ->GetDisplayNearestWindow(window_) |
| + .work_area(); |
| } |
| -Widget::MoveLoopResult NativeWidgetAura::RunMoveLoop( |
| +Widget::MoveLoopResult NativeWidgetAndroid::RunMoveLoop( |
| const gfx::Vector2d& drag_offset, |
| Widget::MoveLoopSource source, |
| Widget::MoveLoopEscapeBehavior escape_behavior) { |
| @@ -654,17 +729,17 @@ Widget::MoveLoopResult NativeWidgetAura::RunMoveLoop( |
| SetCapture(); |
| aura::client::WindowMoveSource window_move_source = |
| - source == Widget::MOVE_LOOP_SOURCE_MOUSE ? |
| - aura::client::WINDOW_MOVE_SOURCE_MOUSE : |
| - aura::client::WINDOW_MOVE_SOURCE_TOUCH; |
| + source == Widget::MOVE_LOOP_SOURCE_MOUSE |
| + ? aura::client::WINDOW_MOVE_SOURCE_MOUSE |
| + : aura::client::WINDOW_MOVE_SOURCE_TOUCH; |
| if (move_client->RunMoveLoop(window_, drag_offset, window_move_source) == |
| - aura::client::MOVE_SUCCESSFUL) { |
| + aura::client::MOVE_SUCCESSFUL) { |
| return Widget::MOVE_LOOP_SUCCESSFUL; |
| } |
| return Widget::MOVE_LOOP_CANCELED; |
| } |
| -void NativeWidgetAura::EndMoveLoop() { |
| +void NativeWidgetAndroid::EndMoveLoop() { |
| if (!window_ || !window_->GetRootWindow()) |
| return; |
| aura::client::WindowMoveClient* move_client = |
| @@ -673,17 +748,17 @@ void NativeWidgetAura::EndMoveLoop() { |
| move_client->EndMoveLoop(); |
| } |
| -void NativeWidgetAura::SetVisibilityChangedAnimationsEnabled(bool value) { |
| +void NativeWidgetAndroid::SetVisibilityChangedAnimationsEnabled(bool value) { |
| if (window_) |
| window_->SetProperty(aura::client::kAnimationsDisabledKey, !value); |
| } |
| -void NativeWidgetAura::SetVisibilityAnimationDuration( |
| +void NativeWidgetAndroid::SetVisibilityAnimationDuration( |
| const base::TimeDelta& duration) { |
| wm::SetWindowVisibilityAnimationDuration(window_, duration); |
| } |
| -void NativeWidgetAura::SetVisibilityAnimationTransition( |
| +void NativeWidgetAndroid::SetVisibilityAnimationTransition( |
| Widget::VisibilityTransition transition) { |
| wm::WindowVisibilityAnimationTransition wm_transition = wm::ANIMATE_NONE; |
| switch (transition) { |
| @@ -703,22 +778,17 @@ void NativeWidgetAura::SetVisibilityAnimationTransition( |
| wm::SetWindowVisibilityAnimationTransition(window_, wm_transition); |
| } |
| -ui::NativeTheme* NativeWidgetAura::GetNativeTheme() const { |
| -#if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) |
| - return DesktopWindowTreeHost::GetNativeTheme(window_); |
| -#else |
| +ui::NativeTheme* NativeWidgetAndroid::GetNativeTheme() const { |
| return ui::NativeThemeAura::instance(); |
| -#endif |
| } |
| -void NativeWidgetAura::OnRootViewLayout() { |
| -} |
| +void NativeWidgetAndroid::OnRootViewLayout() {} |
| -bool NativeWidgetAura::IsTranslucentWindowOpacitySupported() const { |
| +bool NativeWidgetAndroid::IsTranslucentWindowOpacitySupported() const { |
| return true; |
| } |
| -void NativeWidgetAura::OnSizeConstraintsChanged() { |
| +void NativeWidgetAndroid::OnSizeConstraintsChanged() { |
| window_->SetProperty(aura::client::kCanMaximizeKey, |
| GetWidget()->widget_delegate()->CanMaximize()); |
| window_->SetProperty(aura::client::kCanMinimizeKey, |
| @@ -727,18 +797,18 @@ void NativeWidgetAura::OnSizeConstraintsChanged() { |
| GetWidget()->widget_delegate()->CanResize()); |
| } |
| -void NativeWidgetAura::RepostNativeEvent(gfx::NativeEvent native_event) { |
| +void NativeWidgetAndroid::RepostNativeEvent(gfx::NativeEvent native_event) { |
| OnEvent(native_event); |
| } |
| //////////////////////////////////////////////////////////////////////////////// |
| -// NativeWidgetAura, aura::WindowDelegate implementation: |
| +// NativeWidgetAndroid, aura::WindowDelegate implementation: |
| -gfx::Size NativeWidgetAura::GetMinimumSize() const { |
| +gfx::Size NativeWidgetAndroid::GetMinimumSize() const { |
| return delegate_->GetMinimumSize(); |
| } |
| -gfx::Size NativeWidgetAura::GetMaximumSize() const { |
| +gfx::Size NativeWidgetAndroid::GetMaximumSize() const { |
| // If a window have a maximum size, the window should not be |
| // maximizable. |
| DCHECK(delegate_->GetMaximumSize().IsEmpty() || |
| @@ -746,8 +816,8 @@ gfx::Size NativeWidgetAura::GetMaximumSize() const { |
| return delegate_->GetMaximumSize(); |
| } |
| -void NativeWidgetAura::OnBoundsChanged(const gfx::Rect& old_bounds, |
| - const gfx::Rect& new_bounds) { |
| +void NativeWidgetAndroid::OnBoundsChanged(const gfx::Rect& old_bounds, |
| + const gfx::Rect& new_bounds) { |
| // Assume that if the old bounds was completely empty a move happened. This |
| // handles the case of a maximize animation acquiring the layer (acquiring a |
| // layer results in clearing the bounds). |
| @@ -759,17 +829,17 @@ void NativeWidgetAura::OnBoundsChanged(const gfx::Rect& old_bounds, |
| delegate_->OnNativeWidgetSizeChanged(new_bounds.size()); |
| } |
| -gfx::NativeCursor NativeWidgetAura::GetCursor(const gfx::Point& point) { |
| +gfx::NativeCursor NativeWidgetAndroid::GetCursor(const gfx::Point& point) { |
| return cursor_; |
| } |
| -int NativeWidgetAura::GetNonClientComponent(const gfx::Point& point) const { |
| +int NativeWidgetAndroid::GetNonClientComponent(const gfx::Point& point) const { |
| return delegate_->GetNonClientComponent(point); |
| } |
| -bool NativeWidgetAura::ShouldDescendIntoChildForEventHandling( |
| - aura::Window* child, |
| - const gfx::Point& location) { |
| +bool NativeWidgetAndroid::ShouldDescendIntoChildForEventHandling( |
| + aura::Window* child, |
| + const gfx::Point& location) { |
| views::WidgetDelegate* widget_delegate = GetWidget()->widget_delegate(); |
| if (widget_delegate && |
| !widget_delegate->ShouldDescendIntoChildForEventHandling(child, location)) |
| @@ -802,23 +872,24 @@ bool NativeWidgetAura::ShouldDescendIntoChildForEventHandling( |
| return true; |
| } |
| -bool NativeWidgetAura::CanFocus() { |
| +bool NativeWidgetAndroid::CanFocus() { |
| return ShouldActivate(); |
| } |
| -void NativeWidgetAura::OnCaptureLost() { |
| +void NativeWidgetAndroid::OnCaptureLost() { |
| delegate_->OnMouseCaptureLost(); |
| } |
| -void NativeWidgetAura::OnPaint(const ui::PaintContext& context) { |
| +void NativeWidgetAndroid::OnPaint(const ui::PaintContext& context) { |
| delegate_->OnNativeWidgetPaint(context); |
| } |
| -void NativeWidgetAura::OnDeviceScaleFactorChanged(float device_scale_factor) { |
| +void NativeWidgetAndroid::OnDeviceScaleFactorChanged( |
| + float device_scale_factor) { |
| GetWidget()->DeviceScaleFactorChanged(device_scale_factor); |
| } |
| -void NativeWidgetAura::OnWindowDestroying(aura::Window* window) { |
| +void NativeWidgetAndroid::OnWindowDestroying(aura::Window* window) { |
| window_->RemoveObserver(this); |
| delegate_->OnNativeWidgetDestroying(); |
| @@ -826,40 +897,40 @@ void NativeWidgetAura::OnWindowDestroying(aura::Window* window) { |
| tooltip_manager_.reset(); |
| } |
| -void NativeWidgetAura::OnWindowDestroyed(aura::Window* window) { |
| +void NativeWidgetAndroid::OnWindowDestroyed(aura::Window* window) { |
| window_ = NULL; |
| delegate_->OnNativeWidgetDestroyed(); |
| if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) |
| delete this; |
| } |
| -void NativeWidgetAura::OnWindowTargetVisibilityChanged(bool visible) { |
| +void NativeWidgetAndroid::OnWindowTargetVisibilityChanged(bool visible) { |
| delegate_->OnNativeWidgetVisibilityChanged(visible); |
| } |
| -bool NativeWidgetAura::HasHitTestMask() const { |
| +bool NativeWidgetAndroid::HasHitTestMask() const { |
| return delegate_->HasHitTestMask(); |
| } |
| -void NativeWidgetAura::GetHitTestMask(gfx::Path* mask) const { |
| +void NativeWidgetAndroid::GetHitTestMask(gfx::Path* mask) const { |
| DCHECK(mask); |
| delegate_->GetHitTestMask(mask); |
| } |
| //////////////////////////////////////////////////////////////////////////////// |
| -// NativeWidgetAura, aura::WindowObserver implementation: |
| +// NativeWidgetAndroid, aura::WindowObserver implementation: |
| -void NativeWidgetAura::OnWindowPropertyChanged(aura::Window* window, |
| - const void* key, |
| - intptr_t old) { |
| +void NativeWidgetAndroid::OnWindowPropertyChanged(aura::Window* window, |
| + const void* key, |
| + intptr_t old) { |
| if (key == aura::client::kShowStateKey) |
| delegate_->OnNativeWidgetWindowShowStateChanged(); |
| } |
| //////////////////////////////////////////////////////////////////////////////// |
| -// NativeWidgetAura, ui::EventHandler implementation: |
| +// NativeWidgetAndroid, ui::EventHandler implementation: |
| -void NativeWidgetAura::OnKeyEvent(ui::KeyEvent* event) { |
| +void NativeWidgetAndroid::OnKeyEvent(ui::KeyEvent* event) { |
| DCHECK(window_); |
| // Renderer may send a key event back to us if the key event wasn't handled, |
| // and the window may be invisible by that time. |
| @@ -873,7 +944,7 @@ void NativeWidgetAura::OnKeyEvent(ui::KeyEvent* event) { |
| event->SetHandled(); |
| } |
| -void NativeWidgetAura::OnMouseEvent(ui::MouseEvent* event) { |
| +void NativeWidgetAndroid::OnMouseEvent(ui::MouseEvent* event) { |
| DCHECK(window_); |
| DCHECK(window_->IsVisible()); |
| if (event->type() == ui::ET_MOUSEWHEEL) { |
| @@ -888,27 +959,27 @@ void NativeWidgetAura::OnMouseEvent(ui::MouseEvent* event) { |
| delegate_->OnMouseEvent(event); |
| } |
| -void NativeWidgetAura::OnScrollEvent(ui::ScrollEvent* event) { |
| +void NativeWidgetAndroid::OnScrollEvent(ui::ScrollEvent* event) { |
| delegate_->OnScrollEvent(event); |
| } |
| -void NativeWidgetAura::OnGestureEvent(ui::GestureEvent* event) { |
| +void NativeWidgetAndroid::OnGestureEvent(ui::GestureEvent* event) { |
| DCHECK(window_); |
| DCHECK(window_->IsVisible() || event->IsEndingEvent()); |
| delegate_->OnGestureEvent(event); |
| } |
| //////////////////////////////////////////////////////////////////////////////// |
| -// NativeWidgetAura, aura::client::ActivationDelegate implementation: |
| +// NativeWidgetAndroid, aura::client::ActivationDelegate implementation: |
| -bool NativeWidgetAura::ShouldActivate() const { |
| +bool NativeWidgetAndroid::ShouldActivate() const { |
| return delegate_->CanActivate(); |
| } |
| //////////////////////////////////////////////////////////////////////////////// |
| -// NativeWidgetAura, aura::client::ActivationChangeObserver implementation: |
| +// NativeWidgetAndroid, aura::client::ActivationChangeObserver implementation: |
| -void NativeWidgetAura::OnWindowActivated( |
| +void NativeWidgetAndroid::OnWindowActivated( |
| aura::client::ActivationChangeObserver::ActivationReason, |
| aura::Window* gained_active, |
| aura::Window* lost_active) { |
| @@ -923,10 +994,10 @@ void NativeWidgetAura::OnWindowActivated( |
| } |
| //////////////////////////////////////////////////////////////////////////////// |
| -// NativeWidgetAura, aura::client::FocusChangeObserver: |
| +// NativeWidgetAndroid, aura::client::FocusChangeObserver: |
| -void NativeWidgetAura::OnWindowFocused(aura::Window* gained_focus, |
| - aura::Window* lost_focus) { |
| +void NativeWidgetAndroid::OnWindowFocused(aura::Window* gained_focus, |
| + aura::Window* lost_focus) { |
| if (window_ == gained_focus) |
| delegate_->OnNativeFocus(); |
| else if (window_ == lost_focus) |
| @@ -934,36 +1005,36 @@ void NativeWidgetAura::OnWindowFocused(aura::Window* gained_focus, |
| } |
| //////////////////////////////////////////////////////////////////////////////// |
| -// NativeWidgetAura, aura::WindowDragDropDelegate implementation: |
| +// NativeWidgetAndroid, aura::WindowDragDropDelegate implementation: |
| -void NativeWidgetAura::OnDragEntered(const ui::DropTargetEvent& event) { |
| +void NativeWidgetAndroid::OnDragEntered(const ui::DropTargetEvent& event) { |
| DCHECK(drop_helper_.get() != NULL); |
| - last_drop_operation_ = drop_helper_->OnDragOver(event.data(), |
| - event.location(), event.source_operations()); |
| + last_drop_operation_ = drop_helper_->OnDragOver( |
| + event.data(), event.location(), event.source_operations()); |
| } |
| -int NativeWidgetAura::OnDragUpdated(const ui::DropTargetEvent& event) { |
| +int NativeWidgetAndroid::OnDragUpdated(const ui::DropTargetEvent& event) { |
| DCHECK(drop_helper_.get() != NULL); |
| - last_drop_operation_ = drop_helper_->OnDragOver(event.data(), |
| - event.location(), event.source_operations()); |
| + last_drop_operation_ = drop_helper_->OnDragOver( |
| + event.data(), event.location(), event.source_operations()); |
| return last_drop_operation_; |
| } |
| -void NativeWidgetAura::OnDragExited() { |
| +void NativeWidgetAndroid::OnDragExited() { |
| DCHECK(drop_helper_.get() != NULL); |
| drop_helper_->OnDragExit(); |
| } |
| -int NativeWidgetAura::OnPerformDrop(const ui::DropTargetEvent& event) { |
| +int NativeWidgetAndroid::OnPerformDrop(const ui::DropTargetEvent& event) { |
| DCHECK(drop_helper_.get() != NULL); |
| return drop_helper_->OnDrop(event.data(), event.location(), |
| - last_drop_operation_); |
| + last_drop_operation_); |
| } |
| //////////////////////////////////////////////////////////////////////////////// |
| -// NativeWidgetAura, protected: |
| +// NativeWidgetAndroid, protected: |
| -NativeWidgetAura::~NativeWidgetAura() { |
| +NativeWidgetAndroid::~NativeWidgetAndroid() { |
| destroying_ = true; |
| if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) |
| delete delegate_; |
| @@ -972,201 +1043,18 @@ NativeWidgetAura::~NativeWidgetAura() { |
| } |
| //////////////////////////////////////////////////////////////////////////////// |
| -// NativeWidgetAura, private: |
| +// NativeWidgetAndroid, private: |
| -bool NativeWidgetAura::IsDocked() const { |
| +bool NativeWidgetAndroid::IsDocked() const { |
| return window_ && |
| window_->GetProperty(aura::client::kShowStateKey) == |
| ui::SHOW_STATE_DOCKED; |
| } |
| -void NativeWidgetAura::SetInitialFocus(ui::WindowShowState show_state) { |
| +void NativeWidgetAndroid::SetInitialFocus(ui::WindowShowState show_state) { |
| // The window does not get keyboard messages unless we focus it. |
| if (!GetWidget()->SetInitialFocus(show_state)) |
| window_->Focus(); |
| } |
| -//////////////////////////////////////////////////////////////////////////////// |
| -// Widget, public: |
| - |
| -namespace { |
| -#if defined(OS_WIN) || (defined(USE_X11) && !defined(OS_CHROMEOS)) |
| -void CloseWindow(aura::Window* window) { |
| - if (window) { |
| - Widget* widget = Widget::GetWidgetForNativeView(window); |
| - if (widget && widget->is_secondary_widget()) |
| - // To avoid the delay in shutdown caused by using Close which may wait |
| - // for animations, use CloseNow. Because this is only used on secondary |
| - // widgets it seems relatively safe to skip the extra processing of |
| - // Close. |
| - widget->CloseNow(); |
| - } |
| -} |
| -#endif |
| - |
| -#if defined(OS_WIN) |
| -BOOL CALLBACK WindowCallbackProc(HWND hwnd, LPARAM lParam) { |
| - aura::Window* root_window = |
| - DesktopWindowTreeHostWin::GetContentWindowForHWND(hwnd); |
| - CloseWindow(root_window); |
| - return TRUE; |
| -} |
| -#endif |
| -} // namespace |
| - |
| -// static |
| -void Widget::CloseAllSecondaryWidgets() { |
| -#if defined(OS_WIN) |
| - EnumThreadWindows(GetCurrentThreadId(), WindowCallbackProc, 0); |
| -#endif |
| - |
| -#if defined(USE_X11) && !defined(OS_CHROMEOS) |
| - DesktopWindowTreeHostX11::CleanUpWindowList(CloseWindow); |
| -#endif |
| -} |
| - |
| -bool Widget::ConvertRect(const Widget* source, |
| - const Widget* target, |
| - gfx::Rect* rect) { |
| - return false; |
| -} |
| - |
| -namespace internal { |
| - |
| -//////////////////////////////////////////////////////////////////////////////// |
| -// internal::NativeWidgetPrivate, public: |
| - |
| -// static |
| -NativeWidgetPrivate* NativeWidgetPrivate::CreateNativeWidget( |
| - internal::NativeWidgetDelegate* delegate) { |
| - return new NativeWidgetAura(delegate); |
| -} |
| - |
| -// static |
| -NativeWidgetPrivate* NativeWidgetPrivate::GetNativeWidgetForNativeView( |
| - gfx::NativeView native_view) { |
| - // Cast must match type supplied to RegisterNativeWidgetForWindow(). |
| - return reinterpret_cast<NativeWidgetPrivate*>(native_view->user_data()); |
| -} |
| - |
| -// static |
| -NativeWidgetPrivate* NativeWidgetPrivate::GetNativeWidgetForNativeWindow( |
| - gfx::NativeWindow native_window) { |
| - // Cast must match type supplied to RegisterNativeWidgetForWindow(). |
| - return reinterpret_cast<NativeWidgetPrivate*>(native_window->user_data()); |
| -} |
| - |
| -// static |
| -NativeWidgetPrivate* NativeWidgetPrivate::GetTopLevelNativeWidget( |
| - gfx::NativeView native_view) { |
| - aura::Window* window = native_view; |
| - NativeWidgetPrivate* top_level_native_widget = NULL; |
| - while (window) { |
| - NativeWidgetPrivate* native_widget = GetNativeWidgetForNativeView(window); |
| - if (native_widget) |
| - top_level_native_widget = native_widget; |
| - window = window->parent(); |
| - } |
| - return top_level_native_widget; |
| -} |
| - |
| -// static |
| -void NativeWidgetPrivate::GetAllChildWidgets(gfx::NativeView native_view, |
| - Widget::Widgets* children) { |
| - { |
| - // Code expects widget for |native_view| to be added to |children|. |
| - NativeWidgetPrivate* native_widget = static_cast<NativeWidgetPrivate*>( |
| - GetNativeWidgetForNativeView(native_view)); |
| - if (native_widget && native_widget->GetWidget()) |
| - children->insert(native_widget->GetWidget()); |
| - } |
| - |
| - const aura::Window::Windows& child_windows = native_view->children(); |
| - for (aura::Window::Windows::const_iterator i = child_windows.begin(); |
| - i != child_windows.end(); ++i) { |
| - GetAllChildWidgets((*i), children); |
| - } |
| -} |
| - |
| -// static |
| -void NativeWidgetPrivate::GetAllOwnedWidgets(gfx::NativeView native_view, |
| - Widget::Widgets* owned) { |
| - // Add all owned widgets. |
| - for (aura::Window* transient_child : wm::GetTransientChildren(native_view)) { |
| - NativeWidgetPrivate* native_widget = static_cast<NativeWidgetPrivate*>( |
| - GetNativeWidgetForNativeView(transient_child)); |
| - if (native_widget && native_widget->GetWidget()) |
| - owned->insert(native_widget->GetWidget()); |
| - GetAllOwnedWidgets(transient_child, owned); |
| - } |
| - |
| - // Add all child windows. |
| - for (aura::Window* child : native_view->children()) |
| - GetAllChildWidgets(child, owned); |
| -} |
| - |
| -// static |
| -void NativeWidgetPrivate::ReparentNativeView(gfx::NativeView native_view, |
| - gfx::NativeView new_parent) { |
| - DCHECK(native_view != new_parent); |
| - |
| - gfx::NativeView previous_parent = native_view->parent(); |
| - if (previous_parent == new_parent) |
| - return; |
| - |
| - Widget::Widgets widgets; |
| - GetAllChildWidgets(native_view, &widgets); |
| - |
| - // First notify all the widgets that they are being disassociated |
| - // from their previous parent. |
| - for (Widget::Widgets::iterator it = widgets.begin(); |
| - it != widgets.end(); ++it) { |
| - (*it)->NotifyNativeViewHierarchyWillChange(); |
| - } |
| - |
| - if (new_parent) { |
| - new_parent->AddChild(native_view); |
| - } else { |
| - // The following looks weird, but it's the equivalent of what aura has |
| - // always done. (The previous behaviour of aura::Window::SetParent() used |
| - // NULL as a special value that meant ask the WindowTreeClient where things |
| - // should go.) |
| - // |
| - // This probably isn't strictly correct, but its an invariant that a Window |
| - // in use will be attached to a RootWindow, so we can't just call |
| - // RemoveChild here. The only possible thing that could assign a RootWindow |
| - // in this case is the stacking client of the current RootWindow. This |
| - // matches our previous behaviour; the global stacking client would almost |
| - // always reattach the window to the same RootWindow. |
| - aura::Window* root_window = native_view->GetRootWindow(); |
| - aura::client::ParentWindowWithContext( |
| - native_view, root_window, root_window->GetBoundsInScreen()); |
| - } |
| - |
| - // And now, notify them that they have a brand new parent. |
| - for (Widget::Widgets::iterator it = widgets.begin(); |
| - it != widgets.end(); ++it) { |
| - (*it)->NotifyNativeViewHierarchyChanged(); |
| - } |
| -} |
| - |
| -// static |
| -bool NativeWidgetPrivate::IsMouseButtonDown() { |
| - return aura::Env::GetInstance()->IsMouseButtonDown(); |
| -} |
| - |
| -// static |
| -gfx::FontList NativeWidgetPrivate::GetWindowTitleFontList() { |
| -#if defined(OS_WIN) |
| - NONCLIENTMETRICS_XP ncm; |
| - base::win::GetNonClientMetrics(&ncm); |
| - l10n_util::AdjustUIFont(&(ncm.lfCaptionFont)); |
| - base::win::ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont))); |
| - return gfx::FontList(gfx::Font(caption_font)); |
| -#else |
| - return gfx::FontList(); |
| -#endif |
| -} |
| - |
| -} // namespace internal |
| } // namespace views |