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/opaque_browser_frame_view.h" | 5 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 layout_(new OpaqueBrowserFrameViewLayout(this)), | 94 layout_(new OpaqueBrowserFrameViewLayout(this)), |
95 minimize_button_(NULL), | 95 minimize_button_(NULL), |
96 maximize_button_(NULL), | 96 maximize_button_(NULL), |
97 restore_button_(NULL), | 97 restore_button_(NULL), |
98 close_button_(NULL), | 98 close_button_(NULL), |
99 window_icon_(NULL), | 99 window_icon_(NULL), |
100 window_title_(NULL), | 100 window_title_(NULL), |
101 frame_background_(new views::FrameBackground()) { | 101 frame_background_(new views::FrameBackground()) { |
102 SetLayoutManager(layout_); | 102 SetLayoutManager(layout_); |
103 | 103 |
104 if (OpaqueBrowserFrameViewLayout::ShouldAddDefaultCaptionButtons()) { | 104 minimize_button_ = InitWindowCaptionButton(IDR_MINIMIZE, |
105 minimize_button_ = InitWindowCaptionButton(IDR_MINIMIZE, | 105 IDR_MINIMIZE_H, |
106 IDR_MINIMIZE_H, | 106 IDR_MINIMIZE_P, |
107 IDR_MINIMIZE_P, | 107 IDR_MINIMIZE_BUTTON_MASK, |
108 IDR_MINIMIZE_BUTTON_MASK, | 108 IDS_ACCNAME_MINIMIZE, |
109 IDS_ACCNAME_MINIMIZE, | 109 VIEW_ID_MINIMIZE_BUTTON); |
110 VIEW_ID_MINIMIZE_BUTTON); | 110 maximize_button_ = InitWindowCaptionButton(IDR_MAXIMIZE, |
111 maximize_button_ = InitWindowCaptionButton(IDR_MAXIMIZE, | 111 IDR_MAXIMIZE_H, |
112 IDR_MAXIMIZE_H, | 112 IDR_MAXIMIZE_P, |
113 IDR_MAXIMIZE_P, | 113 IDR_MAXIMIZE_BUTTON_MASK, |
114 IDR_MAXIMIZE_BUTTON_MASK, | 114 IDS_ACCNAME_MAXIMIZE, |
115 IDS_ACCNAME_MAXIMIZE, | 115 VIEW_ID_MAXIMIZE_BUTTON); |
116 VIEW_ID_MAXIMIZE_BUTTON); | 116 restore_button_ = InitWindowCaptionButton(IDR_RESTORE, |
117 restore_button_ = InitWindowCaptionButton(IDR_RESTORE, | 117 IDR_RESTORE_H, |
118 IDR_RESTORE_H, | 118 IDR_RESTORE_P, |
119 IDR_RESTORE_P, | 119 IDR_RESTORE_BUTTON_MASK, |
120 IDR_RESTORE_BUTTON_MASK, | 120 IDS_ACCNAME_RESTORE, |
121 IDS_ACCNAME_RESTORE, | 121 VIEW_ID_RESTORE_BUTTON); |
122 VIEW_ID_RESTORE_BUTTON); | 122 close_button_ = InitWindowCaptionButton(IDR_CLOSE, |
123 close_button_ = InitWindowCaptionButton(IDR_CLOSE, | 123 IDR_CLOSE_H, |
124 IDR_CLOSE_H, | 124 IDR_CLOSE_P, |
125 IDR_CLOSE_P, | 125 IDR_CLOSE_BUTTON_MASK, |
126 IDR_CLOSE_BUTTON_MASK, | 126 IDS_ACCNAME_CLOSE, |
127 IDS_ACCNAME_CLOSE, | 127 VIEW_ID_CLOSE_BUTTON); |
128 VIEW_ID_CLOSE_BUTTON); | |
129 } | |
130 | 128 |
131 // Initializing the TabIconView is expensive, so only do it if we need to. | 129 // Initializing the TabIconView is expensive, so only do it if we need to. |
132 if (browser_view->ShouldShowWindowIcon()) { | 130 if (browser_view->ShouldShowWindowIcon()) { |
133 window_icon_ = new TabIconView(this, this); | 131 window_icon_ = new TabIconView(this, this); |
134 window_icon_->set_is_light(true); | 132 window_icon_->set_is_light(true); |
135 window_icon_->set_id(VIEW_ID_WINDOW_ICON); | 133 window_icon_->set_id(VIEW_ID_WINDOW_ICON); |
136 AddChildView(window_icon_); | 134 AddChildView(window_icon_); |
137 window_icon_->Update(); | 135 window_icon_->Update(); |
138 } | 136 } |
139 | 137 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 gfx::Path* window_mask) { | 265 gfx::Path* window_mask) { |
268 DCHECK(window_mask); | 266 DCHECK(window_mask); |
269 | 267 |
270 if (layout_->IsTitleBarCondensed() || frame()->IsFullscreen()) | 268 if (layout_->IsTitleBarCondensed() || frame()->IsFullscreen()) |
271 return; | 269 return; |
272 | 270 |
273 views::GetDefaultWindowMask(size, window_mask); | 271 views::GetDefaultWindowMask(size, window_mask); |
274 } | 272 } |
275 | 273 |
276 void OpaqueBrowserFrameView::ResetWindowControls() { | 274 void OpaqueBrowserFrameView::ResetWindowControls() { |
277 if (!OpaqueBrowserFrameViewLayout::ShouldAddDefaultCaptionButtons()) | |
278 return; | |
279 restore_button_->SetState(views::CustomButton::STATE_NORMAL); | 275 restore_button_->SetState(views::CustomButton::STATE_NORMAL); |
280 minimize_button_->SetState(views::CustomButton::STATE_NORMAL); | 276 minimize_button_->SetState(views::CustomButton::STATE_NORMAL); |
281 maximize_button_->SetState(views::CustomButton::STATE_NORMAL); | 277 maximize_button_->SetState(views::CustomButton::STATE_NORMAL); |
282 // The close button isn't affected by this constraint. | 278 // The close button isn't affected by this constraint. |
283 } | 279 } |
284 | 280 |
285 void OpaqueBrowserFrameView::UpdateWindowIcon() { | 281 void OpaqueBrowserFrameView::UpdateWindowIcon() { |
286 window_icon_->SchedulePaint(); | 282 window_icon_->SchedulePaint(); |
287 } | 283 } |
288 | 284 |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 | 461 |
466 bool OpaqueBrowserFrameView::ShouldLeaveOffsetNearTopBorder() const { | 462 bool OpaqueBrowserFrameView::ShouldLeaveOffsetNearTopBorder() const { |
467 return frame()->ShouldLeaveOffsetNearTopBorder(); | 463 return frame()->ShouldLeaveOffsetNearTopBorder(); |
468 } | 464 } |
469 | 465 |
470 gfx::Size OpaqueBrowserFrameView::GetBrowserViewMinimumSize() const { | 466 gfx::Size OpaqueBrowserFrameView::GetBrowserViewMinimumSize() const { |
471 return browser_view()->GetMinimumSize(); | 467 return browser_view()->GetMinimumSize(); |
472 } | 468 } |
473 | 469 |
474 bool OpaqueBrowserFrameView::ShouldShowCaptionButtons() const { | 470 bool OpaqueBrowserFrameView::ShouldShowCaptionButtons() const { |
475 if (!OpaqueBrowserFrameViewLayout::ShouldAddDefaultCaptionButtons()) | |
476 return false; | |
477 return ShouldShowWindowTitleBar(); | 471 return ShouldShowWindowTitleBar(); |
478 } | 472 } |
479 | 473 |
480 bool OpaqueBrowserFrameView::ShouldShowAvatar() const { | 474 bool OpaqueBrowserFrameView::ShouldShowAvatar() const { |
481 return browser_view()->ShouldShowAvatar(); | 475 return browser_view()->ShouldShowAvatar(); |
482 } | 476 } |
483 | 477 |
484 bool OpaqueBrowserFrameView::IsRegularOrGuestSession() const { | 478 bool OpaqueBrowserFrameView::IsRegularOrGuestSession() const { |
485 return browser_view()->IsRegularOrGuestSession(); | 479 return browser_view()->IsRegularOrGuestSession(); |
486 } | 480 } |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
927 | 921 |
928 int OpaqueBrowserFrameView::GetTopAreaHeight() const { | 922 int OpaqueBrowserFrameView::GetTopAreaHeight() const { |
929 gfx::ImageSkia* frame_image = GetFrameImage(); | 923 gfx::ImageSkia* frame_image = GetFrameImage(); |
930 int top_area_height = frame_image->height(); | 924 int top_area_height = frame_image->height(); |
931 if (browser_view()->IsTabStripVisible()) { | 925 if (browser_view()->IsTabStripVisible()) { |
932 top_area_height = std::max(top_area_height, | 926 top_area_height = std::max(top_area_height, |
933 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom()); | 927 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom()); |
934 } | 928 } |
935 return top_area_height; | 929 return top_area_height; |
936 } | 930 } |
OLD | NEW |