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.
7 #include "base/string_util.h"
8 #include "base/utf_string_conversions.h"
9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIntentServiceInfo.h"
10 #include "webkit/glue/web_intent_service_data.h"
12 namespace webkit_glue
{
14 static const char kIntentsInlineDisposition
[] = "inline";
15 static const char kIntentsWindowDisposition
[] = "window";
17 WebIntentServiceData::WebIntentServiceData()
18 : disposition(WebIntentServiceData::DISPOSITION_WINDOW
) {
21 WebIntentServiceData::WebIntentServiceData(const string16
& svc_action
,
22 const string16
& svc_type
,
23 const string16
& svc_scheme
,
24 const GURL
& svc_service_url
,
25 const string16
& svc_title
)
29 service_url(svc_service_url
),
31 disposition(WebIntentServiceData::DISPOSITION_WINDOW
) {
34 WebIntentServiceData::WebIntentServiceData(
35 const WebKit::WebIntentServiceInfo
& info
)
36 : action(info
.action()),
39 service_url(info
.url()),
41 disposition(WebIntentServiceData::DISPOSITION_WINDOW
) {
42 setDisposition(info
.disposition());
45 WebIntentServiceData::~WebIntentServiceData() {}
47 bool WebIntentServiceData::operator==(const WebIntentServiceData
& other
) const {
48 return action
== other
.action
&&
50 scheme
== other
.scheme
&&
51 service_url
== other
.service_url
&&
52 title
== other
.title
&&
53 disposition
== other
.disposition
;
56 void WebIntentServiceData::setDisposition(const string16
& disp
) {
57 if (EqualsASCII(disp
, kIntentsInlineDisposition
))
58 disposition
= DISPOSITION_INLINE
;
59 else if (EqualsASCII(disp
, kIntentsWindowDisposition
))
60 disposition
= DISPOSITION_WINDOW
;
61 // NOTE: We intentionally do not support setting "native" disposition
62 // via this method. This keeps non-native services from
63 // claiming to be native...which is no supported...obviously.
66 std::ostream
& operator<<(::std::ostream
& os
,
67 const WebIntentServiceData
& intent
) {
69 "{action=" << UTF16ToUTF8(intent
.action
) <<
70 "type=, " << UTF16ToUTF8(intent
.type
) <<
71 "scheme=, " << UTF16ToUTF8(intent
.scheme
) <<
72 "service_url=, " << intent
.service_url
<<
73 "title=, " << UTF16ToUTF8(intent
.title
) <<
74 "disposition=, " << intent
.disposition
<<
78 } // namespace webkit_glue