Chromium Code Reviews| Index: chrome/browser/shell_integration_win.cc |
| diff --git a/chrome/browser/shell_integration_win.cc b/chrome/browser/shell_integration_win.cc |
| index fcb7d451f2bbd7de7ac5258ef2e4689e75b22663..1f47fd9fc632a6f0cde253c31c3e798627961c1b 100644 |
| --- a/chrome/browser/shell_integration_win.cc |
| +++ b/chrome/browser/shell_integration_win.cc |
| @@ -7,9 +7,6 @@ |
| #include <windows.h> |
| #include <shobjidl.h> |
| #include <propkey.h> |
| -#include <propvarutil.h> |
| -#include <tchar.h> |
| -#include <strsafe.h> |
| #include "base/bind.h" |
| #include "base/command_line.h" |
| @@ -39,9 +36,6 @@ |
| #include "chrome/installer/util/work_item_list.h" |
| #include "content/public/browser/browser_thread.h" |
| -// propsys.lib is required for PropvariantTo*(). |
| -#pragma comment(lib, "propsys.lib") |
| - |
| using content::BrowserThread; |
| namespace { |
| @@ -385,7 +379,6 @@ int ShellIntegration::MigrateShortcutsInPathInternal(const FilePath& chrome_exe, |
| int shortcuts_migrated = 0; |
| FilePath target_path; |
| string16 arguments; |
| - string16 existing_app_id; |
| for (FilePath shortcut = shortcuts_enum.Next(); !shortcut.empty(); |
| shortcut = shortcuts_enum.Next()) { |
| // TODO(gab): Use ProgramCompare instead of comparing FilePaths below once |
| @@ -427,31 +420,25 @@ int ShellIntegration::MigrateShortcutsInPathInternal(const FilePath& chrome_exe, |
| // When in doubt, prefer not updating the shortcut. |
| NOTREACHED(); |
| continue; |
| - } else if (pv_app_id.vt == VT_EMPTY) { |
| - // If there is no app_id set, set our app_id if one is expected. |
| - if (!expected_app_id.empty()) |
| - updated_properties.set_app_id(expected_app_id); |
| } else { |
| - // Validate that the existing app_id is the expected app_id; if not, set |
| - // the expected app_id on the shortcut. |
| - size_t expected_size = expected_app_id.size() + 1; |
| - HRESULT result = PropVariantToString( |
| - pv_app_id, WriteInto(&existing_app_id, expected_size), expected_size); |
| - PropVariantClear(&pv_app_id); |
| - if (result != S_OK && result != STRSAFE_E_INSUFFICIENT_BUFFER) { |
| - // Accept the STRSAFE_E_INSUFFICIENT_BUFFER error state as it means the |
| - // existing appid is longer than |expected_app_id| and thus we will |
| - // simply assume inequality. |
| - NOTREACHED(); |
| - continue; |
| - } else if (result == STRSAFE_E_INSUFFICIENT_BUFFER || |
| - expected_app_id != existing_app_id) { |
| - updated_properties.set_app_id(expected_app_id); |
| + switch (pv_app_id.vt) { |
| + case VT_EMPTY: |
| + // If there is no app_id set, set our app_id if one is expected. |
| + if (!expected_app_id.empty()) |
| + updated_properties.set_app_id(expected_app_id); |
| + break; |
| + case VT_LPWSTR: |
| + if (expected_app_id != string16(pv_app_id.pwszVal)) |
| + updated_properties.set_app_id(expected_app_id); |
| + break; |
| + default: |
| + NOTREACHED(); |
|
grt (UTC plus 2)
2013/01/08 04:21:45
PropVariantClear(&pv_app_id) here to ensure that w
gab
2013/01/08 22:33:23
Added a ScopedPropVariant to base/win.
|
| + continue; |
| } |
| + PropVariantClear(&pv_app_id); |
| } |
| if (check_dual_mode) { |
| - BOOL existing_dual_mode; |
| PROPVARIANT pv_dual_mode; |
| PropVariantInit(&pv_dual_mode); |
| if (property_store->GetValue(PKEY_AppUserModel_IsDualMode, |
| @@ -459,18 +446,22 @@ int ShellIntegration::MigrateShortcutsInPathInternal(const FilePath& chrome_exe, |
| // When in doubt, prefer to not update the shortcut. |
| NOTREACHED(); |
| continue; |
| - } else if (pv_dual_mode.vt == VT_EMPTY) { |
| - // If dual_mode is not set at all, make sure it gets set to true. |
| - updated_properties.set_dual_mode(true); |
| } else { |
| - // If it is set to false, make sure it gets set to true as well. |
| - if (PropVariantToBoolean(pv_dual_mode, &existing_dual_mode) != S_OK) { |
| - NOTREACHED(); |
| - continue; |
| + switch (pv_dual_mode.vt) { |
| + case VT_EMPTY: |
| + // If dual_mode is not set at all, make sure it gets set to true. |
| + updated_properties.set_dual_mode(true); |
| + break; |
| + case VT_BOOL: |
| + // If it is set to false, make sure it gets set to true as well. |
| + if (!pv_dual_mode.boolVal) |
| + updated_properties.set_dual_mode(true); |
| + break; |
| + default: |
| + NOTREACHED(); |
|
grt (UTC plus 2)
2013/01/08 04:21:45
same comment here
gab
2013/01/08 22:33:23
Done.
|
| + continue; |
| } |
| PropVariantClear(&pv_dual_mode); |
| - if (!existing_dual_mode) |
| - updated_properties.set_dual_mode(true); |
| } |
| } |