| 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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 """Add actions reported by extensions via chrome.metricsPrivate API. | 329 """Add actions reported by extensions via chrome.metricsPrivate API. |
| 330 | 330 |
| 331 Arguments: | 331 Arguments: |
| 332 actions: set of actions to add to. | 332 actions: set of actions to add to. |
| 333 """ | 333 """ |
| 334 # Actions sent by Chrome OS File Browser. | 334 # Actions sent by Chrome OS File Browser. |
| 335 actions.add('FileBrowser.CreateNewFolder') | 335 actions.add('FileBrowser.CreateNewFolder') |
| 336 actions.add('FileBrowser.PhotoEditor.Edit') | 336 actions.add('FileBrowser.PhotoEditor.Edit') |
| 337 actions.add('FileBrowser.PhotoEditor.View') | 337 actions.add('FileBrowser.PhotoEditor.View') |
| 338 | 338 |
| 339 # Actions sent by Google Now client. |
| 340 actions.add('GoogleNow.MessageClicked') |
| 341 actions.add('GoogleNow.ButtonClicked0') |
| 342 actions.add('GoogleNow.ButtonClicked1') |
| 343 actions.add('GoogleNow.Dismissed') |
| 344 |
| 339 def GrepForActions(path, actions): | 345 def GrepForActions(path, actions): |
| 340 """Grep a source file for calls to UserMetrics functions. | 346 """Grep a source file for calls to UserMetrics functions. |
| 341 | 347 |
| 342 Arguments: | 348 Arguments: |
| 343 path: path to the file | 349 path: path to the file |
| 344 actions: set of actions to add to | 350 actions: set of actions to add to |
| 345 """ | 351 """ |
| 346 global number_of_files_total | 352 global number_of_files_total |
| 347 number_of_files_total = number_of_files_total + 1 | 353 number_of_files_total = number_of_files_total + 1 |
| 348 # we look for the UserMetricsAction structure constructor | 354 # we look for the UserMetricsAction structure constructor |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 # print "Scanned {0} number of files".format(number_of_files_total) | 540 # print "Scanned {0} number of files".format(number_of_files_total) |
| 535 # print "Found {0} entries".format(len(actions)) | 541 # print "Found {0} entries".format(len(actions)) |
| 536 | 542 |
| 537 AddClosedSourceActions(actions) | 543 AddClosedSourceActions(actions) |
| 538 AddChromeOSActions(actions) | 544 AddChromeOSActions(actions) |
| 539 AddExtensionActions(actions) | 545 AddExtensionActions(actions) |
| 540 AddAndroidActions(actions) | 546 AddAndroidActions(actions) |
| 541 AddBookmarkManagerActions(actions) | 547 AddBookmarkManagerActions(actions) |
| 542 | 548 |
| 543 if hash_output: | 549 if hash_output: |
| 544 f = open(chromeactions_path, "w") | 550 f = open(chromeactions_path, "wb") |
| 545 | 551 |
| 546 | 552 |
| 547 # Print out the actions as a sorted list. | 553 # Print out the actions as a sorted list. |
| 548 for action in sorted(actions): | 554 for action in sorted(actions): |
| 549 if hash_output: | 555 if hash_output: |
| 550 hash = hashlib.md5() | 556 hash = hashlib.md5() |
| 551 hash.update(action) | 557 hash.update(action) |
| 552 print >>f, '0x%s\t%s' % (hash.hexdigest()[:16], action) | 558 print >>f, '0x%s\t%s' % (hash.hexdigest()[:16], action) |
| 553 else: | 559 else: |
| 554 print action | 560 print action |
| 555 | 561 |
| 556 if hash_output: | 562 if hash_output: |
| 557 print "Done. Do not forget to add chromeactions.txt to your changelist" | 563 print "Done. Do not forget to add chromeactions.txt to your changelist" |
| 558 return 0 | 564 return 0 |
| 559 | 565 |
| 560 | 566 |
| 561 if '__main__' == __name__: | 567 if '__main__' == __name__: |
| 562 sys.exit(main(sys.argv)) | 568 sys.exit(main(sys.argv)) |
| OLD | NEW |