| 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/ash/browser_non_client_frame_view_ash.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" |
| 11 #include "chrome/browser/ui/views/frame/browser_frame.h" | 11 #include "chrome/browser/ui/views/frame/browser_frame.h" |
| 12 #include "chrome/browser/ui/views/frame/browser_view.h" | 12 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 13 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
| 14 #include "grit/generated_resources.h" // Accessibility names | 14 #include "grit/generated_resources.h" // Accessibility names |
| 15 #include "grit/theme_resources.h" | 15 #include "grit/theme_resources.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 // Height of the shadow in the tab image, used to ensure clicks in the shadow | 49 // Height of the shadow in the tab image, used to ensure clicks in the shadow |
| 50 // area still drag restored windows. This keeps the clickable area large enough | 50 // area still drag restored windows. This keeps the clickable area large enough |
| 51 // to hit easily. | 51 // to hit easily. |
| 52 const int kTabShadowHeight = 4; | 52 const int kTabShadowHeight = 4; |
| 53 // Height of the shadow of the content area, at the top of the toolbar. | 53 // Height of the shadow of the content area, at the top of the toolbar. |
| 54 const int kContentShadowHeight = 1; | 54 const int kContentShadowHeight = 1; |
| 55 | 55 |
| 56 } // namespace | 56 } // namespace |
| 57 | 57 |
| 58 /////////////////////////////////////////////////////////////////////////////// | 58 /////////////////////////////////////////////////////////////////////////////// |
| 59 // BrowserNonClientFrameViewAura, public: | 59 // BrowserNonClientFrameViewAsh, public: |
| 60 | 60 |
| 61 BrowserNonClientFrameViewAura::BrowserNonClientFrameViewAura( | 61 BrowserNonClientFrameViewAsh::BrowserNonClientFrameViewAsh( |
| 62 BrowserFrame* frame, BrowserView* browser_view) | 62 BrowserFrame* frame, BrowserView* browser_view) |
| 63 : BrowserNonClientFrameView(frame, browser_view), | 63 : BrowserNonClientFrameView(frame, browser_view), |
| 64 size_button_(NULL), | 64 size_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 size_button_minimizes_(false) { | 68 size_button_minimizes_(false) { |
| 69 } | 69 } |
| 70 | 70 |
| 71 BrowserNonClientFrameViewAura::~BrowserNonClientFrameViewAura() { | 71 BrowserNonClientFrameViewAsh::~BrowserNonClientFrameViewAsh() { |
| 72 } | 72 } |
| 73 | 73 |
| 74 void BrowserNonClientFrameViewAura::Init() { | 74 void BrowserNonClientFrameViewAsh::Init() { |
| 75 // Panels only minimize. | 75 // Panels only minimize. |
| 76 ash::FramePainter::SizeButtonBehavior size_button_behavior; | 76 ash::FramePainter::SizeButtonBehavior size_button_behavior; |
| 77 if (browser_view()->browser()->is_type_panel() && | 77 if (browser_view()->browser()->is_type_panel() && |
| 78 browser_view()->browser()->app_type() == Browser::APP_TYPE_CHILD) { | 78 browser_view()->browser()->app_type() == Browser::APP_TYPE_CHILD) { |
| 79 size_button_minimizes_ = true; | 79 size_button_minimizes_ = true; |
| 80 size_button_ = new views::ImageButton(this); | 80 size_button_ = new views::ImageButton(this); |
| 81 size_button_behavior = ash::FramePainter::SIZE_BUTTON_MINIMIZES; | 81 size_button_behavior = ash::FramePainter::SIZE_BUTTON_MINIMIZES; |
| 82 } else { | 82 } else { |
| 83 size_button_ = new ash::FrameMaximizeButton(this, this); | 83 size_button_ = new ash::FrameMaximizeButton(this, this); |
| 84 size_button_behavior = ash::FramePainter::SIZE_BUTTON_MAXIMIZES; | 84 size_button_behavior = ash::FramePainter::SIZE_BUTTON_MAXIMIZES; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 103 UpdateAvatarInfo(); | 103 UpdateAvatarInfo(); |
| 104 | 104 |
| 105 // Frame painter handles layout of these buttons. | 105 // Frame painter handles layout of these buttons. |
| 106 frame_painter_->Init(frame(), window_icon_, size_button_, close_button_, | 106 frame_painter_->Init(frame(), window_icon_, size_button_, close_button_, |
| 107 size_button_behavior); | 107 size_button_behavior); |
| 108 } | 108 } |
| 109 | 109 |
| 110 /////////////////////////////////////////////////////////////////////////////// | 110 /////////////////////////////////////////////////////////////////////////////// |
| 111 // BrowserNonClientFrameView overrides: | 111 // BrowserNonClientFrameView overrides: |
| 112 | 112 |
| 113 gfx::Rect BrowserNonClientFrameViewAura::GetBoundsForTabStrip( | 113 gfx::Rect BrowserNonClientFrameViewAsh::GetBoundsForTabStrip( |
| 114 views::View* tabstrip) const { | 114 views::View* tabstrip) const { |
| 115 if (!tabstrip) | 115 if (!tabstrip) |
| 116 return gfx::Rect(); | 116 return gfx::Rect(); |
| 117 int tabstrip_x = | 117 int tabstrip_x = |
| 118 avatar_button() ? | 118 avatar_button() ? |
| 119 (avatar_button()->bounds().right() + kAvatarSideSpacing) : | 119 (avatar_button()->bounds().right() + kAvatarSideSpacing) : |
| 120 kTabstripLeftSpacing; | 120 kTabstripLeftSpacing; |
| 121 int tabstrip_width = | 121 int tabstrip_width = |
| 122 size_button_->x() - kTabstripRightSpacing - tabstrip_x; | 122 size_button_->x() - kTabstripRightSpacing - tabstrip_x; |
| 123 return gfx::Rect(tabstrip_x, | 123 return gfx::Rect(tabstrip_x, |
| 124 GetHorizontalTabStripVerticalOffset(false), | 124 GetHorizontalTabStripVerticalOffset(false), |
| 125 std::max(0, tabstrip_width), | 125 std::max(0, tabstrip_width), |
| 126 tabstrip->GetPreferredSize().height()); | 126 tabstrip->GetPreferredSize().height()); |
| 127 } | 127 } |
| 128 | 128 |
| 129 int BrowserNonClientFrameViewAura::GetHorizontalTabStripVerticalOffset( | 129 int BrowserNonClientFrameViewAsh::GetHorizontalTabStripVerticalOffset( |
| 130 bool force_restored) const { | 130 bool force_restored) const { |
| 131 return NonClientTopBorderHeight(force_restored); | 131 return NonClientTopBorderHeight(force_restored); |
| 132 } | 132 } |
| 133 | 133 |
| 134 void BrowserNonClientFrameViewAura::UpdateThrobber(bool running) { | 134 void BrowserNonClientFrameViewAsh::UpdateThrobber(bool running) { |
| 135 if (window_icon_) | 135 if (window_icon_) |
| 136 window_icon_->Update(); | 136 window_icon_->Update(); |
| 137 } | 137 } |
| 138 | 138 |
| 139 /////////////////////////////////////////////////////////////////////////////// | 139 /////////////////////////////////////////////////////////////////////////////// |
| 140 // views::NonClientFrameView overrides: | 140 // views::NonClientFrameView overrides: |
| 141 | 141 |
| 142 gfx::Rect BrowserNonClientFrameViewAura::GetBoundsForClientView() const { | 142 gfx::Rect BrowserNonClientFrameViewAsh::GetBoundsForClientView() const { |
| 143 int top_height = NonClientTopBorderHeight(false); | 143 int top_height = NonClientTopBorderHeight(false); |
| 144 return frame_painter_->GetBoundsForClientView(top_height, bounds()); | 144 return frame_painter_->GetBoundsForClientView(top_height, bounds()); |
| 145 } | 145 } |
| 146 | 146 |
| 147 gfx::Rect BrowserNonClientFrameViewAura::GetWindowBoundsForClientBounds( | 147 gfx::Rect BrowserNonClientFrameViewAsh::GetWindowBoundsForClientBounds( |
| 148 const gfx::Rect& client_bounds) const { | 148 const gfx::Rect& client_bounds) const { |
| 149 int top_height = NonClientTopBorderHeight(false); | 149 int top_height = NonClientTopBorderHeight(false); |
| 150 return frame_painter_->GetWindowBoundsForClientBounds(top_height, | 150 return frame_painter_->GetWindowBoundsForClientBounds(top_height, |
| 151 client_bounds); | 151 client_bounds); |
| 152 } | 152 } |
| 153 | 153 |
| 154 int BrowserNonClientFrameViewAura::NonClientHitTest(const gfx::Point& point) { | 154 int BrowserNonClientFrameViewAsh::NonClientHitTest(const gfx::Point& point) { |
| 155 int hit_test = frame_painter_->NonClientHitTest(this, point); | 155 int hit_test = frame_painter_->NonClientHitTest(this, point); |
| 156 // When the window is restored we want a large click target above the tabs | 156 // When the window is restored we want a large click target above the tabs |
| 157 // to drag the window, so redirect clicks in the tab's shadow to caption. | 157 // to drag the window, so redirect clicks in the tab's shadow to caption. |
| 158 if (hit_test == HTCLIENT && !frame()->IsMaximized()) { | 158 if (hit_test == HTCLIENT && !frame()->IsMaximized()) { |
| 159 // Convert point to client coordinates. | 159 // Convert point to client coordinates. |
| 160 gfx::Point client_point(point); | 160 gfx::Point client_point(point); |
| 161 View::ConvertPointToView(this, frame()->client_view(), &client_point); | 161 View::ConvertPointToView(this, frame()->client_view(), &client_point); |
| 162 // Report hits in shadow at top of tabstrip as caption. | 162 // Report hits in shadow at top of tabstrip as caption. |
| 163 gfx::Rect tabstrip_bounds(browser_view()->tabstrip()->bounds()); | 163 gfx::Rect tabstrip_bounds(browser_view()->tabstrip()->bounds()); |
| 164 if (client_point.y() < tabstrip_bounds.y() + kTabShadowHeight) | 164 if (client_point.y() < tabstrip_bounds.y() + kTabShadowHeight) |
| 165 hit_test = HTCAPTION; | 165 hit_test = HTCAPTION; |
| 166 } | 166 } |
| 167 return hit_test; | 167 return hit_test; |
| 168 } | 168 } |
| 169 | 169 |
| 170 void BrowserNonClientFrameViewAura::GetWindowMask(const gfx::Size& size, | 170 void BrowserNonClientFrameViewAsh::GetWindowMask(const gfx::Size& size, |
| 171 gfx::Path* window_mask) { | 171 gfx::Path* window_mask) { |
| 172 // Aura does not use window masks. | 172 // Aura does not use window masks. |
| 173 } | 173 } |
| 174 | 174 |
| 175 void BrowserNonClientFrameViewAura::ResetWindowControls() { | 175 void BrowserNonClientFrameViewAsh::ResetWindowControls() { |
| 176 size_button_->SetState(views::CustomButton::BS_NORMAL); | 176 size_button_->SetState(views::CustomButton::BS_NORMAL); |
| 177 // The close button isn't affected by this constraint. | 177 // The close button isn't affected by this constraint. |
| 178 } | 178 } |
| 179 | 179 |
| 180 void BrowserNonClientFrameViewAura::UpdateWindowIcon() { | 180 void BrowserNonClientFrameViewAsh::UpdateWindowIcon() { |
| 181 if (window_icon_) | 181 if (window_icon_) |
| 182 window_icon_->SchedulePaint(); | 182 window_icon_->SchedulePaint(); |
| 183 } | 183 } |
| 184 | 184 |
| 185 /////////////////////////////////////////////////////////////////////////////// | 185 /////////////////////////////////////////////////////////////////////////////// |
| 186 // views::View overrides: | 186 // views::View overrides: |
| 187 | 187 |
| 188 void BrowserNonClientFrameViewAura::OnPaint(gfx::Canvas* canvas) { | 188 void BrowserNonClientFrameViewAsh::OnPaint(gfx::Canvas* canvas) { |
| 189 if (frame()->IsFullscreen()) | 189 if (frame()->IsFullscreen()) |
| 190 return; // Nothing visible, don't paint. | 190 return; // Nothing visible, don't paint. |
| 191 // The primary header image changes based on window activation state and | 191 // The primary header image changes based on window activation state and |
| 192 // theme, so we look it up for each paint. | 192 // theme, so we look it up for each paint. |
| 193 frame_painter_->PaintHeader( | 193 frame_painter_->PaintHeader( |
| 194 this, | 194 this, |
| 195 canvas, | 195 canvas, |
| 196 ShouldPaintAsActive() ? | 196 ShouldPaintAsActive() ? |
| 197 ash::FramePainter::ACTIVE : ash::FramePainter::INACTIVE, | 197 ash::FramePainter::ACTIVE : ash::FramePainter::INACTIVE, |
| 198 GetThemeFrameBitmapId(), | 198 GetThemeFrameBitmapId(), |
| 199 GetThemeFrameOverlayBitmap()); | 199 GetThemeFrameOverlayBitmap()); |
| 200 if (browser_view()->ShouldShowWindowTitle()) | 200 if (browser_view()->ShouldShowWindowTitle()) |
| 201 frame_painter_->PaintTitleBar(this, canvas, BrowserFrame::GetTitleFont()); | 201 frame_painter_->PaintTitleBar(this, canvas, BrowserFrame::GetTitleFont()); |
| 202 if (browser_view()->IsToolbarVisible()) | 202 if (browser_view()->IsToolbarVisible()) |
| 203 PaintToolbarBackground(canvas); | 203 PaintToolbarBackground(canvas); |
| 204 else | 204 else |
| 205 PaintContentEdge(canvas); | 205 PaintContentEdge(canvas); |
| 206 } | 206 } |
| 207 | 207 |
| 208 void BrowserNonClientFrameViewAura::Layout() { | 208 void BrowserNonClientFrameViewAsh::Layout() { |
| 209 // Maximized windows and app/popup windows use shorter buttons. | 209 // Maximized windows and app/popup windows use shorter buttons. |
| 210 bool maximized_layout = | 210 bool maximized_layout = |
| 211 frame()->IsMaximized() || !browser_view()->IsBrowserTypeNormal(); | 211 frame()->IsMaximized() || !browser_view()->IsBrowserTypeNormal(); |
| 212 frame_painter_->LayoutHeader(this, maximized_layout); | 212 frame_painter_->LayoutHeader(this, maximized_layout); |
| 213 if (avatar_button()) | 213 if (avatar_button()) |
| 214 LayoutAvatar(); | 214 LayoutAvatar(); |
| 215 BrowserNonClientFrameView::Layout(); | 215 BrowserNonClientFrameView::Layout(); |
| 216 } | 216 } |
| 217 | 217 |
| 218 bool BrowserNonClientFrameViewAura::HitTest(const gfx::Point& l) const { | 218 bool BrowserNonClientFrameViewAsh::HitTest(const gfx::Point& l) const { |
| 219 // If the point is outside the bounds of the client area, claim it. | 219 // If the point is outside the bounds of the client area, claim it. |
| 220 if (NonClientFrameView::HitTest(l)) | 220 if (NonClientFrameView::HitTest(l)) |
| 221 return true; | 221 return true; |
| 222 | 222 |
| 223 // Otherwise claim it only if it's in a non-tab portion of the tabstrip. | 223 // Otherwise claim it only if it's in a non-tab portion of the tabstrip. |
| 224 if (!browser_view()->tabstrip()) | 224 if (!browser_view()->tabstrip()) |
| 225 return false; | 225 return false; |
| 226 gfx::Rect tabstrip_bounds(browser_view()->tabstrip()->bounds()); | 226 gfx::Rect tabstrip_bounds(browser_view()->tabstrip()->bounds()); |
| 227 gfx::Point tabstrip_origin(tabstrip_bounds.origin()); | 227 gfx::Point tabstrip_origin(tabstrip_bounds.origin()); |
| 228 View::ConvertPointToView(frame()->client_view(), this, &tabstrip_origin); | 228 View::ConvertPointToView(frame()->client_view(), this, &tabstrip_origin); |
| 229 tabstrip_bounds.set_origin(tabstrip_origin); | 229 tabstrip_bounds.set_origin(tabstrip_origin); |
| 230 if (l.y() > tabstrip_bounds.bottom()) | 230 if (l.y() > tabstrip_bounds.bottom()) |
| 231 return false; | 231 return false; |
| 232 | 232 |
| 233 // We convert from our parent's coordinates since we assume we fill its bounds | 233 // We convert from our parent's coordinates since we assume we fill its bounds |
| 234 // completely. We need to do this since we're not a parent of the tabstrip, | 234 // completely. We need to do this since we're not a parent of the tabstrip, |
| 235 // meaning ConvertPointToView would otherwise return something bogus. | 235 // meaning ConvertPointToView would otherwise return something bogus. |
| 236 gfx::Point browser_view_point(l); | 236 gfx::Point browser_view_point(l); |
| 237 View::ConvertPointToView(parent(), browser_view(), &browser_view_point); | 237 View::ConvertPointToView(parent(), browser_view(), &browser_view_point); |
| 238 return browser_view()->IsPositionInWindowCaption(browser_view_point); | 238 return browser_view()->IsPositionInWindowCaption(browser_view_point); |
| 239 } | 239 } |
| 240 | 240 |
| 241 void BrowserNonClientFrameViewAura::GetAccessibleState( | 241 void BrowserNonClientFrameViewAsh::GetAccessibleState( |
| 242 ui::AccessibleViewState* state) { | 242 ui::AccessibleViewState* state) { |
| 243 state->role = ui::AccessibilityTypes::ROLE_TITLEBAR; | 243 state->role = ui::AccessibilityTypes::ROLE_TITLEBAR; |
| 244 } | 244 } |
| 245 | 245 |
| 246 gfx::Size BrowserNonClientFrameViewAura::GetMinimumSize() { | 246 gfx::Size BrowserNonClientFrameViewAsh::GetMinimumSize() { |
| 247 return frame_painter_->GetMinimumSize(this); | 247 return frame_painter_->GetMinimumSize(this); |
| 248 } | 248 } |
| 249 | 249 |
| 250 /////////////////////////////////////////////////////////////////////////////// | 250 /////////////////////////////////////////////////////////////////////////////// |
| 251 // views::ButtonListener overrides: | 251 // views::ButtonListener overrides: |
| 252 | 252 |
| 253 void BrowserNonClientFrameViewAura::ButtonPressed(views::Button* sender, | 253 void BrowserNonClientFrameViewAsh::ButtonPressed(views::Button* sender, |
| 254 const views::Event& event) { | 254 const views::Event& event) { |
| 255 if (sender == size_button_) { | 255 if (sender == size_button_) { |
| 256 // The maximize button may move out from under the cursor. | 256 // The maximize button may move out from under the cursor. |
| 257 ResetWindowControls(); | 257 ResetWindowControls(); |
| 258 if (size_button_minimizes_) | 258 if (size_button_minimizes_) |
| 259 frame()->Minimize(); | 259 frame()->Minimize(); |
| 260 else if (frame()->IsMaximized()) | 260 else if (frame()->IsMaximized()) |
| 261 frame()->Restore(); | 261 frame()->Restore(); |
| 262 else | 262 else |
| 263 frame()->Maximize(); | 263 frame()->Maximize(); |
| 264 // |this| may be deleted - some windows delete their frames on maximize. | 264 // |this| may be deleted - some windows delete their frames on maximize. |
| 265 } else if (sender == close_button_) { | 265 } else if (sender == close_button_) { |
| 266 frame()->Close(); | 266 frame()->Close(); |
| 267 } | 267 } |
| 268 } | 268 } |
| 269 | 269 |
| 270 /////////////////////////////////////////////////////////////////////////////// | 270 /////////////////////////////////////////////////////////////////////////////// |
| 271 // TabIconView::TabIconViewModel overrides: | 271 // TabIconView::TabIconViewModel overrides: |
| 272 | 272 |
| 273 bool BrowserNonClientFrameViewAura::ShouldTabIconViewAnimate() const { | 273 bool BrowserNonClientFrameViewAsh::ShouldTabIconViewAnimate() const { |
| 274 // This function is queried during the creation of the window as the | 274 // This function is queried during the creation of the window as the |
| 275 // TabIconView we host is initialized, so we need to NULL check the selected | 275 // TabIconView we host is initialized, so we need to NULL check the selected |
| 276 // WebContents because in this condition there is not yet a selected tab. | 276 // WebContents because in this condition there is not yet a selected tab. |
| 277 content::WebContents* current_tab = browser_view()->GetSelectedWebContents(); | 277 content::WebContents* current_tab = browser_view()->GetSelectedWebContents(); |
| 278 return current_tab ? current_tab->IsLoading() : false; | 278 return current_tab ? current_tab->IsLoading() : false; |
| 279 } | 279 } |
| 280 | 280 |
| 281 SkBitmap BrowserNonClientFrameViewAura::GetFaviconForTabIconView() { | 281 SkBitmap BrowserNonClientFrameViewAsh::GetFaviconForTabIconView() { |
| 282 views::WidgetDelegate* delegate = frame()->widget_delegate(); | 282 views::WidgetDelegate* delegate = frame()->widget_delegate(); |
| 283 if (!delegate) | 283 if (!delegate) |
| 284 return SkBitmap(); | 284 return SkBitmap(); |
| 285 return delegate->GetWindowIcon(); | 285 return delegate->GetWindowIcon(); |
| 286 } | 286 } |
| 287 | 287 |
| 288 /////////////////////////////////////////////////////////////////////////////// | 288 /////////////////////////////////////////////////////////////////////////////// |
| 289 // BrowserNonClientFrameViewAura, private: | 289 // BrowserNonClientFrameViewAsh, private: |
| 290 | 290 |
| 291 | 291 |
| 292 int BrowserNonClientFrameViewAura::NonClientTopBorderHeight( | 292 int BrowserNonClientFrameViewAsh::NonClientTopBorderHeight( |
| 293 bool force_restored) const { | 293 bool force_restored) const { |
| 294 if (force_restored) | 294 if (force_restored) |
| 295 return kTabstripTopSpacingRestored; | 295 return kTabstripTopSpacingRestored; |
| 296 if (frame()->IsFullscreen()) | 296 if (frame()->IsFullscreen()) |
| 297 return 0; | 297 return 0; |
| 298 // Windows with tab strips need a smaller non-client area. | 298 // Windows with tab strips need a smaller non-client area. |
| 299 if (browser_view()->IsTabStripVisible()) { | 299 if (browser_view()->IsTabStripVisible()) { |
| 300 if (frame()->IsMaximized()) | 300 if (frame()->IsMaximized()) |
| 301 return kTabstripTopSpacingMaximized; | 301 return kTabstripTopSpacingMaximized; |
| 302 return kTabstripTopSpacingRestored; | 302 return kTabstripTopSpacingRestored; |
| 303 } | 303 } |
| 304 // For windows without a tab strip (popups, etc.) ensure we have enough space | 304 // For windows without a tab strip (popups, etc.) ensure we have enough space |
| 305 // to see the window caption buttons and the content separator line. | 305 // to see the window caption buttons and the content separator line. |
| 306 return close_button_->bounds().bottom() + kClientEdgeThickness; | 306 return close_button_->bounds().bottom() + kClientEdgeThickness; |
| 307 } | 307 } |
| 308 | 308 |
| 309 void BrowserNonClientFrameViewAura::LayoutAvatar() { | 309 void BrowserNonClientFrameViewAsh::LayoutAvatar() { |
| 310 DCHECK(avatar_button()); | 310 DCHECK(avatar_button()); |
| 311 SkBitmap incognito_icon = browser_view()->GetOTRAvatarIcon(); | 311 SkBitmap incognito_icon = browser_view()->GetOTRAvatarIcon(); |
| 312 | 312 |
| 313 int avatar_bottom = GetHorizontalTabStripVerticalOffset(false) + | 313 int avatar_bottom = GetHorizontalTabStripVerticalOffset(false) + |
| 314 browser_view()->GetTabStripHeight() - kAvatarBottomSpacing; | 314 browser_view()->GetTabStripHeight() - kAvatarBottomSpacing; |
| 315 int avatar_restored_y = avatar_bottom - incognito_icon.height(); | 315 int avatar_restored_y = avatar_bottom - incognito_icon.height(); |
| 316 int avatar_y = frame()->IsMaximized() ? | 316 int avatar_y = frame()->IsMaximized() ? |
| 317 NonClientTopBorderHeight(false) + kContentShadowHeight: | 317 NonClientTopBorderHeight(false) + kContentShadowHeight: |
| 318 avatar_restored_y; | 318 avatar_restored_y; |
| 319 gfx::Rect avatar_bounds(kAvatarSideSpacing, | 319 gfx::Rect avatar_bounds(kAvatarSideSpacing, |
| 320 avatar_y, | 320 avatar_y, |
| 321 incognito_icon.width(), | 321 incognito_icon.width(), |
| 322 avatar_bottom - avatar_y); | 322 avatar_bottom - avatar_y); |
| 323 avatar_button()->SetBoundsRect(avatar_bounds); | 323 avatar_button()->SetBoundsRect(avatar_bounds); |
| 324 } | 324 } |
| 325 | 325 |
| 326 void BrowserNonClientFrameViewAura::PaintToolbarBackground( | 326 void BrowserNonClientFrameViewAsh::PaintToolbarBackground( |
| 327 gfx::Canvas* canvas) { | 327 gfx::Canvas* canvas) { |
| 328 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds()); | 328 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds()); |
| 329 if (toolbar_bounds.IsEmpty()) | 329 if (toolbar_bounds.IsEmpty()) |
| 330 return; | 330 return; |
| 331 gfx::Point toolbar_origin(toolbar_bounds.origin()); | 331 gfx::Point toolbar_origin(toolbar_bounds.origin()); |
| 332 ConvertPointToView(browser_view(), this, &toolbar_origin); | 332 ConvertPointToView(browser_view(), this, &toolbar_origin); |
| 333 toolbar_bounds.set_origin(toolbar_origin); | 333 toolbar_bounds.set_origin(toolbar_origin); |
| 334 | 334 |
| 335 int x = toolbar_bounds.x(); | 335 int x = toolbar_bounds.x(); |
| 336 int w = toolbar_bounds.width(); | 336 int w = toolbar_bounds.width(); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 toolbar_right->width(), theme_toolbar->height()); | 386 toolbar_right->width(), theme_toolbar->height()); |
| 387 | 387 |
| 388 // Draw the content/toolbar separator. | 388 // Draw the content/toolbar separator. |
| 389 canvas->FillRect(gfx::Rect(x + kClientEdgeThickness, | 389 canvas->FillRect(gfx::Rect(x + kClientEdgeThickness, |
| 390 toolbar_bounds.bottom() - kClientEdgeThickness, | 390 toolbar_bounds.bottom() - kClientEdgeThickness, |
| 391 w - (2 * kClientEdgeThickness), | 391 w - (2 * kClientEdgeThickness), |
| 392 kClientEdgeThickness), | 392 kClientEdgeThickness), |
| 393 ThemeService::GetDefaultColor(ThemeService::COLOR_TOOLBAR_SEPARATOR)); | 393 ThemeService::GetDefaultColor(ThemeService::COLOR_TOOLBAR_SEPARATOR)); |
| 394 } | 394 } |
| 395 | 395 |
| 396 void BrowserNonClientFrameViewAura::PaintContentEdge(gfx::Canvas* canvas) { | 396 void BrowserNonClientFrameViewAsh::PaintContentEdge(gfx::Canvas* canvas) { |
| 397 canvas->FillRect(gfx::Rect(0, close_button_->bounds().bottom(), | 397 canvas->FillRect(gfx::Rect(0, close_button_->bounds().bottom(), |
| 398 width(), kClientEdgeThickness), | 398 width(), kClientEdgeThickness), |
| 399 ThemeService::GetDefaultColor(ThemeService::COLOR_TOOLBAR_SEPARATOR)); | 399 ThemeService::GetDefaultColor(ThemeService::COLOR_TOOLBAR_SEPARATOR)); |
| 400 } | 400 } |
| 401 | 401 |
| 402 int BrowserNonClientFrameViewAura::GetThemeFrameBitmapId() const { | 402 int BrowserNonClientFrameViewAsh::GetThemeFrameBitmapId() const { |
| 403 bool is_incognito = browser_view()->IsOffTheRecord(); | 403 bool is_incognito = browser_view()->IsOffTheRecord(); |
| 404 int resource_id; | 404 int resource_id; |
| 405 if (browser_view()->IsBrowserTypeNormal()) { | 405 if (browser_view()->IsBrowserTypeNormal()) { |
| 406 ui::ThemeProvider* tp = GetThemeProvider(); | 406 ui::ThemeProvider* tp = GetThemeProvider(); |
| 407 if (ShouldPaintAsActive()) { | 407 if (ShouldPaintAsActive()) { |
| 408 // Use the standard resource ids to allow users to theme the frames. | 408 // Use the standard resource ids to allow users to theme the frames. |
| 409 // TODO(jamescook): If this becomes the only frame we use on Aura, define | 409 // TODO(jamescook): If this becomes the only frame we use on Aura, define |
| 410 // the resources to use the standard ids like IDR_THEME_FRAME, etc. | 410 // the resources to use the standard ids like IDR_THEME_FRAME, etc. |
| 411 if (is_incognito) { | 411 if (is_incognito) { |
| 412 return tp->HasCustomImage(IDR_THEME_FRAME_INCOGNITO) ? | 412 return tp->HasCustomImage(IDR_THEME_FRAME_INCOGNITO) ? |
| (...skipping 20 matching lines...) Expand all Loading... |
| 433 IDR_AURA_WINDOW_HEADER_BASE_ACTIVE; | 433 IDR_AURA_WINDOW_HEADER_BASE_ACTIVE; |
| 434 } else { | 434 } else { |
| 435 resource_id = is_incognito ? | 435 resource_id = is_incognito ? |
| 436 IDR_AURA_WINDOW_HEADER_BASE_INCOGNITO_INACTIVE : | 436 IDR_AURA_WINDOW_HEADER_BASE_INCOGNITO_INACTIVE : |
| 437 IDR_AURA_WINDOW_HEADER_BASE_INACTIVE; | 437 IDR_AURA_WINDOW_HEADER_BASE_INACTIVE; |
| 438 } | 438 } |
| 439 return resource_id; | 439 return resource_id; |
| 440 } | 440 } |
| 441 | 441 |
| 442 const SkBitmap* | 442 const SkBitmap* |
| 443 BrowserNonClientFrameViewAura::GetThemeFrameOverlayBitmap() const { | 443 BrowserNonClientFrameViewAsh::GetThemeFrameOverlayBitmap() const { |
| 444 ui::ThemeProvider* tp = GetThemeProvider(); | 444 ui::ThemeProvider* tp = GetThemeProvider(); |
| 445 if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) && | 445 if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) && |
| 446 browser_view()->IsBrowserTypeNormal() && | 446 browser_view()->IsBrowserTypeNormal() && |
| 447 !browser_view()->IsOffTheRecord()) { | 447 !browser_view()->IsOffTheRecord()) { |
| 448 return tp->GetBitmapNamed(ShouldPaintAsActive() ? | 448 return tp->GetBitmapNamed(ShouldPaintAsActive() ? |
| 449 IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE); | 449 IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE); |
| 450 } | 450 } |
| 451 return NULL; | 451 return NULL; |
| 452 } | 452 } |
| OLD | NEW |