Home | History | Annotate | Download | only in multimedia
      1 # Copyright 2015 The Chromium OS Authors. All rights reserved.
      2 # Use of this source code is governed by a BSD-style license that can be
      3 # found in the LICENSE file.
      4 
      5 """An interface to access the local browser facade."""
      6 
      7 import logging
      8 
      9 class BrowserFacadeNativeError(Exception):
     10     """Error in BrowserFacadeNative."""
     11     pass
     12 
     13 
     14 class BrowserFacadeNative(object):
     15     """Facade to access the browser-related functionality."""
     16     def __init__(self, resource):
     17         """Initializes the USB facade.
     18 
     19         @param resource: A FacadeResource object.
     20 
     21         """
     22         self._resource = resource
     23 
     24 
     25     def new_tab(self, url):
     26         """Opens a new tab and loads URL.
     27 
     28         @param url: The URL to load.
     29         @return a str, the tab descriptor of the opened tab.
     30 
     31         """
     32         logging.debug('Load URL %s', url)
     33         return self._resource.load_url(url)
     34 
     35 
     36     def close_tab(self, tab_descriptor):
     37         """Closes a previously opened tab.
     38 
     39         @param tab_descriptor: Indicate which tab to be closed.
     40 
     41         """
     42         tab = self._resource.get_tab_by_descriptor(tab_descriptor)
     43         logging.debug('Closing URL %s', tab.url)
     44         self._resource.close_tab(tab_descriptor)
     45