Esempio n. 1
0
 def load_uri(self, uri):
     """
         Load uri
         @param uri as str
     """
     self._error = None
     self.__related_uri = uri
     parsed = urlparse(uri)
     if uri == "about:blank":
         WebKit2.WebView.load_plain_text(self, "")
     # We are not a ftp browser, fall back to env
     elif parsed.scheme == "ftp":
         argv = [get_ftp_cmd(), uri, None]
         GLib.spawn_sync(None, argv, None,
                         GLib.SpawnFlags.SEARCH_PATH, None)
     else:
         if uri.startswith("/"):
             uri = "file://" + uri
         elif parsed.scheme == "javascript":
             self.__js_load = True
             uri = GLib.uri_unescape_string(uri, None)
             self.run_javascript(uri.replace("javascript:", ""), None, None)
         elif parsed.scheme not in ["http", "https", "file",
                                    "populars", "accept"]:
             uri = "http://" + uri
         # Reset bad tls certificate
         if parsed.scheme != "accept":
             self.reset_bad_tls()
             self.__insecure_content_detected = False
         self.emit("uri-changed", uri)
         WebKit2.WebView.load_uri(self, uri)
Esempio n. 2
0
 def load_uri(self, uri):
     """
         Load uri
         @param uri as str
     """
     self.__cancellable.cancel()
     self.__cancellable.reset()
     if uri == "about:blank":
         WebKit2.WebView.load_plain_text(self, "")
         self.__loaded_uri = uri
         return
     parsed = urlparse(uri)
     # We are not a ftp browser, fall back to env
     if parsed.scheme == "ftp":
         argv = [get_ftp_cmd(), uri, None]
         GLib.spawn_sync(None, argv, None, GLib.SpawnFlags.SEARCH_PATH,
                         None)
         return
     elif parsed.scheme == "javascript":
         uri = GLib.uri_unescape_string(uri, None)
         self.run_javascript(uri.replace("javascript:", ""), None, None)
         return
     elif parsed.scheme not in [
             "http", "https", "file", "populars", "accept"
     ]:
         uri = "http://" + uri
     # Reset bad tls certificate
     elif parsed.scheme != "accept":
         self.__bad_tls = None
         self.__insecure_content_detected = False
     self.__loaded_uri = uri
     WebKit2.WebView.load_uri(self, uri)
Esempio n. 3
0
 def load_uri(self, uri):
     """
         Load uri
         @param uri as str
     """
     if App().phishing.is_phishing(uri):
         self._show_phishing_error(uri)
         return
     self.discard_error()
     # If not an URI, start a search
     parsed = urlparse(uri)
     is_uri = parsed.scheme in [
         "about", "http", "https", "file", "populars"
     ]
     if not is_uri and\
             not uri.startswith("/") and\
             App().search.is_search(uri):
         uri = App().search.get_search_uri(uri)
     parsed = urlparse(uri)
     if uri == "about:blank":
         WebKit2.WebView.load_plain_text(self, "")
     # We are not a ftp browser, fall back to env
     elif parsed.scheme == "ftp":
         argv = [get_ftp_cmd(), uri, None]
         GLib.spawn_sync(None, argv, None, GLib.SpawnFlags.SEARCH_PATH,
                         None)
     else:
         if uri.startswith("/"):
             uri = "file://" + uri
         elif parsed.scheme == "javascript":
             # To bypass popup blocker
             self._last_click_time = time()
             uri = GLib.uri_unescape_string(uri, None)
             self.run_javascript(uri.replace("javascript:", ""), None, None)
         elif parsed.scheme not in [
                 "http", "https", "file", "populars", "accept"
         ]:
             uri = "http://" + uri
         # Reset bad tls certificate
         if parsed.scheme != "accept":
             self.reset_bad_tls()
             self.__insecure_content_detected = False
         self.stop_loading()
         self.update_settings_for_uri(uri)
         GLib.idle_add(WebKit2.WebView.load_uri, self, uri)