From 79abb7cc1a10fb38303126033d64905f8f9945a8 Mon Sep 17 00:00:00 2001 From: "mpcomplete@chromium.org" Date: Wed, 19 Sep 2012 04:03:40 +0000 Subject: Update "First run" FAQ doc to suggest chrome.runtime.onInstalled. BUG=149149 TBR=yoz@chromium.org Review URL: https://chromiumcodereview.appspot.com/10955002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@157489 0039d316-1c4b-4281-b951-d872f2087c98 --- .../extensions/docs/templates/articles/faq.html | 27 ++++++++-------------- 1 file changed, 9 insertions(+), 18 deletions(-) (limited to 'chrome/common/extensions/docs/templates/articles/faq.html') diff --git a/chrome/common/extensions/docs/templates/articles/faq.html b/chrome/common/extensions/docs/templates/articles/faq.html index 9cec4d9..0539c56 100644 --- a/chrome/common/extensions/docs/templates/articles/faq.html +++ b/chrome/common/extensions/docs/templates/articles/faq.html @@ -275,10 +275,11 @@ cros,beta,#.#.###.#,#.#.###.#,mm/dd/yy,mm/dd/yy,#####,#####,#####

Can extensions be notified when they are installed/uninstalled?

- No, there are no events an extension can listen to in order to determine - whether it has been installed or uninstalled. However, an extension can - determine when it has been run for the first time. See this FAQ entry for information. + You can listen to the + runtime.onInstalled + event to be notified when your extension is installed or updated, or when + Chrome itself is updated. There is no corresponding event for when your + extension is uninstalled.

@@ -351,21 +352,11 @@ cros,beta,#.#.###.#,#.#.###.#,mm/dd/yy,mm/dd/yy,#####,#####,#####

How can an extension determine whether it is running for the first time?

- An extension can check to see whether it is running for the first time by - checking for the presence of a value in localStorage, and writing the value if - it does not exist. For example: + You can listen to the + runtime.onInstalled + event. See this FAQ entry.

-
var firstRun = (localStorage['firstRun'] == 'true');
-if (!firstRun) {
-  localStorage['firstRun'] = 'true';
-}
- -

- Note that this check should be run in a background page, not a content script. -

- -

Features and bugs

@@ -483,4 +474,4 @@ if (!firstRun) { to the ticket you starred or opened. This will make it easier for others with the same request to find the correct ticket. - \ No newline at end of file + -- cgit v1.1