summaryrefslogtreecommitdiffstats
path: root/webkit/glue/glue_util.h
blob: 0bb7106c74140a5e7716e83ac0dbc5a4991392bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef WEBKIT_GLUE_GLUE_UTIL_H_
#define WEBKIT_GLUE_GLUE_UTIL_H_

#include <string>

#include "base/file_path.h"
#include "base/string16.h"
#include "googleurl/src/gurl.h"

namespace WebCore {
class CString;
class IntRect;
class KURL;
class String;
}

namespace gfx {
class Rect;
}

namespace webkit_glue {

// WebCore::CString <-> std::string. All characters are 8-bit and are preserved
// unchanged.
std::string CStringToStdString(const WebCore::CString& str);
WebCore::CString StdStringToCString(const std::string& str);

// WebCore::String <-> std::wstring. We assume that the WebCore::String is in
// UTF-16, and will either copy to a UTF-16 std::wstring (on Windows) or convert
// to a UTF-32 one on Linux and Mac.
std::wstring StringToStdWString(const WebCore::String& str);
WebCore::String StdWStringToString(const std::wstring& str);

// WebCore::String -> string16. This is a direct copy of UTF-16 characters.
string16 StringToString16(const WebCore::String& str);
WebCore::String String16ToString(const string16& str);

// WebCore::String <-> std::string. We assume the WebCore::String is UTF-16 and
// the std::string is UTF-8, and convert as necessary.
std::string StringToStdString(const WebCore::String& str);
WebCore::String StdStringToString(const std::string& str);

FilePath::StringType StringToFilePathString(const WebCore::String& str);
WebCore::String FilePathStringToString(const FilePath::StringType& str);

GURL KURLToGURL(const WebCore::KURL& url);
WebCore::KURL GURLToKURL(const GURL& url);
GURL StringToGURL(const WebCore::String& spec);

gfx::Rect FromIntRect(const WebCore::IntRect& r);
WebCore::IntRect ToIntRect(const gfx::Rect& r);

}  // namespace webkit_glue

#endif  // #ifndef WEBKIT_GLUE_GLUE_UTIL_H_