| 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 switch (action) { | 52 switch (action) { |
| 53 case RtcPrivateEventRouter::LAUNCH_ACTIVATE: | 53 case RtcPrivateEventRouter::LAUNCH_ACTIVATE: |
| 54 action_str = kActivateAction; | 54 return api::rtc_private::RTC_PRIVATE_ACTION_TYPE_NONE; |
| 55 break; | |
| 56 case RtcPrivateEventRouter::LAUNCH_CHAT: | 55 case RtcPrivateEventRouter::LAUNCH_CHAT: |
| 57 action_str = kChatAction; | 56 return api::rtc_private::RTC_PRIVATE_ACTION_TYPE_CHAT; |
| 58 break; | |
| 59 case RtcPrivateEventRouter::LAUNCH_VOICE: | 57 case RtcPrivateEventRouter::LAUNCH_VOICE: |
| 60 action_str = kVoiceAction; | 58 return api::rtc_private::RTC_PRIVATE_ACTION_TYPE_VOICE; |
| 61 break; | |
| 62 case RtcPrivateEventRouter::LAUNCH_VIDEO: | 59 case RtcPrivateEventRouter::LAUNCH_VIDEO: |
| 63 action_str = kVideoAction; | 60 return api::rtc_private::RTC_PRIVATE_ACTION_TYPE_VIDEO; |
| 64 break; | |
| 65 default: | |
| 66 NOTREACHED() << "Unknown action " << action; | |
| 67 break; | |
| 68 } | 61 } |
| 69 return action_str; | 62 return api::rtc_private::RTC_PRIVATE_ACTION_TYPE_NONE; |
| 70 } | 63 } |
| 71 | 64 |
| 72 // Creates JSON payload string for contact web intent data. | 65 // Creates JSON payload string for contact web intent data. |
| 73 void GetContactIntentData(const Contact& contact, | 66 void GetContactIntentData(const Contact& contact, |
| 74 DictionaryValue* dict) { | 67 DictionaryValue* dict) { |
| 75 // TODO(derat): This might require more name extraction magic than this. | 68 // TODO(derat): This might require more name extraction magic than this. |
| 76 dict->SetString(kNameIntentField, contact.full_name()); | 69 dict->SetString(kNameIntentField, contact.full_name()); |
| 77 | 70 |
| 78 ListValue* phone_list = new base::ListValue(); | 71 ListValue* phone_list = new base::ListValue(); |
| 79 dict->Set(kPhoneIntentField, phone_list); | 72 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()-> | 112 extensions::ExtensionSystem::Get(profile)->event_router()-> |
| 120 DispatchEventToRenderers( | 113 DispatchEventToRenderers( |
| 121 kOnLaunchEvent, | 114 kOnLaunchEvent, |
| 122 extensions::api::rtc_private::OnLaunch::Create(launch_data), | 115 extensions::api::rtc_private::OnLaunch::Create(launch_data), |
| 123 profile, | 116 profile, |
| 124 GURL()); | 117 GURL()); |
| 125 } | 118 } |
| 126 } | 119 } |
| 127 | 120 |
| 128 } // namespace extensions | 121 } // namespace extensions |
| OLD | NEW |