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

Side by Side Diff: content/child/dwrite_font_proxy/dwrite_localized_strings_win.cc

Issue 1438603002: Create direct write font proxy classes and unit tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge to origin/master Created 5 years, 1 month 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
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/child/dwrite_font_proxy/dwrite_localized_strings_win.h"
6
7 #include "base/logging.h"
8
9 namespace content {
10
11 HRESULT DWriteLocalizedStrings::FindLocaleName(const WCHAR* locale_name,
12 UINT32* index,
13 BOOL* exists) {
14 for (unsigned int n = 0; n < strings_.size(); n++) {
15 if (_wcsicmp(strings_[n].first.data(), locale_name) == 0) {
16 *index = n;
17 *exists = TRUE;
18 return S_OK;
19 }
20 }
21
22 *index = UINT_MAX;
23 *exists = FALSE;
24 return S_OK;
25 }
26
27 UINT32 DWriteLocalizedStrings::GetCount() {
28 return strings_.size();
29 }
30
31 HRESULT DWriteLocalizedStrings::GetLocaleName(UINT32 index,
32 WCHAR* locale_name,
33 UINT32 size) {
34 if (index >= strings_.size())
35 return E_INVALIDARG;
36 if (size <= strings_[index].first.size())
37 return E_INVALIDARG;
38 wcsncpy(locale_name, strings_[index].first.data(), size);
39 return S_OK;
40 }
41
42 HRESULT DWriteLocalizedStrings::GetLocaleNameLength(UINT32 index,
43 UINT32* length) {
44 if (index >= strings_.size())
45 return E_INVALIDARG;
46 *length = strings_[index].first.size();
47 return S_OK;
48 }
49
50 HRESULT DWriteLocalizedStrings::GetString(UINT32 index,
51 WCHAR* string_buffer,
52 UINT32 size) {
53 if (index >= strings_.size())
54 return E_INVALIDARG;
55 if (size <= strings_[index].second.size())
56 return E_INVALIDARG;
57 wcsncpy(string_buffer, strings_[index].second.data(), size);
58 return S_OK;
59 }
60
61 HRESULT DWriteLocalizedStrings::GetStringLength(UINT32 index, UINT32* length) {
62 if (index >= strings_.size())
63 return E_INVALIDARG;
64 *length = strings_[index].second.size();
65 return S_OK;
66 }
67
68 HRESULT DWriteLocalizedStrings::RuntimeClassInitialize(
69 std::vector<std::pair<base::string16, base::string16>>* strings) {
70 strings_.swap(*strings);
71 return S_OK;
72 }
73
74 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698