1 // Copyright (c) 2014 The Chromium 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.
5 var DEFAULT_SCHEME = 3;
9 return document.getElementById(id);
12 function getEnabled() {
13 var result = localStorage['enabled'];
14 if (result === 'true' || result === 'false') {
15 return (result === 'true');
17 localStorage['enabled'] = 'true';
21 function setEnabled(enabled) {
22 localStorage['enabled'] = enabled;
25 function getKeyAction() {
26 var keyAction = localStorage['keyaction'];
27 if (keyAction == 'global' || keyAction == 'site') {
31 localStorage['keyaction'] = keyAction;
35 function setKeyAction(keyAction) {
36 if (keyAction != 'global' && keyAction != 'site') {
39 localStorage['keyaction'] = keyAction;
42 function getDefaultScheme() {
43 var scheme = localStorage['scheme'];
44 if (scheme >= 0 && scheme <= MAX_SCHEME) {
47 scheme = DEFAULT_SCHEME;
48 localStorage['scheme'] = scheme;
52 function setDefaultScheme(scheme) {
53 if (!(scheme >= 0 && scheme <= MAX_SCHEME)) {
54 scheme = DEFAULT_SCHEME;
56 localStorage['scheme'] = scheme;
59 function getSiteScheme(site) {
60 var scheme = getDefaultScheme();
62 var siteSchemes = JSON.parse(localStorage['siteschemes']);
63 scheme = siteSchemes[site];
64 if (!(scheme >= 0 && scheme <= MAX_SCHEME)) {
65 scheme = getDefaultScheme();
68 scheme = getDefaultScheme();
73 function setSiteScheme(site, scheme) {
74 if (!(scheme >= 0 && scheme <= MAX_SCHEME)) {
75 scheme = getDefaultScheme();
79 siteSchemes = JSON.parse(localStorage['siteschemes']);
80 siteSchemes['www.example.com'] = getDefaultScheme();
84 siteSchemes[site] = scheme;
85 localStorage['siteschemes'] = JSON.stringify(siteSchemes);
88 function resetSiteSchemes() {
90 localStorage['siteschemes'] = JSON.stringify(siteSchemes);
93 function siteFromUrl(url) {
94 var a = document.createElement('a');
99 function isDisallowedUrl(url) {
100 return url.indexOf('chrome') == 0 || url.indexOf('about') == 0;