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
3 // found in the LICENSE file.
5 #include "net/proxy/proxy_resolver_script_data.h"
7 #include "base/logging.h"
8 #include "base/strings/utf_string_conversions.h"
13 scoped_refptr
<ProxyResolverScriptData
> ProxyResolverScriptData::FromUTF8(
14 const std::string
& utf8
) {
15 return new ProxyResolverScriptData(TYPE_SCRIPT_CONTENTS
,
17 base::UTF8ToUTF16(utf8
));
21 scoped_refptr
<ProxyResolverScriptData
> ProxyResolverScriptData::FromUTF16(
22 const base::string16
& utf16
) {
23 return new ProxyResolverScriptData(TYPE_SCRIPT_CONTENTS
, GURL(), utf16
);
27 scoped_refptr
<ProxyResolverScriptData
> ProxyResolverScriptData::FromURL(
29 return new ProxyResolverScriptData(TYPE_SCRIPT_URL
, url
, base::string16());
33 scoped_refptr
<ProxyResolverScriptData
>
34 ProxyResolverScriptData::ForAutoDetect() {
35 return new ProxyResolverScriptData(TYPE_AUTO_DETECT
, GURL(),
39 const base::string16
& ProxyResolverScriptData::utf16() const {
40 DCHECK_EQ(TYPE_SCRIPT_CONTENTS
, type_
);
44 const GURL
& ProxyResolverScriptData::url() const {
45 DCHECK_EQ(TYPE_SCRIPT_URL
, type_
);
49 bool ProxyResolverScriptData::Equals(
50 const ProxyResolverScriptData
* other
) const {
51 if (type() != other
->type())
55 case TYPE_SCRIPT_CONTENTS
:
56 return utf16() == other
->utf16();
58 return url() == other
->url();
59 case TYPE_AUTO_DETECT
:
63 return false; // Shouldn't be reached.
66 ProxyResolverScriptData::ProxyResolverScriptData(Type type
,
68 const base::string16
& utf16
)
74 ProxyResolverScriptData::~ProxyResolverScriptData() {}