Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4838)

Unified Diff: chrome/browser/resources/google_now/background.js

Issue 54643008: Utilizing notifications.onShowSettings() event (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/google_now/background_test_util.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/google_now/background.js
diff --git a/chrome/browser/resources/google_now/background.js b/chrome/browser/resources/google_now/background.js
index 093ac6d709f51765f473f8ddf37342fd587290b9..0ef832a066dc0e070f40a3a973fa37f4e499fe57 100644
--- a/chrome/browser/resources/google_now/background.js
+++ b/chrome/browser/resources/google_now/background.js
@@ -79,6 +79,12 @@ var DISMISS_RETENTION_TIME_MS = 20 * 60 * 1000; // 20 minutes
var DEFAULT_OPTIN_CHECK_PERIOD_SECONDS = 60 * 60 * 24 * 7; // 1 week
/**
+ * URL to open when the user clicked on a link for the our notification
+ * settings.
+ */
+var SETTINGS_URL = 'https://support.google.com/chrome/?p=ib_google_now_welcome';
robliao 2013/11/01 22:29:35 Watch out for merge conflicts here.
+
+/**
* Names for tasks that can be created by the extension.
*/
var UPDATE_CARDS_TASK_NAME = 'update-cards';
@@ -165,6 +171,8 @@ wrapper.instrumentChromeApiFunction('notifications.onClosed.addListener', 0);
wrapper.instrumentChromeApiFunction(
'notifications.onPermissionLevelChanged.addListener', 0);
wrapper.instrumentChromeApiFunction(
+ 'notifications.onShowSettings.addListener', 0);
+wrapper.instrumentChromeApiFunction(
'preferencesPrivate.googleGeolocationAccessEnabled.get',
1);
wrapper.instrumentChromeApiFunction(
@@ -842,6 +850,19 @@ function retryPendingDismissals() {
}
/**
+ * Opens a URL in a new tab.
+ * @param {string} url URL to open.
+ */
+function openUrl(url) {
+ instrumented.tabs.create({url: url}, function(tab) {
+ if (tab)
+ chrome.windows.update(tab.windowId, {focused: true});
+ else
+ chrome.windows.create({url: url, focused: true});
+ });
+}
+
+/**
* Opens URL corresponding to the clicked part of the notification.
* @param {string} chromeNotificationId chrome.notifications ID of the card.
* @param {function(Object): string} selector Function that extracts the url for
@@ -860,12 +881,7 @@ function onNotificationClicked(chromeNotificationId, selector) {
if (!url)
return;
- instrumented.tabs.create({url: url}, function(tab) {
- if (tab)
- chrome.windows.update(tab.windowId, {focused: true});
- else
- chrome.windows.create({url: url, focused: true});
- });
+ openUrl(url);
});
}
@@ -1144,6 +1160,10 @@ instrumented.notifications.onPermissionLevelChanged.addListener(
onStateChange();
});
+instrumented.notifications.onShowSettings.addListener(function() {
+ openUrl(SETTINGS_URL);
+});
+
instrumented.location.onLocationUpdate.addListener(function(position) {
recordEvent(GoogleNowEvent.LOCATION_UPDATE);
updateNotificationsCards(position);
« no previous file with comments | « no previous file | chrome/browser/resources/google_now/background_test_util.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698