Disables injection for a URL and reloads tabs with that URL.
@param {string} url URL to activate on.
@param {boolean=} opt_skipReload Whether to skip reloading of pages.
334303
function disableInjectionForUrl(url, opt_skipReload) {
  var url = getCanonicalUrl(url);

  // Disable injection.
  setPagePreference(url, 'enabled', false);

  // Find existing page mod and disable.
  // This will detach workers in those tabs.
  var mod = activePageMods[url];
  if (!mod) {
    return;
  }
  mod.destroy();
  delete activePageMods[url];

  if (!opt_skipReload) {
    // Find tabs with the URL and reload.
    reloadTabsMatchingUrl(url);
  }
}
489887
function _cleanURL(url) {
        var index = url.search(/[#\?]/);
        if (index >= 0) {
            url = url.substr(0, index);
        }
        return url;
    }
1124031
function sanitizeOptions(opts) {
	var content, text, ajax, once;

	if(invalidOpt(opts)) { return FALSE; }

	if(invalidOpt(opts.metadata)) {
		opts.metadata = { type: opts.metadata };
	}

	if('content' in opts) {
		content = opts.content;

		if(invalidOpt(content) || content.jquery || content.done) {
			text = invalidContent(content) ? FALSE : content;
			content = opts.content = {
				text: text
			};
		}
		else { text = content.text; }

		// DEPRECATED - Old content.ajax plugin functionality
		// Converts it into the proper Deferred syntax
		if('ajax' in content) {
			ajax = content.ajax;
			once = ajax && ajax.once !== FALSE;
			delete content.ajax;

			content.text = function(event, api) {
				var loading = text || $(this).attr(api.options.content.attr) || 'Loading...',

				deferred = $.ajax(
					$.extend({}, ajax, { context: api })
				)
				.then(ajax.success, NULL, ajax.error)
				.then(function(newContent) {
					if(newContent && once) { api.set('content.text', newContent); }
					return newContent;
				},
				function(xhr, status, error) {
					if(api.destroyed || xhr.status === 0) { return; }
					api.set('content.text', status + ': ' + error);
				});

				return !once ? (api.set('content.text', loading), deferred) : loading;
			};
		}

		if('title' in content) {
			if($.isPlainObject(content.title)) {
				content.button = content.title.button;
				content.title = content.title.text;
			}

			if(invalidContent(content.title || FALSE)) {
				content.title = FALSE;
			}
		}
	}

	if('position' in opts && invalidOpt(opts.position)) {
		opts.position = { my: opts.position, at: opts.position };
	}

	if('show' in opts && invalidOpt(opts.show)) {
		opts.show = opts.show.jquery ? { target: opts.show } :
			opts.show === TRUE ? { ready: TRUE } : { event: opts.show };
	}

	if('hide' in opts && invalidOpt(opts.hide)) {
		opts.hide = opts.hide.jquery ? { target: opts.hide } : { event: opts.hide };
	}

	if('style' in opts && invalidOpt(opts.style)) {
		opts.style = { classes: opts.style };
	}

	// Sanitize plugin options
	$.each(PLUGINS, function() {
		this.sanitize && this.sanitize(opts);
	});

	return opts;
}
423281
public void setSkipURLString(String skipURL) {
		this.skipURL = skipURL;
		getConfig().setProperty(SPIDER_SKIP_URL, this.skipURL);
		parseSkipURL(this.skipURL);
	}
771378
function bypass(method, options) {
    // jscs:disable
    // jshint -W040
    const self = this;
    // jshint +W040
    // jscs:enable
    const shield = self.constructor.shield;

    if (!_.includes(shield.protectedMethods, method)) {
        return Promise.reject(new Error('no such protected method'));
    }
    const protectedMethod = `_${method}`;
    return shield[protectedMethod].call(self, options);
}
431743
function (url, onImageReady, applyAutocrop) {
            var _this = this;

            this.toggleLoadingImage(true);
            this.clear();
            this._applyAutocrop = (applyAutocrop !== false);

            this._image = new IMSoftcrop.Image(
                IMSoftcrop.Ratio.hashFnv32a(url),
                this
            );

            this._image.load(
                url,
                function () {
                    _this.setZoomToImage(false);
                    _this.centerImage(false);
                    _this.updateImageInfo(false);

                    if (_this._autocrop) {
                        _this.detectDetails();
                        _this.detectFaces();
                    }
                    else {
                        _this.toggleLoadingImage(false);
                    }

                    _this.applySoftcrops();
                    _this.redraw();

                    if (typeof onImageReady === 'function') {
                        onImageReady.call(_this, _this._image);
                    }
                }
            );
        }
590394
protected void handleUrlActivated(HyperlinkEvent e, URL url) {
        try {
            Desktop.getDesktop().browse(url.toURI());
        } catch (Exception ex) {
            throw new ApplicationException("Error handling URL " + url, ex);
        }
    }
776319
function handleLinkClick(data) {
        var event = api.fire('linkclick', data);
        if (!event.isDefaultPrevented()) {
            if (data.uri) {
                window.open(data.uri);
            } else if (data.destination) {
                api.scrollTo(data.destination.pagenum);
            }
        }
    }
592583
public void setReloadReason(String reloadReason)
    {
        Matcher matcher;

        this.reloadReason = reloadReason;
        if (reloadReason == null)
        {
            return;
        }

        matcher = REASON_PATTERN.matcher(reloadReason);
        if (matcher.matches())
        {
            reloadReasonCode = matcher.group(1);
            reloadReasonDescription = matcher.group(2);
        }
    }
263085
function() {
  /**
   * Current options values.
   * These are only ever modified by using the {@see #setOptions} call.
   * @type {!Options}
   * @private
   */
  this.options_ = new Options();

  /**
   * Page options JSON strings mapped by UUID.
   * These are used as a lookup for the HTTP header hack.
   * @type {!Object.<string>}
   * @private
   */
  this.pageOptionsBlobs_ = {};

  /**
   * Injected tabs, mapped by tab ID.
   * @type {!Object.<!InjectedTab>}
   * @private
   */
  this.injectedTabs_ = {};

  /**
   * Tracer.
   * @type {Tracer}
   * @private
   */
  this.tracer_ = null;

  /**
   * All popup window tab IDs mapped by opener tab ID.
   * @type {!Object.<number, number>}
   * @private
   */
  this.popupWindows_ = {};

  chrome.tabs.onActivated.addListener(
      this.tabActivated_.bind(this));
  chrome.tabs.onUpdated.addListener(
      this.tabUpdated_.bind(this));

  // Handle tab closes.
  chrome.tabs.onRemoved.addListener((function(tabId) {
    for (var key in this.popupWindows_) {
      if (this.popupWindows_[key] === tabId) {
        delete this.popupWindows_[key];
        break;
      }
    }
    if (tabId in this.injectedTabs_) {
      var injectedTab = this.injectedTabs_[tabId];
      this.injectedTabs_[tabId] = null;
      injectedTab.dispose();
    }
  }).bind(this));

  // Listen for commands from content scripts.
  chrome.extension.onConnect.addListener(function(port) {
    var options = this.getOptions();
    if (port.name == 'injector') {
      // Setup the extended info provider for the page.
      var tab = port.sender.tab;
      if (!tab) {
        // This sometimes happens on about:blank and the new tab page.
        return;
      }
      var pageUrl = URI.canonicalize(tab.url);
      var pageStatus = options.getPageStatus(pageUrl, tab.id);
      var pageOptions = options.getPageOptions(pageUrl);

      _gaq.push(['_trackEvent', 'extension', 'injected']);

      var injectedTab = new InjectedTab(
          this, tab, pageStatus, pageOptions, port);
      this.injectedTabs_[tab.id] = injectedTab;
    } else if (port.name == 'popup') {
      // Get info about the selected tab and send back.
      // Note: port.sender is the popup tab, not the current tab.
      chrome.tabs.getSelected(null, (function(tab) {
        var pageUrl = URI.canonicalize(tab.url);
        if (!pageUrl.length) {
          return;
        }
        this.sendPopupInfo_(pageUrl, tab.id, port);

        // Listen for messages from the popup.
        port.onMessage.addListener((function(data, port) {
          this.popupMessageReceived_(tab, data, port);
        }).bind(this));
      }).bind(this));
    }
  }.bind(this));

  // Detect the application.
  this.detectApplication_();
  var detectApplication = this.detectApplication_.bind(this);
  chrome.management.onInstalled.addListener(detectApplication);
  chrome.management.onUninstalled.addListener(detectApplication);
  chrome.management.onEnabled.addListener(detectApplication);
  chrome.management.onDisabled.addListener(detectApplication);

  // Rescan all open tabs to reload any that are whitelisted.
  this.options_.load(function() {
    var whitelist = this.options_.getWhitelistedPages();
    var whitelistMap = {};
    for (var n = 0; n < whitelist.length; n++) {
      whitelistMap[whitelist[n]] = true;
    }
    chrome.tabs.query({}, (function(tabs) {
      var tabsReloaded = 0;
      for (var n = 0; n < tabs.length; n++) {
        var pageUrl = URI.canonicalize(tabs[n].url);
        if (whitelistMap[pageUrl]) {
          tabsReloaded++;
          this.reloadTab(tabs[n].id, tabs[n].url);
        }
      }
      _gaq.push(['_trackEvent', 'extension', 'tabs_reloaded',
          null, tabsReloaded]);
    }).bind(this));
  }, this);

  // This hacky thing lets people open wtf from the omnibox.
  // HACK(benvanik): https://code.google.com/p/chromium/issues/detail?id=237817
  try {
    chrome.omnibox.setDefaultSuggestion({
      description: '<url><match>%s</match></url> Open trace file'
    });
  } catch (e) {
  }
  chrome.omnibox.onInputChanged.addListener((function(text, suggest) {
    suggest([
      {
        content: 'ui',
        description: 'Open the UI'
      }
    ]);
  }).bind(this));
  chrome.omnibox.onInputEntered.addListener((function(text) {
    chrome.tabs.getSelected(null, (function(tab) {
      text = text.trim();
      if (text == 'ui' || text.length == 0) {
        // Open the UI.
        _gaq.push(['_trackEvent', 'extension', 'omnibox_show_ui']);
        this.showUi_({
          targetTab: tab
        });
      } else {
        // A URL? File path? etc?
        if (text.indexOf('http') == 0) {
          _gaq.push(['_trackEvent', 'extension', 'omnibox_show_file']);
          this.showFileInUi_({
            targetTab: tab
          }, text);
        }
      }
    }).bind(this));
  }).bind(this));

  // FileBrowserHandler requests, on Chrome OS.
  if (chrome.fileBrowserHandler) {
    chrome.fileBrowserHandler.onExecute.addListener((function(id, details) {
      chrome.tabs.get(details.tab_id, (function(tab) {
        switch (id) {
          case 'open':
            this.showFileEntriesInUi_({
              targetTab: tab
            }, details.entries);
            break;
        }
      }).bind(this));
    }).bind(this));
  }

  // This is a workaround for a regression in Chrome that prevents blob URIs
  // from work in content scripts. Instead, we smuggle the options data
  // synchronously via HTTP headers. Yeah, I know. FML.
  // https://code.google.com/p/chromium/issues/detail?id=295829
  chrome.webRequest.onHeadersReceived.addListener((function(details) {
    var uuid = details.url.substr(details.url.lastIndexOf('/') + 1);
    var headerValue = this.pageOptionsBlobs_[uuid];
    return {
      responseHeaders: [
        {
          name: 'X-WTF-Options',
          value: headerValue
        }
      ]
    };
  }).bind(this), {
    urls: ['http://tracing-framework.appspot.com/tab-options/*'],
    types: ['xmlhttprequest']
  }, ['blocking']);
}
385976
function (options) {
            settings = Pilotfish('extend', {}, settings, options || {});

            // ### Click actions

            // #### `url_change_no_pointer`
            // Click resulted in url change, but target wasn't a pointer
            if (settings.url_change_no_pointer) {
                Pilotfish('on', window, 'unload', function () {
                    if (wasLastClickPointer() === false && wasLastClickRecent() === true) {
                        broadcast('url_change_no_pointer');
                    }
                });
            }


            // #### `hash_change_no_pointer`
            // Click resulted in hash tag change, but wasn't a pointer
            if (settings.hash_change_no_pointer) {
                Pilotfish('on', 'window:hashchange', function () {
                    if (wasLastClickPointer() === false && wasLastClickRecent() === true) {
                        broadcast('hash_change_no_pointer');
                    }
                });
            }

            // TODO Click resulted in an ajax request, but no status indicator


            // ### Application problems

            // TODO User clicked on something that was a pointer, twice

            // #### `click_js_error`
            // click resulted in a javascript error
            Pilotfish('on', 'js_error', function (evt, data) {
                if (wasLastClickRecent() === true) {
                    broadcast('click_js_error', data);
                }
            });


            // #### `multiple_reload`
            // user has reloaded more than x times
            if (settings.multiple_reload) {
                (function () {
                    var reloadCount = 0, currentPath = Pilotfish('currentPath');
                    for (var i = recentPaths.length - 1; i >= 0; i--) {
                        if (recentPaths[i].path == currentPath && recentPaths[i].navType == 1) {
                            reloadCount++;
                        } else {
                            break;
                        }
                    }
                    if (reloadCount == 3) {
                        broadcast('multiple_reload', {path: currentPath});
                    }
                })();
            }

            // ###  Application confusion

            // TODO user sees the same message twice

            // TODO user hit stop and interrupted a transfer

            // TODO user hit back x times in a row (stuck: the js isn't re-executed on back/reload)

            // TODO slowed_cadence - this page is taking signifigantly longer than previous pages

            // TODO lost_focus

            // TODO user_searched

            // TODO Tap into the accelerometer and watch for a thrown computer :)

            // TODO Watch for smashed keys :)
        }
232536
function(fragment, options={}) {

    // Default trigger to true unless otherwise specified
    (options.trigger === undefined) && (options.trigger = true);

    // Stringify any data passed in the options hash
    var query = options.data ? (~fragment.indexOf('?') ? '&' : '?') + $.url.query.stringify(options.data) : '';

    // Un-Mark any `active` links in the page container
    var $container = $(this.config.containers).unMarkLinks();

    // Navigate to the specified path. Return value is the value from the router
    // callback specified on the component
    var resp = Backbone.history.navigate(fragment + query, options);

    // Always return a promise. If the response of `Backbone.histroy.navigate`
    // was a promise, wait for it to resolve before resolving. Once resolved,
    // mark relevent links on the page as `active`.
    return new Promise(function(resolve, reject) {
      if(resp && resp.constructor === Promise) resp.then(resolve, resolve);
      resolve(resp);
    }).then(function(resp){
      $container.markLinks();
      return resp;
    });
  }
484866
function cleanUrl(url) {
    "use strict";
    if (url.toLowerCase().indexOf('http') !== 0) {
        return url;
    }
    var a = document.createElement('a');
    a.href = url;
    return a.href;
}
933491
function (opt, ignoreUpdateRangeUsg) {
        var option = this.option;
        each([['start', 'startValue'], ['end', 'endValue']], function (names) {
            // If only one of 'start' and 'startValue' is not null/undefined, the other
            // should be cleared, which enable clear the option.
            // If both of them are not set, keep option with the original value, which
            // enable use only set start but not set end when calling `dispatchAction`.
            // The same as 'end' and 'endValue'.
            if (opt[names[0]] != null || opt[names[1]] != null) {
                option[names[0]] = opt[names[0]];
                option[names[1]] = opt[names[1]];
            }
        }, this);

        !ignoreUpdateRangeUsg && updateRangeUse(this, opt);
    }
560202
function() {
		// if running in Node.js, don't setup.
		if (isNode()) {
			return;
		}

		var document = getDocument(),
			window = getGlobal();

		this._value = getCurrentUrl();

		// Intercept routable links.
		domEvents.addDelegateListener(document.documentElement, "click", "a", this.anchorClickHandler);
		var originalMethods = this.originalMethods = {};
		var dispatchHandlers = this.dispatchHandlers;

		// Rewrites original `pushState`/`replaceState` methods on `history`
		// and keeps pointer to original methods.
		canReflect.eachKey(methodsToOverwrite, function(method) {
			this.originalMethods[method] = window.history[method];
			window.history[method] = function(state, title, url) {

				// Avoid doubled history states (with pushState).
				var absolute = url.indexOf("http") === 0;
				var location = LOCATION();
				var searchHash = location.search + location.hash;

				// If url differs from current call original history method and update `route` state.
				if ((!absolute && url !== location.pathname + searchHash) ||
					(absolute && url !== location.href + searchHash)) {
					originalMethods[method].apply(window.history, arguments);
					dispatchHandlers();
				}
			};
		}, this);

		// Bind dispatchHandlers to the `popstate` event, so they will fire
		// when `history.back()` or `history.forward()` methods are called.
		domEvents.addEventListener(window, "popstate", this.dispatchHandlers);
	}
1196011
function resetOptionsForActiveTab() {
  var url = getCanonicalUrl(tabs.activeTab.url);
  setPagePreference(url, 'options', '');
  if (isInjectionEnabledForUrl(url)) {
    disableInjectionForUrl(url, true);
    enableInjectionForUrl(url);
  }
}
90846
function onLinkClick(event) {
    // Resolve anchor link
    var page = url.format( url.resolve(location, this.getAttribute('href')) );

    // Load new page
    piccolo.loadPage( page );
    event.preventDefault();
    return false;
  }