Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Unified Diff: tools/chrome_remote_control/chrome_remote_control/desktop_browser_finder.py

Issue 11361165: [chrome_remote_control] Rename chrome_remote_control to telemetry. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/chrome_remote_control/chrome_remote_control/desktop_browser_finder.py
diff --git a/tools/chrome_remote_control/chrome_remote_control/desktop_browser_finder.py b/tools/chrome_remote_control/chrome_remote_control/desktop_browser_finder.py
deleted file mode 100644
index 343c7b2f2c4d535e12c5585b4665e238e08661f6..0000000000000000000000000000000000000000
--- a/tools/chrome_remote_control/chrome_remote_control/desktop_browser_finder.py
+++ /dev/null
@@ -1,151 +0,0 @@
-# Copyright (c) 2012 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-"""Finds desktop browsers that can be controlled by chrome_remote_control."""
-
-import logging
-import os
-import subprocess
-import sys
-
-from chrome_remote_control import browser
-from chrome_remote_control import desktop_browser_backend
-from chrome_remote_control import platform
-from chrome_remote_control import possible_browser
-
-ALL_BROWSER_TYPES = ','.join([
- 'exact',
- 'release',
- 'debug',
- 'canary',
- 'content-shell-debug',
- 'content-shell-release',
- 'system'])
-
-class PossibleDesktopBrowser(possible_browser.PossibleBrowser):
- """A desktop browser that can be controlled."""
-
- def __init__(self, browser_type, options, executable, is_content_shell):
- super(PossibleDesktopBrowser, self).__init__(browser_type, options)
- self._local_executable = executable
- self._is_content_shell = is_content_shell
-
- def __repr__(self):
- return 'PossibleDesktopBrowser(browser_type=%s)' % self.browser_type
-
- def Create(self):
- backend = desktop_browser_backend.DesktopBrowserBackend(
- self._options, self._local_executable, self._is_content_shell)
- return browser.Browser(backend, platform.Platform())
-
-def FindAllAvailableBrowsers(options):
- """Finds all the desktop browsers available on this machine."""
- browsers = []
-
- has_display = True
- if (sys.platform.startswith('linux') and
- os.getenv('DISPLAY') == None):
- has_display = False
-
- # Add the explicit browser executable if given.
- if options.browser_executable:
- if os.path.exists(options.browser_executable):
- browsers.append(PossibleDesktopBrowser('exact', options,
- options.browser_executable, False))
-
- # Look for a browser in the standard chrome build locations.
- if options.chrome_root:
- chrome_root = options.chrome_root
- else:
- chrome_root = os.path.join(os.path.dirname(__file__), '..', '..', '..')
-
- if sys.platform == 'darwin':
- chromium_app_name = 'Chromium.app/Contents/MacOS/Chromium'
- content_shell_app_name = 'Content Shell.app/Contents/MacOS/Content Shell'
- elif sys.platform.startswith('linux'):
- chromium_app_name = 'chrome'
- content_shell_app_name = 'content_shell'
- elif sys.platform.startswith('win'):
- chromium_app_name = 'chrome.exe'
- content_shell_app_name = 'content_shell.exe'
- else:
- raise Exception('Platform not recognized')
-
- build_dirs = ['build',
- 'out',
- 'sconsbuild',
- 'xcodebuild']
-
- def AddIfFound(browser_type, type_dir, app_name, content_shell):
- for build_dir in build_dirs:
- app = os.path.join(chrome_root, build_dir, type_dir, app_name)
- if os.path.exists(app):
- browsers.append(PossibleDesktopBrowser(browser_type, options,
- app, content_shell))
- return True
- return False
-
- # Add local builds
- AddIfFound('debug', 'Debug', chromium_app_name, False)
- AddIfFound('content-shell-debug', 'Debug', content_shell_app_name, True)
- AddIfFound('release', 'Release', chromium_app_name, False)
- AddIfFound('content-shell-release', 'Release', content_shell_app_name, True)
-
- # Mac-specific options.
- if sys.platform == 'darwin':
- mac_canary = ('/Applications/Google Chrome Canary.app/'
- 'Contents/MacOS/Google Chrome Canary')
- mac_system = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
- if os.path.exists(mac_canary):
- browsers.append(PossibleDesktopBrowser('canary', options,
- mac_canary, False))
-
- if os.path.exists(mac_system):
- browsers.append(PossibleDesktopBrowser('system', options,
- mac_system, False))
-
- # Linux specific options.
- if sys.platform.startswith('linux'):
- # Look for a google-chrome instance.
- found = False
- try:
- with open(os.devnull, 'w') as devnull:
- found = subprocess.call(['google-chrome', '--version'],
- stdout=devnull, stderr=devnull) == 0
- except OSError:
- pass
- if found:
- browsers.append(
- PossibleDesktopBrowser('system', options,
- 'google-chrome', False))
-
- # Win32-specific options.
- if sys.platform.startswith('win'):
- system_path = os.path.join('Google', 'Chrome', 'Application')
- canary_path = os.path.join('Google', 'Chrome SxS', 'Application')
-
- win_search_paths = [os.getenv('PROGRAMFILES(X86)'),
- os.getenv('PROGRAMFILES'),
- os.getenv('LOCALAPPDATA')]
-
- for path in win_search_paths:
- if not path:
- continue
- if AddIfFound('canary', os.path.join(path, canary_path),
- chromium_app_name, False):
- break
-
- for path in win_search_paths:
- if not path:
- continue
- if AddIfFound('system', os.path.join(path, system_path),
- chromium_app_name, False):
- break
-
- if len(browsers) and not has_display:
- logging.warning(
- 'Found (%s), but you do not have a DISPLAY environment set.' %
- ','.join([b.browser_type for b in browsers]))
- return []
-
- return browsers

Powered by Google App Engine
This is Rietveld 408576698