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 // Key and value names of the location of the RLZ shared state. 6 7 #include "rlz/lib/lib_values.h" 8 9 #include "base/strings/stringprintf.h" 10 #include "rlz/lib/assert.h" 11 12 namespace rlz_lib { 13 14 // 15 // Ping information. 16 // 17 18 // rep=2: includes the new stateful events. 19 const char kProtocolCgiArgument[] = "rep=2"; 20 21 const char kEventsCgiVariable[] = "events"; 22 const char kStatefulEventsCgiVariable[] = "stateful-events"; 23 const char kEventsCgiSeparator = ','; 24 25 const char kRlzCgiVariable[] = "rlz"; 26 const char kRlzCgiSeparator[] = ","; 27 const char kRlzCgiIndicator[] = ":"; 28 29 const char kProductSignatureCgiVariable[] = "as"; 30 const char kProductBrandCgiVariable[] = "brand"; 31 const char kProductLanguageCgiVariable[] = "hl"; 32 const char kProductIdCgiVariable[] = "pid"; 33 34 const char kDccCgiVariable[] = "dcc"; 35 const char kRlsCgiVariable[] = "rls"; 36 const char kMachineIdCgiVariable[] = "id"; 37 const char kSetDccResponseVariable[] = "set_dcc"; 38 39 // 40 // Financial server information. 41 // 42 43 const char kFinancialPingPath[] = "/tools/pso/ping"; 44 const char kFinancialServer[] = "clients1.google.com"; 45 const int kFinancialPort = 80; 46 47 // Ping times in 100-nanosecond intervals. 48 const int64 kEventsPingInterval = 24LL * 3600LL * 10000000LL; // 1 day 49 const int64 kNoEventsPingInterval = kEventsPingInterval * 7LL; // 1 week 50 51 const char kFinancialPingUserAgent[] = "Mozilla/4.0 (compatible; Win32)"; 52 const char* kFinancialPingResponseObjects[] = { "text/*", NULL }; 53 54 // 55 // AccessPoint and Event names. 56 // 57 // 58 GetAccessPointName(AccessPoint point)59const char* GetAccessPointName(AccessPoint point) { 60 switch (point) { 61 case NO_ACCESS_POINT: return ""; 62 case IE_DEFAULT_SEARCH: return "I7"; 63 case IE_HOME_PAGE: return "W1"; 64 case IETB_SEARCH_BOX: return "T4"; 65 case QUICK_SEARCH_BOX: return "Q1"; 66 case GD_DESKBAND: return "D1"; 67 case GD_SEARCH_GADGET: return "D2"; 68 case GD_WEB_SERVER: return "D3"; 69 case GD_OUTLOOK: return "D4"; 70 case CHROME_OMNIBOX: return "C1"; 71 case CHROME_HOME_PAGE: return "C2"; 72 case FFTB2_BOX: return "B2"; 73 case FFTB3_BOX: return "B3"; 74 case PINYIN_IME_BHO: return "N1"; 75 case IGOOGLE_WEBPAGE: return "G1"; 76 case MOBILE_IDLE_SCREEN_BLACKBERRY: return "H1"; 77 case MOBILE_IDLE_SCREEN_WINMOB: return "H2"; 78 case MOBILE_IDLE_SCREEN_SYMBIAN: return "H3"; 79 case FF_HOME_PAGE: return "R0"; 80 case FF_SEARCH_BOX: return "R1"; 81 case IE_BROWSED_PAGE: return "R2"; 82 case QSB_WIN_BOX: return "R3"; 83 case WEBAPPS_CALENDAR: return "R4"; 84 case WEBAPPS_DOCS: return "R5"; 85 case WEBAPPS_GMAIL: return "R6"; 86 case IETB_LINKDOCTOR: return "R7"; 87 case FFTB_LINKDOCTOR: return "R8"; 88 case IETB7_SEARCH_BOX: return "T7"; 89 case TB8_SEARCH_BOX: return "T8"; 90 case CHROME_FRAME: return "C3"; 91 case PARTNER_AP_1: return "V1"; 92 case PARTNER_AP_2: return "V2"; 93 case PARTNER_AP_3: return "V3"; 94 case PARTNER_AP_4: return "V4"; 95 case PARTNER_AP_5: return "V5"; 96 case CHROME_MAC_OMNIBOX: return "C5"; 97 case CHROME_MAC_HOME_PAGE: return "C6"; 98 case CHROMEOS_OMNIBOX: return "CA"; 99 case CHROMEOS_HOME_PAGE: return "CB"; 100 case CHROMEOS_APP_LIST: return "CC"; 101 case CHROME_IOS_OMNIBOX_TABLET: return "C9"; 102 case CHROME_IOS_OMNIBOX_MOBILE: return "CD"; 103 case CHROME_APP_LIST: return "C7"; 104 case CHROME_MAC_APP_LIST: return "C8"; 105 case UNDEFINED_AP_Q: return "RQ"; 106 case UNDEFINED_AP_R: return "RR"; 107 case UNDEFINED_AP_S: return "RS"; 108 case UNDEFINED_AP_T: return "RT"; 109 case UNDEFINED_AP_U: return "RU"; 110 case UNDEFINED_AP_V: return "RV"; 111 case UNDEFINED_AP_W: return "RW"; 112 case UNDEFINED_AP_X: return "RX"; 113 case UNDEFINED_AP_Y: return "RY"; 114 case UNDEFINED_AP_Z: return "RZ"; 115 case PACK_AP0: return "U0"; 116 case PACK_AP1: return "U1"; 117 case PACK_AP2: return "U2"; 118 case PACK_AP3: return "U3"; 119 case PACK_AP4: return "U4"; 120 case PACK_AP5: return "U5"; 121 case PACK_AP6: return "U6"; 122 case PACK_AP7: return "U7"; 123 case PACK_AP8: return "U8"; 124 case PACK_AP9: return "U9"; 125 case PACK_AP10: return "UA"; 126 case PACK_AP11: return "UB"; 127 case PACK_AP12: return "UC"; 128 case PACK_AP13: return "UD"; 129 case LAST_ACCESS_POINT: ; // Fall through. 130 } 131 132 ASSERT_STRING("GetAccessPointName: Unknown Access Point"); 133 return NULL; 134 } 135 136 GetAccessPointFromName(const char * name,AccessPoint * point)137bool GetAccessPointFromName(const char* name, AccessPoint* point) { 138 if (!point) { 139 ASSERT_STRING("GetAccessPointFromName: point is NULL"); 140 return false; 141 } 142 *point = NO_ACCESS_POINT; 143 if (!name) 144 return false; 145 146 for (int i = NO_ACCESS_POINT; i < LAST_ACCESS_POINT; i++) 147 if (strcmp(name, GetAccessPointName(static_cast<AccessPoint>(i))) == 0) { 148 *point = static_cast<AccessPoint>(i); 149 return true; 150 } 151 152 return false; 153 } 154 155 GetEventName(Event event)156const char* GetEventName(Event event) { 157 switch (event) { 158 case INVALID_EVENT: return ""; 159 case INSTALL: return "I"; 160 case SET_TO_GOOGLE: return "S"; 161 case FIRST_SEARCH: return "F"; 162 case REPORT_RLS: return "R"; 163 case ACTIVATE: return "A"; 164 case LAST_EVENT: ; // Fall through. 165 } 166 167 ASSERT_STRING("GetPointName: Unknown Event"); 168 return NULL; 169 } 170 171 GetEventFromName(const char * name,Event * event)172bool GetEventFromName(const char* name, Event* event) { 173 if (!event) { 174 ASSERT_STRING("GetEventFromName: event is NULL"); 175 return false; 176 } 177 *event = INVALID_EVENT; 178 if (!name) 179 return false; 180 181 for (int i = INVALID_EVENT; i < LAST_EVENT; i++) 182 if (strcmp(name, GetEventName(static_cast<Event>(i))) == 0) { 183 *event = static_cast<Event>(i); 184 return true; 185 } 186 187 return false; 188 } 189 GetProductName(Product product)190const char* GetProductName(Product product) { 191 switch (product) { 192 case IE_TOOLBAR: return "T"; 193 case TOOLBAR_NOTIFIER: return "P"; 194 case PACK: return "U"; 195 case DESKTOP: return "D"; 196 case CHROME: return "C"; 197 case FF_TOOLBAR: return "B"; 198 case QSB_WIN: return "K"; 199 case WEBAPPS: return "W"; 200 case PINYIN_IME: return "N"; 201 case PARTNER: return "V"; 202 } 203 204 ASSERT_STRING("GetProductName: Unknown Product"); 205 return ""; 206 } 207 208 } // namespace rlz_lib 209