| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #include <ostream> | |
| 6 | |
| 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" | |
| 11 | |
| 12 namespace webkit_glue { | |
| 13 | |
| 14 static const char kIntentsInlineDisposition[] = "inline"; | |
| 15 static const char kIntentsWindowDisposition[] = "window"; | |
| 16 | |
| 17 WebIntentServiceData::WebIntentServiceData() | |
| 18 : disposition(WebIntentServiceData::DISPOSITION_WINDOW) { | |
| 19 } | |
| 20 | |
| 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) | |
| 26 : action(svc_action), | |
| 27 type(svc_type), | |
| 28 scheme(svc_scheme), | |
| 29 service_url(svc_service_url), | |
| 30 title(svc_title), | |
| 31 disposition(WebIntentServiceData::DISPOSITION_WINDOW) { | |
| 32 } | |
| 33 | |
| 34 WebIntentServiceData::WebIntentServiceData( | |
| 35 const WebKit::WebIntentServiceInfo& info) | |
| 36 : action(info.action()), | |
| 37 type(info.type()), | |
| 38 scheme(string16()), | |
| 39 service_url(info.url()), | |
| 40 title(info.title()), | |
| 41 disposition(WebIntentServiceData::DISPOSITION_WINDOW) { | |
| 42 setDisposition(info.disposition()); | |
| 43 } | |
| 44 | |
| 45 WebIntentServiceData::~WebIntentServiceData() {} | |
| 46 | |
| 47 bool WebIntentServiceData::operator==(const WebIntentServiceData& other) const { | |
| 48 return action == other.action && | |
| 49 type == other.type && | |
| 50 scheme == other.scheme && | |
| 51 service_url == other.service_url && | |
| 52 title == other.title && | |
| 53 disposition == other.disposition; | |
| 54 } | |
| 55 | |
| 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. | |
| 64 } | |
| 65 | |
| 66 std::ostream& operator<<(::std::ostream& os, | |
| 67 const WebIntentServiceData& intent) { | |
| 68 return os << | |
| 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 << | |
| 75 "}"; | |
| 76 } | |
| 77 | |
| 78 } // namespace webkit_glue | |
| OLD | NEW |