aboutsummaryrefslogtreecommitdiff
path: root/src/background/shared/completions/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/background/shared/completions/index.js')
-rw-r--r--src/background/shared/completions/index.js22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/background/shared/completions/index.js b/src/background/shared/completions/index.js
index 5bfdbfb..8ecdcfc 100644
--- a/src/background/shared/completions/index.js
+++ b/src/background/shared/completions/index.js
@@ -1,5 +1,6 @@
import * as tabs from './tabs';
import * as histories from './histories';
+import * as bookmarks from './bookmarks';
const getSearchCompletions = (command, keywords, searchConfig) => {
let engineNames = Object.keys(searchConfig.engines);
@@ -23,11 +24,24 @@ const getHistoryCompletions = (command, keywords) => {
});
};
+const getBookmarksCompletions = (command, keywords) => {
+ return bookmarks.getCompletions(keywords).then((items) => {
+ return items.map((item) => {
+ return {
+ caption: item.title,
+ content: command + ' ' + item.url,
+ url: item.url,
+ };
+ });
+ });
+};
+
const getOpenCompletions = (command, keywords, searchConfig) => {
return Promise.all([
getSearchCompletions(command, keywords, searchConfig),
getHistoryCompletions(command, keywords),
- ]).then(([engineItems, historyItems]) => {
+ getBookmarksCompletions(command, keywords),
+ ]).then(([engineItems, historyItems, bookmarkItems]) => {
let completions = [];
if (engineItems.length > 0) {
completions.push({
@@ -41,6 +55,12 @@ const getOpenCompletions = (command, keywords, searchConfig) => {
items: historyItems
});
}
+ if (bookmarkItems.length > 0) {
+ completions.push({
+ name: 'Bookmarks',
+ items: bookmarkItems
+ });
+ }
return completions;
});
};