Chromium Code Reviews| Index: apps/ui/views/app_window_frame_view.cc |
| diff --git a/apps/ui/views/app_window_frame_view.cc b/apps/ui/views/app_window_frame_view.cc |
| index e1c399fe23825c0ea573ba0d8442caefc060a805..381c20632403cd929148dc3fc748a7aae91268ab 100644 |
| --- a/apps/ui/views/app_window_frame_view.cc |
| +++ b/apps/ui/views/app_window_frame_view.cc |
| @@ -4,12 +4,12 @@ |
| #include "apps/ui/views/app_window_frame_view.h" |
| -#include "apps/ui/native_app_window.h" |
| #include "base/strings/utf_string_conversions.h" |
| #include "extensions/common/draggable_region.h" |
| #include "grit/theme_resources.h" |
| #include "grit/ui_strings.h" // Accessibility names |
| #include "third_party/skia/include/core/SkPaint.h" |
| +#include "third_party/skia/include/core/SkRegion.h" |
| #include "ui/base/hit_test.h" |
| #include "ui/base/l10n/l10n_util.h" |
| #include "ui/base/resource/resource_bundle.h" |
| @@ -37,9 +37,9 @@ namespace apps { |
| const char AppWindowFrameView::kViewClassName[] = |
| "browser/ui/views/extensions/AppWindowFrameView"; |
| -AppWindowFrameView::AppWindowFrameView(NativeAppWindow* window) |
| - : window_(window), |
| - widget_(NULL), |
| +AppWindowFrameView::AppWindowFrameView() |
| + : widget_(NULL), |
| + draggable_region_(NULL), |
| close_button_(NULL), |
| maximize_button_(NULL), |
| restore_button_(NULL), |
| @@ -51,18 +51,22 @@ AppWindowFrameView::AppWindowFrameView(NativeAppWindow* window) |
| AppWindowFrameView::~AppWindowFrameView() {} |
| void AppWindowFrameView::Init(views::Widget* widget, |
| + bool draw_frame, |
| const SkColor& frame_color, |
| + const SkRegion* draggable_region, |
| int resize_inside_bounds_size, |
| int resize_outside_bounds_size, |
| int resize_outside_scale_for_touch, |
| int resize_area_corner_size) { |
| widget_ = widget; |
| + draw_frame_ = draw_frame; |
| frame_color_ = frame_color; |
| + draggable_region_ = draggable_region; |
| resize_inside_bounds_size_ = resize_inside_bounds_size; |
| resize_outside_bounds_size_ = resize_outside_bounds_size; |
| resize_area_corner_size_ = resize_area_corner_size; |
| - if (!window_->IsFrameless()) { |
| + if (draw_frame) { |
| ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| close_button_ = new views::ImageButton(this); |
| close_button_->SetImage( |
| @@ -125,7 +129,7 @@ void AppWindowFrameView::Init(views::Widget* widget, |
| // views::NonClientFrameView implementation. |
| gfx::Rect AppWindowFrameView::GetBoundsForClientView() const { |
| - if (window_->IsFrameless() || widget_->IsFullscreen()) |
| + if (!draw_frame_ || widget_->IsFullscreen()) |
| return bounds(); |
| return gfx::Rect( |
| 0, kCaptionHeight, width(), std::max(0, height() - kCaptionHeight)); |
| @@ -133,7 +137,7 @@ gfx::Rect AppWindowFrameView::GetBoundsForClientView() const { |
| gfx::Rect AppWindowFrameView::GetWindowBoundsForClientBounds( |
| const gfx::Rect& client_bounds) const { |
| - if (window_->IsFrameless()) { |
| + if (!draw_frame_) { |
| gfx::Rect window_bounds = client_bounds; |
| // Enforce minimum size (1, 1) in case that client_bounds is passed with |
| // empty size. This could occur when the frameless window is being |
| @@ -189,9 +193,8 @@ int AppWindowFrameView::NonClientHitTest(const gfx::Point& point) { |
| // Check for possible draggable region in the client area for the frameless |
| // window. |
| - if (window_->IsFrameless()) { |
| - SkRegion* draggable_region = window_->GetDraggableRegion(); |
| - if (draggable_region && draggable_region->contains(point.x(), point.y())) |
| + if (!draw_frame_) { |
|
Matt Giuca
2014/03/27 06:39:38
This part is a bit weird. On Linux, a native windo
benwells
2014/03/27 08:53:45
Yes, only frameless windows should have draggable
Matt Giuca
2014/03/27 09:16:27
Done.
Note: I did not "only set it if the window
|
| + if (draggable_region_ && draggable_region_->contains(point.x(), point.y())) |
| return HTCAPTION; |
| } |
| @@ -235,7 +238,7 @@ gfx::Size AppWindowFrameView::GetPreferredSize() { |
| } |
| void AppWindowFrameView::Layout() { |
| - if (window_->IsFrameless()) |
| + if (!draw_frame_) |
| return; |
| gfx::Size close_size = close_button_->GetPreferredSize(); |
| const int kButtonOffsetY = 0; |
| @@ -282,7 +285,7 @@ void AppWindowFrameView::Layout() { |
| } |
| void AppWindowFrameView::OnPaint(gfx::Canvas* canvas) { |
| - if (window_->IsFrameless()) |
| + if (!draw_frame_) |
| return; |
| ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| @@ -314,7 +317,7 @@ const char* AppWindowFrameView::GetClassName() const { return kViewClassName; } |
| gfx::Size AppWindowFrameView::GetMinimumSize() { |
| gfx::Size min_size = widget_->client_view()->GetMinimumSize(); |
| - if (window_->IsFrameless()) |
| + if (!draw_frame_) |
| return min_size; |
| // Ensure we can display the top of the caption area. |
| @@ -346,7 +349,7 @@ gfx::Size AppWindowFrameView::GetMaximumSize() { |
| void AppWindowFrameView::ButtonPressed(views::Button* sender, |
| const ui::Event& event) { |
| - DCHECK(!window_->IsFrameless()); |
| + DCHECK(draw_frame_); |
| if (sender == close_button_) |
| widget_->Close(); |
| else if (sender == maximize_button_) |