| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/shell_integration.h" | 5 #include "chrome/browser/shell_integration.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <shobjidl.h> |
| 9 #include <propkey.h> |
| 8 #include <propvarutil.h> | 10 #include <propvarutil.h> |
| 9 #include <shlobj.h> | |
| 10 #include <shobjidl.h> | |
| 11 | 11 |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
| 14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
| 15 #include "base/path_service.h" | 15 #include "base/path_service.h" |
| 16 #include "base/registry.h" | 16 #include "base/registry.h" |
| 17 #include "base/scoped_comptr_win.h" | 17 #include "base/scoped_comptr_win.h" |
| 18 #include "base/string_util.h" | 18 #include "base/string_util.h" |
| 19 #include "base/task.h" | 19 #include "base/task.h" |
| 20 #include "base/utf_string_conversions.h" | 20 #include "base/utf_string_conversions.h" |
| 21 #include "base/win_util.h" | 21 #include "base/win_util.h" |
| 22 #include "base/win/windows_version.h" |
| 22 #include "chrome/browser/browser_thread.h" | 23 #include "chrome/browser/browser_thread.h" |
| 23 #include "chrome/browser/web_applications/web_app.h" | 24 #include "chrome/browser/web_applications/web_app.h" |
| 24 #include "chrome/common/chrome_constants.h" | 25 #include "chrome/common/chrome_constants.h" |
| 25 #include "chrome/common/chrome_paths.h" | 26 #include "chrome/common/chrome_paths.h" |
| 26 #include "chrome/common/chrome_paths_internal.h" | 27 #include "chrome/common/chrome_paths_internal.h" |
| 27 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
| 28 #include "chrome/installer/util/browser_distribution.h" | 29 #include "chrome/installer/util/browser_distribution.h" |
| 29 #include "chrome/installer/util/create_reg_key_work_item.h" | 30 #include "chrome/installer/util/create_reg_key_work_item.h" |
| 30 #include "chrome/installer/util/set_reg_value_work_item.h" | 31 #include "chrome/installer/util/set_reg_value_work_item.h" |
| 31 #include "chrome/installer/util/shell_util.h" | 32 #include "chrome/installer/util/shell_util.h" |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 DCHECK(app_id); | 243 DCHECK(app_id); |
| 243 | 244 |
| 244 app_id->clear(); | 245 app_id->clear(); |
| 245 | 246 |
| 246 ScopedComPtr<IPropertyStore> property_store; | 247 ScopedComPtr<IPropertyStore> property_store; |
| 247 if (FAILED(property_store.QueryFrom(shell_link))) | 248 if (FAILED(property_store.QueryFrom(shell_link))) |
| 248 return false; | 249 return false; |
| 249 | 250 |
| 250 PROPVARIANT appid_value; | 251 PROPVARIANT appid_value; |
| 251 PropVariantInit(&appid_value); | 252 PropVariantInit(&appid_value); |
| 252 if (FAILED(property_store->GetValue(win_util::kPKEYAppUserModelID, | 253 if (FAILED(property_store->GetValue(PKEY_AppUserModel_ID, |
| 253 &appid_value))) | 254 &appid_value))) |
| 254 return false; | 255 return false; |
| 255 | 256 |
| 256 if (appid_value.vt == VT_LPWSTR || | 257 if (appid_value.vt == VT_LPWSTR || |
| 257 appid_value.vt == VT_BSTR) | 258 appid_value.vt == VT_BSTR) |
| 258 app_id->assign(appid_value.pwszVal); | 259 app_id->assign(appid_value.pwszVal); |
| 259 | 260 |
| 260 PropVariantClear(&appid_value); | 261 PropVariantClear(&appid_value); |
| 261 return true; | 262 return true; |
| 262 } | 263 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 293 // type handlers and icons as having changed the default browser status, | 294 // type handlers and icons as having changed the default browser status, |
| 294 // since the user may have changed their shell settings to cause HTML files | 295 // since the user may have changed their shell settings to cause HTML files |
| 295 // to open with a text editor for example. We also don't want to aggressively | 296 // to open with a text editor for example. We also don't want to aggressively |
| 296 // claim FTP, since the user may have a separate FTP client. It is an open | 297 // claim FTP, since the user may have a separate FTP client. It is an open |
| 297 // question as to how to "heal" these settings. Perhaps the user should just | 298 // question as to how to "heal" these settings. Perhaps the user should just |
| 298 // re-run the installer or run with the --set-default-browser command line | 299 // re-run the installer or run with the --set-default-browser command line |
| 299 // flag. There is doubtless some other key we can hook into to cause "Repair" | 300 // flag. There is doubtless some other key we can hook into to cause "Repair" |
| 300 // to show up in Add/Remove programs for us. | 301 // to show up in Add/Remove programs for us. |
| 301 const std::wstring kChromeProtocols[] = {L"http", L"https"}; | 302 const std::wstring kChromeProtocols[] = {L"http", L"https"}; |
| 302 | 303 |
| 303 if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) { | 304 if (base::win::GetVersion() >= base::win::VERSION_VISTA) { |
| 304 IApplicationAssociationRegistration* pAAR; | 305 IApplicationAssociationRegistration* pAAR; |
| 305 HRESULT hr = CoCreateInstance(CLSID_ApplicationAssociationRegistration, | 306 HRESULT hr = CoCreateInstance(CLSID_ApplicationAssociationRegistration, |
| 306 NULL, CLSCTX_INPROC, __uuidof(IApplicationAssociationRegistration), | 307 NULL, CLSCTX_INPROC, __uuidof(IApplicationAssociationRegistration), |
| 307 (void**)&pAAR); | 308 (void**)&pAAR); |
| 308 if (!SUCCEEDED(hr)) | 309 if (!SUCCEEDED(hr)) |
| 309 return NOT_DEFAULT_BROWSER; | 310 return NOT_DEFAULT_BROWSER; |
| 310 | 311 |
| 311 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 312 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 312 std::wstring app_name = dist->GetApplicationName(); | 313 std::wstring app_name = dist->GetApplicationName(); |
| 313 // If a user specific default browser entry exists, we check for that | 314 // If a user specific default browser entry exists, we check for that |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 // registry on XP and Vista: | 362 // registry on XP and Vista: |
| 362 // - HKCR\http\shell\open\command (XP) | 363 // - HKCR\http\shell\open\command (XP) |
| 363 // - HKCU\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\ | 364 // - HKCU\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\ |
| 364 // http\UserChoice (Vista) | 365 // http\UserChoice (Vista) |
| 365 // This method checks if Firefox is defualt browser by checking these | 366 // This method checks if Firefox is defualt browser by checking these |
| 366 // locations and returns true if Firefox traces are found there. In case of | 367 // locations and returns true if Firefox traces are found there. In case of |
| 367 // error (or if Firefox is not found)it returns the default value which | 368 // error (or if Firefox is not found)it returns the default value which |
| 368 // is false. | 369 // is false. |
| 369 bool ShellIntegration::IsFirefoxDefaultBrowser() { | 370 bool ShellIntegration::IsFirefoxDefaultBrowser() { |
| 370 bool ff_default = false; | 371 bool ff_default = false; |
| 371 if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) { | 372 if (base::win::GetVersion() >= base::win::VERSION_VISTA) { |
| 372 std::wstring app_cmd; | 373 std::wstring app_cmd; |
| 373 RegKey key(HKEY_CURRENT_USER, ShellUtil::kRegVistaUrlPrefs, KEY_READ); | 374 RegKey key(HKEY_CURRENT_USER, ShellUtil::kRegVistaUrlPrefs, KEY_READ); |
| 374 if (key.Valid() && key.ReadValue(L"Progid", &app_cmd) && | 375 if (key.Valid() && key.ReadValue(L"Progid", &app_cmd) && |
| 375 app_cmd == L"FirefoxURL") | 376 app_cmd == L"FirefoxURL") |
| 376 ff_default = true; | 377 ff_default = true; |
| 377 } else { | 378 } else { |
| 378 std::wstring key_path(L"http"); | 379 std::wstring key_path(L"http"); |
| 379 key_path.append(ShellUtil::kRegShellOpen); | 380 key_path.append(ShellUtil::kRegShellOpen); |
| 380 RegKey key(HKEY_CLASSES_ROOT, key_path.c_str(), KEY_READ); | 381 RegKey key(HKEY_CLASSES_ROOT, key_path.c_str(), KEY_READ); |
| 381 std::wstring app_cmd; | 382 std::wstring app_cmd; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 400 DCHECK(app_id.length() < 128); | 401 DCHECK(app_id.length() < 128); |
| 401 return app_id; | 402 return app_id; |
| 402 } | 403 } |
| 403 | 404 |
| 404 std::wstring ShellIntegration::GetChromiumAppId(const FilePath& profile_path) { | 405 std::wstring ShellIntegration::GetChromiumAppId(const FilePath& profile_path) { |
| 405 return GetAppId(BrowserDistribution::GetDistribution()->GetBrowserAppId(), | 406 return GetAppId(BrowserDistribution::GetDistribution()->GetBrowserAppId(), |
| 406 profile_path); | 407 profile_path); |
| 407 } | 408 } |
| 408 | 409 |
| 409 void ShellIntegration::MigrateChromiumShortcuts() { | 410 void ShellIntegration::MigrateChromiumShortcuts() { |
| 410 if (win_util::GetWinVersion() < win_util::WINVERSION_WIN7) | 411 if (base::win::GetVersion() < base::win::VERSION_WIN7) |
| 411 return; | 412 return; |
| 412 | 413 |
| 413 BrowserThread::PostTask( | 414 BrowserThread::PostTask( |
| 414 BrowserThread::FILE, FROM_HERE, new MigrateChromiumShortcutsTask()); | 415 BrowserThread::FILE, FROM_HERE, new MigrateChromiumShortcutsTask()); |
| 415 } | 416 } |
| OLD | NEW |