Skip to content

Commit 9d31a95

Browse files
authored
Merge pull request #158 from OneNoteDev/feature/remove-notifications
Remove notifications and permissions
2 parents deb34fa + 9bb4fc7 commit 9d31a95

File tree

3 files changed

+43
-43
lines changed

3 files changed

+43
-43
lines changed

src/scripts/extensions/chrome/manifest.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
"<all_urls>",
2525
"activeTab",
2626
"contextMenus",
27-
"notifications",
2827
"tabs",
2928
"webRequest",
3029
"webRequestBlocking",
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
import {WebExtension} from "./webExtension";
1+
// import {WebExtension} from "./webExtension";
22

3-
type ButtonListener = (notificationId: string, buttonIndex: number) => void;
3+
// type ButtonListener = (notificationId: string, buttonIndex: number) => void;
44

5-
export class WebExtensionNotifications {
6-
private static buttonListener: ButtonListener;
5+
// export class WebExtensionNotifications {
6+
// private static buttonListener: ButtonListener;
77

8-
public static setButtonListener(buttonListener: ButtonListener): void {
9-
WebExtensionNotifications.removeButtonListener();
10-
WebExtensionNotifications.buttonListener = buttonListener;
11-
WebExtension.browser.notifications.onButtonClicked.addListener(buttonListener);
12-
}
8+
// public static setButtonListener(buttonListener: ButtonListener): void {
9+
// WebExtensionNotifications.removeButtonListener();
10+
// WebExtensionNotifications.buttonListener = buttonListener;
11+
// WebExtension.browser.notifications.onButtonClicked.addListener(buttonListener);
12+
// }
1313

14-
public static removeButtonListener(): void {
15-
if (WebExtensionNotifications.buttonListener) {
16-
WebExtension.browser.notifications.onButtonClicked.removeListener(WebExtensionNotifications.buttonListener);
17-
WebExtensionNotifications.buttonListener = undefined;
18-
}
19-
}
20-
}
14+
// public static removeButtonListener(): void {
15+
// if (WebExtensionNotifications.buttonListener) {
16+
// WebExtension.browser.notifications.onButtonClicked.removeListener(WebExtensionNotifications.buttonListener);
17+
// WebExtensionNotifications.buttonListener = undefined;
18+
// }
19+
// }
20+
// }

src/scripts/extensions/webExtensionBase/webExtensionWorker.ts

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {InvokeSource} from "../invokeSource";
2626
import {InjectUrls} from "./injectUrls";
2727
import {WebExtension} from "./webExtension";
2828
import {WebExtensionBackgroundMessageHandler} from "./webExtensionMessageHandler";
29-
import {WebExtensionNotifications} from "./webExtensionNotifications";
29+
// import {WebExtensionNotifications} from "./webExtensionNotifications";
3030

3131
type Tab = chrome.tabs.Tab;
3232
type TabRemoveInfo = chrome.tabs.TabRemoveInfo;
@@ -100,32 +100,33 @@ export class WebExtensionWorker extends ExtensionWorkerBase<W3CTab, number> {
100100
clientInfo: this.clientInfo
101101
});
102102

103-
// The ability to get a store link from the url is only available to Chrome so far (as of 10/21/16)
104-
let extensionUrlRegex = /^chrome-extension:\/\/(\w+)\W/;
105-
if (this.clientInfo.get().clipperType === ClientType.ChromeExtension && extensionUrlRegex.test(this.tab.url)) {
106-
let extensionId = this.tab.url.match(extensionUrlRegex)[1];
107-
let extensionUrl = "https://chrome.google.com/webstore/detail/" + extensionId;
108-
109-
WebExtensionNotifications.setButtonListener((notificationId, buttonIndex) => {
110-
if (notificationId === Constants.Extension.NotificationIds.conflictingExtension && buttonIndex === 0) {
111-
window.open(extensionUrl);
112-
WebExtension.browser.notifications.clear(Constants.Extension.NotificationIds.conflictingExtension);
113-
}
114-
});
115-
116-
WebExtension.browser.notifications.create(Constants.Extension.NotificationIds.conflictingExtension, {
117-
type: "basic",
118-
title: Localization.getLocalizedString("WebClipper.Label.OneNoteWebClipper"),
119-
message: Localization.getLocalizedString("WebClipper.Error.ConflictingExtension"),
120-
buttons: [{ title: extensionUrl }],
121-
iconUrl: "icons/icon-256.png"
122-
});
123-
} else {
124-
// In Firefox, alert() is not callable from the background, so it looks like we have to no-op here
125-
if (this.clientInfo.get().clipperType !== ClientType.FirefoxExtension) {
126-
InjectHelper.alertUserOfUnclippablePage();
127-
}
103+
// // The ability to get a store link from the url is only available to Chrome so far (as of 10/21/16)
104+
// let extensionUrlRegex = /^chrome-extension:\/\/(\w+)\W/;
105+
// if (this.clientInfo.get().clipperType === ClientType.ChromeExtension && extensionUrlRegex.test(this.tab.url)) {
106+
// let extensionId = this.tab.url.match(extensionUrlRegex)[1];
107+
// let extensionUrl = "https://chrome.google.com/webstore/detail/" + extensionId;
108+
109+
// WebExtensionNotifications.setButtonListener((notificationId, buttonIndex) => {
110+
// if (notificationId === Constants.Extension.NotificationIds.conflictingExtension && buttonIndex === 0) {
111+
// window.open(extensionUrl);
112+
// WebExtension.browser.notifications.clear(Constants.Extension.NotificationIds.conflictingExtension);
113+
// }
114+
// });
115+
116+
// WebExtension.browser.notifications.create(Constants.Extension.NotificationIds.conflictingExtension, {
117+
// type: "basic",
118+
// title: Localization.getLocalizedString("WebClipper.Label.OneNoteWebClipper"),
119+
// message: Localization.getLocalizedString("WebClipper.Error.ConflictingExtension"),
120+
// buttons: [{ title: extensionUrl }],
121+
// iconUrl: "icons/icon-256.png"
122+
// });
123+
// } else {
124+
125+
// In Firefox, alert() is not callable from the background, so it looks like we have to no-op here
126+
if (this.clientInfo.get().clipperType !== ClientType.FirefoxExtension) {
127+
InjectHelper.alertUserOfUnclippablePage();
128128
}
129+
// }
129130
resolve(false);
130131
} else {
131132
WebExtension.browser.tabs.executeScript(this.tab.id, { file: this.injectUrls.webClipperInjectUrl });

0 commit comments

Comments
 (0)