Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: src/Utils.cpp

Issue 6584950149087232: Issue 1280 - Update v8 (Closed)
Patch Set: Created Oct. 24, 2014, 12:42 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/Utils.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 25 matching lines...) Expand all
36 36
37 std::string Utils::FromV8String(v8::Handle<v8::Value> value) 37 std::string Utils::FromV8String(v8::Handle<v8::Value> value)
38 { 38 {
39 v8::String::Utf8Value stringValue(value); 39 v8::String::Utf8Value stringValue(value);
40 if (stringValue.length()) 40 if (stringValue.length())
41 return std::string(*stringValue, stringValue.length()); 41 return std::string(*stringValue, stringValue.length());
42 else 42 else
43 return std::string(); 43 return std::string();
44 } 44 }
45 45
46 v8::Local<v8::String> Utils::ToV8String(const std::string& str) 46 v8::Local<v8::String> Utils::ToV8String(v8::Isolate* isolate, const std::string& str)
47 { 47 {
48 return v8::String::New(str.c_str(), str.length()); 48 return v8::String::NewFromUtf8(isolate, str.c_str(),
49 v8::String::NewStringType::kInternalizedString, str.length());
49 } 50 }
50 51
51 52
52 #ifdef _WIN32 53 #ifdef _WIN32
53 std::wstring Utils::ToUtf16String(const std::string& str) 54 std::wstring Utils::ToUtf16String(const std::string& str)
54 { 55 {
55 size_t length = str.size(); 56 size_t length = str.size();
56 if (length == 0) 57 if (length == 0)
57 return std::wstring(); 58 return std::wstring();
58 59
(...skipping 18 matching lines...) Expand all
77 78
78 std::string utf8String(utf8StringLength, '\0'); 79 std::string utf8String(utf8StringLength, '\0');
79 WideCharToMultiByte(CP_UTF8, 0, str.c_str(), length, &utf8String[0], utf8Strin gLength, 0, 0); 80 WideCharToMultiByte(CP_UTF8, 0, str.c_str(), length, &utf8String[0], utf8Strin gLength, 0, 0);
80 return utf8String; 81 return utf8String;
81 } 82 }
82 83
83 std::wstring Utils::CanonizeUrl(const std::wstring& url) 84 std::wstring Utils::CanonizeUrl(const std::wstring& url)
84 { 85 {
85 HRESULT hr; 86 HRESULT hr;
86 87
87 std::wstring canonizedUrl;
88 DWORD canonizedUrlLength = 2049; // de-facto limit of url length 88 DWORD canonizedUrlLength = 2049; // de-facto limit of url length
89 89 std::wstring canonizedUrl(canonizedUrlLength, L'\0');
90 canonizedUrl.resize(canonizedUrlLength); 90 DWORD flags = 0; // nothing special
91 hr = UrlCanonicalize(url.c_str(), &canonizedUrl[0], &canonizedUrlLength, 0); 91 hr = UrlCanonicalizeW(url.c_str(), &canonizedUrl[0], &canonizedUrlLength, flag s);
92 canonizedUrl.resize(canonizedUrlLength); 92 canonizedUrl.resize(canonizedUrlLength);
93 if (FAILED(hr)) 93 if (FAILED(hr))
94 { 94 {
95 hr = UrlCanonicalize(url.c_str(), &canonizedUrl[0], &canonizedUrlLength, 0); 95 hr = UrlCanonicalizeW(url.c_str(), &canonizedUrl[0], &canonizedUrlLength, fl ags);
96 if (FAILED(hr)) 96 if (FAILED(hr))
97 { 97 {
98 throw std::runtime_error("CanonizeUrl failed\n"); 98 throw std::runtime_error("CanonizeUrl failed\n");
99 } 99 }
100 } 100 }
101 return canonizedUrl; 101 return canonizedUrl;
102
103 } 102 }
104 #endif 103 #endif
105 104
OLDNEW
« no previous file with comments | « src/Utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld