From 5885bc779bed46dfcff4b1e82968151448569f9f Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Tue, 19 Aug 2014 18:15:13 +0100 Subject: Move the vomnibar to an iframe --- background_scripts/main.coffee | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) (limited to 'background_scripts') diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index dda1beae..49417d7a 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -119,7 +119,7 @@ root.addExcludedUrl = (url) -> continue # And just keep everything else. newExcludedUrls.push(spec) - + Settings.set("excludedUrls", newExcludedUrls.join("\n")) chrome.tabs.query({ windowId: chrome.windows.WINDOW_ID_CURRENT, active: true }, @@ -635,6 +635,12 @@ getCurrFrameIndex = (frames) -> return i if frames[i].id == focusedFrame frames.length + 1 +# Send message back to the tab unchanged. +# Frames in the same tab can use this to communicate securely. +echo = (request, sender) -> + delete request.handler # No need to send this information + chrome.tabs.sendMessage(sender.tab.id, request) + # Port handler mapping portHandlers = keyDown: handleKeyDown, @@ -642,23 +648,24 @@ portHandlers = filterCompleter: filterCompleter sendRequestHandlers = - getCompletionKeys: getCompletionKeysRequest, - getCurrentTabUrl: getCurrentTabUrl, - openUrlInNewTab: openUrlInNewTab, - openUrlInIncognito: openUrlInIncognito, - openUrlInCurrentTab: openUrlInCurrentTab, - openOptionsPageInNewTab: openOptionsPageInNewTab, - registerFrame: registerFrame, - frameFocused: handleFrameFocused, - upgradeNotificationClosed: upgradeNotificationClosed, - updateScrollPosition: handleUpdateScrollPosition, - copyToClipboard: copyToClipboard, - isEnabledForUrl: isEnabledForUrl, - saveHelpDialogSettings: saveHelpDialogSettings, - selectSpecificTab: selectSpecificTab, + getCompletionKeys: getCompletionKeysRequest + getCurrentTabUrl: getCurrentTabUrl + openUrlInNewTab: openUrlInNewTab + openUrlInIncognito: openUrlInIncognito + openUrlInCurrentTab: openUrlInCurrentTab + openOptionsPageInNewTab: openOptionsPageInNewTab + registerFrame: registerFrame + frameFocused: handleFrameFocused + upgradeNotificationClosed: upgradeNotificationClosed + updateScrollPosition: handleUpdateScrollPosition + copyToClipboard: copyToClipboard + isEnabledForUrl: isEnabledForUrl + saveHelpDialogSettings: saveHelpDialogSettings + selectSpecificTab: selectSpecificTab refreshCompleter: refreshCompleter - createMark: Marks.create.bind(Marks), + createMark: Marks.create.bind(Marks) gotoMark: Marks.goto.bind(Marks) + echo: echo # Convenience function for development use. window.runTests = -> open(chrome.runtime.getURL('tests/dom_tests/dom_tests.html')) -- cgit v1.2.3 From d65f265a6ad137be0db4d8c86879e5123a10087b Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Tue, 2 Sep 2014 17:43:41 +0100 Subject: Add comments about moving the Vomnibar to an iframe --- background_scripts/main.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'background_scripts') diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 49417d7a..03d6143d 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -635,8 +635,8 @@ getCurrFrameIndex = (frames) -> return i if frames[i].id == focusedFrame frames.length + 1 -# Send message back to the tab unchanged. -# Frames in the same tab can use this to communicate securely. +# Send message back to the tab unchanged. This allows different frames from the same tab to message eachother +# while avoiding security concerns such as eavesdropping or message spoofing. echo = (request, sender) -> delete request.handler # No need to send this information chrome.tabs.sendMessage(sender.tab.id, request) -- cgit v1.2.3 From 71af7f016f51e3c8b9c1fcfba46cb8289c91e030 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Mon, 29 Dec 2014 08:12:59 +0000 Subject: IFrame framework; develop demo. --- background_scripts/commands.coffee | 3 +++ 1 file changed, 3 insertions(+) (limited to 'background_scripts') diff --git a/background_scripts/commands.coffee b/background_scripts/commands.coffee index 585ef572..63b870cc 100644 --- a/background_scripts/commands.coffee +++ b/background_scripts/commands.coffee @@ -91,6 +91,7 @@ Commands = commandGroups: pageNavigation: ["scrollDown", + "activateTestUIComponent", "scrollUp", "scrollLeft", "scrollRight", @@ -252,6 +253,7 @@ defaultKeyMappings = "m": "Marks.activateCreateMode" "`": "Marks.activateGotoMode" + "D": "activateTestUIComponent" # This is a mapping of: commandIdentifier => [description, options]. @@ -263,6 +265,7 @@ commandDescriptions = scrollUp: ["Scroll up"] scrollLeft: ["Scroll left"] scrollRight: ["Scroll right"] + activateTestUIComponent: ["UI component test"] scrollToTop: ["Scroll to the top of the page", { noRepeat: true }] scrollToBottom: ["Scroll to the bottom of the page", { noRepeat: true }] -- cgit v1.2.3 From 0524bdc3f76279e8930bfe4b1b42d93e0e9bf6e4 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Mon, 29 Dec 2014 14:22:53 +0000 Subject: Refactor UIComponent, etc., and demo. - Simplify component API. - Iframe flashes on re-focus. - Probably some other stuff which I've forgotten. --- background_scripts/main.coffee | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'background_scripts') diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 647923c0..b85ea844 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -19,6 +19,11 @@ namedKeyRegex = /^(<(?:[amc]-.|(?:[amc]-)?[a-z0-9]{2,5})>)(.*)$/ selectionChangedHandlers = [] tabLoadedHandlers = {} # tabId -> function() +# A secret, available only within the current instantiation of Vimium. The secret is big, likely unguessable +# in practice, but less than 2^31. +chrome.storage.local.set + vimiumSecret: Math.floor Math.random() * 2000000000 + completionSources = bookmarks: new BookmarkCompleter() history: new HistoryCompleter() -- cgit v1.2.3 From c52c0ea57f86c1c5a132819fe85e763db84ce712 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Mon, 29 Dec 2014 16:33:23 +0000 Subject: Descriptions for custom search engines. --- background_scripts/completion.coffee | 16 +++++++++++----- background_scripts/settings.coffee | 16 +++++++++++----- 2 files changed, 22 insertions(+), 10 deletions(-) (limited to 'background_scripts') diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee index d62f82fe..4e570313 100644 --- a/background_scripts/completion.coffee +++ b/background_scripts/completion.coffee @@ -324,11 +324,17 @@ class SearchEngineCompleter searchEngines: {} filter: (queryTerms, onComplete) -> - searchEngineMatch = this.getSearchEngineMatches(queryTerms[0]) + {url: url, description: description} = this.getSearchEngineMatches(queryTerms[0]) suggestions = [] - if searchEngineMatch - searchEngineMatch = searchEngineMatch.replace(/%s/g, Utils.createSearchQuery queryTerms[1..]) - suggestion = new Suggestion(queryTerms, "search", searchEngineMatch, queryTerms[0] + ": " + queryTerms[1..].join(" "), @computeRelevancy) + if url + url = url.replace(/%s/g, Utils.createSearchQuery queryTerms[1..]) + if description + type = description + query = queryTerms[1..].join " " + else + type = "search" + query = queryTerms[0] + ": " + queryTerms[1..].join(" ") + suggestion = new Suggestion(queryTerms, type, url, query, @computeRelevancy) suggestions.push(suggestion) onComplete(suggestions) @@ -338,7 +344,7 @@ class SearchEngineCompleter this.searchEngines = root.Settings.getSearchEngines() getSearchEngineMatches: (queryTerm) -> - this.searchEngines[queryTerm] + this.searchEngines[queryTerm] || {} # A completer which calls filter() on many completers, aggregates the results, ranks them, and returns the top # 10. Queries from the vomnibar frontend script come through a multi completer. diff --git a/background_scripts/settings.coffee b/background_scripts/settings.coffee index e90bc1f8..3ff74749 100644 --- a/background_scripts/settings.coffee +++ b/background_scripts/settings.coffee @@ -46,13 +46,19 @@ root.Settings = Settings = # this is a map that we use to store our search engines for use. searchEnginesMap: {} - # this parses the search engines settings and clears the old searchEngines and sets the new one + # Parse the custom search engines setting and cache it. parseSearchEngines: (searchEnginesText) -> @searchEnginesMap = {} - # find the split pairs by first splitting by line then splitting on the first `: ` - split_pairs = ( pair.split( /: (.+)/, 2) for pair in searchEnginesText.split( /\n/ ) when pair[0] != "#" ) - @searchEnginesMap[a[0]] = a[1] for a in split_pairs - @searchEnginesMap + for line in searchEnginesText.split /\n/ + tokens = line.trim().split /\s+/ + continue if tokens.length < 2 or tokens[0].startsWith('"') or tokens[0].startsWith("#") + keywords = tokens[0].split ":" + continue unless keywords.length == 2 and not keywords[1] # So, like: [ "w", "" ]. + @searchEnginesMap[keywords[0]] = + url: tokens[1] + description: tokens[2..].join(" ") + + # Fetch the search-engine map, building it if necessary. getSearchEngines: -> this.parseSearchEngines(@get("searchEngines") || "") if Object.keys(@searchEnginesMap).length == 0 @searchEnginesMap -- cgit v1.2.3 From 2dc855abaeeda8ad74c3179f7224858860672338 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Mon, 29 Dec 2014 17:32:03 +0000 Subject: Remove UI component demo. --- background_scripts/commands.coffee | 3 --- 1 file changed, 3 deletions(-) (limited to 'background_scripts') diff --git a/background_scripts/commands.coffee b/background_scripts/commands.coffee index 63b870cc..585ef572 100644 --- a/background_scripts/commands.coffee +++ b/background_scripts/commands.coffee @@ -91,7 +91,6 @@ Commands = commandGroups: pageNavigation: ["scrollDown", - "activateTestUIComponent", "scrollUp", "scrollLeft", "scrollRight", @@ -253,7 +252,6 @@ defaultKeyMappings = "m": "Marks.activateCreateMode" "`": "Marks.activateGotoMode" - "D": "activateTestUIComponent" # This is a mapping of: commandIdentifier => [description, options]. @@ -265,7 +263,6 @@ commandDescriptions = scrollUp: ["Scroll up"] scrollLeft: ["Scroll left"] scrollRight: ["Scroll right"] - activateTestUIComponent: ["UI component test"] scrollToTop: ["Scroll to the top of the page", { noRepeat: true }] scrollToBottom: ["Scroll to the bottom of the page", { noRepeat: true }] -- cgit v1.2.3 From 774915f3967655ab800cc3c1ac73f0746618d3de Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Tue, 30 Dec 2014 06:07:20 +0000 Subject: Minor changes to vomnibar-in-iframe. From top to bottom on the diff: - The echo handler on the background page is no longer required. - Simplify/refactor vomnibarUI message handler. - Initialise vomnibar query to "" (rather than null) and simplify. - No need to focus parent window when vomnibar closes; that's handled by the iframe framework. Also no need to blur. --- background_scripts/main.coffee | 7 ------- 1 file changed, 7 deletions(-) (limited to 'background_scripts') diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index d01a3f6c..44ab5bac 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -622,12 +622,6 @@ handleFrameFocused = (request, sender) -> frameIdsForTab[tabId] = [request.frameId, (frameIdsForTab[tabId].filter (id) -> id != request.frameId)...] -# Send message back to the tab unchanged. This allows different frames from the same tab to message eachother -# while avoiding security concerns such as eavesdropping or message spoofing. -echo = (request, sender) -> - delete request.handler # No need to send this information - chrome.tabs.sendMessage(sender.tab.id, request) - # Port handler mapping portHandlers = keyDown: handleKeyDown, @@ -654,7 +648,6 @@ sendRequestHandlers = refreshCompleter: refreshCompleter createMark: Marks.create.bind(Marks) gotoMark: Marks.goto.bind(Marks) - echo: echo # Convenience function for development use. window.runTests = -> open(chrome.runtime.getURL('tests/dom_tests/dom_tests.html')) -- cgit v1.2.3 From 74b5c1a9bb54bbc2a2c9d30925d514e02a5515f7 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Tue, 30 Dec 2014 07:16:45 +0000 Subject: Add description to default search engines settings. --- background_scripts/settings.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'background_scripts') diff --git a/background_scripts/settings.coffee b/background_scripts/settings.coffee index 3ff74749..2fc3b43d 100644 --- a/background_scripts/settings.coffee +++ b/background_scripts/settings.coffee @@ -111,7 +111,7 @@ root.Settings = Settings = # default/fall back search engine searchUrl: "http://www.google.com/search?q=" # put in an example search engine - searchEngines: "w: http://www.wikipedia.org/w/index.php?title=Special:Search&search=%s" + searchEngines: "w: http://www.wikipedia.org/w/index.php?title=Special:Search&search=%s wikipedia" newTabUrl: "chrome://newtab" settingsVersion: Utils.getCurrentVersion() -- cgit v1.2.3 From 094753c5a536ebacdaa3f811d198595ef2c67d24 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Tue, 30 Dec 2014 16:57:27 +0000 Subject: Delay recognising query as search-engine query. --- background_scripts/completion.coffee | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'background_scripts') diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee index 4e570313..5cab54ed 100644 --- a/background_scripts/completion.coffee +++ b/background_scripts/completion.coffee @@ -324,7 +324,7 @@ class SearchEngineCompleter searchEngines: {} filter: (queryTerms, onComplete) -> - {url: url, description: description} = this.getSearchEngineMatches(queryTerms[0]) + {url: url, description: description} = @getSearchEngineMatches queryTerms suggestions = [] if url url = url.replace(/%s/g, Utils.createSearchQuery queryTerms[1..]) @@ -343,8 +343,8 @@ class SearchEngineCompleter refresh: -> this.searchEngines = root.Settings.getSearchEngines() - getSearchEngineMatches: (queryTerm) -> - this.searchEngines[queryTerm] || {} + getSearchEngineMatches: (queryTerms) -> + if 1 < queryTerms.length and engine = @searchEngines[queryTerms[0]] then engine else {} # A completer which calls filter() on many completers, aggregates the results, ranks them, and returns the top # 10. Queries from the vomnibar frontend script come through a multi completer. -- cgit v1.2.3 From 877bf98618ba4f8c2dfdb6a82459a98816062112 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Wed, 31 Dec 2014 08:58:06 +0000 Subject: Simplify search engine logic. --- background_scripts/completion.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'background_scripts') diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee index 5cab54ed..d6402019 100644 --- a/background_scripts/completion.coffee +++ b/background_scripts/completion.coffee @@ -344,7 +344,7 @@ class SearchEngineCompleter this.searchEngines = root.Settings.getSearchEngines() getSearchEngineMatches: (queryTerms) -> - if 1 < queryTerms.length and engine = @searchEngines[queryTerms[0]] then engine else {} + (1 < queryTerms.length and @searchEngines[queryTerms[0]]) or {} # A completer which calls filter() on many completers, aggregates the results, ranks them, and returns the top # 10. Queries from the vomnibar frontend script come through a multi completer. -- cgit v1.2.3