Commit 0c2dc016 authored by ben@chromium.org's avatar ben@chromium.org

Move WindowModalityController to CoreWm.

I left the unittest in ash still for the time being as it requires a bunch of stuff from ash too (mostly the activation logic which is still in progress for Corewm).

http://crbug.com/162100
R=rouslan@chromium.org
Review URL: https://codereview.chromium.org/11316287

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170679 0039d316-1c4b-4281-b951-d872f2087c98
parent df2d1010
......@@ -373,8 +373,6 @@
'wm/window_cycle_controller.h',
'wm/window_cycle_list.cc',
'wm/window_cycle_list.h',
'wm/window_modality_controller.cc',
'wm/window_modality_controller.h',
'wm/window_properties.cc',
'wm/window_properties.h',
'wm/window_resizer.cc',
......@@ -459,10 +457,6 @@
'sources': [
'test/ash_test_base.cc',
'test/ash_test_base.h',
'test/capture_tracking_view.cc',
'test/capture_tracking_view.h',
'test/child_modal_window.cc',
'test/child_modal_window.h',
'test/cursor_manager_test_api.cc',
'test/cursor_manager_test_api.h',
'test/launcher_view_test_api.cc',
......@@ -506,6 +500,7 @@
'../ui/ui.gyp:ui_resources',
'../ui/ui.gyp:ui_test_support',
'../ui/views/views.gyp:views',
'../ui/views/views.gyp:views_test_support',
'../ui/views/views.gyp:views_examples_with_content_lib',
'../ui/views/views.gyp:views_with_content_test_support',
'ash',
......@@ -642,7 +637,6 @@
'../ui/views/views.gyp:views_test_support',
'ash',
'ash_resources',
'test_support_ash',
],
'sources': [
'shell/app_list.cc',
......
......@@ -60,7 +60,6 @@
#include "ash/wm/video_detector.h"
#include "ash/wm/window_animations.h"
#include "ash/wm/window_cycle_controller.h"
#include "ash/wm/window_modality_controller.h"
#include "ash/wm/window_properties.h"
#include "ash/wm/window_util.h"
#include "ash/wm/workspace_controller.h"
......@@ -87,6 +86,7 @@
#include "ui/views/corewm/input_method_event_filter.h"
#include "ui/views/corewm/shadow_controller.h"
#include "ui/views/corewm/visibility_controller.h"
#include "ui/views/corewm/window_modality_controller.h"
#include "ui/views/focus/focus_manager_factory.h"
#include "ui/views/widget/native_widget_aura.h"
#include "ui/views/widget/widget.h"
......@@ -508,7 +508,8 @@ void Shell::Init() {
visibility_controller_.reset(new AshVisibilityController);
drag_drop_controller_.reset(new internal::DragDropController);
user_action_client_.reset(delegate_->CreateUserActionClient());
window_modality_controller_.reset(new internal::WindowModalityController);
window_modality_controller_.reset(
new views::corewm::WindowModalityController);
AddPreTargetHandler(window_modality_controller_.get());
magnification_controller_.reset(
......
......@@ -58,6 +58,7 @@ class CompoundEventFilter;
class InputMethodEventFilter;
class ShadowController;
class VisibilityController;
class WindowModalityController;
}
}
......@@ -110,7 +111,6 @@ class SystemGestureEventFilter;
class SystemModalContainerEventFilter;
class TooltipController;
class TouchObserverHUD;
class WindowModalityController;
class WorkspaceController;
}
......@@ -488,11 +488,12 @@ class ASH_EXPORT Shell : internal::SystemModalContainerEventFilterDelegate,
scoped_ptr<aura::client::StackingClient> stacking_client_;
scoped_ptr<internal::ActivationController> activation_controller_;
scoped_ptr<internal::CaptureController> capture_controller_;
scoped_ptr<internal::WindowModalityController> window_modality_controller_;
scoped_ptr<internal::DragDropController> drag_drop_controller_;
scoped_ptr<internal::ResizeShadowController> resize_shadow_controller_;
scoped_ptr<views::corewm::ShadowController> shadow_controller_;
scoped_ptr<views::corewm::VisibilityController> visibility_controller_;
scoped_ptr<views::corewm::WindowModalityController>
window_modality_controller_;
scoped_ptr<internal::TooltipController> tooltip_controller_;
scoped_ptr<DesktopBackgroundController> desktop_background_controller_;
scoped_ptr<PowerButtonController> power_button_controller_;
......
......@@ -14,7 +14,6 @@
#include "ash/shell_window_ids.h"
#include "ash/system/status_area_widget.h"
#include "ash/system/web_notification/web_notification_tray.h"
#include "ash/test/child_modal_window.h"
#include "base/bind.h"
#include "base/time.h"
#include "base/utf_string_conversions.h"
......@@ -29,6 +28,7 @@
#include "ui/views/corewm/shadow_types.h"
#include "ui/views/examples/examples_window_with_content.h"
#include "ui/views/layout/grid_layout.h"
#include "ui/views/test/child_modal_window.h"
#include "ui/views/widget/widget.h"
using views::MenuItemView;
......@@ -322,7 +322,7 @@ void WindowTypeLauncher::ButtonPressed(views::Button* sender,
ModalWindow::OpenModalWindow(GetWidget()->GetNativeView(),
ui::MODAL_TYPE_WINDOW);
} else if (sender == child_modal_button_) {
ash::test::CreateChildModalParent();
views::test::CreateChildModalParent();
} else if (sender == transient_button_) {
NonModalTransient::OpenNonModalTransient(GetWidget()->GetNativeView());
} else if (sender == show_hide_window_button_) {
......
......@@ -9,7 +9,6 @@
#include "ash/shell_window_ids.h"
#include "ash/wm/activation_controller_delegate.h"
#include "ash/wm/property_util.h"
#include "ash/wm/window_modality_controller.h"
#include "ash/wm/window_util.h"
#include "ash/wm/workspace_controller.h"
#include "base/auto_reset.h"
......@@ -23,6 +22,7 @@
#include "ui/aura/window_delegate.h"
#include "ui/base/ui_base_types.h"
#include "ui/compositor/layer.h"
#include "ui/views/corewm/window_modality_controller.h"
namespace ash {
namespace internal {
......
......@@ -8,9 +8,9 @@
#include "ash/shell.h"
#include "ash/wm/activation_controller.h"
#include "ash/wm/property_util.h"
#include "ash/wm/window_modality_controller.h"
#include "ash/wm/window_util.h"
#include "ash/wm/workspace_controller.h"
#include "ui/views/corewm/window_modality_controller.h"
namespace ash {
namespace internal {
......@@ -29,7 +29,8 @@ AshActivationController::~AshActivationController() {
aura::Window* AshActivationController::WillActivateWindow(
aura::Window* window) {
aura::Window* window_modal_transient = GetModalTransient(window);
aura::Window* window_modal_transient =
views::corewm::GetModalTransient(window);
if (window_modal_transient)
return window_modal_transient;
......@@ -69,7 +70,8 @@ aura::Window* AshActivationController::WillActivateWindow(
aura::Window* AshActivationController::WillFocusWindow(
aura::Window* window) {
aura::Window* window_modal_transient = GetModalTransient(window);
aura::Window* window_modal_transient =
views::corewm::GetModalTransient(window);
if (window_modal_transient)
return window_modal_transient;
return window;
......
......@@ -9,7 +9,6 @@
#include "ash/shell_delegate.h"
#include "ash/shell_window_ids.h"
#include "ash/test/ash_test_base.h"
#include "ash/test/capture_tracking_view.h"
#include "ash/wm/window_util.h"
#include "base/compiler_specific.h"
#include "ui/aura/root_window.h"
......@@ -17,6 +16,7 @@
#include "ui/aura/window.h"
#include "ui/compositor/layer.h"
#include "ui/gfx/screen.h"
#include "ui/views/test/capture_tracking_view.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"
......@@ -333,7 +333,7 @@ TEST_F(SystemModalContainerLayoutManagerTest, ChangeCapture) {
views::Widget* widget =
views::Widget::CreateWindowWithParent(new TestWindow(false), NULL);
scoped_ptr<aura::Window> widget_window(widget->GetNativeView());
CaptureTrackingView* view = new CaptureTrackingView;
views::test::CaptureTrackingView* view = new views::test::CaptureTrackingView;
widget->GetContentsView()->AddChildView(view);
view->SetBoundsRect(widget->GetContentsView()->bounds());
widget->Show();
......
......@@ -2,12 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/wm/window_modality_controller.h"
#include "ui/views/corewm/window_modality_controller.h"
#include "ash/shell.h"
#include "ash/test/ash_test_base.h"
#include "ash/test/capture_tracking_view.h"
#include "ash/test/child_modal_window.h"
#include "ash/wm/window_util.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/test/event_generator.h"
......@@ -15,6 +13,8 @@
#include "ui/aura/test/test_windows.h"
#include "ui/aura/window.h"
#include "ui/base/ui_base_types.h"
#include "ui/views/test/capture_tracking_view.h"
#include "ui/views/test/child_modal_window.h"
#include "ui/views/widget/widget.h"
namespace ash {
......@@ -219,7 +219,7 @@ TEST_F(WindowModalityControllerTest, GetModalTransient) {
w2->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW);
aura::Window* wt;
wt = GetModalTransient(w1.get());
wt = views::corewm::GetModalTransient(w1.get());
ASSERT_EQ(static_cast<aura::Window*>(NULL), wt);
// Parent w2 to w1. It should get parented to the parent of w1.
......@@ -228,12 +228,12 @@ TEST_F(WindowModalityControllerTest, GetModalTransient) {
EXPECT_EQ(-2, w1->parent()->children().at(1)->id());
// Request the modal transient window for w1, it should be w2.
wt = GetModalTransient(w1.get());
wt = views::corewm::GetModalTransient(w1.get());
ASSERT_NE(static_cast<aura::Window*>(NULL), wt);
EXPECT_EQ(-2, wt->id());
// Request the modal transient window for w11, it should also be w2.
wt = GetModalTransient(w11.get());
wt = views::corewm::GetModalTransient(w11.get());
ASSERT_NE(static_cast<aura::Window*>(NULL), wt);
EXPECT_EQ(-2, wt->id());
}
......@@ -242,7 +242,7 @@ TEST_F(WindowModalityControllerTest, GetModalTransient) {
TEST_F(WindowModalityControllerTest, ChangeCapture) {
views::Widget* widget = views::Widget::CreateWindow(NULL);
scoped_ptr<aura::Window> widget_window(widget->GetNativeView());
test::CaptureTrackingView* view = new test::CaptureTrackingView;
views::test::CaptureTrackingView* view = new views::test::CaptureTrackingView;
widget->client_view()->AddChildView(view);
widget->SetBounds(gfx::Rect(0, 0, 200, 200));
view->SetBoundsRect(widget->client_view()->GetLocalBounds());
......@@ -258,7 +258,8 @@ TEST_F(WindowModalityControllerTest, ChangeCapture) {
views::Widget::CreateWindowWithParent(NULL, widget->GetNativeView());
scoped_ptr<aura::Window> modal_window(modal_widget->GetNativeView());
modal_window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW);
test::CaptureTrackingView* modal_view = new test::CaptureTrackingView;
views::test::CaptureTrackingView* modal_view =
new views::test::CaptureTrackingView;
modal_widget->client_view()->AddChildView(modal_view);
modal_widget->SetBounds(gfx::Rect(50, 50, 200, 200));
modal_view->SetBoundsRect(modal_widget->client_view()->GetLocalBounds());
......@@ -359,7 +360,7 @@ TEST_F(WindowModalityControllerTest, TouchEvent) {
// |child| window.
// - Focus should follow the active window.
TEST_F(WindowModalityControllerTest, ChildModal) {
test::ChildModalParent* delegate = new test::ChildModalParent;
views::test::ChildModalParent* delegate = new views::test::ChildModalParent;
views::Widget* widget = views::Widget::CreateWindowWithBounds(
delegate, gfx::Rect(0, 0, 400, 400));
widget->Show();
......@@ -418,7 +419,7 @@ TEST_F(WindowModalityControllerTest, ChildModal) {
// Same as |ChildModal| test, but using |EventGenerator| rather than bypassing
// it by calling |ActivateWindow|.
TEST_F(WindowModalityControllerTest, ChildModalEventGenerator) {
test::ChildModalParent* delegate = new test::ChildModalParent;
views::test::ChildModalParent* delegate = new views::test::ChildModalParent;
views::Widget* widget = views::Widget::CreateWindowWithBounds(
delegate, gfx::Rect(0, 0, 400, 400));
widget->Show();
......@@ -532,7 +533,7 @@ TEST_F(WindowModalityControllerTest, ChildModalAncestor) {
scoped_ptr<aura::Window> w4(
CreateTestWindowInShellWithDelegate(&d, -2, gfx::Rect()));
w4->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_CHILD);
SetModalParent(w4.get(), w2.get());
views::corewm::SetModalParent(w4.get(), w2.get());
w1->AddTransientChild(w4.get());
wm::ActivateWindow(w1.get());
......
......@@ -57,8 +57,10 @@
#endif
#if defined(USE_AURA)
#include "ui/aura/window.h"
#include "ui/views/corewm/visibility_controller.h"
#include "ui/views/corewm/window_animations.h"
#include "ui/views/corewm/window_modality_controller.h"
#endif
#if defined(USE_ASH)
......@@ -66,8 +68,6 @@
#include "ash/ash_switches.h"
#include "ash/shell.h"
#include "ash/wm/custom_frame_view_ash.h"
#include "ash/wm/window_modality_controller.h"
#include "ui/aura/window.h"
#endif
using base::TimeDelta;
......@@ -632,8 +632,8 @@ ConstrainedWindowViews::ConstrainedWindowViews(
constrained_window_tab_helper->AddConstrainedDialog(this);
#if defined(USE_ASH)
GetNativeWindow()->SetProperty(ash::kConstrainedWindowKey, true);
ash::SetModalParent(GetNativeWindow(),
web_contents_->GetView()->GetNativeView());
views::corewm::SetModalParent(GetNativeWindow(),
web_contents_->GetView()->GetNativeView());
#endif
}
......
......@@ -45,6 +45,7 @@ void TestActivationClient::ActivateWindow(Window* window) {
RemoveActiveWindow(window);
active_windows_.push_back(window);
window->parent()->StackChildAtTop(window);
window->AddObserver(this);
FOR_EACH_OBSERVER(client::ActivationChangeObserver,
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/wm/window_modality_controller.h"
#include "ui/views/corewm/window_modality_controller.h"
#include <algorithm>
......@@ -17,7 +17,8 @@
#include "ui/views/corewm/window_animations.h"
#include "ui/views/corewm/window_util.h"
namespace ash {
namespace views {
namespace corewm {
// Transient child's modal parent.
extern const aura::WindowProperty<aura::Window*>* const kModalParentKey;
......@@ -80,15 +81,13 @@ aura::Window* GetModalTransient(aura::Window* window) {
// We always want to check the for the transient child of the activatable
// window.
aura::Window* activatable = views::corewm::GetActivatableWindow(window);
aura::Window* activatable = GetActivatableWindow(window);
if (!activatable)
return NULL;
return GetModalTransientChild(activatable, window);
}
namespace internal {
////////////////////////////////////////////////////////////////////////////////
// WindowModalityController, public:
......@@ -150,11 +149,10 @@ bool WindowModalityController::ProcessLocatedEvent(aura::Window* target,
aura::Window* modal_transient_child = GetModalTransient(target);
if (modal_transient_child && (event->type() == ui::ET_MOUSE_PRESSED ||
event->type() == ui::ET_TOUCH_PRESSED)) {
views::corewm::AnimateWindow(modal_transient_child,
views::corewm::WINDOW_ANIMATION_TYPE_BOUNCE);
AnimateWindow(modal_transient_child, WINDOW_ANIMATION_TYPE_BOUNCE);
}
return !!modal_transient_child;
}
} // namespace internal
} // namespace ash
} // namespace corewm
} // namespace views
......@@ -2,38 +2,37 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_WM_WINDOW_MODALITY_CONTROLLER_H_
#define ASH_WM_WINDOW_MODALITY_CONTROLLER_H_
#ifndef UI_VIEWS_COREWM_WINDOW_MODALITY_CONTROLLER_H_
#define UI_VIEWS_COREWM_WINDOW_MODALITY_CONTROLLER_H_
#include <vector>
#include "ash/ash_export.h"
#include "base/compiler_specific.h"
#include "ui/aura/env_observer.h"
#include "ui/aura/window_observer.h"
#include "ui/base/events/event_handler.h"
#include "ui/views/views_export.h"
namespace ui {
class LocatedEvent;
}
namespace ash {
namespace views {
namespace corewm {
// Sets the modal parent for the child.
ASH_EXPORT void SetModalParent(aura::Window* child, aura::Window* parent);
VIEWS_EXPORT void SetModalParent(aura::Window* child, aura::Window* parent);
// Returns the modal transient child of |window|, or NULL if |window| does not
// have any modal transient children.
ASH_EXPORT aura::Window* GetModalTransient(aura::Window* window);
namespace internal {
VIEWS_EXPORT aura::Window* GetModalTransient(aura::Window* window);
// WindowModalityController is an event filter that consumes events sent to
// windows that are the transient parents of window-modal windows. This filter
// must be added to the CompoundEventFilter so that activation works properly.
class WindowModalityController : public ui::EventHandler,
public aura::EnvObserver,
public aura::WindowObserver {
class VIEWS_EXPORT WindowModalityController : public ui::EventHandler,
public aura::EnvObserver,
public aura::WindowObserver {
public:
WindowModalityController();
virtual ~WindowModalityController();
......@@ -62,7 +61,7 @@ class WindowModalityController : public ui::EventHandler,
DISALLOW_COPY_AND_ASSIGN(WindowModalityController);
};
} // namespace internal
} // namespace ash
} // namespace corewm
} // namespace views
#endif // ASH_WM_WINDOW_MODALITY_CONTROLLER_H_
#endif // UI_VIEWS_COREWM_WINDOW_MODALITY_CONTROLLER_H_
......@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/test/capture_tracking_view.h"
#include "ui/views/test/capture_tracking_view.h"
namespace ash {
namespace views {
namespace test {
CaptureTrackingView::CaptureTrackingView()
......@@ -25,4 +25,4 @@ void CaptureTrackingView::OnMouseCaptureLost() {
}
} // namespace test
} // namespace ash
} // namespace views
......@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_TEST_CAPTURE_TRACKING_VIEW_
#define ASH_TEST_CAPTURE_TRACKING_VIEW_
#ifndef UI_VIEWS_TEST_CAPTURE_TRACKING_VIEW_
#define UI_VIEWS_TEST_CAPTURE_TRACKING_VIEW_
#include "base/compiler_specific.h"
#include "ui/views/view.h"
namespace ash {
namespace views {
namespace test {
// Used to track OnMousePressed() and OnMouseCaptureLost().
......@@ -38,6 +38,6 @@ class CaptureTrackingView : public views::View {
};
} // namespace test
} // namespace ash
} // namespace views
#endif // ASH_TEST_CAPTURE_TRACKING_VIEW_
#endif // UI_VIEWS_TEST_CAPTURE_TRACKING_VIEW_
......@@ -2,9 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/test/child_modal_window.h"
#include "ui/views/test/child_modal_window.h"
#include "ash/wm/window_modality_controller.h"
#include "base/utf_string_conversions.h" // ASCIIToUTF16
#include "ui/aura/window.h"
#include "ui/gfx/canvas.h"
......@@ -12,10 +11,11 @@
#include "ui/views/controls/button/text_button.h"
#include "ui/views/controls/native/native_view_host.h"
#include "ui/views/controls/textfield/textfield.h"
#include "ui/views/corewm/window_modality_controller.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"
namespace ash {
namespace views {
namespace test {
namespace {
......@@ -46,24 +46,24 @@ const SkColor kChildColor = SK_ColorWHITE;
} // namespace
void CreateChildModalParent() {
views::Widget::CreateWindowWithBounds(
Widget::CreateWindowWithBounds(
new ChildModalParent,
gfx::Rect(kWindowLeft, kWindowTop, kWindowWidth, kWindowHeight))->Show();
}
class ChildModalWindow : public views::WidgetDelegateView {
class ChildModalWindow : public WidgetDelegateView {
public:
ChildModalWindow();
virtual ~ChildModalWindow();
private:
// Overridden from views::View:
// Overridden from View:
virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
virtual gfx::Size GetPreferredSize() OVERRIDE;
// Overridden from views::WidgetDelegate:
virtual views::View* GetContentsView() OVERRIDE;
// Overridden from WidgetDelegate:
virtual View* GetContentsView() OVERRIDE;
virtual string16 GetWindowTitle() const OVERRIDE;
virtual bool CanResize() const OVERRIDE;
virtual ui::ModalType GetModalType() const OVERRIDE;
......@@ -72,7 +72,7 @@ class ChildModalWindow : public views::WidgetDelegateView {
};
ChildModalWindow::ChildModalWindow() {
views::Textfield* textfield = new views::Textfield;
Textfield* textfield = new Textfield;
AddChildView(textfield);
textfield->SetBounds(
kChildTextfieldLeft, kChildTextfieldTop,
......@@ -90,7 +90,7 @@ gfx::Size ChildModalWindow::GetPreferredSize() {
return gfx::Size(kChildWindowWidth, kChildWindowHeight);
}
views::View* ChildModalWindow::GetContentsView() {
View* ChildModalWindow::GetContentsView() {
return this;
}
......@@ -107,17 +107,16 @@ ui::ModalType ChildModalWindow::GetModalType() const {
}
ChildModalParent::ChildModalParent()
: ALLOW_THIS_IN_INITIALIZER_LIST(button_(new views::NativeTextButton(
: ALLOW_THIS_IN_INITIALIZER_LIST(button_(new NativeTextButton(
this, ASCIIToUTF16("Show/Hide Child Modal Window")))),
textfield_(new views::Textfield),
host_(new views::NativeViewHost),
textfield_(new Textfield),
host_(new NativeViewHost),
modal_parent_(NULL),
child_(NULL) {
views::Widget* widget = new views::Widget;
widget->Init(
views::Widget::InitParams(views::Widget::InitParams::TYPE_CONTROL));
Widget* widget = new Widget;
widget->Init(Widget::InitParams(Widget::InitParams::TYPE_CONTROL));
widget->GetRootView()->set_background(
views::Background::CreateSolidBackground(kModalParentColor));
Background::CreateSolidBackground(kModalParentColor));
modal_parent_ = widget->GetNativeView();
widget->GetNativeView()->SetName("ModalParent");
AddChildView(button_);
......@@ -144,16 +143,16 @@ gfx::NativeWindow ChildModalParent::GetChild() const {
return NULL;
}
views::Widget* ChildModalParent::CreateChild() {
views::Widget* child = views::Widget::CreateWindowWithParent(
Widget* ChildModalParent::CreateChild() {
Widget* child = Widget::CreateWindowWithParent(
new ChildModalWindow, GetWidget()->GetNativeView());
ash::SetModalParent(child->GetNativeView(), GetModalParent());
corewm::SetModalParent(child->GetNativeView(), GetModalParent());
child->AddObserver(this);
child->GetNativeView()->SetName("ChildModalWindow");
return child;
}
views::View* ChildModalParent::GetContentsView() {
View* ChildModalParent::GetContentsView() {
return this;
}
......@@ -183,15 +182,15 @@ void ChildModalParent::Layout() {
}
void ChildModalParent::ViewHierarchyChanged(bool is_add,
views::View* parent,
views::View* child) {
View* parent,
View* child) {
if (is_add && child == this) {
host_->Attach(modal_parent_);
GetWidget()->GetNativeView()->SetName("Parent");
}
}
void ChildModalParent::ButtonPressed(views::Button* sender,
void ChildModalParent::ButtonPressed(Button* sender,
const ui::Event& event) {
if (sender == button_) {
if (!child_)
......@@ -203,7 +202,7 @@ void ChildModalParent::ButtonPressed(views::Button* sender,
}
}
void ChildModalParent::OnWidgetClosing(views::Widget* widget) {
void ChildModalParent::OnWidgetClosing(Widget* widget) {
if (child_) {
DCHECK_EQ(child_, widget);
child_ = NULL;
......@@ -211,4 +210,4 @@ void ChildModalParent::OnWidgetClosing(views::Widget* widget) {
}
} // namespace test
} // namespace ash
} // namespace views
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_TEST_CHILD_WMODAL_WINDOW_H_
#define ASH_TEST_CHILD_WMODAL_WINDOW_H_
#ifndef UI_VIEWS_TEST_CHILD_WMODAL_WINDOW_H_
#define UI_VIEWS_TEST_CHILD_WMODAL_WINDOW_H_
#include "ui/views/controls/button/button.h"
#include "ui/views/widget/widget_delegate.h"
......@@ -15,16 +15,13 @@ class NativeViewHost;
class Textfield;
class View;
class Widget;
}
namespace ash {
namespace test {
void CreateChildModalParent();
class ChildModalParent : public views::WidgetDelegateView,
public views::ButtonListener,
public views::WidgetObserver {
class ChildModalParent : public WidgetDelegateView,
public ButtonListener,
public WidgetObserver {
public:
ChildModalParent();
virtual ~ChildModalParent();
......@@ -34,46 +31,46 @@ class ChildModalParent : public views::WidgetDelegateView,
gfx::NativeWindow GetChild() const;
private:
views::Widget* CreateChild();
Widget* CreateChild();
// Overridden from views::WidgetDelegate:
virtual views::View* GetContentsView() OVERRIDE;
// Overridden from WidgetDelegate:
virtual View* GetContentsView() OVERRIDE;
virtual string16 GetWindowTitle() const OVERRIDE;
virtual bool CanResize() const OVERRIDE;
virtual void DeleteDelegate() OVERRIDE;
virtual void Layout() OVERRIDE;
virtual void ViewHierarchyChanged(bool is_add,
views::View* parent,
views::View* child) OVERRIDE;
View* parent,
View* child) OVERRIDE;
// Overridden from views::ButtonListener:
virtual void ButtonPressed(views::Button* sender,
// Overridden from ButtonListener:
virtual void ButtonPressed(Button* sender,
const ui::Event& event) OVERRIDE;
// Overridden from views::WidgetObserver:
virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE;
// Overridden from WidgetObserver:
virtual void OnWidgetClosing(Widget* widget) OVERRIDE;
// The button to toggle showing and hiding the child window. The child window
// does not block input to this button.
views::NativeTextButton* button_;
NativeTextButton* button_;
// The text field to indicate the keyboard focus.
views::Textfield* textfield_;
Textfield* textfield_;
// The host for the modal parent.
views::NativeViewHost* host_;
NativeViewHost* host_;
// The modal parent of the child window. The child window blocks input to this
// view.
gfx::NativeWindow modal_parent_;
// The child window.
views::Widget* child_;
Widget* child_;
DISALLOW_COPY_AND_ASSIGN(ChildModalParent);
};
} // namespace test
} // namespace ash
} // namespace views
#endif // ASH_TEST_CHILD_WMODAL_WINDOW_H_
#endif // UI_VIEWS_TEST_CHILD_WMODAL_WINDOW_H_
......@@ -265,6 +265,8 @@
'corewm/visibility_controller.h',
'corewm/window_animations.cc',
'corewm/window_animations.h',
'corewm/window_modality_controller.cc',
'corewm/window_modality_controller.h',
'corewm/window_util.cc',
'corewm/window_util.h',
'debug_utils.cc',
......@@ -571,6 +573,10 @@
'..',
],
'sources': [
'test/capture_tracking_view.cc',
'test/capture_tracking_view.h',
'test/child_modal_window.cc',
'test/child_modal_window.h',
'test/desktop_test_views_delegate.cc',
'test/desktop_test_views_delegate.h',
'test/test_views_delegate.cc',
......@@ -578,6 +584,19 @@
'test/views_test_base.cc',
'test/views_test_base.h',
],
'conditions': [
['use_aura==1', {
'dependencies': [
'../aura/aura.gyp:test_support_aura',
'../compositor/compositor.gyp:compositor',
],
}, { # use_aura==0
'sources!': [
'test/child_modal_window.cc',
'test/child_modal_window.h',
],
}],
],
}, # target_name: views_test_support
{
'target_name': 'views_with_content_test_support',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment