| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/views/constrained_window_views.h" | 5 #include "chrome/browser/ui/views/constrained_window_views.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #include "net/base/net_util.h" | 28 #include "net/base/net_util.h" |
| 29 #include "ui/aura/client/aura_constants.h" | 29 #include "ui/aura/client/aura_constants.h" |
| 30 #include "ui/base/hit_test.h" | 30 #include "ui/base/hit_test.h" |
| 31 #include "ui/base/resource/resource_bundle.h" | 31 #include "ui/base/resource/resource_bundle.h" |
| 32 #include "ui/base/ui_base_switches.h" | 32 #include "ui/base/ui_base_switches.h" |
| 33 #include "ui/gfx/canvas.h" | 33 #include "ui/gfx/canvas.h" |
| 34 #include "ui/gfx/font.h" | 34 #include "ui/gfx/font.h" |
| 35 #include "ui/gfx/path.h" | 35 #include "ui/gfx/path.h" |
| 36 #include "ui/gfx/rect.h" | 36 #include "ui/gfx/rect.h" |
| 37 #include "ui/gfx/screen.h" | 37 #include "ui/gfx/screen.h" |
| 38 #include "ui/views/border.h" | |
| 39 #include "ui/views/color_constants.h" | 38 #include "ui/views/color_constants.h" |
| 40 #include "ui/views/controls/button/image_button.h" | 39 #include "ui/views/controls/button/image_button.h" |
| 41 #include "ui/views/focus/focus_manager.h" | 40 #include "ui/views/focus/focus_manager.h" |
| 42 #include "ui/views/views_delegate.h" | 41 #include "ui/views/views_delegate.h" |
| 43 #include "ui/views/widget/widget.h" | 42 #include "ui/views/widget/widget.h" |
| 44 #include "ui/views/widget/widget_observer.h" | 43 #include "ui/views/widget/widget_observer.h" |
| 45 #include "ui/views/window/client_view.h" | 44 #include "ui/views/window/client_view.h" |
| 46 #include "ui/views/window/dialog_client_view.h" | 45 #include "ui/views/window/dialog_client_view.h" |
| 47 #include "ui/views/window/dialog_delegate.h" | 46 #include "ui/views/window/dialog_delegate.h" |
| 48 #include "ui/views/window/frame_background.h" | 47 #include "ui/views/window/frame_background.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 | 108 |
| 110 // WidgetObserver overrides | 109 // WidgetObserver overrides |
| 111 virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE { | 110 virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE { |
| 112 delete this; | 111 delete this; |
| 113 } | 112 } |
| 114 | 113 |
| 115 // WebContentsModalDialogHostObserver overrides | 114 // WebContentsModalDialogHostObserver overrides |
| 116 virtual void OnPositionRequiresUpdate() OVERRIDE { | 115 virtual void OnPositionRequiresUpdate() OVERRIDE { |
| 117 gfx::Size size = target_widget_->GetWindowBoundsInScreen().size(); | 116 gfx::Size size = target_widget_->GetWindowBoundsInScreen().size(); |
| 118 gfx::Point position = host_->GetDialogPosition(size); | 117 gfx::Point position = host_->GetDialogPosition(size); |
| 119 views::Border* border = | |
| 120 target_widget_->non_client_view()->frame_view()->border(); | |
| 121 // Border may be null during widget initialization. | |
| 122 if (border) { | |
| 123 // Align the first row of pixels inside the border. This is the apparent | |
| 124 // top of the dialog. | |
| 125 gfx::Insets border_insets = border->GetInsets(); | |
| 126 position -= gfx::Vector2d(border_insets.left(), border_insets.top()); | |
| 127 } | |
| 128 target_widget_->SetBounds(gfx::Rect(position, size)); | 118 target_widget_->SetBounds(gfx::Rect(position, size)); |
| 129 } | 119 } |
| 130 | 120 |
| 131 private: | 121 private: |
| 132 WebContentsModalDialogHost* host_; | 122 WebContentsModalDialogHost* host_; |
| 133 views::Widget* target_widget_; | 123 views::Widget* target_widget_; |
| 134 const char* const native_window_property_; | 124 const char* const native_window_property_; |
| 135 | 125 |
| 136 DISALLOW_COPY_AND_ASSIGN(WebContentsModalDialogHostObserverViews); | 126 DISALLOW_COPY_AND_ASSIGN(WebContentsModalDialogHostObserverViews); |
| 137 }; | 127 }; |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 dialog->SetNativeWindowProperty(kWebContentsModalDialogHostObserverViewsKey, | 663 dialog->SetNativeWindowProperty(kWebContentsModalDialogHostObserverViewsKey, |
| 674 dialog_host_observer); | 664 dialog_host_observer); |
| 675 } | 665 } |
| 676 | 666 |
| 677 return dialog; | 667 return dialog; |
| 678 } | 668 } |
| 679 | 669 |
| 680 views::NonClientFrameView* CreateConstrainedStyleNonClientFrameView( | 670 views::NonClientFrameView* CreateConstrainedStyleNonClientFrameView( |
| 681 views::Widget* widget, | 671 views::Widget* widget, |
| 682 content::BrowserContext* browser_context) { | 672 content::BrowserContext* browser_context) { |
| 683 if (views::DialogDelegate::UseNewStyle()) { | 673 if (views::DialogDelegate::UseNewStyle()) |
| 684 #if defined(USE_AURA) | 674 return views::DialogDelegate::CreateNewStyleFrameView(widget); |
| 685 const bool force_opaque_border = false; | |
| 686 #else | |
| 687 const bool force_opaque_border = true; | |
| 688 #endif | |
| 689 return views::DialogDelegate::CreateNewStyleFrameView(widget, | |
| 690 force_opaque_border); | |
| 691 } | |
| 692 #if defined(USE_ASH) | 675 #if defined(USE_ASH) |
| 693 ConstrainedWindowFrameViewAsh* frame = new ConstrainedWindowFrameViewAsh; | 676 ConstrainedWindowFrameViewAsh* frame = new ConstrainedWindowFrameViewAsh; |
| 694 frame->Init(widget); | 677 frame->Init(widget); |
| 695 return frame; | 678 return frame; |
| 696 #endif | 679 #endif |
| 697 return new ConstrainedWindowFrameView(widget, | 680 return new ConstrainedWindowFrameView(widget, |
| 698 browser_context->IsOffTheRecord()); | 681 browser_context->IsOffTheRecord()); |
| 699 } | 682 } |
| OLD | NEW |