| 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/frame/browser_non_client_frame_view_aura.h" | 5 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view_aura.h" |
| 6 | 6 |
| 7 #include "ash/wm/frame_painter.h" | 7 #include "ash/wm/frame_painter.h" |
| 8 #include "ash/wm/workspace/frame_maximize_button.h" | 8 #include "ash/wm/workspace/frame_maximize_button.h" |
| 9 #include "chrome/browser/themes/theme_service.h" | 9 #include "chrome/browser/themes/theme_service.h" |
| 10 #include "chrome/browser/ui/views/avatar_menu_button.h" | 10 #include "chrome/browser/ui/views/avatar_menu_button.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 57 |
| 58 /////////////////////////////////////////////////////////////////////////////// | 58 /////////////////////////////////////////////////////////////////////////////// |
| 59 // BrowserNonClientFrameViewAura, public: | 59 // BrowserNonClientFrameViewAura, public: |
| 60 | 60 |
| 61 BrowserNonClientFrameViewAura::BrowserNonClientFrameViewAura( | 61 BrowserNonClientFrameViewAura::BrowserNonClientFrameViewAura( |
| 62 BrowserFrame* frame, BrowserView* browser_view) | 62 BrowserFrame* frame, BrowserView* browser_view) |
| 63 : BrowserNonClientFrameView(frame, browser_view), | 63 : BrowserNonClientFrameView(frame, browser_view), |
| 64 maximize_button_(NULL), | 64 maximize_button_(NULL), |
| 65 close_button_(NULL), | 65 close_button_(NULL), |
| 66 window_icon_(NULL), | 66 window_icon_(NULL), |
| 67 frame_painter_(new ash::FramePainter), | 67 frame_painter_(new ash::FramePainter) { |
| 68 allow_maximize_(true) { | |
| 69 } | 68 } |
| 70 | 69 |
| 71 BrowserNonClientFrameViewAura::~BrowserNonClientFrameViewAura() { | 70 BrowserNonClientFrameViewAura::~BrowserNonClientFrameViewAura() { |
| 72 } | 71 } |
| 73 | 72 |
| 74 void BrowserNonClientFrameViewAura::Init() { | 73 void BrowserNonClientFrameViewAura::Init() { |
| 75 // Caption buttons. | 74 // Caption buttons. |
| 76 ash::FrameMaximizeButton* maximize_button = | 75 maximize_button_ = new ash::FrameMaximizeButton(this, this); |
| 77 new ash::FrameMaximizeButton(this, this); | |
| 78 maximize_button_ = maximize_button; | |
| 79 // Disable snap left/right and maximize for Panels. | |
| 80 if (browser_view()->browser()->is_type_panel() && | |
| 81 browser_view()->browser()->app_type() == Browser::APP_TYPE_CHILD) { | |
| 82 allow_maximize_ = false; | |
| 83 maximize_button->SetIsLeftRightEnabled(false); | |
| 84 maximize_button->set_is_maximize_enabled(false); | |
| 85 } | |
| 86 maximize_button_->SetAccessibleName( | 76 maximize_button_->SetAccessibleName( |
| 87 l10n_util::GetStringUTF16(IDS_ACCNAME_MAXIMIZE)); | 77 l10n_util::GetStringUTF16(IDS_ACCNAME_MAXIMIZE)); |
| 88 AddChildView(maximize_button_); | 78 AddChildView(maximize_button_); |
| 89 close_button_ = new views::ImageButton(this); | 79 close_button_ = new views::ImageButton(this); |
| 90 close_button_->SetAccessibleName( | 80 close_button_->SetAccessibleName( |
| 91 l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE)); | 81 l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE)); |
| 92 AddChildView(close_button_); | 82 AddChildView(close_button_); |
| 93 | 83 |
| 94 // Initializing the TabIconView is expensive, so only do it if we need to. | 84 // Initializing the TabIconView is expensive, so only do it if we need to. |
| 95 if (browser_view()->ShouldShowWindowIcon()) { | 85 if (browser_view()->ShouldShowWindowIcon()) { |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 } | 237 } |
| 248 | 238 |
| 249 /////////////////////////////////////////////////////////////////////////////// | 239 /////////////////////////////////////////////////////////////////////////////// |
| 250 // views::ButtonListener overrides: | 240 // views::ButtonListener overrides: |
| 251 | 241 |
| 252 void BrowserNonClientFrameViewAura::ButtonPressed(views::Button* sender, | 242 void BrowserNonClientFrameViewAura::ButtonPressed(views::Button* sender, |
| 253 const views::Event& event) { | 243 const views::Event& event) { |
| 254 if (sender == maximize_button_) { | 244 if (sender == maximize_button_) { |
| 255 // The maximize button may move out from under the cursor. | 245 // The maximize button may move out from under the cursor. |
| 256 ResetWindowControls(); | 246 ResetWindowControls(); |
| 257 // Don't maximize if this is a Panel. | |
| 258 if (!allow_maximize_) | |
| 259 return; | |
| 260 if (frame()->IsMaximized()) | 247 if (frame()->IsMaximized()) |
| 261 frame()->Restore(); | 248 frame()->Restore(); |
| 262 else | 249 else |
| 263 frame()->Maximize(); | 250 frame()->Maximize(); |
| 264 // |this| may be deleted - some windows delete their frames on maximize. | 251 // |this| may be deleted - some windows delete their frames on maximize. |
| 265 } else if (sender == close_button_) { | 252 } else if (sender == close_button_) { |
| 266 frame()->Close(); | 253 frame()->Close(); |
| 267 } | 254 } |
| 268 } | 255 } |
| 269 | 256 |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 } | 435 } |
| 449 | 436 |
| 450 SkBitmap* BrowserNonClientFrameViewAura::GetCustomBitmap( | 437 SkBitmap* BrowserNonClientFrameViewAura::GetCustomBitmap( |
| 451 int bitmap_id, | 438 int bitmap_id, |
| 452 int fallback_bitmap_id) const { | 439 int fallback_bitmap_id) const { |
| 453 ui::ThemeProvider* tp = GetThemeProvider(); | 440 ui::ThemeProvider* tp = GetThemeProvider(); |
| 454 if (tp->HasCustomImage(bitmap_id)) | 441 if (tp->HasCustomImage(bitmap_id)) |
| 455 return tp->GetBitmapNamed(bitmap_id); | 442 return tp->GetBitmapNamed(bitmap_id); |
| 456 return tp->GetBitmapNamed(fallback_bitmap_id); | 443 return tp->GetBitmapNamed(fallback_bitmap_id); |
| 457 } | 444 } |
| OLD | NEW |