| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Presubmit script for HTML files in chrome/browser/resources. | 5 """Presubmit script for HTML files in chrome/browser/resources. |
| 6 | 6 |
| 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts | 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts |
| 8 for more details about the presubmit API built into gcl. | 8 for more details about the presubmit API built into gcl. |
| 9 """ | 9 """ |
| 10 | 10 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 | 52 |
| 53 Args: | 53 Args: |
| 54 current_actions: The content of the actions.xml file. | 54 current_actions: The content of the actions.xml file. |
| 55 metric_name: The name for which the check should be done. | 55 metric_name: The name for which the check should be done. |
| 56 is_boolean: Whether the action comes from a boolean control. | 56 is_boolean: Whether the action comes from a boolean control. |
| 57 """ | 57 """ |
| 58 if not is_boolean: | 58 if not is_boolean: |
| 59 action = 'name="{0}"'.format(metric_name) | 59 action = 'name="{0}"'.format(metric_name) |
| 60 return action in current_actions | 60 return action in current_actions |
| 61 | 61 |
| 62 action_disabled = 'name="{0}_Disabled"'.format(metric_name) | 62 action_disabled = 'name="{0}_Disable"'.format(metric_name) |
| 63 action_enabled = 'name="{0}_Enabled"'.format(metric_name) | 63 action_enabled = 'name="{0}_Enable"'.format(metric_name) |
| 64 | 64 |
| 65 return (action_disabled in current_actions and | 65 return (action_disabled in current_actions and |
| 66 action_enabled in current_actions) | 66 action_enabled in current_actions) |
| 67 | 67 |
| 68 | 68 |
| 69 def IsBoolean(new_content_lines, metric_name, input_api): | 69 def IsBoolean(new_content_lines, metric_name, input_api): |
| 70 """Check whether action defined in the changed code is boolean or not. | 70 """Check whether action defined in the changed code is boolean or not. |
| 71 | 71 |
| 72 Checks whether the action comes from boolean control based on the HTML | 72 Checks whether the action comes from boolean control based on the HTML |
| 73 elements attributes. | 73 elements attributes. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 86 return (match and | 86 return (match and |
| 87 any(input_api.re.search(type_re, match.group(i)) for i in (1, 3))) | 87 any(input_api.re.search(type_re, match.group(i)) for i in (1, 3))) |
| 88 | 88 |
| 89 | 89 |
| 90 def CheckChangeOnUpload(input_api, output_api): | 90 def CheckChangeOnUpload(input_api, output_api): |
| 91 return CheckUserActionUpdate(input_api, output_api, ACTION_XML_PATH) | 91 return CheckUserActionUpdate(input_api, output_api, ACTION_XML_PATH) |
| 92 | 92 |
| 93 | 93 |
| 94 def CheckChangeOnCommit(input_api, output_api): | 94 def CheckChangeOnCommit(input_api, output_api): |
| 95 return CheckUserActionUpdate(input_api, output_api, ACTION_XML_PATH) | 95 return CheckUserActionUpdate(input_api, output_api, ACTION_XML_PATH) |
| OLD | NEW |