OLD | NEW |
(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 #ifndef CONTENT_COMMON_DWRITE_LOCALIZED_STRINGS_WIN_H_ |
| 6 #define CONTENT_COMMON_DWRITE_LOCALIZED_STRINGS_WIN_H_ |
| 7 |
| 8 #include <dwrite.h> |
| 9 #include <wrl.h> |
| 10 #include <utility> |
| 11 #include <vector> |
| 12 |
| 13 #include "base/strings/string16.h" |
| 14 |
| 15 namespace mswr = Microsoft::WRL; |
| 16 |
| 17 namespace content { |
| 18 |
| 19 // Impements IDWriteLocalizedStrings, backed by a vector of string pairs. |
| 20 class DWriteLocalizedStrings |
| 21 : public mswr::RuntimeClass<mswr::RuntimeClassFlags<mswr::ClassicCom>, |
| 22 IDWriteLocalizedStrings> { |
| 23 public: |
| 24 HRESULT STDMETHODCALLTYPE FindLocaleName(const WCHAR* localeName, |
| 25 UINT32* index, |
| 26 BOOL* exists) override; |
| 27 |
| 28 UINT32 STDMETHODCALLTYPE GetCount() override; |
| 29 |
| 30 HRESULT STDMETHODCALLTYPE GetLocaleName(UINT32 index, |
| 31 WCHAR* localeName, |
| 32 UINT32 size) override; |
| 33 |
| 34 HRESULT STDMETHODCALLTYPE GetLocaleNameLength(UINT32 index, |
| 35 UINT32* length) override; |
| 36 |
| 37 HRESULT STDMETHODCALLTYPE GetString(UINT32 index, |
| 38 WCHAR* stringBuffer, |
| 39 UINT32 size) override; |
| 40 |
| 41 HRESULT STDMETHODCALLTYPE GetStringLength(UINT32 index, |
| 42 UINT32* length) override; |
| 43 |
| 44 HRESULT STDMETHODCALLTYPE RuntimeClassInitialize( |
| 45 std::vector<std::pair<base::string16, base::string16>>* strings); |
| 46 |
| 47 protected: |
| 48 HRESULT ReturnString(base::string16 string, WCHAR* buffer, UINT32 size); |
| 49 |
| 50 private: |
| 51 // List of strings. First element of each pair is the locale, and the second |
| 52 // element is the associated value. Use a vector because the expected number |
| 53 // of pairs is small (typically 1-2, rarely up to a few dozen?) and we need |
| 54 // index-based access. |
| 55 std::vector<std::pair<base::string16, base::string16>> strings_; |
| 56 }; |
| 57 |
| 58 } // namespace content |
| 59 #endif // CONTENT_COMMON_DWRITE_LOCALIZED_STRINGS_WIN_H_ |
OLD | NEW |