| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 'external_metrics.cc', # see AddChromeOSActions() | 60 'external_metrics.cc', # see AddChromeOSActions() |
| 61 'core_options_handler.cc', # see AddWebUIActions() | 61 'core_options_handler.cc', # see AddWebUIActions() |
| 62 'browser_render_process_host.cc', # see AddRendererActions() | 62 'browser_render_process_host.cc', # see AddRendererActions() |
| 63 'render_thread_impl.cc', # impl of RenderThread::RecordComputedAction() | 63 'render_thread_impl.cc', # impl of RenderThread::RecordComputedAction() |
| 64 'render_process_host_impl.cc', # browser side impl for | 64 'render_process_host_impl.cc', # browser side impl for |
| 65 # RenderThread::RecordComputedAction() | 65 # RenderThread::RecordComputedAction() |
| 66 'mock_render_thread.cc', # mock of RenderThread::RecordComputedAction() | 66 'mock_render_thread.cc', # mock of RenderThread::RecordComputedAction() |
| 67 'ppb_pdf_impl.cc', # see AddClosedSourceActions() | 67 'ppb_pdf_impl.cc', # see AddClosedSourceActions() |
| 68 'pepper_pdf_host.cc', # see AddClosedSourceActions() | 68 'pepper_pdf_host.cc', # see AddClosedSourceActions() |
| 69 'key_systems_support_uma.cc', # See AddKeySystemSupportActions() | 69 'key_systems_support_uma.cc', # See AddKeySystemSupportActions() |
| 70 'browser_child_process_host_impl.cc', # See AddBadMessageActions() |
| 70 ) | 71 ) |
| 71 | 72 |
| 72 # Language codes used in Chrome. The list should be updated when a new | 73 # Language codes used in Chrome. The list should be updated when a new |
| 73 # language is added to app/l10n_util.cc, as follows: | 74 # language is added to app/l10n_util.cc, as follows: |
| 74 # | 75 # |
| 75 # % (cat app/l10n_util.cc | \ | 76 # % (cat app/l10n_util.cc | \ |
| 76 # perl -n0e 'print $1 if /kAcceptLanguageList.*?\{(.*?)\}/s' | \ | 77 # perl -n0e 'print $1 if /kAcceptLanguageList.*?\{(.*?)\}/s' | \ |
| 77 # perl -nle 'print $1, if /"(.*)"/'; echo 'es-419') | \ | 78 # perl -nle 'print $1, if /"(.*)"/'; echo 'es-419') | \ |
| 78 # sort | perl -pe "s/(.*)\n/'\$1', /" | \ | 79 # sort | perl -pe "s/(.*)\n/'\$1', /" | \ |
| 79 # fold -w75 -s | perl -pe 's/^/ /;s/ $//'; echo | 80 # fold -w75 -s | perl -pe 's/^/ /;s/ $//'; echo |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 actions.add('AutomaticReset_WebUIBanner_BannerShown') | 596 actions.add('AutomaticReset_WebUIBanner_BannerShown') |
| 596 actions.add('AutomaticReset_WebUIBanner_ManuallyClosed') | 597 actions.add('AutomaticReset_WebUIBanner_ManuallyClosed') |
| 597 actions.add('AutomaticReset_WebUIBanner_ResetClicked') | 598 actions.add('AutomaticReset_WebUIBanner_ResetClicked') |
| 598 | 599 |
| 599 # These actions relate to the the automatic settings reset banner shown as | 600 # These actions relate to the the automatic settings reset banner shown as |
| 600 # a result of settings hardening. | 601 # a result of settings hardening. |
| 601 actions.add('AutomaticSettingsReset_WebUIBanner_BannerShown') | 602 actions.add('AutomaticSettingsReset_WebUIBanner_BannerShown') |
| 602 actions.add('AutomaticSettingsReset_WebUIBanner_ManuallyClosed') | 603 actions.add('AutomaticSettingsReset_WebUIBanner_ManuallyClosed') |
| 603 actions.add('AutomaticSettingsReset_WebUIBanner_LearnMoreClicked') | 604 actions.add('AutomaticSettingsReset_WebUIBanner_LearnMoreClicked') |
| 604 | 605 |
| 606 def AddBadMessageActions(actions): |
| 607 """Add actions that are used when terminating a child process that sent an IPC |
| 608 which couldn't be deserialized. |
| 609 |
| 610 Arguments |
| 611 actions: set of actions to add to. |
| 612 """ |
| 613 actions.add('BadMessageTerminate_Plug-in') |
| 614 actions.add('BadMessageTerminate_WebWorker') |
| 615 actions.add('BadMessageTerminate_Utility') |
| 616 actions.add('BadMessageTerminate_Zygote') |
| 617 actions.add('BadMessageTerminate_Sandboxhelper') |
| 618 actions.add('BadMessageTerminate_GPU') |
| 619 actions.add('BadMessageTerminate_PepperPlugin') |
| 620 actions.add('BadMessageTerminate_PepperPluginBroker') |
| 621 actions.add('BadMessageTerminate_NativeClientmodule') |
| 622 actions.add('BadMessageTerminate_NativeClientbroker') |
| 605 | 623 |
| 606 class Error(Exception): | 624 class Error(Exception): |
| 607 pass | 625 pass |
| 608 | 626 |
| 609 | 627 |
| 610 def _ExtractText(parent_dom, tag_name): | 628 def _ExtractText(parent_dom, tag_name): |
| 611 """Extract the text enclosed by |tag_name| under |parent_dom| | 629 """Extract the text enclosed by |tag_name| under |parent_dom| |
| 612 | 630 |
| 613 Args: | 631 Args: |
| 614 parent_dom: The parent Element under which text node is searched for. | 632 parent_dom: The parent Element under which text node is searched for. |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 801 # print "Found {0} entries".format(len(actions)) | 819 # print "Found {0} entries".format(len(actions)) |
| 802 | 820 |
| 803 AddAndroidActions(actions) | 821 AddAndroidActions(actions) |
| 804 AddAutomaticResetBannerActions(actions) | 822 AddAutomaticResetBannerActions(actions) |
| 805 AddBookmarkManagerActions(actions) | 823 AddBookmarkManagerActions(actions) |
| 806 AddChromeOSActions(actions) | 824 AddChromeOSActions(actions) |
| 807 AddClosedSourceActions(actions) | 825 AddClosedSourceActions(actions) |
| 808 AddExtensionActions(actions) | 826 AddExtensionActions(actions) |
| 809 AddHistoryPageActions(actions) | 827 AddHistoryPageActions(actions) |
| 810 AddKeySystemSupportActions(actions) | 828 AddKeySystemSupportActions(actions) |
| 829 AddBadMessageActions(actions) |
| 811 | 830 |
| 812 pretty = PrettyPrint(actions, actions_dict, comment_nodes) | 831 pretty = PrettyPrint(actions, actions_dict, comment_nodes) |
| 813 if original_xml == pretty: | 832 if original_xml == pretty: |
| 814 print 'actions.xml is correctly pretty-printed.' | 833 print 'actions.xml is correctly pretty-printed.' |
| 815 sys.exit(0) | 834 sys.exit(0) |
| 816 if presubmit: | 835 if presubmit: |
| 817 logging.info('actions.xml is not formatted correctly; run ' | 836 logging.info('actions.xml is not formatted correctly; run ' |
| 818 'extract_actions.py to fix.') | 837 'extract_actions.py to fix.') |
| 819 sys.exit(1) | 838 sys.exit(1) |
| 820 | 839 |
| 821 # Prompt user to consent on the change. | 840 # Prompt user to consent on the change. |
| 822 if not diff_util.PromptUserToAcceptDiff( | 841 if not diff_util.PromptUserToAcceptDiff( |
| 823 original_xml, pretty, 'Is the new version acceptable?'): | 842 original_xml, pretty, 'Is the new version acceptable?'): |
| 824 logging.error('Aborting') | 843 logging.error('Aborting') |
| 825 sys.exit(1) | 844 sys.exit(1) |
| 826 | 845 |
| 827 print 'Creating backup file: actions.old.xml.' | 846 print 'Creating backup file: actions.old.xml.' |
| 828 shutil.move(actions_xml_path, 'actions.old.xml') | 847 shutil.move(actions_xml_path, 'actions.old.xml') |
| 829 | 848 |
| 830 with open(actions_xml_path, 'wb') as f: | 849 with open(actions_xml_path, 'wb') as f: |
| 831 f.write(pretty) | 850 f.write(pretty) |
| 832 print ('Updated %s. Don\'t forget to add it to your changelist' % | 851 print ('Updated %s. Don\'t forget to add it to your changelist' % |
| 833 actions_xml_path) | 852 actions_xml_path) |
| 834 return 0 | 853 return 0 |
| 835 | 854 |
| 836 | 855 |
| 837 if '__main__' == __name__: | 856 if '__main__' == __name__: |
| 838 sys.exit(main(sys.argv)) | 857 sys.exit(main(sys.argv)) |
| OLD | NEW |