Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: chrome/browser/ui/views/frame/opaque_browser_frame_view.cc

Issue 7015051: Re-land: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/prefs/pref_service.h" 10 #include "chrome/browser/prefs/pref_service.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 minimize_button_(new views::ImageButton(this))), 131 minimize_button_(new views::ImageButton(this))),
132 ALLOW_THIS_IN_INITIALIZER_LIST( 132 ALLOW_THIS_IN_INITIALIZER_LIST(
133 maximize_button_(new views::ImageButton(this))), 133 maximize_button_(new views::ImageButton(this))),
134 ALLOW_THIS_IN_INITIALIZER_LIST( 134 ALLOW_THIS_IN_INITIALIZER_LIST(
135 restore_button_(new views::ImageButton(this))), 135 restore_button_(new views::ImageButton(this))),
136 ALLOW_THIS_IN_INITIALIZER_LIST( 136 ALLOW_THIS_IN_INITIALIZER_LIST(
137 close_button_(new views::ImageButton(this))), 137 close_button_(new views::ImageButton(this))),
138 window_icon_(NULL), 138 window_icon_(NULL),
139 frame_(frame), 139 frame_(frame),
140 browser_view_(browser_view) { 140 browser_view_(browser_view) {
141 ui::ThemeProvider* tp = frame_->GetThemeProviderForFrame(); 141 ui::ThemeProvider* tp = frame_->GetThemeProvider();
142 SkColor color = tp->GetColor(ThemeService::COLOR_BUTTON_BACKGROUND); 142 SkColor color = tp->GetColor(ThemeService::COLOR_BUTTON_BACKGROUND);
143 SkBitmap* background = 143 SkBitmap* background =
144 tp->GetBitmapNamed(IDR_THEME_WINDOW_CONTROL_BACKGROUND); 144 tp->GetBitmapNamed(IDR_THEME_WINDOW_CONTROL_BACKGROUND);
145 minimize_button_->SetImage(views::CustomButton::BS_NORMAL, 145 minimize_button_->SetImage(views::CustomButton::BS_NORMAL,
146 tp->GetBitmapNamed(IDR_MINIMIZE)); 146 tp->GetBitmapNamed(IDR_MINIMIZE));
147 minimize_button_->SetImage(views::CustomButton::BS_HOT, 147 minimize_button_->SetImage(views::CustomButton::BS_HOT,
148 tp->GetBitmapNamed(IDR_MINIMIZE_H)); 148 tp->GetBitmapNamed(IDR_MINIMIZE_H));
149 minimize_button_->SetImage(views::CustomButton::BS_PUSHED, 149 minimize_button_->SetImage(views::CustomButton::BS_PUSHED,
150 tp->GetBitmapNamed(IDR_MINIMIZE_P)); 150 tp->GetBitmapNamed(IDR_MINIMIZE_P));
151 if (browser_view_->IsBrowserTypeNormal()) { 151 if (browser_view_->IsBrowserTypeNormal()) {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 return gfx::Rect( 236 return gfx::Rect(
237 client_view_bounds.x(), 237 client_view_bounds.x(),
238 client_view_bounds.y() + client_view_bounds.height(), 238 client_view_bounds.y() + client_view_bounds.height(),
239 client_view_bounds.width(), 239 client_view_bounds.width(),
240 GetReservedHeight()); 240 GetReservedHeight());
241 } 241 }
242 242
243 int OpaqueBrowserFrameView::NonClientTopBorderHeight( 243 int OpaqueBrowserFrameView::NonClientTopBorderHeight(
244 bool restored, 244 bool restored,
245 bool ignore_vertical_tabs) const { 245 bool ignore_vertical_tabs) const {
246 views::Window* window = frame_->GetWindow(); 246 views::WindowDelegate* delegate = frame_->window_delegate();
247 views::WindowDelegate* delegate = window->window_delegate();
248 // |delegate| may be NULL if called from callback of InputMethodChanged while 247 // |delegate| may be NULL if called from callback of InputMethodChanged while
249 // a window is being destroyed. 248 // a window is being destroyed.
250 // See more discussion at http://crosbug.com/8958 249 // See more discussion at http://crosbug.com/8958
251 if ((delegate && delegate->ShouldShowWindowTitle()) || 250 if ((delegate && delegate->ShouldShowWindowTitle()) ||
252 (browser_view_->IsTabStripVisible() && !ignore_vertical_tabs && 251 (browser_view_->IsTabStripVisible() && !ignore_vertical_tabs &&
253 browser_view_->UseVerticalTabs())) { 252 browser_view_->UseVerticalTabs())) {
254 return std::max(FrameBorderThickness(restored) + IconSize(), 253 return std::max(FrameBorderThickness(restored) + IconSize(),
255 CaptionButtonY(restored) + kCaptionButtonHeightWithPadding) + 254 CaptionButtonY(restored) + kCaptionButtonHeightWithPadding) +
256 TitlebarBottomThickness(restored); 255 TitlebarBottomThickness(restored);
257 } 256 }
258 257
259 return FrameBorderThickness(restored) - 258 return FrameBorderThickness(restored) -
260 ((browser_view_->IsTabStripVisible() && !restored && 259 ((browser_view_->IsTabStripVisible() && !restored &&
261 window->IsMaximized()) ? kTabstripTopShadowThickness : 0); 260 frame_->IsMaximized()) ? kTabstripTopShadowThickness : 0);
262 } 261 }
263 262
264 /////////////////////////////////////////////////////////////////////////////// 263 ///////////////////////////////////////////////////////////////////////////////
265 // OpaqueBrowserFrameView, BrowserNonClientFrameView implementation: 264 // OpaqueBrowserFrameView, BrowserNonClientFrameView implementation:
266 265
267 gfx::Rect OpaqueBrowserFrameView::GetBoundsForTabStrip( 266 gfx::Rect OpaqueBrowserFrameView::GetBoundsForTabStrip(
268 views::View* tabstrip) const { 267 views::View* tabstrip) const {
269 if (!tabstrip) { 268 if (!tabstrip) {
270 return gfx::Rect(); 269 return gfx::Rect();
271 } 270 }
272 271
273 if (browser_view_->UseVerticalTabs()) { 272 if (browser_view_->UseVerticalTabs()) {
274 gfx::Size ps = tabstrip->GetPreferredSize(); 273 gfx::Size ps = tabstrip->GetPreferredSize();
275 return gfx::Rect(NonClientBorderThickness(), 274 return gfx::Rect(NonClientBorderThickness(),
276 NonClientTopBorderHeight(false, false), ps.width(), 275 NonClientTopBorderHeight(false, false), ps.width(),
277 browser_view_->height()); 276 browser_view_->height());
278 } 277 }
279 278
280 int tabstrip_x = browser_view_->ShouldShowOffTheRecordAvatar() ? 279 int tabstrip_x = browser_view_->ShouldShowOffTheRecordAvatar() ?
281 (otr_avatar_bounds_.right() + kOTRSideSpacing) : 280 (otr_avatar_bounds_.right() + kOTRSideSpacing) :
282 NonClientBorderThickness() + kTabStripIndent; 281 NonClientBorderThickness() + kTabStripIndent;
283 282
284 int maximized_spacing = 283 int maximized_spacing =
285 kNewTabCaptionMaximizedSpacing + 284 kNewTabCaptionMaximizedSpacing +
286 (show_profile_button() && profile_button_->IsVisible() ? 285 (show_profile_button() && profile_button_->IsVisible() ?
287 profile_button_->GetPreferredSize().width() + 286 profile_button_->GetPreferredSize().width() +
288 ProfileMenuButton::kProfileTagHorizontalSpacing : 0); 287 ProfileMenuButton::kProfileTagHorizontalSpacing : 0);
289 int tabstrip_width = minimize_button_->x() - tabstrip_x - 288 int tabstrip_width = minimize_button_->x() - tabstrip_x -
290 (frame_->GetWindow()->IsMaximized() ? 289 (frame_->IsMaximized() ?
291 maximized_spacing : kNewTabCaptionRestoredSpacing); 290 maximized_spacing : kNewTabCaptionRestoredSpacing);
292 int tabstrip_height = 0; 291 int tabstrip_height = 0;
293 if (tabstrip) 292 if (tabstrip)
294 tabstrip_height = tabstrip->GetPreferredSize().height(); 293 tabstrip_height = tabstrip->GetPreferredSize().height();
295 return gfx::Rect(tabstrip_x, GetHorizontalTabStripVerticalOffset(false), 294 return gfx::Rect(tabstrip_x, GetHorizontalTabStripVerticalOffset(false),
296 std::max(0, tabstrip_width), tabstrip_height); 295 std::max(0, tabstrip_width), tabstrip_height);
297 } 296 }
298 297
299 int OpaqueBrowserFrameView::GetHorizontalTabStripVerticalOffset( 298 int OpaqueBrowserFrameView::GetHorizontalTabStripVerticalOffset(
300 bool restored) const { 299 bool restored) const {
301 return NonClientTopBorderHeight(restored, true) + ((!restored && 300 return NonClientTopBorderHeight(restored, true) + ((!restored &&
302 (frame_->GetWindow()->IsMaximized() || 301 (frame_->IsMaximized() ||
303 frame_->GetWindow()->IsFullscreen())) ? 302 frame_->IsFullscreen())) ?
304 0 : kNonClientRestoredExtraThickness); 303 0 : kNonClientRestoredExtraThickness);
305 } 304 }
306 305
307 void OpaqueBrowserFrameView::UpdateThrobber(bool running) { 306 void OpaqueBrowserFrameView::UpdateThrobber(bool running) {
308 if (window_icon_) 307 if (window_icon_)
309 window_icon_->Update(); 308 window_icon_->Update();
310 } 309 }
311 310
312 gfx::Size OpaqueBrowserFrameView::GetMinimumSize() { 311 gfx::Size OpaqueBrowserFrameView::GetMinimumSize() {
313 gfx::Size min_size(browser_view_->GetMinimumSize()); 312 gfx::Size min_size(browser_view_->GetMinimumSize());
314 int border_thickness = NonClientBorderThickness(); 313 int border_thickness = NonClientBorderThickness();
315 min_size.Enlarge(2 * border_thickness, 314 min_size.Enlarge(2 * border_thickness,
316 NonClientTopBorderHeight(false, false) + border_thickness); 315 NonClientTopBorderHeight(false, false) + border_thickness);
317 316
318 views::WindowDelegate* delegate = frame_->GetWindow()->window_delegate(); 317 views::WindowDelegate* delegate = frame_->window_delegate();
319 int min_titlebar_width = (2 * FrameBorderThickness(false)) + 318 int min_titlebar_width = (2 * FrameBorderThickness(false)) +
320 kIconLeftSpacing + 319 kIconLeftSpacing +
321 (delegate && delegate->ShouldShowWindowIcon() ? 320 (delegate && delegate->ShouldShowWindowIcon() ?
322 (IconSize() + kTitleLogoSpacing) : 0); 321 (IconSize() + kTitleLogoSpacing) : 0);
323 #if !defined(OS_CHROMEOS) 322 #if !defined(OS_CHROMEOS)
324 min_titlebar_width += 323 min_titlebar_width +=
325 minimize_button_->GetMinimumSize().width() + 324 minimize_button_->GetMinimumSize().width() +
326 restore_button_->GetMinimumSize().width() + 325 restore_button_->GetMinimumSize().width() +
327 close_button_->GetMinimumSize().width(); 326 close_button_->GetMinimumSize().width();
328 #endif 327 #endif
(...skipping 24 matching lines...) Expand all
353 std::max(0, client_bounds.y() - top_height), 352 std::max(0, client_bounds.y() - top_height),
354 client_bounds.width() + (2 * border_thickness), 353 client_bounds.width() + (2 * border_thickness),
355 client_bounds.height() + top_height + border_thickness); 354 client_bounds.height() + top_height + border_thickness);
356 } 355 }
357 356
358 int OpaqueBrowserFrameView::NonClientHitTest(const gfx::Point& point) { 357 int OpaqueBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
359 if (!bounds().Contains(point)) 358 if (!bounds().Contains(point))
360 return HTNOWHERE; 359 return HTNOWHERE;
361 360
362 int frame_component = 361 int frame_component =
363 frame_->GetWindow()->client_view()->NonClientHitTest(point); 362 frame_->client_view()->NonClientHitTest(point);
364 363
365 // See if we're in the sysmenu region. We still have to check the tabstrip 364 // See if we're in the sysmenu region. We still have to check the tabstrip
366 // first so that clicks in a tab don't get treated as sysmenu clicks. 365 // first so that clicks in a tab don't get treated as sysmenu clicks.
367 gfx::Rect sysmenu_rect(IconBounds()); 366 gfx::Rect sysmenu_rect(IconBounds());
368 // In maximized mode we extend the rect to the screen corner to take advantage 367 // In maximized mode we extend the rect to the screen corner to take advantage
369 // of Fitts' Law. 368 // of Fitts' Law.
370 if (frame_->GetWindow()->IsMaximized()) 369 if (frame_->IsMaximized())
371 sysmenu_rect.SetRect(0, 0, sysmenu_rect.right(), sysmenu_rect.bottom()); 370 sysmenu_rect.SetRect(0, 0, sysmenu_rect.right(), sysmenu_rect.bottom());
372 sysmenu_rect.set_x(GetMirroredXForRect(sysmenu_rect)); 371 sysmenu_rect.set_x(GetMirroredXForRect(sysmenu_rect));
373 if (sysmenu_rect.Contains(point)) 372 if (sysmenu_rect.Contains(point))
374 return (frame_component == HTCLIENT) ? HTCLIENT : HTSYSMENU; 373 return (frame_component == HTCLIENT) ? HTCLIENT : HTSYSMENU;
375 374
376 if (frame_component != HTNOWHERE) 375 if (frame_component != HTNOWHERE)
377 return frame_component; 376 return frame_component;
378 377
379 // Then see if the point is within any of the window controls. 378 // Then see if the point is within any of the window controls.
380 if (close_button_->IsVisible() && 379 if (close_button_->IsVisible() &&
381 close_button_->GetMirroredBounds().Contains(point)) 380 close_button_->GetMirroredBounds().Contains(point))
382 return HTCLOSE; 381 return HTCLOSE;
383 if (restore_button_->IsVisible() && 382 if (restore_button_->IsVisible() &&
384 restore_button_->GetMirroredBounds().Contains(point)) 383 restore_button_->GetMirroredBounds().Contains(point))
385 return HTMAXBUTTON; 384 return HTMAXBUTTON;
386 if (maximize_button_->IsVisible() && 385 if (maximize_button_->IsVisible() &&
387 maximize_button_->GetMirroredBounds().Contains(point)) 386 maximize_button_->GetMirroredBounds().Contains(point))
388 return HTMAXBUTTON; 387 return HTMAXBUTTON;
389 if (minimize_button_->IsVisible() && 388 if (minimize_button_->IsVisible() &&
390 minimize_button_->GetMirroredBounds().Contains(point)) 389 minimize_button_->GetMirroredBounds().Contains(point))
391 return HTMINBUTTON; 390 return HTMINBUTTON;
392 391
393 // See if the point is within the profile menu button. 392 // See if the point is within the profile menu button.
394 if (show_profile_button() && profile_button_->IsVisible() && 393 if (show_profile_button() && profile_button_->IsVisible() &&
395 profile_button_->GetMirroredBounds().Contains(point)) 394 profile_button_->GetMirroredBounds().Contains(point))
396 return HTCLIENT; 395 return HTCLIENT;
397 396
398 views::WindowDelegate* delegate = frame_->GetWindow()->window_delegate(); 397 views::WindowDelegate* delegate = frame_->window_delegate();
399 if (!delegate) { 398 if (!delegate) {
400 LOG(WARNING) << "delegate is NULL, returning safe default."; 399 LOG(WARNING) << "delegate is NULL, returning safe default.";
401 return HTCAPTION; 400 return HTCAPTION;
402 } 401 }
403 int window_component = GetHTComponentForFrame(point, TopResizeHeight(), 402 int window_component = GetHTComponentForFrame(point, TopResizeHeight(),
404 NonClientBorderThickness(), kResizeAreaCornerSize, kResizeAreaCornerSize, 403 NonClientBorderThickness(), kResizeAreaCornerSize, kResizeAreaCornerSize,
405 delegate->CanResize()); 404 delegate->CanResize());
406 // Fall back to the caption if no other component matches. 405 // Fall back to the caption if no other component matches.
407 return (window_component == HTNOWHERE) ? HTCAPTION : window_component; 406 return (window_component == HTNOWHERE) ? HTCAPTION : window_component;
408 } 407 }
409 408
410 void OpaqueBrowserFrameView::GetWindowMask(const gfx::Size& size, 409 void OpaqueBrowserFrameView::GetWindowMask(const gfx::Size& size,
411 gfx::Path* window_mask) { 410 gfx::Path* window_mask) {
412 DCHECK(window_mask); 411 DCHECK(window_mask);
413 412
414 if (frame_->GetWindow()->IsMaximized() || frame_->GetWindow()->IsFullscreen()) 413 if (frame_->IsMaximized() || frame_->IsFullscreen())
415 return; 414 return;
416 415
417 views::GetDefaultWindowMask(size, window_mask); 416 views::GetDefaultWindowMask(size, window_mask);
418 } 417 }
419 418
420 void OpaqueBrowserFrameView::EnableClose(bool enable) { 419 void OpaqueBrowserFrameView::EnableClose(bool enable) {
421 close_button_->SetEnabled(enable); 420 close_button_->SetEnabled(enable);
422 } 421 }
423 422
424 void OpaqueBrowserFrameView::ResetWindowControls() { 423 void OpaqueBrowserFrameView::ResetWindowControls() {
(...skipping 15 matching lines...) Expand all
440 profile_menu_model_.reset(new ProfileMenuModel); 439 profile_menu_model_.reset(new ProfileMenuModel);
441 gfx::Point menu_point(pt.x(), 440 gfx::Point menu_point(pt.x(),
442 pt.y() + kMenuDisplayOffset); 441 pt.y() + kMenuDisplayOffset);
443 profile_menu_model_->RunMenuAt(menu_point); 442 profile_menu_model_->RunMenuAt(menu_point);
444 } 443 }
445 444
446 /////////////////////////////////////////////////////////////////////////////// 445 ///////////////////////////////////////////////////////////////////////////////
447 // OpaqueBrowserFrameView, views::View overrides: 446 // OpaqueBrowserFrameView, views::View overrides:
448 447
449 void OpaqueBrowserFrameView::OnPaint(gfx::Canvas* canvas) { 448 void OpaqueBrowserFrameView::OnPaint(gfx::Canvas* canvas) {
450 views::Window* window = frame_->GetWindow(); 449 if (frame_->IsFullscreen())
451 if (window->IsFullscreen())
452 return; // Nothing is visible, so don't bother to paint. 450 return; // Nothing is visible, so don't bother to paint.
453 451
454 if (window->IsMaximized()) 452 if (frame_->IsMaximized())
455 PaintMaximizedFrameBorder(canvas); 453 PaintMaximizedFrameBorder(canvas);
456 else 454 else
457 PaintRestoredFrameBorder(canvas); 455 PaintRestoredFrameBorder(canvas);
458 PaintTitleBar(canvas); 456 PaintTitleBar(canvas);
459 if (browser_view_->IsToolbarVisible() || 457 if (browser_view_->IsToolbarVisible() ||
460 browser_view_->UseCompactNavigationBar()) 458 browser_view_->UseCompactNavigationBar())
461 PaintToolbarBackground(canvas); 459 PaintToolbarBackground(canvas);
462 if (browser_view_->ShouldShowOffTheRecordAvatar()) 460 if (browser_view_->ShouldShowOffTheRecordAvatar())
463 PaintOTRAvatar(canvas); 461 PaintOTRAvatar(canvas);
464 if (!window->IsMaximized()) 462 if (!frame_->IsMaximized())
465 PaintRestoredClientEdge(canvas); 463 PaintRestoredClientEdge(canvas);
466 } 464 }
467 465
468 void OpaqueBrowserFrameView::Layout() { 466 void OpaqueBrowserFrameView::Layout() {
469 LayoutWindowControls(); 467 LayoutWindowControls();
470 LayoutTitleBar(); 468 LayoutTitleBar();
471 LayoutOTRAvatar(); 469 LayoutOTRAvatar();
472 LayoutProfileTag(); 470 LayoutProfileTag();
473 client_view_bounds_ = CalculateClientAreaBounds(width(), height()); 471 client_view_bounds_ = CalculateClientAreaBounds(width(), height());
474 } 472 }
475 473
476 bool OpaqueBrowserFrameView::HitTest(const gfx::Point& l) const { 474 bool OpaqueBrowserFrameView::HitTest(const gfx::Point& l) const {
477 // If the point is outside the bounds of the client area, claim it. 475 // If the point is outside the bounds of the client area, claim it.
478 bool in_nonclient = NonClientFrameView::HitTest(l); 476 bool in_nonclient = NonClientFrameView::HitTest(l);
479 if (in_nonclient) 477 if (in_nonclient)
480 return in_nonclient; 478 return in_nonclient;
481 479
482 // Otherwise claim it only if it's in a non-tab portion of the tabstrip. 480 // Otherwise claim it only if it's in a non-tab portion of the tabstrip.
483 bool vertical_tabs = browser_view_->UseVerticalTabs(); 481 bool vertical_tabs = browser_view_->UseVerticalTabs();
484 gfx::Rect tabstrip_bounds = GetBoundsForTabStrip(browser_view_->tabstrip()); 482 gfx::Rect tabstrip_bounds = GetBoundsForTabStrip(browser_view_->tabstrip());
485 gfx::Point tabstrip_origin(tabstrip_bounds.origin()); 483 gfx::Point tabstrip_origin(tabstrip_bounds.origin());
486 View::ConvertPointToView(frame_->GetWindow()->client_view(), 484 View::ConvertPointToView(frame_->client_view(), this, &tabstrip_origin);
487 this, &tabstrip_origin);
488 tabstrip_bounds.set_origin(tabstrip_origin); 485 tabstrip_bounds.set_origin(tabstrip_origin);
489 if ((!vertical_tabs && l.y() > tabstrip_bounds.bottom()) || 486 if ((!vertical_tabs && l.y() > tabstrip_bounds.bottom()) ||
490 (vertical_tabs && l.x() > tabstrip_bounds.right())) { 487 (vertical_tabs && l.x() > tabstrip_bounds.right())) {
491 return false; 488 return false;
492 } 489 }
493 490
494 // Claim it only if we're also not in the compact navigation buttons. 491 // Claim it only if we're also not in the compact navigation buttons.
495 if (browser_view_->UseCompactNavigationBar()) { 492 if (browser_view_->UseCompactNavigationBar()) {
496 if (ConvertedContainsCheck(browser_view_->GetCompactNavigationBarBounds(), 493 if (ConvertedContainsCheck(browser_view_->GetCompactNavigationBarBounds(),
497 frame_->GetWindow()->client_view(), 494 frame_->client_view(),
498 static_cast<const View*>(this), 495 static_cast<const View*>(this),
499 l)) { 496 l)) {
500 return false; 497 return false;
501 } 498 }
502 if (ConvertedContainsCheck(browser_view_->GetCompactOptionsBarBounds(), 499 if (ConvertedContainsCheck(browser_view_->GetCompactOptionsBarBounds(),
503 frame_->GetWindow()->client_view(), 500 frame_->client_view(),
504 static_cast<const View*>(this), 501 static_cast<const View*>(this),
505 l)) { 502 l)) {
506 return false; 503 return false;
507 } 504 }
508 } 505 }
509 506
510 // We convert from our parent's coordinates since we assume we fill its bounds 507 // We convert from our parent's coordinates since we assume we fill its bounds
511 // completely. We need to do this since we're not a parent of the tabstrip, 508 // completely. We need to do this since we're not a parent of the tabstrip,
512 // meaning ConvertPointToView would otherwise return something bogus. 509 // meaning ConvertPointToView would otherwise return something bogus.
513 gfx::Point browser_view_point(l); 510 gfx::Point browser_view_point(l);
514 View::ConvertPointToView(parent(), browser_view_, &browser_view_point); 511 View::ConvertPointToView(parent(), browser_view_, &browser_view_point);
515 return browser_view_->IsPositionInWindowCaption(browser_view_point); 512 return browser_view_->IsPositionInWindowCaption(browser_view_point);
516 } 513 }
517 514
518 void OpaqueBrowserFrameView::GetAccessibleState( 515 void OpaqueBrowserFrameView::GetAccessibleState(
519 ui::AccessibleViewState* state) { 516 ui::AccessibleViewState* state) {
520 state->role = ui::AccessibilityTypes::ROLE_TITLEBAR; 517 state->role = ui::AccessibilityTypes::ROLE_TITLEBAR;
521 } 518 }
522 519
523 /////////////////////////////////////////////////////////////////////////////// 520 ///////////////////////////////////////////////////////////////////////////////
524 // OpaqueBrowserFrameView, views::ButtonListener implementation: 521 // OpaqueBrowserFrameView, views::ButtonListener implementation:
525 522
526 void OpaqueBrowserFrameView::ButtonPressed(views::Button* sender, 523 void OpaqueBrowserFrameView::ButtonPressed(views::Button* sender,
527 const views::Event& event) { 524 const views::Event& event) {
528 views::Window* window = frame_->GetWindow();
529 if (sender == minimize_button_) 525 if (sender == minimize_button_)
530 window->Minimize(); 526 frame_->Minimize();
531 else if (sender == maximize_button_) 527 else if (sender == maximize_button_)
532 window->Maximize(); 528 frame_->Maximize();
533 else if (sender == restore_button_) 529 else if (sender == restore_button_)
534 window->Restore(); 530 frame_->Restore();
535 else if (sender == close_button_) 531 else if (sender == close_button_)
536 window->CloseWindow(); 532 frame_->Close();
537 } 533 }
538 534
539 /////////////////////////////////////////////////////////////////////////////// 535 ///////////////////////////////////////////////////////////////////////////////
540 // OpaqueBrowserFrameView, TabIconView::TabContentsProvider implementation: 536 // OpaqueBrowserFrameView, TabIconView::TabContentsProvider implementation:
541 537
542 bool OpaqueBrowserFrameView::ShouldTabIconViewAnimate() const { 538 bool OpaqueBrowserFrameView::ShouldTabIconViewAnimate() const {
543 // This function is queried during the creation of the window as the 539 // This function is queried during the creation of the window as the
544 // TabIconView we host is initialized, so we need to NULL check the selected 540 // TabIconView we host is initialized, so we need to NULL check the selected
545 // TabContents because in this condition there is not yet a selected tab. 541 // TabContents because in this condition there is not yet a selected tab.
546 TabContents* current_tab = browser_view_->GetSelectedTabContents(); 542 TabContents* current_tab = browser_view_->GetSelectedTabContents();
547 return current_tab ? current_tab->is_loading() : false; 543 return current_tab ? current_tab->is_loading() : false;
548 } 544 }
549 545
550 SkBitmap OpaqueBrowserFrameView::GetFaviconForTabIconView() { 546 SkBitmap OpaqueBrowserFrameView::GetFaviconForTabIconView() {
551 views::WindowDelegate* delegate = frame_->GetWindow()->window_delegate(); 547 views::WindowDelegate* delegate = frame_->window_delegate();
552 if (!delegate) { 548 if (!delegate) {
553 LOG(WARNING) << "delegate is NULL, returning safe default."; 549 LOG(WARNING) << "delegate is NULL, returning safe default.";
554 return SkBitmap(); 550 return SkBitmap();
555 } 551 }
556 return delegate->GetWindowIcon(); 552 return delegate->GetWindowIcon();
557 } 553 }
558 554
559 /////////////////////////////////////////////////////////////////////////////// 555 ///////////////////////////////////////////////////////////////////////////////
560 // OpaqueBrowserFrameView, protected: 556 // OpaqueBrowserFrameView, protected:
561 557
562 void OpaqueBrowserFrameView::Observe(NotificationType type, 558 void OpaqueBrowserFrameView::Observe(NotificationType type,
563 const NotificationSource& source, 559 const NotificationSource& source,
564 const NotificationDetails& details) { 560 const NotificationDetails& details) {
565 DCHECK_EQ(NotificationType::PREF_CHANGED, type.value); 561 DCHECK_EQ(NotificationType::PREF_CHANGED, type.value);
566 std::string* name = Details<std::string>(details).ptr(); 562 std::string* name = Details<std::string>(details).ptr();
567 if (prefs::kGoogleServicesUsername == *name) 563 if (prefs::kGoogleServicesUsername == *name)
568 LayoutProfileTag(); 564 LayoutProfileTag();
569 } 565 }
570 566
571 /////////////////////////////////////////////////////////////////////////////// 567 ///////////////////////////////////////////////////////////////////////////////
572 // OpaqueBrowserFrameView, private: 568 // OpaqueBrowserFrameView, private:
573 569
574 int OpaqueBrowserFrameView::FrameBorderThickness(bool restored) const { 570 int OpaqueBrowserFrameView::FrameBorderThickness(bool restored) const {
575 views::Window* window = frame_->GetWindow(); 571 return (!restored && (frame_->IsMaximized() || frame_->IsFullscreen())) ?
576 return (!restored && (window->IsMaximized() || window->IsFullscreen())) ?
577 0 : kFrameBorderThickness; 572 0 : kFrameBorderThickness;
578 } 573 }
579 574
580 int OpaqueBrowserFrameView::TopResizeHeight() const { 575 int OpaqueBrowserFrameView::TopResizeHeight() const {
581 return FrameBorderThickness(false) - kTopResizeAdjust; 576 return FrameBorderThickness(false) - kTopResizeAdjust;
582 } 577 }
583 578
584 int OpaqueBrowserFrameView::NonClientBorderThickness() const { 579 int OpaqueBrowserFrameView::NonClientBorderThickness() const {
585 // When we fill the screen, we don't show a client edge. 580 // When we fill the screen, we don't show a client edge.
586 views::Window* window = frame_->GetWindow();
587 return FrameBorderThickness(false) + 581 return FrameBorderThickness(false) +
588 ((window->IsMaximized() || window->IsFullscreen()) ? 582 ((frame_->IsMaximized() || frame_->IsFullscreen()) ?
589 0 : kClientEdgeThickness); 583 0 : kClientEdgeThickness);
590 } 584 }
591 585
592 void OpaqueBrowserFrameView::ModifyMaximizedFramePainting( 586 void OpaqueBrowserFrameView::ModifyMaximizedFramePainting(
593 int* theme_offset, SkBitmap** left_corner, SkBitmap** right_corner) { 587 int* theme_offset, SkBitmap** left_corner, SkBitmap** right_corner) {
594 } 588 }
595 589
596 int OpaqueBrowserFrameView::CaptionButtonY(bool restored) const { 590 int OpaqueBrowserFrameView::CaptionButtonY(bool restored) const {
597 // Maximized buttons start at window top so that even if their images aren't 591 // Maximized buttons start at window top so that even if their images aren't
598 // drawn flush with the screen edge, they still obey Fitts' Law. 592 // drawn flush with the screen edge, they still obey Fitts' Law.
599 return (!restored && frame_->GetWindow()->IsMaximized()) ? 593 return (!restored && frame_->IsMaximized()) ?
600 FrameBorderThickness(false) : kFrameShadowThickness; 594 FrameBorderThickness(false) : kFrameShadowThickness;
601 } 595 }
602 596
603 int OpaqueBrowserFrameView::TitlebarBottomThickness(bool restored) const { 597 int OpaqueBrowserFrameView::TitlebarBottomThickness(bool restored) const {
604 return kTitlebarTopAndBottomEdgeThickness + 598 return kTitlebarTopAndBottomEdgeThickness +
605 ((!restored && frame_->GetWindow()->IsMaximized()) ? 599 ((!restored && frame_->IsMaximized()) ? 0 : kClientEdgeThickness);
606 0 : kClientEdgeThickness);
607 } 600 }
608 601
609 int OpaqueBrowserFrameView::IconSize() const { 602 int OpaqueBrowserFrameView::IconSize() const {
610 #if defined(OS_WIN) 603 #if defined(OS_WIN)
611 // This metric scales up if either the titlebar height or the titlebar font 604 // This metric scales up if either the titlebar height or the titlebar font
612 // size are increased. 605 // size are increased.
613 return GetSystemMetrics(SM_CYSMICON); 606 return GetSystemMetrics(SM_CYSMICON);
614 #else 607 #else
615 return std::max(BrowserFrame::GetTitleFont().GetHeight(), kIconMinimumSize); 608 return std::max(BrowserFrame::GetTitleFont().GetHeight(), kIconMinimumSize);
616 #endif 609 #endif
617 } 610 }
618 611
619 gfx::Rect OpaqueBrowserFrameView::IconBounds() const { 612 gfx::Rect OpaqueBrowserFrameView::IconBounds() const {
620 int size = IconSize(); 613 int size = IconSize();
621 int frame_thickness = FrameBorderThickness(false); 614 int frame_thickness = FrameBorderThickness(false);
622 int y; 615 int y;
623 views::WindowDelegate* delegate = frame_->GetWindow()->window_delegate(); 616 views::WindowDelegate* delegate = frame_->window_delegate();
624 if (delegate && (delegate->ShouldShowWindowIcon() || 617 if (delegate && (delegate->ShouldShowWindowIcon() ||
625 delegate->ShouldShowWindowTitle())) { 618 delegate->ShouldShowWindowTitle())) {
626 // Our frame border has a different "3D look" than Windows'. Theirs has a 619 // Our frame border has a different "3D look" than Windows'. Theirs has a
627 // more complex gradient on the top that they push their icon/title below; 620 // more complex gradient on the top that they push their icon/title below;
628 // then the maximized window cuts this off and the icon/title are centered 621 // then the maximized window cuts this off and the icon/title are centered
629 // in the remaining space. Because the apparent shape of our border is 622 // in the remaining space. Because the apparent shape of our border is
630 // simpler, using the same positioning makes things look slightly uncentered 623 // simpler, using the same positioning makes things look slightly uncentered
631 // with restored windows, so when the window is restored, instead of 624 // with restored windows, so when the window is restored, instead of
632 // calculating the remaining space from below the frame border, we calculate 625 // calculating the remaining space from below the frame border, we calculate
633 // from below the 3D edge. 626 // from below the 3D edge.
634 int unavailable_px_at_top = frame_->GetWindow()->IsMaximized() ? 627 int unavailable_px_at_top = frame_->IsMaximized() ?
635 frame_thickness : kTitlebarTopAndBottomEdgeThickness; 628 frame_thickness : kTitlebarTopAndBottomEdgeThickness;
636 // When the icon is shorter than the minimum space we reserve for the 629 // When the icon is shorter than the minimum space we reserve for the
637 // caption button, we vertically center it. We want to bias rounding to put 630 // caption button, we vertically center it. We want to bias rounding to put
638 // extra space above the icon, since the 3D edge (+ client edge, for 631 // extra space above the icon, since the 3D edge (+ client edge, for
639 // restored windows) below looks (to the eye) more like additional space 632 // restored windows) below looks (to the eye) more like additional space
640 // than does the 3D edge (or nothing at all, for maximized windows) above; 633 // than does the 3D edge (or nothing at all, for maximized windows) above;
641 // hence the +1. 634 // hence the +1.
642 y = unavailable_px_at_top + (NonClientTopBorderHeight(false, false) - 635 y = unavailable_px_at_top + (NonClientTopBorderHeight(false, false) -
643 unavailable_px_at_top - size - TitlebarBottomThickness(false) + 1) / 2; 636 unavailable_px_at_top - size - TitlebarBottomThickness(false) + 1) / 2;
644 } else { 637 } else {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 canvas->DrawBitmapInt(*bottom_left_corner, 0, 754 canvas->DrawBitmapInt(*bottom_left_corner, 0,
762 height() - bottom_left_corner->height()); 755 height() - bottom_left_corner->height());
763 756
764 // Left. 757 // Left.
765 canvas->TileImageInt(*left_edge, 0, top_left_height, left_edge->width(), 758 canvas->TileImageInt(*left_edge, 0, top_left_height, left_edge->width(),
766 height() - top_left_height - bottom_left_corner->height()); 759 height() - top_left_height - bottom_left_corner->height());
767 } 760 }
768 761
769 void OpaqueBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) { 762 void OpaqueBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) {
770 ui::ThemeProvider* tp = GetThemeProvider(); 763 ui::ThemeProvider* tp = GetThemeProvider();
771 views::Window* window = frame_->GetWindow();
772
773 // Window frame mode and color 764 // Window frame mode and color
774 SkBitmap* theme_frame; 765 SkBitmap* theme_frame;
775 766
776 // Allow customization of these attributes. 767 // Allow customization of these attributes.
777 SkBitmap* left = NULL; 768 SkBitmap* left = NULL;
778 SkBitmap* right = NULL; 769 SkBitmap* right = NULL;
779 int top_offset = 0; 770 int top_offset = 0;
780 ModifyMaximizedFramePainting(&top_offset, &left, &right); 771 ModifyMaximizedFramePainting(&top_offset, &left, &right);
781 772
782 // Never theme app and popup windows. 773 // Never theme app and popup windows.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 } 812 }
822 813
823 if (!browser_view_->IsToolbarVisible()) { 814 if (!browser_view_->IsToolbarVisible()) {
824 // There's no toolbar to edge the frame border, so we need to draw a bottom 815 // There's no toolbar to edge the frame border, so we need to draw a bottom
825 // edge. The graphic we use for this has a built in client edge, so we clip 816 // edge. The graphic we use for this has a built in client edge, so we clip
826 // it off the bottom. 817 // it off the bottom.
827 SkBitmap* top_center = 818 SkBitmap* top_center =
828 tp->GetBitmapNamed(IDR_APP_TOP_CENTER); 819 tp->GetBitmapNamed(IDR_APP_TOP_CENTER);
829 int edge_height = top_center->height() - kClientEdgeThickness; 820 int edge_height = top_center->height() - kClientEdgeThickness;
830 canvas->TileImageInt(*top_center, 0, 821 canvas->TileImageInt(*top_center, 0,
831 window->client_view()->y() - edge_height, width(), edge_height); 822 frame_->client_view()->y() - edge_height, width(), edge_height);
832 } 823 }
833 } 824 }
834 825
835 void OpaqueBrowserFrameView::PaintTitleBar(gfx::Canvas* canvas) { 826 void OpaqueBrowserFrameView::PaintTitleBar(gfx::Canvas* canvas) {
836 // The window icon is painted by the TabIconView. 827 // The window icon is painted by the TabIconView.
837 views::WindowDelegate* delegate = frame_->GetWindow()->window_delegate(); 828 views::WindowDelegate* delegate = frame_->window_delegate();
838 if (!delegate) { 829 if (!delegate) {
839 LOG(WARNING) << "delegate is NULL"; 830 LOG(WARNING) << "delegate is NULL";
840 return; 831 return;
841 } 832 }
842 if (delegate->ShouldShowWindowTitle()) { 833 if (delegate->ShouldShowWindowTitle()) {
843 canvas->DrawStringInt(WideToUTF16Hack(delegate->GetWindowTitle()), 834 canvas->DrawStringInt(WideToUTF16Hack(delegate->GetWindowTitle()),
844 BrowserFrame::GetTitleFont(), 835 BrowserFrame::GetTitleFont(),
845 SK_ColorWHITE, GetMirroredXForRect(title_bounds_), 836 SK_ColorWHITE, GetMirroredXForRect(title_bounds_),
846 title_bounds_.y(), title_bounds_.width(), title_bounds_.height()); 837 title_bounds_.y(), title_bounds_.width(), title_bounds_.height());
847 /* TODO(pkasting): If this window is active, we should also draw a drop 838 /* TODO(pkasting): If this window is active, we should also draw a drop
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
979 // as the shadows at the image top mean the apparent center is below the 970 // as the shadows at the image top mean the apparent center is below the
980 // real center. 971 // real center.
981 ((otr_avatar_icon.height() - otr_avatar_bounds_.height()) + 1) / 2, w, h, 972 ((otr_avatar_icon.height() - otr_avatar_bounds_.height()) + 1) / 2, w, h,
982 otr_avatar_bounds_.x(), otr_avatar_bounds_.y(), w, h, false); 973 otr_avatar_bounds_.x(), otr_avatar_bounds_.y(), w, h, false);
983 974
984 canvas->Restore(); 975 canvas->Restore();
985 } 976 }
986 977
987 void OpaqueBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { 978 void OpaqueBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) {
988 ui::ThemeProvider* tp = GetThemeProvider(); 979 ui::ThemeProvider* tp = GetThemeProvider();
989 int client_area_top = frame_->GetWindow()->client_view()->y(); 980 int client_area_top = frame_->client_view()->y();
990 int image_top = client_area_top; 981 int image_top = client_area_top;
991 982
992 gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height()); 983 gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height());
993 SkColor toolbar_color = tp->GetColor(ThemeService::COLOR_TOOLBAR); 984 SkColor toolbar_color = tp->GetColor(ThemeService::COLOR_TOOLBAR);
994 985
995 if (browser_view_->IsToolbarVisible() || 986 if (browser_view_->IsToolbarVisible() ||
996 browser_view_->UseCompactNavigationBar()) { 987 browser_view_->UseCompactNavigationBar()) {
997 // The client edge images always start below the toolbar corner images. The 988 // The client edge images always start below the toolbar corner images. The
998 // client edge filled rects start there or at the bottom of the toolbar, 989 // client edge filled rects start there or at the bottom of the toolbar,
999 // whichever is shorter. 990 // whichever is shorter.
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1065 kClientEdgeThickness, 1056 kClientEdgeThickness,
1066 client_area_bottom + kClientEdgeThickness - client_area_top); 1057 client_area_bottom + kClientEdgeThickness - client_area_top);
1067 canvas->FillRectInt(toolbar_color, client_area_bounds.x(), client_area_bottom, 1058 canvas->FillRectInt(toolbar_color, client_area_bounds.x(), client_area_bottom,
1068 client_area_bounds.width(), kClientEdgeThickness); 1059 client_area_bounds.width(), kClientEdgeThickness);
1069 canvas->FillRectInt(toolbar_color, client_area_bounds.right(), 1060 canvas->FillRectInt(toolbar_color, client_area_bounds.right(),
1070 client_area_top, kClientEdgeThickness, 1061 client_area_top, kClientEdgeThickness,
1071 client_area_bottom + kClientEdgeThickness - client_area_top); 1062 client_area_bottom + kClientEdgeThickness - client_area_top);
1072 } 1063 }
1073 1064
1074 void OpaqueBrowserFrameView::LayoutWindowControls() { 1065 void OpaqueBrowserFrameView::LayoutWindowControls() {
1075 bool is_maximized = frame_->GetWindow()->IsMaximized(); 1066 bool is_maximized = frame_->IsMaximized();
1076 close_button_->SetImageAlignment(views::ImageButton::ALIGN_LEFT, 1067 close_button_->SetImageAlignment(views::ImageButton::ALIGN_LEFT,
1077 views::ImageButton::ALIGN_BOTTOM); 1068 views::ImageButton::ALIGN_BOTTOM);
1078 int caption_y = CaptionButtonY(false); 1069 int caption_y = CaptionButtonY(false);
1079 // There should always be the same number of non-shadow pixels visible to the 1070 // There should always be the same number of non-shadow pixels visible to the
1080 // side of the caption buttons. In maximized mode we extend the rightmost 1071 // side of the caption buttons. In maximized mode we extend the rightmost
1081 // button to the screen corner to obey Fitts' Law. 1072 // button to the screen corner to obey Fitts' Law.
1082 int right_extra_width = is_maximized ? 1073 int right_extra_width = is_maximized ?
1083 (kFrameBorderThickness - kFrameShadowThickness) : 0; 1074 (kFrameBorderThickness - kFrameShadowThickness) : 0;
1084 gfx::Size close_button_size = close_button_->GetPreferredSize(); 1075 gfx::Size close_button_size = close_button_->GetPreferredSize();
1085 close_button_->SetBounds(width() - FrameBorderThickness(false) - 1076 close_button_->SetBounds(width() - FrameBorderThickness(false) -
1086 right_extra_width - close_button_size.width(), caption_y, 1077 right_extra_width - close_button_size.width(), caption_y,
1087 close_button_size.width() + right_extra_width, 1078 close_button_size.width() + right_extra_width,
1088 close_button_size.height()); 1079 close_button_size.height());
1089 1080
1090 #if defined(OS_CHROMEOS) 1081 #if defined(OS_CHROMEOS)
1091 // LayoutWindowControls could be triggered from WindowGtk::UpdateWindowTitle, 1082 // LayoutWindowControls could be triggered from WindowGtk::UpdateWindowTitle,
1092 // which could happen when user navigates in fullscreen mode. And because 1083 // which could happen when user navigates in fullscreen mode. And because
1093 // BrowserFrameChromeos::IsMaximized return false for fullscreen mode, we 1084 // BrowserFrameChromeos::IsMaximized return false for fullscreen mode, we
1094 // explicitly test fullscreen mode here and make it use the same code path 1085 // explicitly test fullscreen mode here and make it use the same code path
1095 // as maximized mode. 1086 // as maximized mode.
1096 // TODO(oshima): Optimize the relayout logic to defer the frame view's 1087 // TODO(oshima): Optimize the relayout logic to defer the frame view's
1097 // relayout until it is necessary, i.e when it becomes visible. 1088 // relayout until it is necessary, i.e when it becomes visible.
1098 if (is_maximized || frame_->GetWindow()->IsFullscreen()) { 1089 if (is_maximized || frame_->IsFullscreen()) {
1099 minimize_button_->SetVisible(false); 1090 minimize_button_->SetVisible(false);
1100 restore_button_->SetVisible(false); 1091 restore_button_->SetVisible(false);
1101 maximize_button_->SetVisible(false); 1092 maximize_button_->SetVisible(false);
1102 1093
1103 if (browser_view_->browser()->is_devtools()) { 1094 if (browser_view_->browser()->is_devtools()) {
1104 close_button_->SetVisible(true); 1095 close_button_->SetVisible(true);
1105 minimize_button_->SetBounds(close_button_->bounds().x(), 0, 0, 0); 1096 minimize_button_->SetBounds(close_button_->bounds().x(), 0, 0, 0);
1106 } else { 1097 } else {
1107 close_button_->SetVisible(false); 1098 close_button_->SetVisible(false);
1108 // Set the bounds of the minimize button so that we don't have to change 1099 // Set the bounds of the minimize button so that we don't have to change
1109 // other places that rely on the bounds. Put it slightly to the right 1100 // other places that rely on the bounds. Put it slightly to the right
1110 // of the edge of the view, so that when we remove the spacing it lines 1101 // of the edge of the view, so that when we remove the spacing it lines
1111 // up with the edge. 1102 // up with the edge.
1112 minimize_button_->SetBounds(width() - FrameBorderThickness(false) + 1103 minimize_button_->SetBounds(width() - FrameBorderThickness(false) +
1113 kNewTabCaptionMaximizedSpacing, 0, 0, 0); 1104 kNewTabCaptionMaximizedSpacing, 0, 0, 0);
1114 } 1105 }
1115 1106
1116 return; 1107 return;
1117 } else { 1108 } else {
1118 close_button_->SetVisible(true); 1109 close_button_->SetVisible(true);
1119 } 1110 }
1120 #endif 1111 #endif
1121 1112
1122 // When the window is restored, we show a maximized button; otherwise, we show 1113 // When the window is restored, we show a maximized button; otherwise, we show
1123 // a restore button. 1114 // a restore button.
1124 bool is_restored = !is_maximized && !frame_->GetWindow()->IsMinimized(); 1115 bool is_restored = !is_maximized && !frame_->IsMinimized();
1125 views::ImageButton* invisible_button = is_restored ? 1116 views::ImageButton* invisible_button = is_restored ?
1126 restore_button_ : maximize_button_; 1117 restore_button_ : maximize_button_;
1127 invisible_button->SetVisible(false); 1118 invisible_button->SetVisible(false);
1128 1119
1129 views::ImageButton* visible_button = is_restored ? 1120 views::ImageButton* visible_button = is_restored ?
1130 maximize_button_ : restore_button_; 1121 maximize_button_ : restore_button_;
1131 visible_button->SetVisible(true); 1122 visible_button->SetVisible(true);
1132 visible_button->SetImageAlignment(views::ImageButton::ALIGN_LEFT, 1123 visible_button->SetImageAlignment(views::ImageButton::ALIGN_LEFT,
1133 views::ImageButton::ALIGN_BOTTOM); 1124 views::ImageButton::ALIGN_BOTTOM);
1134 gfx::Size visible_button_size = visible_button->GetPreferredSize(); 1125 gfx::Size visible_button_size = visible_button->GetPreferredSize();
1135 visible_button->SetBounds(close_button_->x() - visible_button_size.width(), 1126 visible_button->SetBounds(close_button_->x() - visible_button_size.width(),
1136 caption_y, visible_button_size.width(), 1127 caption_y, visible_button_size.width(),
1137 visible_button_size.height()); 1128 visible_button_size.height());
1138 1129
1139 minimize_button_->SetVisible(true); 1130 minimize_button_->SetVisible(true);
1140 minimize_button_->SetImageAlignment(views::ImageButton::ALIGN_LEFT, 1131 minimize_button_->SetImageAlignment(views::ImageButton::ALIGN_LEFT,
1141 views::ImageButton::ALIGN_BOTTOM); 1132 views::ImageButton::ALIGN_BOTTOM);
1142 gfx::Size minimize_button_size = minimize_button_->GetPreferredSize(); 1133 gfx::Size minimize_button_size = minimize_button_->GetPreferredSize();
1143 minimize_button_->SetBounds( 1134 minimize_button_->SetBounds(
1144 visible_button->x() - minimize_button_size.width(), caption_y, 1135 visible_button->x() - minimize_button_size.width(), caption_y,
1145 minimize_button_size.width(), 1136 minimize_button_size.width(),
1146 minimize_button_size.height()); 1137 minimize_button_size.height());
1147 } 1138 }
1148 1139
1149 void OpaqueBrowserFrameView::LayoutTitleBar() { 1140 void OpaqueBrowserFrameView::LayoutTitleBar() {
1150 // The window title is based on the calculated icon position, even when there 1141 // The window title is based on the calculated icon position, even when there
1151 // is no icon. 1142 // is no icon.
1152 gfx::Rect icon_bounds(IconBounds()); 1143 gfx::Rect icon_bounds(IconBounds());
1153 views::WindowDelegate* delegate = frame_->GetWindow()->window_delegate(); 1144 views::WindowDelegate* delegate = frame_->window_delegate();
1154 if (delegate && delegate->ShouldShowWindowIcon()) 1145 if (delegate && delegate->ShouldShowWindowIcon())
1155 window_icon_->SetBoundsRect(icon_bounds); 1146 window_icon_->SetBoundsRect(icon_bounds);
1156 1147
1157 // Size the title, if visible. 1148 // Size the title, if visible.
1158 if (delegate && delegate->ShouldShowWindowTitle()) { 1149 if (delegate && delegate->ShouldShowWindowTitle()) {
1159 int title_x = delegate->ShouldShowWindowIcon() ? 1150 int title_x = delegate->ShouldShowWindowIcon() ?
1160 icon_bounds.right() + kIconTitleSpacing : icon_bounds.x(); 1151 icon_bounds.right() + kIconTitleSpacing : icon_bounds.x();
1161 int title_height = BrowserFrame::GetTitleFont().GetHeight(); 1152 int title_height = BrowserFrame::GetTitleFont().GetHeight();
1162 // We bias the title position so that when the difference between the icon 1153 // We bias the title position so that when the difference between the icon
1163 // and title heights is odd, the extra pixel of the title is above the 1154 // and title heights is odd, the extra pixel of the title is above the
(...skipping 11 matching lines...) Expand all
1175 SkBitmap otr_avatar_icon = browser_view_->GetOTRAvatarIcon(); 1166 SkBitmap otr_avatar_icon = browser_view_->GetOTRAvatarIcon();
1176 int otr_bottom, otr_restored_y; 1167 int otr_bottom, otr_restored_y;
1177 if (browser_view_->UseVerticalTabs()) { 1168 if (browser_view_->UseVerticalTabs()) {
1178 otr_bottom = NonClientTopBorderHeight(false, false) - kOTRBottomSpacing; 1169 otr_bottom = NonClientTopBorderHeight(false, false) - kOTRBottomSpacing;
1179 otr_restored_y = kFrameShadowThickness; 1170 otr_restored_y = kFrameShadowThickness;
1180 } else { 1171 } else {
1181 otr_bottom = GetHorizontalTabStripVerticalOffset(false) + 1172 otr_bottom = GetHorizontalTabStripVerticalOffset(false) +
1182 browser_view_->GetTabStripHeight() - kOTRBottomSpacing; 1173 browser_view_->GetTabStripHeight() - kOTRBottomSpacing;
1183 otr_restored_y = otr_bottom - otr_avatar_icon.height(); 1174 otr_restored_y = otr_bottom - otr_avatar_icon.height();
1184 } 1175 }
1185 int otr_y = frame_->GetWindow()->IsMaximized() ? 1176 int otr_y = frame_->IsMaximized() ?
1186 (NonClientTopBorderHeight(false, true) + kTabstripTopShadowThickness) : 1177 (NonClientTopBorderHeight(false, true) + kTabstripTopShadowThickness) :
1187 otr_restored_y; 1178 otr_restored_y;
1188 otr_avatar_bounds_.SetRect(NonClientBorderThickness() + kOTRSideSpacing, 1179 otr_avatar_bounds_.SetRect(NonClientBorderThickness() + kOTRSideSpacing,
1189 otr_y, otr_avatar_icon.width(), 1180 otr_y, otr_avatar_icon.width(),
1190 browser_view_->ShouldShowOffTheRecordAvatar() ? (otr_bottom - otr_y) : 0); 1181 browser_view_->ShouldShowOffTheRecordAvatar() ? (otr_bottom - otr_y) : 0);
1191 } 1182 }
1192 1183
1193 void OpaqueBrowserFrameView::LayoutProfileTag() { 1184 void OpaqueBrowserFrameView::LayoutProfileTag() {
1194 if (!show_profile_button()) 1185 if (!show_profile_button())
1195 return; 1186 return;
(...skipping 12 matching lines...) Expand all
1208 profile_button_->SetVisible(true); 1199 profile_button_->SetVisible(true);
1209 int x_tag = 1200 int x_tag =
1210 // The x position of minimize button in the frame 1201 // The x position of minimize button in the frame
1211 minimize_button_->x() - 1202 minimize_button_->x() -
1212 // - the space between the minimize button and the profile button 1203 // - the space between the minimize button and the profile button
1213 ProfileMenuButton::kProfileTagHorizontalSpacing - 1204 ProfileMenuButton::kProfileTagHorizontalSpacing -
1214 // - the width of the profile button 1205 // - the width of the profile button
1215 profile_button_->GetPreferredSize().width(); 1206 profile_button_->GetPreferredSize().width();
1216 // Adjust for different default font sizes on different Windows platforms. 1207 // Adjust for different default font sizes on different Windows platforms.
1217 int y_tag = profile_button_->font().GetHeight() < 14 ? 2 : 0; 1208 int y_tag = profile_button_->font().GetHeight() < 14 ? 2 : 0;
1218 int y_maximized_offset = frame_->GetWindow()->IsMaximized() ? 1209 int y_maximized_offset = frame_->IsMaximized() ?
1219 kProfileElementMaximizedYOffset : 0; 1210 kProfileElementMaximizedYOffset : 0;
1220 profile_button_->SetBounds( 1211 profile_button_->SetBounds(
1221 x_tag, 1212 x_tag,
1222 y_tag + y_maximized_offset, 1213 y_tag + y_maximized_offset,
1223 profile_button_->GetPreferredSize().width(), 1214 profile_button_->GetPreferredSize().width(),
1224 profile_button_->GetPreferredSize().height()); 1215 profile_button_->GetPreferredSize().height());
1225 1216
1226 if (!profile_name.empty()) { 1217 if (!profile_name.empty()) {
1227 profile_tag_->SetVisible(true); 1218 profile_tag_->SetVisible(true);
1228 profile_tag_->SetBounds( 1219 profile_tag_->SetBounds(
(...skipping 15 matching lines...) Expand all
1244 std::max(0, width - (2 * border_thickness)), 1235 std::max(0, width - (2 * border_thickness)),
1245 std::max(0, height - GetReservedHeight() - 1236 std::max(0, height - GetReservedHeight() -
1246 top_height - border_thickness)); 1237 top_height - border_thickness));
1247 } 1238 }
1248 1239
1249 void OpaqueBrowserFrameView::RegisterLoginNotifications() { 1240 void OpaqueBrowserFrameView::RegisterLoginNotifications() {
1250 PrefService* pref_service = browser_view_->browser()->profile()->GetPrefs(); 1241 PrefService* pref_service = browser_view_->browser()->profile()->GetPrefs();
1251 DCHECK(pref_service); 1242 DCHECK(pref_service);
1252 username_pref_.Init(prefs::kGoogleServicesUsername, pref_service, this); 1243 username_pref_.Init(prefs::kGoogleServicesUsername, pref_service, this);
1253 } 1244 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/native_browser_frame.h ('k') | chrome/browser/ui/views/fullscreen_exit_bubble.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698