Skip to content

Commit

Permalink
views: Remove Widget::CreateWindow methods that don't have parent/con…
Browse files Browse the repository at this point in the history
…text.

These methods are rarely used and are deprecated. In the few cases that a
parent/context is not available callers can either pass nullptr or initialize
the widget manually.

BUG=none
TEST=compiles, ash_unittests

Review URL: https://codereview.chromium.org/1840543002

Cr-Commit-Position: refs/heads/master@{#383503}
  • Loading branch information
jamescook authored and Commit bot committed Mar 28, 2016
1 parent a5697c2 commit 5967e2a
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 44 deletions.
6 changes: 3 additions & 3 deletions ash/popup_message_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

namespace ash {

typedef test::AshTestBase PopupMessageTest;
using PopupMessageTest = test::AshTestBase;

// Verifies the layout of the popup, especially it does not crop the caption and
// message text. See http://crbug.com/468494.
TEST_F(PopupMessageTest, Layout) {
views::Widget* widget =
views::Widget::CreateWindowWithBounds(nullptr, gfx::Rect(0, 0, 100, 100));
views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds(
nullptr, CurrentContext(), gfx::Rect(0, 0, 100, 100));
PopupMessage message(base::ASCIIToUTF16("caption text"),
base::ASCIIToUTF16(
"Message text, which will be usually longer than "
Expand Down
10 changes: 3 additions & 7 deletions chrome/browser/ui/views/chrome_web_dialog_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,11 @@ namespace chrome {
gfx::NativeWindow ShowWebDialog(gfx::NativeView parent,
content::BrowserContext* context,
ui::WebDialogDelegate* delegate) {
views::Widget* widget = NULL;
views::WebDialogView* view =
new views::WebDialogView(context, delegate, new ChromeWebContentsHandler);
if (parent) {
widget = views::Widget::CreateWindowWithParent(view, parent);
} else {
// We shouldn't be called with a NULL parent, but sometimes are.
widget = views::Widget::CreateWindow(view);
}
// NOTE: The |parent| may be null, which will result in the default window
// placement on Aura.
views::Widget* widget = views::Widget::CreateWindowWithParent(view, parent);

// Observer is needed for ChromeVox extension to send messages between content
// and background scripts.
Expand Down
4 changes: 2 additions & 2 deletions mash/quick_launch/quick_launch_application.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ void QuickLaunchApplication::Initialize(mojo::Connector* connector,
aura_init_.reset(new views::AuraInit(connector, "views_mus_resources.pak"));
views::WindowManagerConnection::Create(connector);

views::Widget* window = views::Widget::CreateWindowWithBounds(
new QuickLaunchUI(connector), gfx::Rect(10, 640, 0, 0));
views::Widget* window = views::Widget::CreateWindowWithContextAndBounds(
new QuickLaunchUI(connector), nullptr, gfx::Rect(10, 640, 0, 0));
window->Show();
}

Expand Down
4 changes: 2 additions & 2 deletions mash/task_viewer/task_viewer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ void TaskViewer::Initialize(mojo::Connector* connector,

TaskViewerContents* task_viewer = new TaskViewerContents(
std::move(request), std::move(catalog));
views::Widget* window = views::Widget::CreateWindowWithBounds(
task_viewer, gfx::Rect(10, 10, 500, 500));
views::Widget* window = views::Widget::CreateWindowWithContextAndBounds(
task_viewer, nullptr, gfx::Rect(10, 10, 500, 500));
window->Show();
}

Expand Down
16 changes: 0 additions & 16 deletions ui/views/widget/widget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -180,22 +180,6 @@ Widget::~Widget() {
}
}

// static
Widget* Widget::CreateWindow(WidgetDelegate* delegate) {
return CreateWindowWithBounds(delegate, gfx::Rect());
}

// static
Widget* Widget::CreateWindowWithBounds(WidgetDelegate* delegate,
const gfx::Rect& bounds) {
Widget* widget = new Widget;
Widget::InitParams params;
params.bounds = bounds;
params.delegate = delegate;
widget->Init(params);
return widget;
}

// static
Widget* Widget::CreateWindowWithParent(WidgetDelegate* delegate,
gfx::NativeView parent) {
Expand Down
14 changes: 0 additions & 14 deletions ui/views/widget/widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,20 +282,6 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate,
Widget();
~Widget() override;

// Creates a toplevel window with no context. These methods should only be
// used in cases where there is no contextual information because we're
// creating a toplevel window connected to no other event.
//
// If you have any parenting or context information, or can pass that
// information, prefer the WithParent or WithContext versions of these
// methods.
//
// The returned Widget is owned by its NativeWidget; see Widget class comment
// for details.
static Widget* CreateWindow(WidgetDelegate* delegate);
static Widget* CreateWindowWithBounds(WidgetDelegate* delegate,
const gfx::Rect& bounds);

// Creates a decorated window Widget with the specified properties. The
// returned Widget is owned by its NativeWidget; see Widget class comment for
// details.
Expand Down

0 comments on commit 5967e2a

Please sign in to comment.