OLD | NEW |
---|---|
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <Carbon/Carbon.h> | 5 #include <Carbon/Carbon.h> |
6 | 6 |
7 #include "base/mac_util.h" | 7 #include "base/mac_util.h" |
8 #include "base/scoped_nsdisable_screen_updates.h" | 8 #include "base/scoped_nsdisable_screen_updates.h" |
9 #import "base/scoped_nsobject.h" | 9 #import "base/scoped_nsobject.h" |
10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
(...skipping 1184 matching lines...) Loading... | |
1195 // Position the find bar relative to the infobar container. | 1195 // Position the find bar relative to the infobar container. |
1196 [findBarCocoaController_ | 1196 [findBarCocoaController_ |
1197 positionFindBarView:[infoBarContainerController_ view]]; | 1197 positionFindBarView:[infoBarContainerController_ view]]; |
1198 } | 1198 } |
1199 | 1199 |
1200 @end | 1200 @end |
1201 | 1201 |
1202 @implementation GTMTheme (BrowserThemeProviderInitialization) | 1202 @implementation GTMTheme (BrowserThemeProviderInitialization) |
1203 + (GTMTheme *)themeWithBrowserThemeProvider:(BrowserThemeProvider*)provider | 1203 + (GTMTheme *)themeWithBrowserThemeProvider:(BrowserThemeProvider*)provider |
1204 isOffTheRecord:(BOOL)isOffTheRecord { | 1204 isOffTheRecord:(BOOL)isOffTheRecord { |
1205 GTMTheme *theme = [[[GTMTheme alloc] init] autorelease]; | 1205 // First check if it's in the cache. |
1206 typedef std::pair<std::string, BOOL> ThemeKey; | |
1207 static std::map<ThemeKey, GTMTheme*> cache; | |
Mark Mentovai
2009/08/26 01:25:49
I think that every place we have a static that lea
pink (ping after 24hrs)
2009/08/26 14:55:56
Done.
| |
1208 ThemeKey key(provider->GetThemeID(), isOffTheRecord); | |
1209 GTMTheme* theme = cache[key]; | |
1210 if (theme) | |
1211 return theme; | |
1212 | |
1213 theme = [[GTMTheme alloc] init]; // "Leak" it in the cache. | |
1214 cache[key] = theme; | |
1206 if (isOffTheRecord) { | 1215 if (isOffTheRecord) { |
1207 NSColor* incognitoColor = [NSColor colorWithCalibratedRed:83/255.0 | 1216 NSColor* incognitoColor = [NSColor colorWithCalibratedRed:83/255.0 |
1208 green:108.0/255.0 | 1217 green:108.0/255.0 |
1209 blue:140/255.0 | 1218 blue:140/255.0 |
1210 alpha:1.0]; | 1219 alpha:1.0]; |
1211 [theme setBackgroundColor:incognitoColor]; | 1220 [theme setBackgroundColor:incognitoColor]; |
1212 return theme; | 1221 return theme; |
1213 } | 1222 } |
1214 | 1223 |
1215 NSImage* frameImage = provider->GetNSImageNamed(IDR_THEME_FRAME); | 1224 NSImage* frameImage = provider->GetNSImageNamed(IDR_THEME_FRAME); |
(...skipping 69 matching lines...) Loading... | |
1285 NSColor* toolbarButtonBorderColor = toolbarButtonIconColor; | 1294 NSColor* toolbarButtonBorderColor = toolbarButtonIconColor; |
1286 [theme setValue:toolbarButtonBorderColor | 1295 [theme setValue:toolbarButtonBorderColor |
1287 forAttribute:@"borderColor" | 1296 forAttribute:@"borderColor" |
1288 style:GTMThemeStyleToolBar | 1297 style:GTMThemeStyleToolBar |
1289 state:YES]; | 1298 state:YES]; |
1290 | 1299 |
1291 return theme; | 1300 return theme; |
1292 } | 1301 } |
1293 @end | 1302 @end |
1294 | 1303 |
OLD | NEW |