OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/browser/extensions/api/rtc_private/rtc_private_api.h" | 5 #include "chrome/browser/extensions/api/rtc_private/rtc_private_api.h" |
6 | 6 |
7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
(...skipping 28 matching lines...) Expand all Loading... | |
39 // Web intent actions. | 39 // Web intent actions. |
40 const char kActivateAction[] = "activate"; | 40 const char kActivateAction[] = "activate"; |
41 const char kChatAction[] = "chat"; | 41 const char kChatAction[] = "chat"; |
42 const char kVoiceAction[] = "voice"; | 42 const char kVoiceAction[] = "voice"; |
43 const char kVideoAction[] = "video"; | 43 const char kVideoAction[] = "video"; |
44 // Web intent data structure fields. | 44 // Web intent data structure fields. |
45 const char kNameIntentField[] = "name"; | 45 const char kNameIntentField[] = "name"; |
46 const char kPhoneIntentField[] = "phone"; | 46 const char kPhoneIntentField[] = "phone"; |
47 const char kEmailIntentField[] = "email"; | 47 const char kEmailIntentField[] = "email"; |
48 | 48 |
49 // Returns string representation of intent action. | 49 // Returns the ActionType of intent action. |
50 const char* GetLaunchAction(RtcPrivateEventRouter::LaunchAction action) { | 50 api::rtc_private::ActionType GetLaunchAction( |
51 const char* action_str = kActivateAction; | 51 RtcPrivateEventRouter::LaunchAction action) { |
52 api::rtc_private::ActionType action_type = | |
53 api::rtc_private::RTC_PRIVATE_ACTION_TYPE_NONE; | |
52 switch (action) { | 54 switch (action) { |
53 case RtcPrivateEventRouter::LAUNCH_ACTIVATE: | 55 case RtcPrivateEventRouter::LAUNCH_ACTIVATE: |
54 action_str = kActivateAction; | 56 action_type = api::rtc_private::RTC_PRIVATE_ACTION_TYPE_NONE; |
not at google - send to devlin
2012/09/24 22:46:29
why does this map to NONE not ACTIVATE?
cduvall
2012/09/24 22:51:47
In the IDL file there is only "chat", "voice", and
not at google - send to devlin
2012/09/24 22:54:14
Bizarre. I don't know how the code works as is, th
zel
2012/09/24 23:00:57
That's fine as it is right now. We will modify C++
| |
55 break; | 57 break; |
56 case RtcPrivateEventRouter::LAUNCH_CHAT: | 58 case RtcPrivateEventRouter::LAUNCH_CHAT: |
57 action_str = kChatAction; | 59 action_type = api::rtc_private::RTC_PRIVATE_ACTION_TYPE_CHAT; |
58 break; | 60 break; |
59 case RtcPrivateEventRouter::LAUNCH_VOICE: | 61 case RtcPrivateEventRouter::LAUNCH_VOICE: |
60 action_str = kVoiceAction; | 62 action_type = api::rtc_private::RTC_PRIVATE_ACTION_TYPE_VOICE; |
61 break; | 63 break; |
62 case RtcPrivateEventRouter::LAUNCH_VIDEO: | 64 case RtcPrivateEventRouter::LAUNCH_VIDEO: |
63 action_str = kVideoAction; | 65 action_type = api::rtc_private::RTC_PRIVATE_ACTION_TYPE_VIDEO; |
64 break; | 66 break; |
65 default: | 67 default: |
66 NOTREACHED() << "Unknown action " << action; | 68 NOTREACHED() << "Unknown action " << action; |
67 break; | 69 break; |
not at google - send to devlin
2012/09/24 22:46:29
this method could be more concise by returning the
cduvall
2012/09/24 22:51:47
Done.
| |
68 } | 70 } |
69 return action_str; | 71 return action_type; |
70 } | 72 } |
71 | 73 |
72 // Creates JSON payload string for contact web intent data. | 74 // Creates JSON payload string for contact web intent data. |
73 void GetContactIntentData(const Contact& contact, | 75 void GetContactIntentData(const Contact& contact, |
74 DictionaryValue* dict) { | 76 DictionaryValue* dict) { |
75 // TODO(derat): This might require more name extraction magic than this. | 77 // TODO(derat): This might require more name extraction magic than this. |
76 dict->SetString(kNameIntentField, contact.full_name()); | 78 dict->SetString(kNameIntentField, contact.full_name()); |
77 | 79 |
78 ListValue* phone_list = new base::ListValue(); | 80 ListValue* phone_list = new base::ListValue(); |
79 dict->Set(kPhoneIntentField, phone_list); | 81 dict->Set(kPhoneIntentField, phone_list); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 extensions::ExtensionSystem::Get(profile)->event_router()-> | 121 extensions::ExtensionSystem::Get(profile)->event_router()-> |
120 DispatchEventToRenderers( | 122 DispatchEventToRenderers( |
121 kOnLaunchEvent, | 123 kOnLaunchEvent, |
122 extensions::api::rtc_private::OnLaunch::Create(launch_data), | 124 extensions::api::rtc_private::OnLaunch::Create(launch_data), |
123 profile, | 125 profile, |
124 GURL()); | 126 GURL()); |
125 } | 127 } |
126 } | 128 } |
127 | 129 |
128 } // namespace extensions | 130 } // namespace extensions |
OLD | NEW |