| 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/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 // OpaqueBrowserFrameView, TabIconView::TabContentsProvider implementation: | 409 // OpaqueBrowserFrameView, TabIconView::TabContentsProvider implementation: |
| 410 | 410 |
| 411 bool OpaqueBrowserFrameView::ShouldTabIconViewAnimate() const { | 411 bool OpaqueBrowserFrameView::ShouldTabIconViewAnimate() const { |
| 412 // This function is queried during the creation of the window as the | 412 // This function is queried during the creation of the window as the |
| 413 // TabIconView we host is initialized, so we need to NULL check the selected | 413 // TabIconView we host is initialized, so we need to NULL check the selected |
| 414 // WebContents because in this condition there is not yet a selected tab. | 414 // WebContents because in this condition there is not yet a selected tab. |
| 415 WebContents* current_tab = browser_view()->GetSelectedWebContents(); | 415 WebContents* current_tab = browser_view()->GetSelectedWebContents(); |
| 416 return current_tab ? current_tab->IsLoading() : false; | 416 return current_tab ? current_tab->IsLoading() : false; |
| 417 } | 417 } |
| 418 | 418 |
| 419 SkBitmap OpaqueBrowserFrameView::GetFaviconForTabIconView() { | 419 gfx::ImageSkia OpaqueBrowserFrameView::GetFaviconForTabIconView() { |
| 420 views::WidgetDelegate* delegate = frame()->widget_delegate(); | 420 views::WidgetDelegate* delegate = frame()->widget_delegate(); |
| 421 if (!delegate) { | 421 if (!delegate) { |
| 422 LOG(WARNING) << "delegate is NULL, returning safe default."; | 422 LOG(WARNING) << "delegate is NULL, returning safe default."; |
| 423 return SkBitmap(); | 423 return gfx::ImageSkia(); |
| 424 } | 424 } |
| 425 return delegate->GetWindowIcon(); | 425 return delegate->GetWindowIcon(); |
| 426 } | 426 } |
| 427 | 427 |
| 428 /////////////////////////////////////////////////////////////////////////////// | 428 /////////////////////////////////////////////////////////////////////////////// |
| 429 // OpaqueBrowserFrameView, protected: | 429 // OpaqueBrowserFrameView, protected: |
| 430 | 430 |
| 431 void OpaqueBrowserFrameView::Observe( | 431 void OpaqueBrowserFrameView::Observe( |
| 432 int type, | 432 int type, |
| 433 const content::NotificationSource& source, | 433 const content::NotificationSource& source, |
| 434 const content::NotificationDetails& details) { | 434 const content::NotificationDetails& details) { |
| 435 switch (type) { | 435 switch (type) { |
| 436 case chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED: | 436 case chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED: |
| 437 UpdateAvatarInfo(); | 437 UpdateAvatarInfo(); |
| 438 break; | 438 break; |
| 439 default: | 439 default: |
| 440 NOTREACHED() << "Got a notification we didn't register for!"; | 440 NOTREACHED() << "Got a notification we didn't register for!"; |
| 441 break; | 441 break; |
| 442 } | 442 } |
| 443 } | 443 } |
| 444 | 444 |
| 445 /////////////////////////////////////////////////////////////////////////////// | 445 /////////////////////////////////////////////////////////////////////////////// |
| 446 // OpaqueBrowserFrameView, private: | 446 // OpaqueBrowserFrameView, private: |
| 447 | 447 |
| 448 views::ImageButton* OpaqueBrowserFrameView::InitWindowCaptionButton( | 448 views::ImageButton* OpaqueBrowserFrameView::InitWindowCaptionButton( |
| 449 int normal_bitmap_id, | 449 int normal_image_id, |
| 450 int hot_bitmap_id, | 450 int hot_image_id, |
| 451 int pushed_bitmap_id, | 451 int pushed_image_id, |
| 452 int mask_bitmap_id, | 452 int mask_image_id, |
| 453 int accessibility_string_id) { | 453 int accessibility_string_id) { |
| 454 views::ImageButton* button = new views::ImageButton(this); | 454 views::ImageButton* button = new views::ImageButton(this); |
| 455 ui::ThemeProvider* tp = frame()->GetThemeProvider(); | 455 ui::ThemeProvider* tp = frame()->GetThemeProvider(); |
| 456 button->SetImage(views::CustomButton::BS_NORMAL, | 456 button->SetImage(views::CustomButton::BS_NORMAL, |
| 457 tp->GetImageSkiaNamed(normal_bitmap_id)); | 457 tp->GetImageSkiaNamed(normal_image_id)); |
| 458 button->SetImage(views::CustomButton::BS_HOT, | 458 button->SetImage(views::CustomButton::BS_HOT, |
| 459 tp->GetImageSkiaNamed(hot_bitmap_id)); | 459 tp->GetImageSkiaNamed(hot_image_id)); |
| 460 button->SetImage(views::CustomButton::BS_PUSHED, | 460 button->SetImage(views::CustomButton::BS_PUSHED, |
| 461 tp->GetImageSkiaNamed(pushed_bitmap_id)); | 461 tp->GetImageSkiaNamed(pushed_image_id)); |
| 462 if (browser_view()->IsBrowserTypeNormal()) { | 462 if (browser_view()->IsBrowserTypeNormal()) { |
| 463 button->SetBackground( | 463 button->SetBackground( |
| 464 tp->GetColor(ThemeService::COLOR_BUTTON_BACKGROUND), | 464 tp->GetColor(ThemeService::COLOR_BUTTON_BACKGROUND), |
| 465 tp->GetImageSkiaNamed(IDR_THEME_WINDOW_CONTROL_BACKGROUND), | 465 tp->GetImageSkiaNamed(IDR_THEME_WINDOW_CONTROL_BACKGROUND), |
| 466 tp->GetImageSkiaNamed(mask_bitmap_id)); | 466 tp->GetImageSkiaNamed(mask_image_id)); |
| 467 } | 467 } |
| 468 button->SetAccessibleName( | 468 button->SetAccessibleName( |
| 469 l10n_util::GetStringUTF16(accessibility_string_id)); | 469 l10n_util::GetStringUTF16(accessibility_string_id)); |
| 470 AddChildView(button); | 470 AddChildView(button); |
| 471 return button; | 471 return button; |
| 472 } | 472 } |
| 473 | 473 |
| 474 int OpaqueBrowserFrameView::FrameBorderThickness(bool restored) const { | 474 int OpaqueBrowserFrameView::FrameBorderThickness(bool restored) const { |
| 475 return (!restored && (frame()->IsMaximized() || frame()->IsFullscreen())) ? | 475 return (!restored && (frame()->IsMaximized() || frame()->IsFullscreen())) ? |
| 476 0 : kFrameBorderThickness; | 476 0 : kFrameBorderThickness; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 } else { | 537 } else { |
| 538 // For "browser mode" windows, we use the native positioning, which is just | 538 // For "browser mode" windows, we use the native positioning, which is just |
| 539 // below the top frame border. | 539 // below the top frame border. |
| 540 y = frame_thickness; | 540 y = frame_thickness; |
| 541 } | 541 } |
| 542 return gfx::Rect(frame_thickness + kIconLeftSpacing, y, size, size); | 542 return gfx::Rect(frame_thickness + kIconLeftSpacing, y, size, size); |
| 543 } | 543 } |
| 544 | 544 |
| 545 void OpaqueBrowserFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) { | 545 void OpaqueBrowserFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) { |
| 546 frame_background_->set_frame_color(GetFrameColor()); | 546 frame_background_->set_frame_color(GetFrameColor()); |
| 547 frame_background_->set_theme_bitmap(GetFrameBitmap()); | 547 frame_background_->set_theme_image(GetFrameImage()); |
| 548 frame_background_->set_theme_overlay_bitmap(GetFrameOverlayBitmap()); | 548 frame_background_->set_theme_overlay_image(GetFrameOverlayImage()); |
| 549 frame_background_->set_top_area_height(GetTopAreaHeight()); | 549 frame_background_->set_top_area_height(GetTopAreaHeight()); |
| 550 | 550 |
| 551 ui::ThemeProvider* tp = GetThemeProvider(); | 551 ui::ThemeProvider* tp = GetThemeProvider(); |
| 552 frame_background_->SetSideImages( | 552 frame_background_->SetSideImages( |
| 553 tp->GetBitmapNamed(IDR_WINDOW_LEFT_SIDE), | 553 tp->GetImageSkiaNamed(IDR_WINDOW_LEFT_SIDE), |
| 554 tp->GetBitmapNamed(IDR_WINDOW_TOP_CENTER), | 554 tp->GetImageSkiaNamed(IDR_WINDOW_TOP_CENTER), |
| 555 tp->GetBitmapNamed(IDR_WINDOW_RIGHT_SIDE), | 555 tp->GetImageSkiaNamed(IDR_WINDOW_RIGHT_SIDE), |
| 556 tp->GetBitmapNamed(IDR_WINDOW_BOTTOM_CENTER)); | 556 tp->GetImageSkiaNamed(IDR_WINDOW_BOTTOM_CENTER)); |
| 557 frame_background_->SetCornerImages( | 557 frame_background_->SetCornerImages( |
| 558 tp->GetBitmapNamed(IDR_WINDOW_TOP_LEFT_CORNER), | 558 tp->GetImageSkiaNamed(IDR_WINDOW_TOP_LEFT_CORNER), |
| 559 tp->GetBitmapNamed(IDR_WINDOW_TOP_RIGHT_CORNER), | 559 tp->GetImageSkiaNamed(IDR_WINDOW_TOP_RIGHT_CORNER), |
| 560 tp->GetBitmapNamed(IDR_WINDOW_BOTTOM_LEFT_CORNER), | 560 tp->GetImageSkiaNamed(IDR_WINDOW_BOTTOM_LEFT_CORNER), |
| 561 tp->GetBitmapNamed(IDR_WINDOW_BOTTOM_RIGHT_CORNER)); | 561 tp->GetImageSkiaNamed(IDR_WINDOW_BOTTOM_RIGHT_CORNER)); |
| 562 frame_background_->PaintRestored(canvas, this); | 562 frame_background_->PaintRestored(canvas, this); |
| 563 | 563 |
| 564 // Note: When we don't have a toolbar, we need to draw some kind of bottom | 564 // Note: When we don't have a toolbar, we need to draw some kind of bottom |
| 565 // edge here. Because the App Window graphics we use for this have an | 565 // edge here. Because the App Window graphics we use for this have an |
| 566 // attached client edge and their sizing algorithm is a little involved, we do | 566 // attached client edge and their sizing algorithm is a little involved, we do |
| 567 // all this in PaintRestoredClientEdge(). | 567 // all this in PaintRestoredClientEdge(). |
| 568 } | 568 } |
| 569 | 569 |
| 570 void OpaqueBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) { | 570 void OpaqueBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) { |
| 571 frame_background_->set_frame_color(GetFrameColor()); | 571 frame_background_->set_frame_color(GetFrameColor()); |
| 572 frame_background_->set_theme_bitmap(GetFrameBitmap()); | 572 frame_background_->set_theme_image(GetFrameImage()); |
| 573 frame_background_->set_theme_overlay_bitmap(GetFrameOverlayBitmap()); | 573 frame_background_->set_theme_overlay_image(GetFrameOverlayImage()); |
| 574 frame_background_->set_top_area_height(GetTopAreaHeight()); | 574 frame_background_->set_top_area_height(GetTopAreaHeight()); |
| 575 | 575 |
| 576 // Theme frame must be aligned with the tabstrip as if we were | 576 // Theme frame must be aligned with the tabstrip as if we were |
| 577 // in restored mode. Note that the top of the tabstrip is | 577 // in restored mode. Note that the top of the tabstrip is |
| 578 // kTabstripTopShadowThickness px off the top of the screen. | 578 // kTabstripTopShadowThickness px off the top of the screen. |
| 579 int theme_background_y = -(GetHorizontalTabStripVerticalOffset(true) + | 579 int theme_background_y = -(GetHorizontalTabStripVerticalOffset(true) + |
| 580 kTabstripTopShadowThickness); | 580 kTabstripTopShadowThickness); |
| 581 frame_background_->set_theme_background_y(theme_background_y); | 581 frame_background_->set_theme_background_y(theme_background_y); |
| 582 | 582 |
| 583 frame_background_->PaintMaximized(canvas, this); | 583 frame_background_->PaintMaximized(canvas, this); |
| 584 | 584 |
| 585 // TODO(jamescook): Migrate this into FrameBackground. | 585 // TODO(jamescook): Migrate this into FrameBackground. |
| 586 if (!browser_view()->IsToolbarVisible()) { | 586 if (!browser_view()->IsToolbarVisible()) { |
| 587 // There's no toolbar to edge the frame border, so we need to draw a bottom | 587 // There's no toolbar to edge the frame border, so we need to draw a bottom |
| 588 // edge. The graphic we use for this has a built in client edge, so we clip | 588 // edge. The graphic we use for this has a built in client edge, so we clip |
| 589 // it off the bottom. | 589 // it off the bottom. |
| 590 SkBitmap* top_center = | 590 gfx::ImageSkia* top_center = |
| 591 GetThemeProvider()->GetBitmapNamed(IDR_APP_TOP_CENTER); | 591 GetThemeProvider()->GetImageSkiaNamed(IDR_APP_TOP_CENTER); |
| 592 int edge_height = top_center->height() - kClientEdgeThickness; | 592 int edge_height = top_center->height() - kClientEdgeThickness; |
| 593 canvas->TileImageInt(*top_center, 0, | 593 canvas->TileImageInt(*top_center, 0, |
| 594 frame()->client_view()->y() - edge_height, width(), edge_height); | 594 frame()->client_view()->y() - edge_height, width(), edge_height); |
| 595 } | 595 } |
| 596 } | 596 } |
| 597 | 597 |
| 598 void OpaqueBrowserFrameView::PaintTitleBar(gfx::Canvas* canvas) { | 598 void OpaqueBrowserFrameView::PaintTitleBar(gfx::Canvas* canvas) { |
| 599 // The window icon is painted by the TabIconView. | 599 // The window icon is painted by the TabIconView. |
| 600 views::WidgetDelegate* delegate = frame()->widget_delegate(); | 600 views::WidgetDelegate* delegate = frame()->widget_delegate(); |
| 601 if (!delegate) { | 601 if (!delegate) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 629 int y = toolbar_bounds.y(); | 629 int y = toolbar_bounds.y(); |
| 630 int h = toolbar_bounds.height(); | 630 int h = toolbar_bounds.height(); |
| 631 | 631 |
| 632 // Gross hack: We split the toolbar images into two pieces, since sometimes | 632 // Gross hack: We split the toolbar images into two pieces, since sometimes |
| 633 // (popup mode) the toolbar isn't tall enough to show the whole image. The | 633 // (popup mode) the toolbar isn't tall enough to show the whole image. The |
| 634 // split happens between the top shadow section and the bottom gradient | 634 // split happens between the top shadow section and the bottom gradient |
| 635 // section so that we never break the gradient. | 635 // section so that we never break the gradient. |
| 636 int split_point = kFrameShadowThickness * 2; | 636 int split_point = kFrameShadowThickness * 2; |
| 637 int bottom_y = y + split_point; | 637 int bottom_y = y + split_point; |
| 638 ui::ThemeProvider* tp = GetThemeProvider(); | 638 ui::ThemeProvider* tp = GetThemeProvider(); |
| 639 SkBitmap* toolbar_left = tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER); | 639 gfx::ImageSkia* toolbar_left = tp->GetImageSkiaNamed( |
| 640 IDR_CONTENT_TOP_LEFT_CORNER); |
| 640 int bottom_edge_height = std::min(toolbar_left->height(), h) - split_point; | 641 int bottom_edge_height = std::min(toolbar_left->height(), h) - split_point; |
| 641 | 642 |
| 642 // Split our canvas out so we can mask out the corners of the toolbar | 643 // Split our canvas out so we can mask out the corners of the toolbar |
| 643 // without masking out the frame. | 644 // without masking out the frame. |
| 644 canvas->SaveLayerAlpha( | 645 canvas->SaveLayerAlpha( |
| 645 255, gfx::Rect(x - kClientEdgeThickness, y, w + kClientEdgeThickness * 3, | 646 255, gfx::Rect(x - kClientEdgeThickness, y, w + kClientEdgeThickness * 3, |
| 646 h)); | 647 h)); |
| 647 canvas->sk_canvas()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); | 648 canvas->sk_canvas()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); |
| 648 | 649 |
| 649 canvas->FillRect(gfx::Rect(x, bottom_y, w, bottom_edge_height), | 650 canvas->FillRect(gfx::Rect(x, bottom_y, w, bottom_edge_height), |
| 650 tp->GetColor(ThemeService::COLOR_TOOLBAR)); | 651 tp->GetColor(ThemeService::COLOR_TOOLBAR)); |
| 651 | 652 |
| 652 // Tile the toolbar image starting at the frame edge on the left and where the | 653 // Tile the toolbar image starting at the frame edge on the left and where the |
| 653 // horizontal tabstrip is (or would be) on the top. | 654 // horizontal tabstrip is (or would be) on the top. |
| 654 SkBitmap* theme_toolbar = tp->GetBitmapNamed(IDR_THEME_TOOLBAR); | 655 gfx::ImageSkia* theme_toolbar = tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR); |
| 655 canvas->TileImageInt(*theme_toolbar, x, | 656 canvas->TileImageInt(*theme_toolbar, x, |
| 656 bottom_y - GetHorizontalTabStripVerticalOffset(false), x, | 657 bottom_y - GetHorizontalTabStripVerticalOffset(false), x, |
| 657 bottom_y, w, theme_toolbar->height()); | 658 bottom_y, w, theme_toolbar->height()); |
| 658 | 659 |
| 659 // Draw rounded corners for the tab. | 660 // Draw rounded corners for the tab. |
| 660 SkBitmap* toolbar_left_mask = | 661 gfx::ImageSkia* toolbar_left_mask = |
| 661 tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER_MASK); | 662 tp->GetImageSkiaNamed(IDR_CONTENT_TOP_LEFT_CORNER_MASK); |
| 662 SkBitmap* toolbar_right_mask = | 663 gfx::ImageSkia* toolbar_right_mask = |
| 663 tp->GetBitmapNamed(IDR_CONTENT_TOP_RIGHT_CORNER_MASK); | 664 tp->GetImageSkiaNamed(IDR_CONTENT_TOP_RIGHT_CORNER_MASK); |
| 664 | 665 |
| 665 // We mask out the corners by using the DestinationIn transfer mode, | 666 // We mask out the corners by using the DestinationIn transfer mode, |
| 666 // which keeps the RGB pixels from the destination and the alpha from | 667 // which keeps the RGB pixels from the destination and the alpha from |
| 667 // the source. | 668 // the source. |
| 668 SkPaint paint; | 669 SkPaint paint; |
| 669 paint.setXfermodeMode(SkXfermode::kDstIn_Mode); | 670 paint.setXfermodeMode(SkXfermode::kDstIn_Mode); |
| 670 | 671 |
| 671 // Mask the left edge. | 672 // Mask the left edge. |
| 672 int left_x = x - kContentEdgeShadowThickness; | 673 int left_x = x - kContentEdgeShadowThickness; |
| 673 canvas->DrawBitmapInt(*toolbar_left_mask, 0, 0, toolbar_left_mask->width(), | 674 canvas->DrawBitmapInt(*toolbar_left_mask, 0, 0, toolbar_left_mask->width(), |
| (...skipping 16 matching lines...) Expand all Loading... |
| 690 toolbar_right_mask->width(), bottom_edge_height, false, paint); | 691 toolbar_right_mask->width(), bottom_edge_height, false, paint); |
| 691 canvas->Restore(); | 692 canvas->Restore(); |
| 692 | 693 |
| 693 canvas->DrawBitmapInt(*toolbar_left, 0, 0, toolbar_left->width(), split_point, | 694 canvas->DrawBitmapInt(*toolbar_left, 0, 0, toolbar_left->width(), split_point, |
| 694 left_x, y, toolbar_left->width(), split_point, false); | 695 left_x, y, toolbar_left->width(), split_point, false); |
| 695 canvas->DrawBitmapInt(*toolbar_left, 0, | 696 canvas->DrawBitmapInt(*toolbar_left, 0, |
| 696 toolbar_left->height() - bottom_edge_height, toolbar_left->width(), | 697 toolbar_left->height() - bottom_edge_height, toolbar_left->width(), |
| 697 bottom_edge_height, left_x, bottom_y, toolbar_left->width(), | 698 bottom_edge_height, left_x, bottom_y, toolbar_left->width(), |
| 698 bottom_edge_height, false); | 699 bottom_edge_height, false); |
| 699 | 700 |
| 700 SkBitmap* toolbar_center = | 701 gfx::ImageSkia* toolbar_center = |
| 701 tp->GetBitmapNamed(IDR_CONTENT_TOP_CENTER); | 702 tp->GetImageSkiaNamed(IDR_CONTENT_TOP_CENTER); |
| 702 canvas->TileImageInt(*toolbar_center, 0, 0, left_x + toolbar_left->width(), | 703 canvas->TileImageInt(*toolbar_center, 0, 0, left_x + toolbar_left->width(), |
| 703 y, right_x - (left_x + toolbar_left->width()), | 704 y, right_x - (left_x + toolbar_left->width()), |
| 704 split_point); | 705 split_point); |
| 705 | 706 |
| 706 SkBitmap* toolbar_right = tp->GetBitmapNamed(IDR_CONTENT_TOP_RIGHT_CORNER); | 707 gfx::ImageSkia* toolbar_right = tp->GetImageSkiaNamed( |
| 708 IDR_CONTENT_TOP_RIGHT_CORNER); |
| 707 canvas->DrawBitmapInt(*toolbar_right, 0, 0, toolbar_right->width(), | 709 canvas->DrawBitmapInt(*toolbar_right, 0, 0, toolbar_right->width(), |
| 708 split_point, right_x, y, toolbar_right->width(), split_point, false); | 710 split_point, right_x, y, toolbar_right->width(), split_point, false); |
| 709 canvas->DrawBitmapInt(*toolbar_right, 0, | 711 canvas->DrawBitmapInt(*toolbar_right, 0, |
| 710 toolbar_right->height() - bottom_edge_height, toolbar_right->width(), | 712 toolbar_right->height() - bottom_edge_height, toolbar_right->width(), |
| 711 bottom_edge_height, right_x, bottom_y, toolbar_right->width(), | 713 bottom_edge_height, right_x, bottom_y, toolbar_right->width(), |
| 712 bottom_edge_height, false); | 714 bottom_edge_height, false); |
| 713 | 715 |
| 714 // Draw the content/toolbar separator. | 716 // Draw the content/toolbar separator. |
| 715 canvas->FillRect(gfx::Rect(x + kClientEdgeThickness, | 717 canvas->FillRect(gfx::Rect(x + kClientEdgeThickness, |
| 716 toolbar_bounds.bottom() - kClientEdgeThickness, | 718 toolbar_bounds.bottom() - kClientEdgeThickness, |
| 717 w - (2 * kClientEdgeThickness), | 719 w - (2 * kClientEdgeThickness), |
| 718 kClientEdgeThickness), | 720 kClientEdgeThickness), |
| 719 ThemeService::GetDefaultColor(ThemeService::COLOR_TOOLBAR_SEPARATOR)); | 721 ThemeService::GetDefaultColor(ThemeService::COLOR_TOOLBAR_SEPARATOR)); |
| 720 } | 722 } |
| 721 | 723 |
| 722 void OpaqueBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { | 724 void OpaqueBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { |
| 723 ui::ThemeProvider* tp = GetThemeProvider(); | 725 ui::ThemeProvider* tp = GetThemeProvider(); |
| 724 int client_area_top = frame()->client_view()->y(); | 726 int client_area_top = frame()->client_view()->y(); |
| 725 int image_top = client_area_top; | 727 int image_top = client_area_top; |
| 726 | 728 |
| 727 gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height()); | 729 gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height()); |
| 728 SkColor toolbar_color = tp->GetColor(ThemeService::COLOR_TOOLBAR); | 730 SkColor toolbar_color = tp->GetColor(ThemeService::COLOR_TOOLBAR); |
| 729 | 731 |
| 730 if (browser_view()->IsToolbarVisible()) { | 732 if (browser_view()->IsToolbarVisible()) { |
| 731 // The client edge images always start below the toolbar corner images. The | 733 // The client edge images always start below the toolbar corner images. The |
| 732 // client edge filled rects start there or at the bottom of the toolbar, | 734 // client edge filled rects start there or at the bottom of the toolbar, |
| 733 // whichever is shorter. | 735 // whichever is shorter. |
| 734 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds()); | 736 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds()); |
| 735 image_top += toolbar_bounds.y() + | 737 image_top += toolbar_bounds.y() + |
| 736 tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER)->height(); | 738 tp->GetImageSkiaNamed(IDR_CONTENT_TOP_LEFT_CORNER)->height(); |
| 737 client_area_top = std::min(image_top, | 739 client_area_top = std::min(image_top, |
| 738 client_area_top + toolbar_bounds.bottom() - kClientEdgeThickness); | 740 client_area_top + toolbar_bounds.bottom() - kClientEdgeThickness); |
| 739 } else if (!browser_view()->IsTabStripVisible()) { | 741 } else if (!browser_view()->IsTabStripVisible()) { |
| 740 // The toolbar isn't going to draw a client edge for us, so draw one | 742 // The toolbar isn't going to draw a client edge for us, so draw one |
| 741 // ourselves. | 743 // ourselves. |
| 742 SkBitmap* top_left = tp->GetBitmapNamed(IDR_APP_TOP_LEFT); | 744 gfx::ImageSkia* top_left = tp->GetImageSkiaNamed(IDR_APP_TOP_LEFT); |
| 743 SkBitmap* top_center = tp->GetBitmapNamed(IDR_APP_TOP_CENTER); | 745 gfx::ImageSkia* top_center = tp->GetImageSkiaNamed(IDR_APP_TOP_CENTER); |
| 744 SkBitmap* top_right = tp->GetBitmapNamed(IDR_APP_TOP_RIGHT); | 746 gfx::ImageSkia* top_right = tp->GetImageSkiaNamed(IDR_APP_TOP_RIGHT); |
| 745 int top_edge_y = client_area_top - top_center->height(); | 747 int top_edge_y = client_area_top - top_center->height(); |
| 746 int height = client_area_top - top_edge_y; | 748 int height = client_area_top - top_edge_y; |
| 747 | 749 |
| 748 canvas->DrawBitmapInt(*top_left, 0, 0, top_left->width(), height, | 750 canvas->DrawBitmapInt(*top_left, 0, 0, top_left->width(), height, |
| 749 client_area_bounds.x() - top_left->width(), top_edge_y, | 751 client_area_bounds.x() - top_left->width(), top_edge_y, |
| 750 top_left->width(), height, false); | 752 top_left->width(), height, false); |
| 751 canvas->TileImageInt(*top_center, 0, 0, client_area_bounds.x(), top_edge_y, | 753 canvas->TileImageInt(*top_center, 0, 0, client_area_bounds.x(), top_edge_y, |
| 752 client_area_bounds.width(), std::min(height, top_center->height())); | 754 client_area_bounds.width(), std::min(height, top_center->height())); |
| 753 canvas->DrawBitmapInt(*top_right, 0, 0, top_right->width(), height, | 755 canvas->DrawBitmapInt(*top_right, 0, 0, top_right->width(), height, |
| 754 client_area_bounds.right(), top_edge_y, | 756 client_area_bounds.right(), top_edge_y, |
| 755 top_right->width(), height, false); | 757 top_right->width(), height, false); |
| 756 | 758 |
| 757 // Draw the toolbar color across the top edge. | 759 // Draw the toolbar color across the top edge. |
| 758 canvas->FillRect(gfx::Rect(client_area_bounds.x() - kClientEdgeThickness, | 760 canvas->FillRect(gfx::Rect(client_area_bounds.x() - kClientEdgeThickness, |
| 759 client_area_top - kClientEdgeThickness, | 761 client_area_top - kClientEdgeThickness, |
| 760 client_area_bounds.width() + (2 * kClientEdgeThickness), | 762 client_area_bounds.width() + (2 * kClientEdgeThickness), |
| 761 kClientEdgeThickness), toolbar_color); | 763 kClientEdgeThickness), toolbar_color); |
| 762 } | 764 } |
| 763 | 765 |
| 764 int client_area_bottom = | 766 int client_area_bottom = |
| 765 std::max(client_area_top, height() - NonClientBorderThickness()); | 767 std::max(client_area_top, height() - NonClientBorderThickness()); |
| 766 int image_height = client_area_bottom - image_top; | 768 int image_height = client_area_bottom - image_top; |
| 767 | 769 |
| 768 // Draw the client edge images. | 770 // Draw the client edge images. |
| 769 // Draw the client edge images. | 771 // Draw the client edge images. |
| 770 SkBitmap* right = tp->GetBitmapNamed(IDR_CONTENT_RIGHT_SIDE); | 772 gfx::ImageSkia* right = tp->GetImageSkiaNamed(IDR_CONTENT_RIGHT_SIDE); |
| 771 canvas->TileImageInt(*right, client_area_bounds.right(), image_top, | 773 canvas->TileImageInt(*right, client_area_bounds.right(), image_top, |
| 772 right->width(), image_height); | 774 right->width(), image_height); |
| 773 canvas->DrawBitmapInt( | 775 canvas->DrawBitmapInt( |
| 774 *tp->GetBitmapNamed(IDR_CONTENT_BOTTOM_RIGHT_CORNER), | 776 *tp->GetImageSkiaNamed(IDR_CONTENT_BOTTOM_RIGHT_CORNER), |
| 775 client_area_bounds.right(), client_area_bottom); | 777 client_area_bounds.right(), client_area_bottom); |
| 776 SkBitmap* bottom = tp->GetBitmapNamed(IDR_CONTENT_BOTTOM_CENTER); | 778 gfx::ImageSkia* bottom = tp->GetImageSkiaNamed(IDR_CONTENT_BOTTOM_CENTER); |
| 777 canvas->TileImageInt(*bottom, client_area_bounds.x(), | 779 canvas->TileImageInt(*bottom, client_area_bounds.x(), |
| 778 client_area_bottom, client_area_bounds.width(), | 780 client_area_bottom, client_area_bounds.width(), |
| 779 bottom->height()); | 781 bottom->height()); |
| 780 SkBitmap* bottom_left = | 782 gfx::ImageSkia* bottom_left = |
| 781 tp->GetBitmapNamed(IDR_CONTENT_BOTTOM_LEFT_CORNER); | 783 tp->GetImageSkiaNamed(IDR_CONTENT_BOTTOM_LEFT_CORNER); |
| 782 canvas->DrawBitmapInt(*bottom_left, | 784 canvas->DrawBitmapInt(*bottom_left, |
| 783 client_area_bounds.x() - bottom_left->width(), client_area_bottom); | 785 client_area_bounds.x() - bottom_left->width(), client_area_bottom); |
| 784 SkBitmap* left = tp->GetBitmapNamed(IDR_CONTENT_LEFT_SIDE); | 786 gfx::ImageSkia* left = tp->GetImageSkiaNamed(IDR_CONTENT_LEFT_SIDE); |
| 785 canvas->TileImageInt(*left, client_area_bounds.x() - left->width(), | 787 canvas->TileImageInt(*left, client_area_bounds.x() - left->width(), |
| 786 image_top, left->width(), image_height); | 788 image_top, left->width(), image_height); |
| 787 | 789 |
| 788 // Draw the toolbar color so that the client edges show the right color even | 790 // Draw the toolbar color so that the client edges show the right color even |
| 789 // where not covered by the toolbar image. NOTE: We do this after drawing the | 791 // where not covered by the toolbar image. NOTE: We do this after drawing the |
| 790 // images because the images are meant to alpha-blend atop the frame whereas | 792 // images because the images are meant to alpha-blend atop the frame whereas |
| 791 // these rects are meant to be fully opaque, without anything overlaid. | 793 // these rects are meant to be fully opaque, without anything overlaid. |
| 792 canvas->FillRect(gfx::Rect(client_area_bounds.x() - kClientEdgeThickness, | 794 canvas->FillRect(gfx::Rect(client_area_bounds.x() - kClientEdgeThickness, |
| 793 client_area_top, kClientEdgeThickness, | 795 client_area_top, kClientEdgeThickness, |
| 794 client_area_bottom + kClientEdgeThickness - client_area_top), | 796 client_area_bottom + kClientEdgeThickness - client_area_top), |
| (...skipping 21 matching lines...) Expand all Loading... |
| 816 // Never theme app and popup windows. | 818 // Never theme app and popup windows. |
| 817 if (ShouldPaintAsActive()) { | 819 if (ShouldPaintAsActive()) { |
| 818 return ThemeService::GetDefaultColor(is_incognito ? | 820 return ThemeService::GetDefaultColor(is_incognito ? |
| 819 ThemeService::COLOR_FRAME_INCOGNITO : ThemeService::COLOR_FRAME); | 821 ThemeService::COLOR_FRAME_INCOGNITO : ThemeService::COLOR_FRAME); |
| 820 } | 822 } |
| 821 return ThemeService::GetDefaultColor(is_incognito ? | 823 return ThemeService::GetDefaultColor(is_incognito ? |
| 822 ThemeService::COLOR_FRAME_INCOGNITO_INACTIVE : | 824 ThemeService::COLOR_FRAME_INCOGNITO_INACTIVE : |
| 823 ThemeService::COLOR_FRAME_INACTIVE); | 825 ThemeService::COLOR_FRAME_INACTIVE); |
| 824 } | 826 } |
| 825 | 827 |
| 826 SkBitmap* OpaqueBrowserFrameView::GetFrameBitmap() const { | 828 gfx::ImageSkia* OpaqueBrowserFrameView::GetFrameImage() const { |
| 827 bool is_incognito = browser_view()->IsOffTheRecord(); | 829 bool is_incognito = browser_view()->IsOffTheRecord(); |
| 828 int resource_id; | 830 int resource_id; |
| 829 if (browser_view()->IsBrowserTypeNormal()) { | 831 if (browser_view()->IsBrowserTypeNormal()) { |
| 830 if (ShouldPaintAsActive()) { | 832 if (ShouldPaintAsActive()) { |
| 831 resource_id = is_incognito ? | 833 resource_id = is_incognito ? |
| 832 IDR_THEME_FRAME_INCOGNITO : IDR_THEME_FRAME; | 834 IDR_THEME_FRAME_INCOGNITO : IDR_THEME_FRAME; |
| 833 } else { | 835 } else { |
| 834 resource_id = is_incognito ? | 836 resource_id = is_incognito ? |
| 835 IDR_THEME_FRAME_INCOGNITO_INACTIVE : IDR_THEME_FRAME_INACTIVE; | 837 IDR_THEME_FRAME_INCOGNITO_INACTIVE : IDR_THEME_FRAME_INACTIVE; |
| 836 } | 838 } |
| 837 return GetThemeProvider()->GetBitmapNamed(resource_id); | 839 return GetThemeProvider()->GetImageSkiaNamed(resource_id); |
| 838 } | 840 } |
| 839 // Never theme app and popup windows. | 841 // Never theme app and popup windows. |
| 840 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 842 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 841 if (ShouldPaintAsActive()) { | 843 if (ShouldPaintAsActive()) { |
| 842 resource_id = is_incognito ? | 844 resource_id = is_incognito ? |
| 843 IDR_THEME_FRAME_INCOGNITO : IDR_FRAME; | 845 IDR_THEME_FRAME_INCOGNITO : IDR_FRAME; |
| 844 } else { | 846 } else { |
| 845 resource_id = is_incognito ? | 847 resource_id = is_incognito ? |
| 846 IDR_THEME_FRAME_INCOGNITO_INACTIVE : IDR_THEME_FRAME_INACTIVE; | 848 IDR_THEME_FRAME_INCOGNITO_INACTIVE : IDR_THEME_FRAME_INACTIVE; |
| 847 } | 849 } |
| 848 return rb.GetBitmapNamed(resource_id); | 850 return rb.GetImageSkiaNamed(resource_id); |
| 849 } | 851 } |
| 850 | 852 |
| 851 SkBitmap* OpaqueBrowserFrameView::GetFrameOverlayBitmap() const { | 853 gfx::ImageSkia* OpaqueBrowserFrameView::GetFrameOverlayImage() const { |
| 852 ui::ThemeProvider* tp = GetThemeProvider(); | 854 ui::ThemeProvider* tp = GetThemeProvider(); |
| 853 if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) && | 855 if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) && |
| 854 browser_view()->IsBrowserTypeNormal() && | 856 browser_view()->IsBrowserTypeNormal() && |
| 855 !browser_view()->IsOffTheRecord()) { | 857 !browser_view()->IsOffTheRecord()) { |
| 856 return tp->GetBitmapNamed(ShouldPaintAsActive() ? | 858 return tp->GetImageSkiaNamed(ShouldPaintAsActive() ? |
| 857 IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE); | 859 IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE); |
| 858 } | 860 } |
| 859 return NULL; | 861 return NULL; |
| 860 } | 862 } |
| 861 | 863 |
| 862 int OpaqueBrowserFrameView::GetTopAreaHeight() const { | 864 int OpaqueBrowserFrameView::GetTopAreaHeight() const { |
| 863 SkBitmap* frame_bitmap = GetFrameBitmap(); | 865 gfx::ImageSkia* frame_image = GetFrameImage(); |
| 864 int top_area_height = frame_bitmap->height(); | 866 int top_area_height = frame_image->height(); |
| 865 if (browser_view()->IsTabStripVisible()) { | 867 if (browser_view()->IsTabStripVisible()) { |
| 866 top_area_height = std::max(top_area_height, | 868 top_area_height = std::max(top_area_height, |
| 867 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom()); | 869 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom()); |
| 868 } | 870 } |
| 869 return top_area_height; | 871 return top_area_height; |
| 870 } | 872 } |
| 871 | 873 |
| 872 void OpaqueBrowserFrameView::LayoutWindowControls() { | 874 void OpaqueBrowserFrameView::LayoutWindowControls() { |
| 873 bool is_maximized = frame()->IsMaximized(); | 875 bool is_maximized = frame()->IsMaximized(); |
| 874 close_button_->SetImageAlignment(views::ImageButton::ALIGN_LEFT, | 876 close_button_->SetImageAlignment(views::ImageButton::ALIGN_LEFT, |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 934 icon_bounds.y() + ((icon_bounds.height() - title_height - 1) / 2), | 936 icon_bounds.y() + ((icon_bounds.height() - title_height - 1) / 2), |
| 935 std::max(0, minimize_button_->x() - kTitleLogoSpacing - title_x), | 937 std::max(0, minimize_button_->x() - kTitleLogoSpacing - title_x), |
| 936 title_height); | 938 title_height); |
| 937 } | 939 } |
| 938 } | 940 } |
| 939 | 941 |
| 940 void OpaqueBrowserFrameView::LayoutAvatar() { | 942 void OpaqueBrowserFrameView::LayoutAvatar() { |
| 941 // Even though the avatar is used for both incognito and profiles we always | 943 // Even though the avatar is used for both incognito and profiles we always |
| 942 // use the incognito icon to layout the avatar button. The profile icon | 944 // use the incognito icon to layout the avatar button. The profile icon |
| 943 // can be customized so we can't depend on its size to perform layout. | 945 // can be customized so we can't depend on its size to perform layout. |
| 944 SkBitmap incognito_icon = browser_view()->GetOTRAvatarIcon(); | 946 gfx::ImageSkia incognito_icon = browser_view()->GetOTRAvatarIcon(); |
| 945 | 947 |
| 946 int avatar_bottom = GetHorizontalTabStripVerticalOffset(false) + | 948 int avatar_bottom = GetHorizontalTabStripVerticalOffset(false) + |
| 947 browser_view()->GetTabStripHeight() - kAvatarBottomSpacing; | 949 browser_view()->GetTabStripHeight() - kAvatarBottomSpacing; |
| 948 int avatar_restored_y = avatar_bottom - incognito_icon.height(); | 950 int avatar_restored_y = avatar_bottom - incognito_icon.height(); |
| 949 int avatar_y = frame()->IsMaximized() ? | 951 int avatar_y = frame()->IsMaximized() ? |
| 950 (NonClientTopBorderHeight(false) + kTabstripTopShadowThickness) : | 952 (NonClientTopBorderHeight(false) + kTabstripTopShadowThickness) : |
| 951 avatar_restored_y; | 953 avatar_restored_y; |
| 952 avatar_bounds_.SetRect(NonClientBorderThickness() + kAvatarLeftSpacing, | 954 avatar_bounds_.SetRect(NonClientBorderThickness() + kAvatarLeftSpacing, |
| 953 avatar_y, incognito_icon.width(), | 955 avatar_y, incognito_icon.width(), |
| 954 browser_view()->ShouldShowAvatar() ? (avatar_bottom - avatar_y) : 0); | 956 browser_view()->ShouldShowAvatar() ? (avatar_bottom - avatar_y) : 0); |
| 955 | 957 |
| 956 if (avatar_button()) | 958 if (avatar_button()) |
| 957 avatar_button()->SetBoundsRect(avatar_bounds_); | 959 avatar_button()->SetBoundsRect(avatar_bounds_); |
| 958 } | 960 } |
| 959 | 961 |
| 960 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width, | 962 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width, |
| 961 int height) const { | 963 int height) const { |
| 962 int top_height = NonClientTopBorderHeight(false); | 964 int top_height = NonClientTopBorderHeight(false); |
| 963 int border_thickness = NonClientBorderThickness(); | 965 int border_thickness = NonClientBorderThickness(); |
| 964 return gfx::Rect(border_thickness, top_height, | 966 return gfx::Rect(border_thickness, top_height, |
| 965 std::max(0, width - (2 * border_thickness)), | 967 std::max(0, width - (2 * border_thickness)), |
| 966 std::max(0, height - GetReservedHeight() - | 968 std::max(0, height - GetReservedHeight() - |
| 967 top_height - border_thickness)); | 969 top_height - border_thickness)); |
| 968 } | 970 } |
| OLD | NEW |