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

Side by Side Diff: app/mac/nsimage_cache.mm

Issue 6046009: Move base/mac_util.h to base/mac and use the base::mac namespace.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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
« no previous file with comments | « app/clipboard/clipboard_mac.mm ('k') | app/resource_bundle_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "app/mac/nsimage_cache.h" 5 #include "app/mac/nsimage_cache.h"
6 6
7 #import <AppKit/AppKit.h> 7 #import <AppKit/AppKit.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/mac_util.h" 10 #include "base/mac/mac_util.h"
11 11
12 // When C++ exceptions are disabled, the C++ library defines |try| and 12 // When C++ exceptions are disabled, the C++ library defines |try| and
13 // |catch| so as to allow exception-expecting C++ code to build properly when 13 // |catch| so as to allow exception-expecting C++ code to build properly when
14 // language support for exceptions is not present. These macros interfere 14 // language support for exceptions is not present. These macros interfere
15 // with the use of |@try| and |@catch| in Objective-C files such as this one. 15 // with the use of |@try| and |@catch| in Objective-C files such as this one.
16 // Undefine these macros here, after everything has been #included, since 16 // Undefine these macros here, after everything has been #included, since
17 // there will be no C++ uses and only Objective-C uses from this point on. 17 // there will be no C++ uses and only Objective-C uses from this point on.
18 #undef try 18 #undef try
19 #undef catch 19 #undef catch
20 20
(...skipping 11 matching lines...) Expand all
32 if (!image_cache) { 32 if (!image_cache) {
33 image_cache = [[NSMutableDictionary alloc] init]; 33 image_cache = [[NSMutableDictionary alloc] init];
34 DCHECK(image_cache); 34 DCHECK(image_cache);
35 } 35 }
36 36
37 NSImage* result = [image_cache objectForKey:name]; 37 NSImage* result = [image_cache objectForKey:name];
38 if (!result) { 38 if (!result) {
39 DVLOG_IF(1, [[name pathExtension] length] == 0) << "Suggest including the " 39 DVLOG_IF(1, [[name pathExtension] length] == 0) << "Suggest including the "
40 "extension in the image name"; 40 "extension in the image name";
41 41
42 NSString* path = [mac_util::MainAppBundle() pathForImageResource:name]; 42 NSString* path = [base::mac::MainAppBundle() pathForImageResource:name];
43 if (path) { 43 if (path) {
44 @try { 44 @try {
45 result = [[[NSImage alloc] initWithContentsOfFile:path] autorelease]; 45 result = [[[NSImage alloc] initWithContentsOfFile:path] autorelease];
46 if (result) { 46 if (result) {
47 // Auto-template images with names ending in "Template". 47 // Auto-template images with names ending in "Template".
48 NSString* extensionlessName = [name stringByDeletingPathExtension]; 48 NSString* extensionlessName = [name stringByDeletingPathExtension];
49 if ([extensionlessName hasSuffix:@"Template"]) 49 if ([extensionlessName hasSuffix:@"Template"])
50 [result setTemplate:YES]; 50 [result setTemplate:YES];
51 51
52 [image_cache setObject:result forKey:name]; 52 [image_cache setObject:result forKey:name];
(...skipping 13 matching lines...) Expand all
66 return result; 66 return result;
67 } 67 }
68 68
69 void ClearCachedImages(void) { 69 void ClearCachedImages(void) {
70 // NOTE: to make this thread safe, we'd have to sync on the cache. 70 // NOTE: to make this thread safe, we'd have to sync on the cache.
71 [image_cache removeAllObjects]; 71 [image_cache removeAllObjects];
72 } 72 }
73 73
74 } // namespace mac 74 } // namespace mac
75 } // namespace app 75 } // namespace app
OLDNEW
« no previous file with comments | « app/clipboard/clipboard_mac.mm ('k') | app/resource_bundle_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698