summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorkuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-19 23:05:25 +0000
committerkuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-19 23:05:25 +0000
commit8f794cb1c1a3a989cf1fb2e453a56afadfa8db4c (patch)
tree3c6caa4facc64ee5e257591b135554b26027a2ff /chrome
parent721c3f17a7fb36edaa17f607a11db9c82ba720ca (diff)
downloadchromium_src-8f794cb1c1a3a989cf1fb2e453a56afadfa8db4c.zip
chromium_src-8f794cb1c1a3a989cf1fb2e453a56afadfa8db4c.tar.gz
chromium_src-8f794cb1c1a3a989cf1fb2e453a56afadfa8db4c.tar.bz2
Move creation of 'open with' registry keys to installer. We should place nice and not create these keys on every Chrome start just in case user wants a customized open with list. So now we only create these keys at installation or when user choses to make Chrome default browser. Also we clean them up on uninstall.
BUG=1190855 Review URL: http://codereview.chromium.org/11491 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5726 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/browser_main.cc5
-rw-r--r--chrome/browser/shell_integration.cc84
-rw-r--r--chrome/browser/shell_integration.h11
-rw-r--r--chrome/installer/setup/uninstall.cc19
-rw-r--r--chrome/installer/util/shell_util.cc15
-rw-r--r--chrome/installer/util/shell_util.h3
6 files changed, 36 insertions, 101 deletions
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc
index b5bdc8a..93aa8aa 100644
--- a/chrome/browser/browser_main.cc
+++ b/chrome/browser/browser_main.cc
@@ -492,11 +492,6 @@ int BrowserMain(CommandLine &parsed_command_line,
// Register our global network handler for chrome-resource:// URLs.
RegisterURLRequestChromeJob();
- // TODO(brettw): we may want to move this to the browser window somewhere so
- // that if it pops up a dialog box, the user gets it as the child of the
- // browser window instead of a disembodied floating box blocking startup.
- ShellIntegration::VerifyInstallation();
-
browser_process->InitBrokerServices(broker_services);
// In unittest mode, this will do nothing. In normal mode, this will create
diff --git a/chrome/browser/shell_integration.cc b/chrome/browser/shell_integration.cc
index a1afecc..d0481cf 100644
--- a/chrome/browser/shell_integration.cc
+++ b/chrome/browser/shell_integration.cc
@@ -26,88 +26,6 @@
#include "chrome/installer/util/work_item.h"
#include "chrome/installer/util/work_item_list.h"
-namespace {
-
-const wchar_t kAppInstallKey[] =
- L"Applications\\chrome.exe\\shell\\open\\command";
-
-// Append to an extension (preceeded by a dot) to add us to the "Open With"
-// list for a file. For example ".html".
-const wchar_t kOpenWithUs[] = L"\\OpenWithList\\chrome.exe";
-
-// Wait this long after startup before verifying registry keys.
-const int kVerifyTimeoutMs = 5000;
-
-bool VerifyApplicationKey();
-bool VerifyAssociations();
-
-// Include the dot in the extension.
-bool AddToOpenWithList(const wchar_t* extension);
-
-// There should be a key HKEY_CLASSES_ROOT\Applications\<appname>, the
-// OpenWithList for files refers to this key
-bool VerifyApplicationKey() {
- // we want to make Applications\<appname>\shell\open\command = <path> "%1"
- RegKey key(HKEY_CLASSES_ROOT, kAppInstallKey, KEY_WRITE);
- if (!key.Valid())
- return false;
-
- std::wstring app_path;
- if (!PathService::Get(base::FILE_EXE, &app_path))
- return false;
- app_path.append(L" -- \"%1\"");
- return key.WriteValue(NULL, app_path.c_str());
-}
-
-// This just checks that we are installed as a handler for HTML files. We
-// don't currently check for defaultness, only that we appear in the
-// "Open With" list. This will need to become more elaborate in the future.
-bool VerifyAssociations() {
- if (!AddToOpenWithList(L".html"))
- return false;
- if (!AddToOpenWithList(L".htm"))
- return false;
- return true;
-}
-
-bool AddToOpenWithList(const wchar_t* extension) {
- std::wstring path(extension);
- path.append(kOpenWithUs);
- RegKey key(HKEY_CLASSES_ROOT, path.c_str(), KEY_WRITE);
- return key.Valid();
-}
-
-class InstallationVerifyTask : public Task {
- public:
- virtual void Run() {
- ShellIntegration::VerifyInstallationNow();
- }
-};
-
-const wchar_t kVistaUrlPrefs[] =
- L"Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice";
-
-} // namespace
-
-void ShellIntegration::VerifyInstallation() {
- MessageLoop::current()->PostDelayedTask(FROM_HERE,
- new InstallationVerifyTask(),
- kVerifyTimeoutMs);
-}
-
-bool ShellIntegration::VerifyInstallationNow() {
- // Currently we only install ourselves as a verb for HTML files, and not as
- // the default handler. We don't prompt the user. In the future, we will
- // want to set as the default and prompt the user if something changed. We
- // will also care about more file types.
- //
- // MSDN's description of file associations:
- // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/programmersguide/shell_basics/shell_basics_extending/fileassociations/fileassoc.asp
- if (!VerifyApplicationKey())
- return false;
- return VerifyAssociations();
-}
-
bool ShellIntegration::SetAsDefaultBrowser() {
std::wstring chrome_exe;
if (!PathService::Get(base::FILE_EXE, &chrome_exe)) {
@@ -213,7 +131,7 @@ bool ShellIntegration::IsFirefoxDefaultBrowser() {
bool ff_default = false;
if (win_util::GetWinVersion() == win_util::WINVERSION_VISTA) {
std::wstring app_cmd;
- RegKey key(HKEY_CURRENT_USER, kVistaUrlPrefs, KEY_READ);
+ RegKey key(HKEY_CURRENT_USER, ShellUtil::kRegVistaUrlPrefs, KEY_READ);
if (key.Valid() && key.ReadValue(L"Progid", &app_cmd) &&
app_cmd == L"FirefoxURL")
ff_default = true;
diff --git a/chrome/browser/shell_integration.h b/chrome/browser/shell_integration.h
index 85e1c3c..165fa6c 100644
--- a/chrome/browser/shell_integration.h
+++ b/chrome/browser/shell_integration.h
@@ -9,17 +9,6 @@
class ShellIntegration {
public:
- // Makes sure we are installed as a handler for the types we care about.
- // It should be called once, probably at startup.
- //
- // It will not check everything right away, but will instead do it on a timer
- // to avoid blocking startup.
- static void VerifyInstallation();
-
- // Like VerifyInstallation() but does the operations synchronously, returning
- // true on success.
- static bool VerifyInstallationNow();
-
// Sets Chrome as default browser (only for current user). Returns false if
// this operation fails.
static bool SetAsDefaultBrowser();
diff --git a/chrome/installer/setup/uninstall.cc b/chrome/installer/setup/uninstall.cc
index 4bf5856..27e8801 100644
--- a/chrome/installer/setup/uninstall.cc
+++ b/chrome/installer/setup/uninstall.cc
@@ -258,12 +258,29 @@ installer_util::InstallStatus installer_setup::UninstallChrome(
DeleteRegistryValue(reg_root, ShellUtil::kRegRegisteredApplications,
dist->GetApplicationName());
+
+ // Cleanup Software\Classes\Applications\chrome.exe and OpenWithList
+ RegKey hklm_key(HKEY_LOCAL_MACHINE, L"", KEY_ALL_ACCESS);
+ std::wstring app_key(ShellUtil::kRegClasses);
+ file_util::AppendToPath(&app_key, L"Applications");
+ file_util::AppendToPath(&app_key, installer_util::kChromeExe);
+ DeleteRegistryKey(key, app_key);
+ if (remove_all)
+ DeleteRegistryKey(hklm_key, app_key);
+ for (int i = 0; ShellUtil::kFileAssociations[i] != NULL; i++) {
+ std::wstring open_with_key(ShellUtil::kRegClasses);
+ file_util::AppendToPath(&open_with_key, ShellUtil::kFileAssociations[i]);
+ file_util::AppendToPath(&open_with_key, L"OpenWithList");
+ file_util::AppendToPath(&open_with_key, installer_util::kChromeExe);
+ DeleteRegistryKey(key, open_with_key);
+ if (remove_all)
+ DeleteRegistryKey(hklm_key, open_with_key);
+ }
key.Close();
// Delete shared registry keys as well (these require admin rights) if
// remove_all option is specified.
if (remove_all) {
- RegKey hklm_key(HKEY_LOCAL_MACHINE, L"", KEY_ALL_ACCESS);
DeleteRegistryKey(hklm_key, set_access_key);
DeleteRegistryKey(hklm_key, html_prog_id);
DeleteRegistryValue(HKEY_LOCAL_MACHINE,
diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc
index 4f97cd6..ba8c0fe 100644
--- a/chrome/installer/util/shell_util.cc
+++ b/chrome/installer/util/shell_util.cc
@@ -11,7 +11,7 @@
#include <shellapi.h>
#include <shlobj.h>
-#include "shell_util.h"
+#include "chrome/installer/util/shell_util.h"
#include "base/file_util.h"
#include "base/logging.h"
@@ -57,6 +57,17 @@ class RegistryEntry {
entries.push_front(new RegistryEntry(
L"Software\\Classes\\ChromeHTML\\shell\\open\\command", open_cmd));
+ std::wstring exe_name = file_util::GetFilenameFromPath(chrome_exe);
+ std::wstring app_key = L"Software\\Classes\\Applications\\" + exe_name +
+ L"\\shell\\open\\command";
+ entries.push_front(new RegistryEntry(app_key, open_cmd));
+ for (int i = 0; ShellUtil::kFileAssociations[i] != NULL; i++) {
+ std::wstring open_with_key(L"Software\\Classes\\");
+ open_with_key.append(ShellUtil::kFileAssociations[i]);
+ open_with_key.append(L"\\OpenWithList\\" + exe_name);
+ entries.push_front(new RegistryEntry(open_with_key, std::wstring()));
+ }
+
BrowserDistribution* dist = BrowserDistribution::GetDistribution();
entries.push_front(new RegistryEntry(
L"Software\\Clients\\StartMenuInternet\\chrome.exe",
@@ -333,6 +344,8 @@ const wchar_t* ShellUtil::kRegRegisteredApplications =
const wchar_t* ShellUtil::kRegShellChromeHTML = L"\\shell\\ChromeHTML";
const wchar_t* ShellUtil::kRegShellChromeHTMLCommand =
L"\\shell\\ChromeHTML\\command";
+const wchar_t* ShellUtil::kRegVistaUrlPrefs =
+ L"Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice";
const wchar_t* ShellUtil::kChromeHTMLProgId = L"ChromeHTML";
const wchar_t* ShellUtil::kFileAssociations[] = {L".htm", L".html", L".shtml",
diff --git a/chrome/installer/util/shell_util.h b/chrome/installer/util/shell_util.h
index bdf77a19..ee7153a 100644
--- a/chrome/installer/util/shell_util.h
+++ b/chrome/installer/util/shell_util.h
@@ -65,6 +65,9 @@ class ShellUtil {
// (i.e. \\shell\\ChromeHTML\\command).
static const wchar_t* kRegShellChromeHTMLCommand;
+ // Registry path that stores url associations on Vista.
+ static const wchar_t* kRegVistaUrlPrefs;
+
// File extensions that Chrome registers itself for.
static const wchar_t* kFileAssociations[];