2 # Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
6 """Manages configuring Microsoft Internet Explorer."""
17 def _ConfigureSecurityKeyForZone(zone_number
, key
, value
):
18 """Set key under the Zone settings in Security.
21 zone_number: Integer identifier of zone to edit.
22 key: key under "HKEY_CURRENT_USER\Software\Microsoft\Windows\
23 CurrentVersion\Internet Settings\Zones\<Zone>"
25 value: new value for key.
30 if not util
.RegAdd(('HKEY_CURRENT_USER\\Software\\Microsoft\\'
31 'Windows\\CurrentVersion\\Internet Settings\\'
32 'Zones\\%s' % zone_number
), key
, util
.REG_DWORD
, value
):
37 def GetInstalledVersion():
38 """Reads the version of IE installed by checking the registry.
40 The complete version is returned. For example: 6.0.2900.55.5512.
43 String for version or None on failure.
45 return util
.RegQuery('HKLM\\Software\\Microsoft\\Internet Explorer','Version')
48 def ConfigurePopupBlocker(active
):
49 """Configure if popup blocker is active for IE 8.
52 active: new active state for popup blocker.
63 if not util
.RegAdd(('HKEY_LOCAL_MACHINE\\Software\\Microsoft'
64 '\\Internet Explorer\\Main\\FeatureControl\\'
65 'FEATURE_WEBOC_POPUPMANAGEMENT'), 'iexplore.exe',
66 util
.REG_DWORD
, value
):
75 if not util
.RegAdd(('HKEY_CURRENT_USER\\Software\\Microsoft\\'
76 'Internet Explorer\\New Windows'),
77 'PopupMgr', util
.REG_SZ
, value
):
83 def DisableDefaultBrowserCheck(active
):
84 """Turn off the check to be set as default browser on start up.
87 active: if True then disables browser check, otherwise enables.
97 path
= 'HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\Main'
99 if not util
.RegAdd(path
, 'Check_Associations', util
.REG_SZ
, value
):
105 def DisableWelcomeWindowForInternetExplorer8():
106 """Turn off the window which asks user to configure IE8 on start up.
111 path
= 'HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\Main'
113 if not util
.RegAdd(path
, 'IE8RunOnceLastShown', util
.REG_DWORD
, '1'):
116 if not util
.RegAdd(path
, 'IE8RunOnceLastShown_TIMESTAMP', util
.REG_BINARY
,
120 if not util
.RegAdd(path
, 'IE8RunOnceCompletionTime', util
.REG_BINARY
,
124 if not util
.RegAdd(path
, 'IE8TourShown', util
.REG_DWORD
, '1'):
127 if not util
.RegAdd(path
, 'IE8TourShownTime', util
.REG_BINARY
,
131 if not util
.RegAdd(path
, 'DisableFirstRunCustomize', util
.REG_DWORD
, '1'):
137 def DisableInformationBarIntro():
138 """Turn off the dialog which tells you about information bar.
143 path
= (r
'HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer'
146 if not util
.RegAdd(path
, 'FirstTime', util
.REG_DWORD
, '0'):
152 def DisableInternetExplorerPhishingFilter():
153 """Turn off the dialog for Phishing filter which blocks tests on IE 7.
158 path
= ('HKEY_CURRENT_USER\\Software\\Microsoft\\'
159 'Internet Explorer\\PhishingFilter')
161 if not util
.RegAdd(path
, 'Enabled', util
.REG_DWORD
, '1'):
164 if not util
.RegAdd(path
, 'ShownVerifyBalloon', util
.REG_DWORD
, '1'):
167 if not util
.RegAdd(path
, 'EnabledV8', util
.REG_DWORD
, '1'):
173 def ConfigureAllowActiveX(activate
):
174 """Configure internet zone to use Active X.
177 activate: Turn on if True, otherwise turn off.
189 return _ConfigureSecurityKeyForZone(internet_zone
, '1200', value
)
192 def ConfigureAllowPreviouslyUnusedActiveXControlsToRun(activate
):
193 """Configure internet zone to allow new Active X controls to run.
196 activate: Turn on if True, otherwise turn off.
208 return _ConfigureSecurityKeyForZone(internet_zone
, '1208', value
)
211 def ConfigureAllowAllDomainsToUseActiveX(activate
):
212 """Configure internet zone to allow all domains to use Active X.
215 activate: Turn on if True, otherwise turn off.
227 return _ConfigureSecurityKeyForZone(internet_zone
, '120B', value
)
230 def ConfigureAllowActiveContentFromMyComputer(activate
):
231 """Allow Active X to run from local files loaded from My Computer.
233 This option is shown under Security of the Advanced tab of Internet Options.
236 activate: Turn on if True, otherwise turn off.
246 if not util
.RegAdd(('HKEY_CURRENT_USER\\Software\\Microsoft\\'
247 'Internet Explorer\\Main\\FeatureControl\\'
248 'FEATURE_LOCALMACHINE_LOCKDOWN'),
249 'iexplore.exe', util
.REG_DWORD
, value
):
251 if not util
.RegAdd(('HKLM\\SOFTWARE\\Microsoft\\Internet Explorer\\Main\\'
252 'FeatureControl\\FEATURE_LOCALMACHINE_LOCKDOWN'),
253 'iexplore.exe', util
.REG_DWORD
, value
):
260 """Calls the other methods to allow testing with Internet Explorer.
266 logging
.info('Configuring IE...')
267 logging
.info('Allowing all active domains to use ActiveX...')
268 if not ConfigureAllowAllDomainsToUseActiveX(on
):
271 logging
.info('Allowing ActiveX...')
272 if not ConfigureAllowActiveX(on
):
275 logging
.info('Allowing previously unused ActiveX to run...')
276 if not ConfigureAllowPreviouslyUnusedActiveXControlsToRun(on
):
279 logging
.info('Disabling default browser check...')
280 if not DisableDefaultBrowserCheck(on
):
283 logging
.info('Allowing active content from my computer...')
284 if not ConfigureAllowActiveContentFromMyComputer(on
):
287 logging
.info('Disabling popup blocker...')
288 if not ConfigurePopupBlocker(False):
291 logging
.info('Disabling Phishing Filter...')
292 if not DisableInternetExplorerPhishingFilter():
295 logging
.info('Disabling welcome window for IE 8...')
296 if not DisableWelcomeWindowForInternetExplorer8():
299 logging
.info('Disabling info bar intro...')
300 if not DisableInformationBarIntro():