LEFT | RIGHT |
1 /* This Source Code Form is subject to the terms of the Mozilla Public | 1 /* This Source Code Form is subject to the terms of the Mozilla Public |
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file, | 2 * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */ | 3 * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
4 | 4 |
5 Cu.import("resource://gre/modules/Services.jsm"); | 5 Cu.import("resource://gre/modules/Services.jsm"); |
6 Cu.import("resource://gre/modules/FileUtils.jsm"); | 6 Cu.import("resource://gre/modules/FileUtils.jsm"); |
7 | 7 |
8 let {Prefs} = require("prefs"); | 8 let {Prefs} = require("prefs"); |
9 | 9 |
10 let RULES_VERSION = 2; | 10 let RULES_VERSION = 2; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 catch (e) | 74 catch (e) |
75 { | 75 { |
76 if (e.result != Cr.NS_ERROR_FILE_NOT_FOUND) | 76 if (e.result != Cr.NS_ERROR_FILE_NOT_FOUND) |
77 Cu.reportError(e); | 77 Cu.reportError(e); |
78 callback(false); | 78 callback(false); |
79 } | 79 } |
80 } | 80 } |
81 | 81 |
82 function getRuleFile() | 82 function getRuleFile() |
83 { | 83 { |
84 let result = FileUtils.getFile("ProfD", ["url-fixer-rules.json"]); | 84 let result = FileUtils.getFile("ProfD", [require("info").addonName + "-rules.j
son"]); |
85 | 85 |
86 getRuleFile = function() result; | 86 getRuleFile = function() result; |
87 return getRuleFile(); | 87 return getRuleFile(); |
88 } | 88 } |
89 | 89 |
90 function addCustomRules() | 90 function addCustomRules() |
91 { | 91 { |
92 for (let domain in Prefs.whitelist) | 92 for (let domain in Prefs.whitelist) |
93 onWhitelistEntryAdded(domain); | 93 onWhitelistEntryAdded(domain); |
94 } | 94 } |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 bestSuggestionDistance = distance; | 400 bestSuggestionDistance = distance; |
401 bestSuggestionMatched = matchedLen; | 401 bestSuggestionMatched = matchedLen; |
402 bestSuggestionPriority = priority; | 402 bestSuggestionPriority = priority; |
403 } | 403 } |
404 } | 404 } |
405 if (bestSuggestion) | 405 if (bestSuggestion) |
406 return input.substr(0, input.length - bestSuggestionMatched) + bestSuggestio
n; | 406 return input.substr(0, input.length - bestSuggestionMatched) + bestSuggestio
n; |
407 else | 407 else |
408 return input; | 408 return input; |
409 } | 409 } |
LEFT | RIGHT |