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

Side by Side Diff: chrome/installer/util/l10n_string_util.cc

Issue 1492403002: Remove kuint32max. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: http security header file Created 5 years 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // This file defines utility functions for fetching localized resources. 5 // This file defines utility functions for fetching localized resources.
6 6
7 #include "chrome/installer/util/l10n_string_util.h" 7 #include "chrome/installer/util/l10n_string_util.h"
8 8
9 #include <atlbase.h> 9 #include <atlbase.h>
10 #include <stdint.h>
10 11
11 #include <algorithm> 12 #include <algorithm>
13 #include <limits>
12 14
13 #include "base/logging.h" 15 #include "base/logging.h"
14 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
15 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
16 #include "base/strings/stringprintf.h" 18 #include "base/strings/stringprintf.h"
17 #include "chrome/installer/util/language_selector.h" 19 #include "chrome/installer/util/language_selector.h"
18 20
19 namespace { 21 namespace {
20 22
21 const installer::LanguageSelector& GetLanguageSelector() { 23 const installer::LanguageSelector& GetLanguageSelector() {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 // Fall back on "en" if we don't have a resource for this language. 84 // Fall back on "en" if we don't have a resource for this language.
83 if (NULL == FindResource(NULL, resource.c_str(), RT_HTML)) 85 if (NULL == FindResource(NULL, resource.c_str(), RT_HTML))
84 resource = L"IDR_OEMPG_EN.HTML"; 86 resource = L"IDR_OEMPG_EN.HTML";
85 87
86 // Spaces and DOS paths must be url encoded. 88 // Spaces and DOS paths must be url encoded.
87 std::wstring url_path = 89 std::wstring url_path =
88 base::StringPrintf(L"res://%ls/#23/%ls", full_exe_path, resource.c_str()); 90 base::StringPrintf(L"res://%ls/#23/%ls", full_exe_path, resource.c_str());
89 91
90 // The cast is safe because url_path has limited length 92 // The cast is safe because url_path has limited length
91 // (see the definition of full_exe_path and resource). 93 // (see the definition of full_exe_path and resource).
92 DCHECK(kuint32max > (url_path.size() * 3)); 94 DCHECK(std::numeric_limits<uint32_t>::max() > (url_path.size() * 3));
93 DWORD count = static_cast<DWORD>(url_path.size() * 3); 95 DWORD count = static_cast<DWORD>(url_path.size() * 3);
94 scoped_ptr<wchar_t[]> url_canon(new wchar_t[count]); 96 scoped_ptr<wchar_t[]> url_canon(new wchar_t[count]);
95 HRESULT hr = ::UrlCanonicalizeW(url_path.c_str(), url_canon.get(), 97 HRESULT hr = ::UrlCanonicalizeW(url_path.c_str(), url_canon.get(),
96 &count, URL_ESCAPE_UNSAFE); 98 &count, URL_ESCAPE_UNSAFE);
97 if (SUCCEEDED(hr)) 99 if (SUCCEEDED(hr))
98 return std::wstring(url_canon.get()); 100 return std::wstring(url_canon.get());
99 return url_path; 101 return url_path;
100 } 102 }
101 103
102 std::wstring GetCurrentTranslation() { 104 std::wstring GetCurrentTranslation() {
103 return GetLanguageSelector().selected_translation(); 105 return GetLanguageSelector().selected_translation();
104 } 106 }
105 107
106 } // namespace installer 108 } // namespace installer
OLDNEW
« no previous file with comments | « chrome/browser/media_galleries/linux/snapshot_file_details.cc ('k') | extensions/browser/api/cast_channel/cast_framer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698