| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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> | 8 #include <shobjidl.h> |
| 9 #include <propkey.h> | 9 #include <propkey.h> |
| 10 #include <propvarutil.h> | 10 #include <propvarutil.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/scoped_comptr_win.h" | |
| 17 #include "base/string_util.h" | 16 #include "base/string_util.h" |
| 18 #include "base/task.h" | 17 #include "base/task.h" |
| 19 #include "base/utf_string_conversions.h" | 18 #include "base/utf_string_conversions.h" |
| 20 #include "base/win/registry.h" | 19 #include "base/win/registry.h" |
| 20 #include "base/win/scoped_comptr.h" |
| 21 #include "base/win/windows_version.h" | 21 #include "base/win/windows_version.h" |
| 22 #include "chrome/browser/web_applications/web_app.h" | 22 #include "chrome/browser/web_applications/web_app.h" |
| 23 #include "chrome/common/chrome_constants.h" | 23 #include "chrome/common/chrome_constants.h" |
| 24 #include "chrome/common/chrome_paths.h" | 24 #include "chrome/common/chrome_paths.h" |
| 25 #include "chrome/common/chrome_paths_internal.h" | 25 #include "chrome/common/chrome_paths_internal.h" |
| 26 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
| 27 #include "chrome/installer/util/browser_distribution.h" | 27 #include "chrome/installer/util/browser_distribution.h" |
| 28 #include "chrome/installer/util/create_reg_key_work_item.h" | 28 #include "chrome/installer/util/create_reg_key_work_item.h" |
| 29 #include "chrome/installer/util/set_reg_value_work_item.h" | 29 #include "chrome/installer/util/set_reg_value_work_item.h" |
| 30 #include "chrome/installer/util/shell_util.h" | 30 #include "chrome/installer/util/shell_util.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 // Enumerate all pinned shortcuts in the given path directly. | 147 // Enumerate all pinned shortcuts in the given path directly. |
| 148 file_util::FileEnumerator shortcuts_enum( | 148 file_util::FileEnumerator shortcuts_enum( |
| 149 path, | 149 path, |
| 150 false, // not recursive | 150 false, // not recursive |
| 151 file_util::FileEnumerator::FILES, | 151 file_util::FileEnumerator::FILES, |
| 152 FILE_PATH_LITERAL("*.lnk")); | 152 FILE_PATH_LITERAL("*.lnk")); |
| 153 | 153 |
| 154 for (FilePath shortcut = shortcuts_enum.Next(); !shortcut.empty(); | 154 for (FilePath shortcut = shortcuts_enum.Next(); !shortcut.empty(); |
| 155 shortcut = shortcuts_enum.Next()) { | 155 shortcut = shortcuts_enum.Next()) { |
| 156 // Load the shortcut. | 156 // Load the shortcut. |
| 157 ScopedComPtr<IShellLink> shell_link; | 157 base::win::ScopedComPtr<IShellLink> shell_link; |
| 158 if (FAILED(shell_link.CreateInstance(CLSID_ShellLink, | 158 if (FAILED(shell_link.CreateInstance(CLSID_ShellLink, |
| 159 NULL, | 159 NULL, |
| 160 CLSCTX_INPROC_SERVER))) { | 160 CLSCTX_INPROC_SERVER))) { |
| 161 NOTREACHED(); | 161 NOTREACHED(); |
| 162 return; | 162 return; |
| 163 } | 163 } |
| 164 | 164 |
| 165 ScopedComPtr<IPersistFile> persist_file; | 165 base::win::ScopedComPtr<IPersistFile> persist_file; |
| 166 if (FAILED(persist_file.QueryFrom(shell_link)) || | 166 if (FAILED(persist_file.QueryFrom(shell_link)) || |
| 167 FAILED(persist_file->Load(shortcut.value().c_str(), STGM_READ))) { | 167 FAILED(persist_file->Load(shortcut.value().c_str(), STGM_READ))) { |
| 168 NOTREACHED(); | 168 NOTREACHED(); |
| 169 return; | 169 return; |
| 170 } | 170 } |
| 171 | 171 |
| 172 // Get expected app id from shortcut. | 172 // Get expected app id from shortcut. |
| 173 std::wstring expected_app_id; | 173 std::wstring expected_app_id; |
| 174 if (!GetExpectedAppId(shell_link, &expected_app_id) || | 174 if (!GetExpectedAppId(shell_link, &expected_app_id) || |
| 175 expected_app_id.empty()) | 175 expected_app_id.empty()) |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 } | 241 } |
| 242 | 242 |
| 243 bool MigrateChromiumShortcutsTask::GetShortcutAppId( | 243 bool MigrateChromiumShortcutsTask::GetShortcutAppId( |
| 244 IShellLink* shell_link, | 244 IShellLink* shell_link, |
| 245 std::wstring* app_id) const { | 245 std::wstring* app_id) const { |
| 246 DCHECK(shell_link); | 246 DCHECK(shell_link); |
| 247 DCHECK(app_id); | 247 DCHECK(app_id); |
| 248 | 248 |
| 249 app_id->clear(); | 249 app_id->clear(); |
| 250 | 250 |
| 251 ScopedComPtr<IPropertyStore> property_store; | 251 base::win::ScopedComPtr<IPropertyStore> property_store; |
| 252 if (FAILED(property_store.QueryFrom(shell_link))) | 252 if (FAILED(property_store.QueryFrom(shell_link))) |
| 253 return false; | 253 return false; |
| 254 | 254 |
| 255 PROPVARIANT appid_value; | 255 PROPVARIANT appid_value; |
| 256 PropVariantInit(&appid_value); | 256 PropVariantInit(&appid_value); |
| 257 if (FAILED(property_store->GetValue(PKEY_AppUserModel_ID, | 257 if (FAILED(property_store->GetValue(PKEY_AppUserModel_ID, |
| 258 &appid_value))) | 258 &appid_value))) |
| 259 return false; | 259 return false; |
| 260 | 260 |
| 261 if (appid_value.vt == VT_LPWSTR || | 261 if (appid_value.vt == VT_LPWSTR || |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 profile_path); | 414 profile_path); |
| 415 } | 415 } |
| 416 | 416 |
| 417 void ShellIntegration::MigrateChromiumShortcuts() { | 417 void ShellIntegration::MigrateChromiumShortcuts() { |
| 418 if (base::win::GetVersion() < base::win::VERSION_WIN7) | 418 if (base::win::GetVersion() < base::win::VERSION_WIN7) |
| 419 return; | 419 return; |
| 420 | 420 |
| 421 BrowserThread::PostTask( | 421 BrowserThread::PostTask( |
| 422 BrowserThread::FILE, FROM_HERE, new MigrateChromiumShortcutsTask()); | 422 BrowserThread::FILE, FROM_HERE, new MigrateChromiumShortcutsTask()); |
| 423 } | 423 } |
| OLD | NEW |