OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Extract UserMetrics "actions" strings from the Chrome source. | 6 """Extract UserMetrics "actions" strings from the Chrome source. |
7 | 7 |
8 This program generates the list of known actions we expect to see in the | 8 This program generates the list of known actions we expect to see in the |
9 user behavior logs. It walks the Chrome source, looking for calls to | 9 user behavior logs. It walks the Chrome source, looking for calls to |
10 UserMetrics functions, extracting actions and warning on improper calls, | 10 UserMetrics functions, extracting actions and warning on improper calls, |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 actions.add('PDF_Unsupported_Movie') | 181 actions.add('PDF_Unsupported_Movie') |
182 actions.add('PDF_Unsupported_Sound') | 182 actions.add('PDF_Unsupported_Sound') |
183 actions.add('PDF_Unsupported_Screen') | 183 actions.add('PDF_Unsupported_Screen') |
184 actions.add('PDF_Unsupported_Portfolios_Packages') | 184 actions.add('PDF_Unsupported_Portfolios_Packages') |
185 actions.add('PDF_Unsupported_Attachment') | 185 actions.add('PDF_Unsupported_Attachment') |
186 actions.add('PDF_Unsupported_Digital_Signature') | 186 actions.add('PDF_Unsupported_Digital_Signature') |
187 actions.add('PDF_Unsupported_Shared_Review') | 187 actions.add('PDF_Unsupported_Shared_Review') |
188 actions.add('PDF_Unsupported_Shared_Form') | 188 actions.add('PDF_Unsupported_Shared_Form') |
189 actions.add('PDF_Unsupported_Bookmarks') | 189 actions.add('PDF_Unsupported_Bookmarks') |
190 | 190 |
| 191 def AddAndroidActions(actions): |
| 192 """Add actions that are used by Chrome on Android. |
| 193 |
| 194 Arguments |
| 195 actions: set of actions to add to. |
| 196 """ |
| 197 actions.add('MobileBeamCallbackSuccess') |
| 198 actions.add('MobileBeamInvalidAppState') |
| 199 actions.add('MobileBreakpadUploadAttempt') |
| 200 actions.add('MobileBreakpadUploadFailure') |
| 201 actions.add('MobileBreakpadUploadSuccess') |
| 202 actions.add('MobileContextMenuCopyImageLinkAddress') |
| 203 actions.add('MobileContextMenuCopyLinkAddress') |
| 204 actions.add('MobileContextMenuCopyLinkText') |
| 205 actions.add('MobileContextMenuImage') |
| 206 actions.add('MobileContextMenuLink') |
| 207 actions.add('MobileContextMenuOpenImageInNewTab') |
| 208 actions.add('MobileContextMenuOpenLink') |
| 209 actions.add('MobileContextMenuOpenLinkInIncognito') |
| 210 actions.add('MobileContextMenuOpenLinkInNewTab') |
| 211 actions.add('MobileContextMenuSaveImage') |
| 212 actions.add('MobileContextMenuShareLink') |
| 213 actions.add('MobileContextMenuText') |
| 214 actions.add('MobileContextMenuViewImage') |
| 215 actions.add('MobileFreAttemptSignIn') |
| 216 actions.add('MobileFreSignInSuccessful') |
| 217 actions.add('MobileFreSkipSignIn') |
| 218 actions.add('MobileMenuAddToBookmarks') |
| 219 actions.add('MobileMenuAllBookmarks') |
| 220 actions.add('MobileMenuBack') |
| 221 actions.add('MobileMenuCloseAllTabs') |
| 222 actions.add('MobileMenuCloseTab') |
| 223 actions.add('MobileMenuFeedback') |
| 224 actions.add('MobileMenuFindInPage') |
| 225 actions.add('MobileMenuForward') |
| 226 actions.add('MobileMenuFullscreen') |
| 227 actions.add('MobileMenuNewIncognitoTab') |
| 228 actions.add('MobileMenuNewTab') |
| 229 actions.add('MobileMenuOpenTabs') |
| 230 actions.add('MobileMenuQuit') |
| 231 actions.add('MobileMenuReload') |
| 232 actions.add('MobileMenuSettings') |
| 233 actions.add('MobileMenuShare') |
| 234 actions.add('MobileMenuShow') |
| 235 actions.add('MobileNTPBookmark') |
| 236 actions.add('MobileNTPForeignSession') |
| 237 actions.add('MobileNTPMostVisited') |
| 238 actions.add('MobileNTPSwitchToBookmarks') |
| 239 actions.add('MobileNTPSwitchToIncognito') |
| 240 actions.add('MobileNTPSwitchToMostVisited') |
| 241 actions.add('MobileNTPSwitchToOpenTabs') |
| 242 actions.add('MobileNewTabOpened') |
| 243 actions.add('MobileOmniboxSearch') |
| 244 actions.add('MobileOmniboxVoiceSearch') |
| 245 actions.add('MobilePageLoaded') |
| 246 actions.add('MobilePageLoadedDesktopUserAgent') |
| 247 actions.add('MobilePageLoadedWithKeyboard') |
| 248 actions.add('MobileReceivedExternalIntent') |
| 249 actions.add('MobileRendererCrashed') |
| 250 actions.add('MobileShortcutAllBookmarks') |
| 251 actions.add('MobileShortcutFindInPage') |
| 252 actions.add('MobileShortcutNewIncognitoTab') |
| 253 actions.add('MobileShortcutNewTab') |
| 254 actions.add('MobileSideSwipeFinished') |
| 255 actions.add('MobileStackViewCloseTab') |
| 256 actions.add('MobileStackViewSwipeCloseTab') |
| 257 actions.add('MobileTabClobbered') |
| 258 actions.add('MobileTabClosed') |
| 259 actions.add('MobileTabStripCloseTab') |
| 260 actions.add('MobileTabStripNewTab') |
| 261 actions.add('MobileTabSwitched') |
| 262 actions.add('MobileToolbarBack') |
| 263 actions.add('MobileToolbarForward') |
| 264 actions.add('MobileToolbarNewTab') |
| 265 actions.add('MobileToolbarReload') |
| 266 actions.add('MobileToolbarShowMenu') |
| 267 actions.add('MobileToolbarShowStackView') |
| 268 actions.add('MobileToolbarStackViewNewTab') |
| 269 actions.add('MobileToolbarToggleBookmark') |
| 270 actions.add('SystemBack') |
| 271 actions.add('SystemBackForNavigation') |
| 272 |
191 def AddAboutFlagsActions(actions): | 273 def AddAboutFlagsActions(actions): |
192 """This parses the experimental feature flags for UMA actions. | 274 """This parses the experimental feature flags for UMA actions. |
193 | 275 |
194 Arguments: | 276 Arguments: |
195 actions: set of actions to add to. | 277 actions: set of actions to add to. |
196 """ | 278 """ |
197 about_flags = os.path.join(path_utils.ScriptDir(), '..', 'browser', | 279 about_flags = os.path.join(path_utils.ScriptDir(), '..', 'browser', |
198 'about_flags.cc') | 280 'about_flags.cc') |
199 flag_name_re = re.compile(r'\s*"([0-9a-zA-Z\-_]+)",\s*// FLAGS:RECORD_UMA') | 281 flag_name_re = re.compile(r'\s*"([0-9a-zA-Z\-_]+)",\s*// FLAGS:RECORD_UMA') |
200 for line in open(about_flags): | 282 for line in open(about_flags): |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 AddRendererActions(actions) | 501 AddRendererActions(actions) |
420 | 502 |
421 AddLiteralActions(actions) | 503 AddLiteralActions(actions) |
422 | 504 |
423 # print "Scanned {0} number of files".format(number_of_files_total) | 505 # print "Scanned {0} number of files".format(number_of_files_total) |
424 # print "Found {0} entries".format(len(actions)) | 506 # print "Found {0} entries".format(len(actions)) |
425 | 507 |
426 AddClosedSourceActions(actions) | 508 AddClosedSourceActions(actions) |
427 AddChromeOSActions(actions) | 509 AddChromeOSActions(actions) |
428 AddExtensionActions(actions) | 510 AddExtensionActions(actions) |
| 511 AddAndroidActions(actions) |
429 | 512 |
430 if hash_output: | 513 if hash_output: |
431 f = open(chromeactions_path, "w") | 514 f = open(chromeactions_path, "w") |
432 | 515 |
433 | 516 |
434 # Print out the actions as a sorted list. | 517 # Print out the actions as a sorted list. |
435 for action in sorted(actions): | 518 for action in sorted(actions): |
436 if hash_output: | 519 if hash_output: |
437 hash = hashlib.md5() | 520 hash = hashlib.md5() |
438 hash.update(action) | 521 hash.update(action) |
439 print >>f, '0x%s\t%s' % (hash.hexdigest()[:16], action) | 522 print >>f, '0x%s\t%s' % (hash.hexdigest()[:16], action) |
440 else: | 523 else: |
441 print action | 524 print action |
442 | 525 |
443 if hash_output: | 526 if hash_output: |
444 print "Done. Do not forget to add chromeactions.txt to your changelist" | 527 print "Done. Do not forget to add chromeactions.txt to your changelist" |
445 return 0 | 528 return 0 |
446 | 529 |
447 | 530 |
448 if '__main__' == __name__: | 531 if '__main__' == __name__: |
449 sys.exit(main(sys.argv)) | 532 sys.exit(main(sys.argv)) |
OLD | NEW |