| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 """Quits Chrome. | 5 """Quits Chrome. |
| 6 | 6 |
| 7 This script sends a WM_CLOSE message to each window of Chrome and waits until | 7 This script sends a WM_CLOSE message to each window of Chrome and waits until |
| 8 the process terminates. | 8 the process terminates. |
| 9 """ | 9 """ |
| 10 | 10 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 | 62 |
| 63 def QuitChrome(chrome_path): | 63 def QuitChrome(chrome_path): |
| 64 """ Tries to quit chrome in a safe way. If there is still an open instance | 64 """ Tries to quit chrome in a safe way. If there is still an open instance |
| 65 after a timeout delay, the process is killed the hard way. | 65 after a timeout delay, the process is killed the hard way. |
| 66 | 66 |
| 67 Args: | 67 Args: |
| 68 chrome_path: The path to chrome.exe. | 68 chrome_path: The path to chrome.exe. |
| 69 """ | 69 """ |
| 70 if not CloseWindows(chrome_path): | 70 if not CloseWindows(chrome_path): |
| 71 # TODO(robertshield): Investigate why Chrome occasionally doesn't shut down. | 71 # TODO(robertshield): Investigate why Chrome occasionally doesn't shut down. |
| 72 print 'Warning: Chrome not responding to window closure. Killing process...' | 72 sys.stderr.write('Warning: Chrome not responding to window closure. ' |
| 73 'Killing all processes belonging to %s\n' % chrome_path) |
| 73 KillNamedProcess(chrome_path) | 74 KillNamedProcess(chrome_path) |
| 74 | 75 |
| 75 | 76 |
| 76 def main(): | 77 def main(): |
| 77 usage = 'usage: %prog chrome_path' | 78 usage = 'usage: %prog chrome_path' |
| 78 parser = optparse.OptionParser(usage, description='Quit Chrome.') | 79 parser = optparse.OptionParser(usage, description='Quit Chrome.') |
| 79 _, args = parser.parse_args() | 80 _, args = parser.parse_args() |
| 80 if len(args) != 1: | 81 if len(args) != 1: |
| 81 parser.error('Incorrect number of arguments.') | 82 parser.error('Incorrect number of arguments.') |
| 82 chrome_path = args[0] | 83 chrome_path = args[0] |
| 83 | 84 |
| 84 QuitChrome(chrome_path) | 85 QuitChrome(chrome_path) |
| 85 return 0 | 86 return 0 |
| 86 | 87 |
| 87 | 88 |
| 88 if __name__ == '__main__': | 89 if __name__ == '__main__': |
| 89 sys.exit(main()) | 90 sys.exit(main()) |
| OLD | NEW |