OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <ostream> | 5 #include <ostream> |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "webkit/glue/web_intent_service_data.h" | 8 #include "webkit/glue/web_intent_service_data.h" |
9 | 9 |
| 10 namespace webkit_glue { |
| 11 |
| 12 static const char kIntentsInlineDisposition[] = "inline"; |
| 13 |
| 14 } // namespace webkit_glue |
| 15 |
10 WebIntentServiceData::WebIntentServiceData() | 16 WebIntentServiceData::WebIntentServiceData() |
11 : disposition(WebIntentServiceData::DISPOSITION_WINDOW) { | 17 : disposition(WebIntentServiceData::DISPOSITION_WINDOW) { |
12 } | 18 } |
13 | 19 |
14 WebIntentServiceData::WebIntentServiceData(const GURL& svc_url, | 20 WebIntentServiceData::WebIntentServiceData(const GURL& svc_url, |
15 const string16& svc_action, | 21 const string16& svc_action, |
16 const string16& svc_type, | 22 const string16& svc_type, |
17 const string16& svc_title) | 23 const string16& svc_title) |
18 : service_url(svc_url), | 24 : service_url(svc_url), |
19 action(svc_action), | 25 action(svc_action), |
20 type(svc_type), | 26 type(svc_type), |
21 title(svc_title), | 27 title(svc_title), |
22 disposition(WebIntentServiceData::DISPOSITION_WINDOW) { | 28 disposition(WebIntentServiceData::DISPOSITION_WINDOW) { |
23 } | 29 } |
24 | 30 |
25 WebIntentServiceData::~WebIntentServiceData() {} | 31 WebIntentServiceData::~WebIntentServiceData() {} |
26 | 32 |
27 bool WebIntentServiceData::operator==(const WebIntentServiceData& other) const { | 33 bool WebIntentServiceData::operator==(const WebIntentServiceData& other) const { |
28 return service_url == other.service_url && | 34 return service_url == other.service_url && |
29 action == other.action && | 35 action == other.action && |
30 type == other.type && | 36 type == other.type && |
31 title == other.title && | 37 title == other.title && |
32 disposition == other.disposition; | 38 disposition == other.disposition; |
33 } | 39 } |
34 | 40 |
| 41 void WebIntentServiceData::setDisposition(const string16& disp) { |
| 42 if (disp == ASCIIToUTF16(webkit_glue::kIntentsInlineDisposition)) |
| 43 disposition = DISPOSITION_INLINE; |
| 44 else |
| 45 disposition = DISPOSITION_WINDOW; |
| 46 } |
| 47 |
35 std::ostream& operator<<(::std::ostream& os, | 48 std::ostream& operator<<(::std::ostream& os, |
36 const WebIntentServiceData& intent) { | 49 const WebIntentServiceData& intent) { |
37 return os << | 50 return os << |
38 "{" << intent.service_url << | 51 "{" << intent.service_url << |
39 ", " << UTF16ToUTF8(intent.action) << | 52 ", " << UTF16ToUTF8(intent.action) << |
40 ", " << UTF16ToUTF8(intent.type) << | 53 ", " << UTF16ToUTF8(intent.type) << |
41 ", " << UTF16ToUTF8(intent.title) << | 54 ", " << UTF16ToUTF8(intent.title) << |
42 ", " << intent.disposition << | 55 ", " << intent.disposition << |
43 "}"; | 56 "}"; |
44 } | 57 } |
OLD | NEW |