Chromium Code Reviews| Index: chrome_frame/test/ie_configurator.cc |
| diff --git a/chrome_frame/test/ie_configurator.cc b/chrome_frame/test/ie_configurator.cc |
| index 10c445f981da77096496972f7c3eca0669b77527..8ed6d2fc46b9a6f4bdb2bd6405a784c7dfd1116f 100644 |
| --- a/chrome_frame/test/ie_configurator.cc |
| +++ b/chrome_frame/test/ie_configurator.cc |
| @@ -42,6 +42,8 @@ const wchar_t kValueIE9Completed[] = L"IE9RunOncePerInstallCompleted"; |
| const wchar_t kValueIE9CompletionTime[] = L"IE9RunOnceCompletionTime"; |
| const wchar_t kValueIE9LastShown[] = L"IE9RunOnceLastShown"; |
| const wchar_t kValueIE9TourNoShow[] = L"IE9TourNoShow"; |
| +const wchar_t kValueIE10Completed[] = L"IE10RunOncePerInstallCompleted"; |
| +const wchar_t kValueIE10CompletionTime[] = L"IE10RunOnceCompletionTime"; |
| const wchar_t kValueIgnoreFrameApprovalCheck[] = L"IgnoreFrameApprovalCheck"; |
| const wchar_t kValueMSCompatibilityMode[] = L"MSCompatibilityMode"; |
| @@ -140,24 +142,36 @@ class IE7Configurator : public IEConfigurator { |
| DISALLOW_COPY_AND_ASSIGN(IE7Configurator); |
| }; |
| -// A configurator for Internet Explorer 9. |
| -class IE9Configurator : public IEConfigurator { |
| +// A configurator for Internet Explorer 9 and 10. |
| +class ModernIEConfigurator : public IEConfigurator { |
| public: |
| - IE9Configurator(); |
| - virtual ~IE9Configurator(); |
| + explicit ModernIEConfigurator(IEVersion ie_version); |
| + virtual ~ModernIEConfigurator(); |
| virtual void Initialize() OVERRIDE; |
| virtual void ApplySettings() OVERRIDE; |
| virtual void RevertSettings() OVERRIDE; |
| private: |
| - static bool IsPerUserSetupComplete(); |
| + // The names of the registry values used to determine if IE's one-time |
| + // initialization has been completed. |
| + struct RunOnceValueNames { |
| + // This DWORD value is non-zero once initialization has been completed. |
| + const wchar_t* completed; |
| + // This 8-byte binary value is the FILETIME of completion. |
| + const wchar_t* completion_time; |
| + }; |
| + |
| + static RunOnceValueNames RunOnceNamesForVersion(IEVersion ie_version); |
| + bool IsPerUserSetupComplete(); |
| static string16 GetChromeFrameBHOCLSID(); |
| static bool IsAddonPromptDisabledForChromeFrame(); |
| + const IEVersion ie_version_; |
| + RunOnceValueNames run_once_value_names_; |
| RegistrySetter setter_; |
| - DISALLOW_COPY_AND_ASSIGN(IE9Configurator); |
| + DISALLOW_COPY_AND_ASSIGN(ModernIEConfigurator); |
| }; |
| // RegistrySetter implementation. |
| @@ -334,17 +348,38 @@ void IE7Configurator::RevertSettings() { |
| setter_.Revert(); |
| } |
| -// IE9Configurator implementation |
| +// ModernIEConfigurator implementation |
| -IE9Configurator::IE9Configurator() { |
| +ModernIEConfigurator::ModernIEConfigurator(IEVersion ie_version) |
| + : ie_version_(ie_version), |
| + run_once_value_names_(RunOnceNamesForVersion(ie_version)) { |
| } |
| -IE9Configurator::~IE9Configurator() { |
| +ModernIEConfigurator::~ModernIEConfigurator() { |
| } |
| -// Returns true if the per-user setup is complete. |
| // static |
| -bool IE9Configurator::IsPerUserSetupComplete() { |
| +ModernIEConfigurator::RunOnceValueNames |
|
robertshield
2012/10/14 01:30:34
how do you feel about sticking this in a construct
grt (UTC plus 2)
2012/10/15 14:16:17
Not so great. The names struct is a super-lightwe
|
| + ModernIEConfigurator::RunOnceNamesForVersion( |
| + IEVersion ie_version) { |
| + RunOnceValueNames names = {}; |
| + switch (ie_version) { |
| + case IE_9: |
| + names.completed = kValueIE9Completed; |
| + names.completion_time = kValueIE9CompletionTime; |
| + break; |
| + case IE_10: |
| + names.completed = kValueIE10Completed; |
| + names.completion_time = kValueIE10CompletionTime; |
| + break; |
| + default: |
| + NOTREACHED(); |
| + } |
| + return names; |
| +} |
| + |
| +// Returns true if the per-user setup is complete. |
| +bool ModernIEConfigurator::IsPerUserSetupComplete() { |
| bool is_complete = false; |
| base::win::RegKey key_main; |
| @@ -354,11 +389,11 @@ bool IE9Configurator::IsPerUserSetupComplete() { |
| FILETIME completion_time = {}; |
| DWORD size = sizeof(completion_time); |
| - if (key_main.ReadValueDW(kValueIE9Completed, |
| + if (key_main.ReadValueDW(run_once_value_names_.completed, |
| &completed) == ERROR_SUCCESS && |
| completed != 0 && |
| - key_main.ReadValue(kValueIE9CompletionTime, &completion_time, |
| - &size, NULL) == ERROR_SUCCESS && |
| + key_main.ReadValue(run_once_value_names_.completion_time, |
| + &completion_time, &size, NULL) == ERROR_SUCCESS && |
| size == sizeof(completion_time)) { |
| is_complete = true; |
| } |
| @@ -369,7 +404,7 @@ bool IE9Configurator::IsPerUserSetupComplete() { |
| // Returns the path to the IE9 Approved Extensions key for Chrome Frame. |
| // static |
| -string16 IE9Configurator::GetChromeFrameBHOCLSID() { |
| +string16 ModernIEConfigurator::GetChromeFrameBHOCLSID() { |
| string16 bho_guid(39, L'\0'); |
| int guid_len = StringFromGUID2(CLSID_ChromeFrameBHO, &bho_guid[0], |
| bho_guid.size()); |
| @@ -380,7 +415,7 @@ string16 IE9Configurator::GetChromeFrameBHOCLSID() { |
| // Returns true if the add-on enablement prompt is disabled by Group Policy. |
| // static |
| -bool IE9Configurator::IsAddonPromptDisabledForChromeFrame() { |
| +bool ModernIEConfigurator::IsAddonPromptDisabledForChromeFrame() { |
| bool is_disabled = false; |
| base::win::RegKey key; |
| @@ -411,17 +446,20 @@ bool IE9Configurator::IsAddonPromptDisabledForChromeFrame() { |
| return is_disabled; |
| } |
| -void IE9Configurator::Initialize() { |
| +void ModernIEConfigurator::Initialize() { |
| // Check for per-user IE setup. |
| if (!IsPerUserSetupComplete()) { |
| const HKEY root = HKEY_CURRENT_USER; |
| // Suppress the "Set up Internet Explorer 9" dialog. |
|
robertshield
2012/10/14 01:30:34
nit: no 9
grt (UTC plus 2)
2012/10/15 14:16:17
Done.
|
| - setter_.AddDWORDValue(root, kKeyIEMain, kValueIE9Completed, 1); |
| - setter_.AddFILETIMEValue(root, kKeyIEMain, kValueIE9CompletionTime, |
| + setter_.AddDWORDValue(root, kKeyIEMain, run_once_value_names_.completed, 1); |
| + setter_.AddFILETIMEValue(root, kKeyIEMain, |
| + run_once_value_names_.completion_time, |
| base::Time::Now().ToFileTime()); |
| - setter_.AddDWORDValue(root, kKeyIEMain, kValueIE9LastShown, 1); |
| - // Don't show a tour of IE 9. |
| - setter_.AddDWORDValue(root, kKeyIEMain, kValueIE9TourNoShow, 1); |
| + if (ie_version_ == IE_9) { |
| + setter_.AddDWORDValue(root, kKeyIEMain, kValueIE9LastShown, 1); |
| + // Don't show a tour of IE 9. |
| + setter_.AddDWORDValue(root, kKeyIEMain, kValueIE9TourNoShow, 1); |
| + } |
| // Turn off the phishing filter. |
| setter_.AddDWORDValue(root, kKeyIEPhishingFilter, kValueEnabledV9, 0); |
| // Don't download compatibility view lists. |
| @@ -437,11 +475,11 @@ void IE9Configurator::Initialize() { |
| } |
| } |
| -void IE9Configurator::ApplySettings() { |
| +void ModernIEConfigurator::ApplySettings() { |
| setter_.Apply(); |
| } |
| -void IE9Configurator::RevertSettings() { |
| +void ModernIEConfigurator::RevertSettings() { |
| setter_.Revert(); |
| } |
| @@ -458,12 +496,14 @@ IEConfigurator::~IEConfigurator() { |
| IEConfigurator* CreateConfigurator() { |
| IEConfigurator* configurator = NULL; |
| - switch (GetInstalledIEVersion()) { |
| + IEVersion ie_version = GetInstalledIEVersion(); |
| + switch (ie_version) { |
| case IE_7: |
| configurator = new IE7Configurator(); |
| break; |
| case IE_9: |
| - configurator = new IE9Configurator(); |
| + case IE_10: |
| + configurator = new ModernIEConfigurator(ie_version); |
| break; |
| default: |
| break; |