| 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/theme_background.h" | 5 #include "chrome/browser/ui/views/theme_background.h" |
| 6 | 6 |
| 7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
| 8 #include "chrome/browser/themes/theme_service.h" | 8 #include "chrome/browser/themes/theme_service.h" |
| 9 #include "chrome/browser/themes/theme_service_factory.h" | 9 #include "chrome/browser/themes/theme_service_factory.h" |
| 10 #include "chrome/browser/ui/views/frame/browser_view.h" | 10 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 11 #include "grit/generated_resources.h" | 11 #include "grit/generated_resources.h" |
| 12 #include "grit/theme_resources.h" | 12 #include "grit/theme_resources.h" |
| 13 #include "grit/theme_resources_standard.h" | 13 #include "grit/theme_resources_standard.h" |
| 14 #include "grit/ui_resources.h" | 14 #include "grit/ui_resources.h" |
| 15 #include "ui/base/resource/resource_bundle.h" | 15 #include "ui/base/resource/resource_bundle.h" |
| 16 #include "ui/gfx/canvas.h" | 16 #include "ui/gfx/canvas.h" |
| 17 #include "ui/views/view.h" | 17 #include "ui/views/view.h" |
| 18 | 18 |
| 19 ThemeBackground::ThemeBackground(BrowserView* browser_view) | 19 ThemeBackground::ThemeBackground(BrowserView* browser_view) |
| 20 : browser_view_(browser_view) { | 20 : browser_view_(browser_view) { |
| 21 } | 21 } |
| 22 | 22 |
| 23 void ThemeBackground::Paint(gfx::Canvas* canvas, views::View* view) const { | 23 void ThemeBackground::Paint(gfx::Canvas* canvas, views::View* view) const { |
| 24 SkBitmap* background; | 24 gfx::ImageSkia* background; |
| 25 | 25 |
| 26 // Never theme app and popup windows. | 26 // Never theme app and popup windows. |
| 27 if (!browser_view_->IsBrowserTypeNormal()) { | 27 if (!browser_view_->IsBrowserTypeNormal()) { |
| 28 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 28 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 29 if (browser_view_->IsActive()) | 29 if (browser_view_->IsActive()) |
| 30 background = rb.GetBitmapNamed(IDR_FRAME); | 30 background = rb.GetImageSkiaNamed(IDR_FRAME); |
| 31 else | 31 else |
| 32 background = rb.GetBitmapNamed(IDR_THEME_FRAME_INACTIVE); | 32 background = rb.GetImageSkiaNamed(IDR_THEME_FRAME_INACTIVE); |
| 33 } else { | 33 } else { |
| 34 Profile* profile = browser_view_->browser()->profile(); | 34 Profile* profile = browser_view_->browser()->profile(); |
| 35 ui::ThemeProvider* theme = ThemeServiceFactory::GetForProfile(profile); | 35 ui::ThemeProvider* theme = ThemeServiceFactory::GetForProfile(profile); |
| 36 | 36 |
| 37 if (browser_view_->IsActive()) { | 37 if (browser_view_->IsActive()) { |
| 38 background = theme->GetBitmapNamed( | 38 background = theme->GetImageSkiaNamed( |
| 39 profile->IsOffTheRecord() ? | 39 profile->IsOffTheRecord() ? |
| 40 IDR_THEME_FRAME_INCOGNITO : IDR_THEME_FRAME); | 40 IDR_THEME_FRAME_INCOGNITO : IDR_THEME_FRAME); |
| 41 } else { | 41 } else { |
| 42 background = theme->GetBitmapNamed( | 42 background = theme->GetImageSkiaNamed( |
| 43 profile->IsOffTheRecord() ? | 43 profile->IsOffTheRecord() ? |
| 44 IDR_THEME_FRAME_INCOGNITO_INACTIVE : IDR_THEME_FRAME_INACTIVE); | 44 IDR_THEME_FRAME_INCOGNITO_INACTIVE : IDR_THEME_FRAME_INACTIVE); |
| 45 } | 45 } |
| 46 } | 46 } |
| 47 | 47 |
| 48 gfx::Point origin(0, 0); | 48 gfx::Point origin(0, 0); |
| 49 views::View::ConvertPointToView(view, | 49 views::View::ConvertPointToView(view, |
| 50 browser_view_->frame()->GetFrameView(), | 50 browser_view_->frame()->GetFrameView(), |
| 51 &origin); | 51 &origin); |
| 52 canvas->TileImageInt(*background, | 52 canvas->TileImageInt(*background, |
| 53 origin.x(), origin.y(), 0, 0, | 53 origin.x(), origin.y(), 0, 0, |
| 54 view->width(), view->height()); | 54 view->width(), view->height()); |
| 55 } | 55 } |
| OLD | NEW |