summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/views/frame/opaque_non_client_view.cc47
-rw-r--r--chrome/browser/views/frame/opaque_non_client_view.h14
2 files changed, 33 insertions, 28 deletions
diff --git a/chrome/browser/views/frame/opaque_non_client_view.cc b/chrome/browser/views/frame/opaque_non_client_view.cc
index 7fdbe04..751b4b6 100644
--- a/chrome/browser/views/frame/opaque_non_client_view.cc
+++ b/chrome/browser/views/frame/opaque_non_client_view.cc
@@ -302,10 +302,6 @@ ChromeFont OTRActiveWindowResources::title_font_;
SkBitmap* OTRInactiveWindowResources::standard_frame_bitmaps_[];
ChromeFont OTRInactiveWindowResources::title_font_;
-WindowResources* OpaqueNonClientView::active_resources_ = NULL;
-WindowResources* OpaqueNonClientView::inactive_resources_ = NULL;
-WindowResources* OpaqueNonClientView::active_otr_resources_ = NULL;
-WindowResources* OpaqueNonClientView::inactive_otr_resources_ = NULL;
SkBitmap OpaqueNonClientView::distributor_logo_;
// The distance between the top of the window and the top of the window
@@ -381,22 +377,12 @@ OpaqueNonClientView::OpaqueNonClientView(OpaqueFrame* frame,
close_button_(new ChromeViews::Button),
window_icon_(new TabIconView(this)),
frame_(frame),
- browser_view_(browser_view) {
+ browser_view_(browser_view),
+ current_active_resources_(NULL),
+ current_inactive_resources_(NULL) {
InitClass();
- if (browser_view->IsOffTheRecord()) {
- if (!active_otr_resources_) {
- // Lazy load OTR resources only when we first show an OTR frame.
- active_otr_resources_ = new OTRActiveWindowResources;
- inactive_otr_resources_ = new OTRInactiveWindowResources;
- }
- current_active_resources_ = active_otr_resources_;
- current_inactive_resources_= inactive_otr_resources_;
- } else {
- current_active_resources_ = active_resources_;
- current_inactive_resources_ = inactive_resources_;
- }
- WindowResources* resources = current_active_resources_;
+ WindowResources* resources = GetActiveResources();
minimize_button_->SetImage(
ChromeViews::Button::BS_NORMAL,
resources->GetPartBitmap(FRAME_MINIMIZE_BUTTON_ICON));
@@ -1033,13 +1019,32 @@ void OpaqueNonClientView::LayoutClientView() {
frame_->client_view()->SetBounds(client_bounds.ToRECT());
}
+WindowResources* OpaqueNonClientView::GetActiveResources() const {
+ if (!current_active_resources_) {
+ if (browser_view_->IsOffTheRecord()) {
+ current_active_resources_ = new OTRActiveWindowResources;
+ } else {
+ current_active_resources_ = new ActiveWindowResources;
+ }
+ }
+ return current_active_resources_;
+}
+
+WindowResources* OpaqueNonClientView::GetInactiveResources() const {
+ if (!current_inactive_resources_) {
+ if (browser_view_->IsOffTheRecord()) {
+ current_inactive_resources_ = new OTRInactiveWindowResources;
+ } else {
+ current_inactive_resources_ = new InactiveWindowResources;
+ }
+ }
+ return current_inactive_resources_;
+}
+
// static
void OpaqueNonClientView::InitClass() {
static bool initialized = false;
if (!initialized) {
- active_resources_ = new ActiveWindowResources;
- inactive_resources_ = new InactiveWindowResources;
-
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
SkBitmap* image = rb.GetBitmapNamed(IDR_DISTRIBUTOR_LOGO_LIGHT);
if (!image->isNull())
diff --git a/chrome/browser/views/frame/opaque_non_client_view.h b/chrome/browser/views/frame/opaque_non_client_view.h
index e684d81..0387798 100644
--- a/chrome/browser/views/frame/opaque_non_client_view.h
+++ b/chrome/browser/views/frame/opaque_non_client_view.h
@@ -92,10 +92,14 @@ class OpaqueNonClientView : public ChromeViews::NonClientView,
void LayoutClientView();
// Returns the set of resources to use to paint this view.
+ // TODO(beng): Make this conform to Google-style if this trick works.
WindowResources* resources() const {
return frame_->is_active() || paint_as_active() ?
- current_active_resources_ : current_inactive_resources_;
+ GetActiveResources() : GetInactiveResources();
}
+
+ inline WindowResources* GetActiveResources() const;
+ inline WindowResources* GetInactiveResources() const;
// The layout rect of the title, if visible.
gfx::Rect title_bounds_;
@@ -122,18 +126,14 @@ class OpaqueNonClientView : public ChromeViews::NonClientView,
BrowserView2* browser_view_;
// The resources currently used to paint this view.
- WindowResources* current_active_resources_;
- WindowResources* current_inactive_resources_;
+ mutable WindowResources* current_active_resources_;
+ mutable WindowResources* current_inactive_resources_;
// The accessible name of this view.
std::wstring accessible_name_;
static void InitClass();
static SkBitmap distributor_logo_;
- static WindowResources* active_resources_;
- static WindowResources* inactive_resources_;
- static WindowResources* active_otr_resources_;
- static WindowResources* inactive_otr_resources_;
DISALLOW_EVIL_CONSTRUCTORS(OpaqueNonClientView);
};