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

Side by Side Diff: ui/base/resource/resource_bundle_win.cc

Issue 7698005: Move base/resource_util.* into base/win/ since it's windows specific. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 years, 3 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 | « base/win/resource_util.cc ('k') | ui/gfx/canvas_direct2d_unittest.cc » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "ui/base/resource/resource_bundle.h" 5 #include "ui/base/resource/resource_bundle.h"
6 6
7 #include <atlbase.h> 7 #include <atlbase.h>
8 8
9 #include "base/debug/stack_trace.h" 9 #include "base/debug/stack_trace.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "base/resource_util.h"
13 #include "base/stl_util.h" 12 #include "base/stl_util.h"
14 #include "base/string_piece.h" 13 #include "base/string_piece.h"
14 #include "base/win/resource_util.h"
15 #include "base/win/windows_version.h" 15 #include "base/win/windows_version.h"
16 #include "ui/base/resource/data_pack.h" 16 #include "ui/base/resource/data_pack.h"
17 #include "ui/gfx/font.h" 17 #include "ui/gfx/font.h"
18 18
19 namespace ui { 19 namespace ui {
20 20
21 namespace { 21 namespace {
22 22
23 HINSTANCE resources_data_dll; 23 HINSTANCE resources_data_dll;
24 24
(...skipping 29 matching lines...) Expand all
54 void ResourceBundle::LoadTestResources(const FilePath& path) { 54 void ResourceBundle::LoadTestResources(const FilePath& path) {
55 // On Windows, the test resources are normally compiled into the binary 55 // On Windows, the test resources are normally compiled into the binary
56 // itself. 56 // itself.
57 } 57 }
58 58
59 // static 59 // static
60 RefCountedStaticMemory* ResourceBundle::LoadResourceBytes( 60 RefCountedStaticMemory* ResourceBundle::LoadResourceBytes(
61 DataHandle module, int resource_id) { 61 DataHandle module, int resource_id) {
62 void* data_ptr; 62 void* data_ptr;
63 size_t data_size; 63 size_t data_size;
64 if (base::GetDataResourceFromModule(module, resource_id, &data_ptr, 64 if (base::win::GetDataResourceFromModule(module, resource_id, &data_ptr,
65 &data_size)) { 65 &data_size)) {
66 return new RefCountedStaticMemory( 66 return new RefCountedStaticMemory(
67 reinterpret_cast<const unsigned char*>(data_ptr), data_size); 67 reinterpret_cast<const unsigned char*>(data_ptr), data_size);
68 } else { 68 } else {
69 return NULL; 69 return NULL;
70 } 70 }
71 } 71 }
72 72
73 // static 73 // static
74 void ResourceBundle::SetResourcesDataDLL(HINSTANCE handle) { 74 void ResourceBundle::SetResourcesDataDLL(HINSTANCE handle) {
75 resources_data_dll = handle; 75 resources_data_dll = handle;
76 } 76 }
77 77
78 HICON ResourceBundle::LoadThemeIcon(int icon_id) { 78 HICON ResourceBundle::LoadThemeIcon(int icon_id) {
79 return ::LoadIcon(resources_data_, MAKEINTRESOURCE(icon_id)); 79 return ::LoadIcon(resources_data_, MAKEINTRESOURCE(icon_id));
80 } 80 }
81 81
82 base::StringPiece ResourceBundle::GetRawDataResource(int resource_id) const { 82 base::StringPiece ResourceBundle::GetRawDataResource(int resource_id) const {
83 void* data_ptr; 83 void* data_ptr;
84 size_t data_size; 84 size_t data_size;
85 base::StringPiece data; 85 base::StringPiece data;
86 if (base::GetDataResourceFromModule(resources_data_, 86 if (base::win::GetDataResourceFromModule(resources_data_,
87 resource_id, 87 resource_id,
88 &data_ptr, 88 &data_ptr,
89 &data_size)) { 89 &data_size)) {
90 return base::StringPiece(static_cast<const char*>(data_ptr), data_size); 90 return base::StringPiece(static_cast<const char*>(data_ptr), data_size);
91 } else if (locale_resources_data_.get() && 91 } else if (locale_resources_data_.get() &&
92 locale_resources_data_->GetStringPiece(resource_id, &data)) { 92 locale_resources_data_->GetStringPiece(resource_id, &data)) {
93 return data; 93 return data;
94 } 94 }
95 95
96 // TODO(tony): Remove this ATL code once we remove the strings in 96 // TODO(tony): Remove this ATL code once we remove the strings in
97 // chrome.dll. 97 // chrome.dll.
98 const ATLSTRINGRESOURCEIMAGE* image = AtlGetStringResourceImage( 98 const ATLSTRINGRESOURCEIMAGE* image = AtlGetStringResourceImage(
99 resources_data_, resource_id); 99 resources_data_, resource_id);
(...skipping 15 matching lines...) Expand all
115 return ::LoadCursor(resources_data_, MAKEINTRESOURCE(cursor_id)); 115 return ::LoadCursor(resources_data_, MAKEINTRESOURCE(cursor_id));
116 } 116 }
117 117
118 // Windows only uses SkBitmap for gfx::Image, so this is the same as 118 // Windows only uses SkBitmap for gfx::Image, so this is the same as
119 // GetImageNamed. 119 // GetImageNamed.
120 gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id) { 120 gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id) {
121 return GetImageNamed(resource_id); 121 return GetImageNamed(resource_id);
122 } 122 }
123 123
124 } // namespace ui; 124 } // namespace ui;
OLDNEW
« no previous file with comments | « base/win/resource_util.cc ('k') | ui/gfx/canvas_direct2d_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698