OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 """Extract UserMetrics "actions" strings from the Chrome source. | 7 """Extract UserMetrics "actions" strings from the Chrome source. |
8 | 8 |
9 This program generates the list of known actions we expect to see in the | 9 This program generates the list of known actions we expect to see in the |
10 user behavior logs. It walks the Chrome source, looking for calls to | 10 user behavior logs. It walks the Chrome source, looking for calls to |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 actions.add('HistoryPage_NewestHistoryClick') | 543 actions.add('HistoryPage_NewestHistoryClick') |
544 actions.add('HistoryPage_NewerHistoryClick') | 544 actions.add('HistoryPage_NewerHistoryClick') |
545 actions.add('HistoryPage_OlderHistoryClick') | 545 actions.add('HistoryPage_OlderHistoryClick') |
546 actions.add('HistoryPage_Search') | 546 actions.add('HistoryPage_Search') |
547 actions.add('HistoryPage_InitClearBrowsingData') | 547 actions.add('HistoryPage_InitClearBrowsingData') |
548 actions.add('HistoryPage_RemoveSelected') | 548 actions.add('HistoryPage_RemoveSelected') |
549 actions.add('HistoryPage_SearchResultRemove') | 549 actions.add('HistoryPage_SearchResultRemove') |
550 actions.add('HistoryPage_ConfirmRemoveSelected') | 550 actions.add('HistoryPage_ConfirmRemoveSelected') |
551 actions.add('HistoryPage_CancelRemoveSelected') | 551 actions.add('HistoryPage_CancelRemoveSelected') |
552 | 552 |
| 553 def AddDevicesPageActions(actions): |
| 554 """Add actions that are used in Devices page. |
| 555 |
| 556 Arguments |
| 557 actions: set of actions to add to. |
| 558 """ |
| 559 actions.add('DevicesPage_Opened') |
| 560 actions.add('DevicesPage_AddPrintersClicked') |
| 561 actions.add('DevicesPage_RegisterClicked') |
| 562 actions.add('DevicesPage_RegisterCancel') |
| 563 actions.add('DevicesPage_RegisterFailure') |
| 564 actions.add('DevicesPage_RegisterSuccess') |
| 565 actions.add('DevicesPage_ManageClicked') |
| 566 |
553 def main(argv): | 567 def main(argv): |
554 if '--hash' in argv: | 568 if '--hash' in argv: |
555 hash_output = True | 569 hash_output = True |
556 else: | 570 else: |
557 hash_output = False | 571 hash_output = False |
558 print >>sys.stderr, "WARNING: If you added new UMA tags, you must" + \ | 572 print >>sys.stderr, "WARNING: If you added new UMA tags, you must" + \ |
559 " use the --hash option to update chromeactions.txt." | 573 " use the --hash option to update chromeactions.txt." |
560 # if we do a hash output, we want to only append NEW actions, and we know | 574 # if we do a hash output, we want to only append NEW actions, and we know |
561 # the file we want to work on | 575 # the file we want to work on |
562 actions = set() | 576 actions = set() |
(...skipping 14 matching lines...) Expand all Loading... |
577 # AddWebKitEditorActions(actions) | 591 # AddWebKitEditorActions(actions) |
578 AddAboutFlagsActions(actions) | 592 AddAboutFlagsActions(actions) |
579 AddWebUIActions(actions) | 593 AddWebUIActions(actions) |
580 AddRendererActions(actions) | 594 AddRendererActions(actions) |
581 | 595 |
582 AddLiteralActions(actions) | 596 AddLiteralActions(actions) |
583 | 597 |
584 # print "Scanned {0} number of files".format(number_of_files_total) | 598 # print "Scanned {0} number of files".format(number_of_files_total) |
585 # print "Found {0} entries".format(len(actions)) | 599 # print "Found {0} entries".format(len(actions)) |
586 | 600 |
587 AddClosedSourceActions(actions) | |
588 AddChromeOSActions(actions) | |
589 AddExtensionActions(actions) | |
590 AddAndroidActions(actions) | 601 AddAndroidActions(actions) |
591 AddBookmarkManagerActions(actions) | 602 AddBookmarkManagerActions(actions) |
| 603 AddChromeOSActions(actions) |
| 604 AddClosedSourceActions(actions) |
| 605 AddDevicesPageActions(actions) |
| 606 AddExtensionActions(actions) |
592 AddHistoryPageActions(actions) | 607 AddHistoryPageActions(actions) |
593 | 608 |
594 if hash_output: | 609 if hash_output: |
595 f = open(chromeactions_path, "wb") | 610 f = open(chromeactions_path, "wb") |
596 | 611 |
597 | 612 |
598 # Print out the actions as a sorted list. | 613 # Print out the actions as a sorted list. |
599 for action in sorted(actions): | 614 for action in sorted(actions): |
600 if hash_output: | 615 if hash_output: |
601 hash = hashlib.md5() | 616 hash = hashlib.md5() |
602 hash.update(action) | 617 hash.update(action) |
603 print >>f, '0x%s\t%s' % (hash.hexdigest()[:16], action) | 618 print >>f, '0x%s\t%s' % (hash.hexdigest()[:16], action) |
604 else: | 619 else: |
605 print action | 620 print action |
606 | 621 |
607 if hash_output: | 622 if hash_output: |
608 print "Done. Do not forget to add chromeactions.txt to your changelist" | 623 print "Done. Do not forget to add chromeactions.txt to your changelist" |
609 return 0 | 624 return 0 |
610 | 625 |
611 | 626 |
612 if '__main__' == __name__: | 627 if '__main__' == __name__: |
613 sys.exit(main(sys.argv)) | 628 sys.exit(main(sys.argv)) |
OLD | NEW |