Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(244)

Unified Diff: views/window/window.cc

Issue 7015051: Re-land: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « views/window/window.h ('k') | views/window/window_gtk.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/window/window.cc
===================================================================
--- views/window/window.cc (revision 85284)
+++ views/window/window.cc (working copy)
@@ -47,7 +47,7 @@
Window* Window::CreateChromeWindow(gfx::NativeWindow parent,
const gfx::Rect& bounds,
WindowDelegate* window_delegate) {
- Window* window = NativeWindow::CreateNativeWindow();
+ Window* window = new Window;
Window::InitParams params(window_delegate);
params.parent_window = parent;
params.widget_init_params.bounds = bounds;
@@ -74,34 +74,24 @@
GetLocalizedContentsHeight(row_resource_id));
}
-// static
-void Window::CloseSecondaryWidget(Widget* widget) {
- if (!widget)
- return;
-
- // Close widget if it's identified as a secondary window.
- Window* window = widget->GetWindow();
- if (window) {
- if (!window->IsAppWindow())
- window->CloseWindow();
- } else {
- // If it's not a Window, then close it anyway since it probably is
- // secondary.
- widget->Close();
- }
-}
-
void Window::InitWindow(const InitParams& params) {
window_delegate_ = params.window_delegate;
AsWidget()->set_widget_delegate(window_delegate_);
DCHECK(window_delegate_);
DCHECK(!window_delegate_->window_);
window_delegate_->window_ = this;
+ set_widget_delegate(window_delegate_);
+ native_window_ =
+ params.native_window ? params.native_window
+ : NativeWindow::CreateNativeWindow(this);
// If frame_view was set already, don't replace it with default one.
if (!non_client_view()->frame_view())
non_client_view()->SetFrameView(CreateFrameViewForWindow());
- AsWidget()->Init(params.widget_init_params);
- OnNativeWindowCreated(params.widget_init_params.bounds);
+ InitParams modified_params = params;
+ modified_params.widget_init_params.native_widget =
+ native_window_->AsNativeWidget();
+ Init(modified_params.widget_init_params);
+ OnNativeWindowCreated(modified_params.widget_init_params.bounds);
}
gfx::Rect Window::GetBounds() const {
@@ -149,7 +139,7 @@
native_window_->Deactivate();
}
-void Window::CloseWindow() {
+void Window::Close() {
if (window_closed_) {
// It appears we can hit this code path if you close a modal dialog then
// close the last browser before the destructor is hit, which triggers
@@ -159,9 +149,7 @@
if (non_client_view_->CanClose()) {
SaveWindowPosition();
- // TODO(beng): This can be simplified to Widget::Close() once Window
- // subclasses Widget.
- native_window_->AsNativeWidget()->GetWidget()->Close();
+ Widget::Close();
window_closed_ = true;
}
}
@@ -206,10 +194,6 @@
native_window_->SetUseDragFrame(use_drag_frame);
}
-bool Window::IsAppWindow() const {
- return native_window_->IsAppWindow();
-}
-
void Window::EnableClose(bool enable) {
non_client_view_->EnableClose(enable);
native_window_->EnableClose(enable);
@@ -261,22 +245,7 @@
native_window_->FrameTypeChanged();
}
-Widget* Window::AsWidget() {
- return const_cast<Widget*>(const_cast<const Window*>(this)->AsWidget());
-}
-
-const Widget* Window::AsWidget() const {
- return native_window_->AsNativeWidget()->GetWidget();
-}
-
////////////////////////////////////////////////////////////////////////////////
-// Window, protected:
-
-void Window::SetNativeWindow(NativeWindow* native_window) {
- native_window_ = native_window;
-}
-
-////////////////////////////////////////////////////////////////////////////////
// Window, internal::NativeWindowDelegate implementation:
bool Window::CanActivate() const {
@@ -364,6 +333,14 @@
SaveWindowPosition();
}
+Window* Window::AsWindow() {
+ return this;
+}
+
+internal::NativeWidgetDelegate* Window::AsNativeWidgetDelegate() {
+ return this;
+}
+
////////////////////////////////////////////////////////////////////////////////
// Window, private:
« no previous file with comments | « views/window/window.h ('k') | views/window/window_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698