| OLD | NEW |
| 1 // Copyright (c) 2011 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_frame/utils.h" | 5 #include "chrome_frame/utils.h" |
| 6 | 6 |
| 7 #include <atlsafe.h> | 7 #include <atlsafe.h> |
| 8 #include <atlsecurity.h> | 8 #include <atlsecurity.h> |
| 9 #include <htiframe.h> | 9 #include <htiframe.h> |
| 10 #include <mshtml.h> | 10 #include <mshtml.h> |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 const wchar_t kPatchProtocols[] = L"PatchProtocols"; | 57 const wchar_t kPatchProtocols[] = L"PatchProtocols"; |
| 58 const wchar_t kChromeFrameConfigKey[] = L"Software\\Google\\ChromeFrame"; | 58 const wchar_t kChromeFrameConfigKey[] = L"Software\\Google\\ChromeFrame"; |
| 59 const wchar_t kRenderInGCFUrlList[] = L"RenderInGcfUrls"; | 59 const wchar_t kRenderInGCFUrlList[] = L"RenderInGcfUrls"; |
| 60 const wchar_t kRenderInHostUrlList[] = L"RenderInHostUrls"; | 60 const wchar_t kRenderInHostUrlList[] = L"RenderInHostUrls"; |
| 61 const wchar_t kEnableGCFRendererByDefault[] = L"IsDefaultRenderer"; | 61 const wchar_t kEnableGCFRendererByDefault[] = L"IsDefaultRenderer"; |
| 62 const wchar_t kIexploreProfileName[] = L"iexplore"; | 62 const wchar_t kIexploreProfileName[] = L"iexplore"; |
| 63 const wchar_t kRundllProfileName[] = L"rundll32"; | 63 const wchar_t kRundllProfileName[] = L"rundll32"; |
| 64 | 64 |
| 65 const wchar_t kAllowUnsafeURLs[] = L"AllowUnsafeURLs"; | 65 const wchar_t kAllowUnsafeURLs[] = L"AllowUnsafeURLs"; |
| 66 const wchar_t kEnableBuggyBhoIntercept[] = L"EnableBuggyBhoIntercept"; | 66 const wchar_t kEnableBuggyBhoIntercept[] = L"EnableBuggyBhoIntercept"; |
| 67 const wchar_t kEnableFirefoxPrivilegeMode[] = L"EnableFirefoxPrivilegeMode"; | |
| 68 | 67 |
| 69 static const wchar_t kChromeFrameNPAPIKey[] = | |
| 70 L"Software\\MozillaPlugins\\@google.com/ChromeFrame,version=1.0"; | |
| 71 static const wchar_t kChromeFramePersistNPAPIReg[] = L"PersistNPAPIReg"; | 68 static const wchar_t kChromeFramePersistNPAPIReg[] = L"PersistNPAPIReg"; |
| 72 | 69 |
| 73 const char kAttachExternalTabPrefix[] = "attach_external_tab"; | 70 const char kAttachExternalTabPrefix[] = "attach_external_tab"; |
| 74 | 71 |
| 75 // Indicates that we are running in a test environment, where execptions, etc | 72 // Indicates that we are running in a test environment, where execptions, etc |
| 76 // are handled by the chrome test crash server. | 73 // are handled by the chrome test crash server. |
| 77 const wchar_t kChromeFrameHeadlessMode[] = L"ChromeFrameHeadlessMode"; | 74 const wchar_t kChromeFrameHeadlessMode[] = L"ChromeFrameHeadlessMode"; |
| 78 | 75 |
| 79 // Indicates that we are running in an environment that expects chrome renderer | 76 // Indicates that we are running in an environment that expects chrome renderer |
| 80 // accessibility to be enabled for use in automation tests. | 77 // accessibility to be enabled for use in automation tests. |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 hr = unreg_tlb(tla->guid, | 207 hr = unreg_tlb(tla->guid, |
| 211 tla->wMajorVerNum, | 208 tla->wMajorVerNum, |
| 212 tla->wMinorVerNum, | 209 tla->wMinorVerNum, |
| 213 tla->lcid, | 210 tla->lcid, |
| 214 tla->syskind); | 211 tla->syskind); |
| 215 typelib->ReleaseTLibAttr(tla); | 212 typelib->ReleaseTLibAttr(tla); |
| 216 } | 213 } |
| 217 return hr; | 214 return hr; |
| 218 } | 215 } |
| 219 | 216 |
| 220 bool UtilIsNPAPIPluginRegistered() { | 217 bool UtilRemovePersistentNPAPIMarker() { |
| 221 std::wstring npapi_key_name(kChromeFrameNPAPIKey); | |
| 222 RegKey npapi_key(HKEY_LOCAL_MACHINE, npapi_key_name.c_str(), KEY_QUERY_VALUE); | |
| 223 return npapi_key.Valid(); | |
| 224 } | |
| 225 | |
| 226 bool UtilChangePersistentNPAPIMarker(bool set) { | |
| 227 BrowserDistribution* cf_dist = BrowserDistribution::GetDistribution(); | 218 BrowserDistribution* cf_dist = BrowserDistribution::GetDistribution(); |
| 228 std::wstring cf_state_key_path(cf_dist->GetStateKey()); | 219 std::wstring cf_state_key_path(cf_dist->GetStateKey()); |
| 220 RegKey cf_state_key; |
| 229 | 221 |
| 230 RegKey cf_state_key(HKEY_LOCAL_MACHINE, cf_state_key_path.c_str(), | 222 LONG result = cf_state_key.Open(HKEY_LOCAL_MACHINE, cf_state_key_path.c_str(), |
| 231 KEY_READ | KEY_WRITE); | 223 KEY_SET_VALUE); |
| 232 | 224 if (result == ERROR_SUCCESS) |
| 233 bool success = false; | 225 result = cf_state_key.DeleteValue(kChromeFramePersistNPAPIReg); |
| 234 if (cf_state_key.Valid()) { | 226 return (result == ERROR_SUCCESS || result == ERROR_FILE_NOT_FOUND); |
| 235 if (set) { | |
| 236 success = (cf_state_key.WriteValue(kChromeFramePersistNPAPIReg, 1) == | |
| 237 ERROR_SUCCESS); | |
| 238 } else { | |
| 239 // Unfortunately, DeleteValue returns true only if the value | |
| 240 // previously existed, so we do a separate existence check to | |
| 241 // validate success. | |
| 242 cf_state_key.DeleteValue(kChromeFramePersistNPAPIReg); | |
| 243 success = !cf_state_key.ValueExists(kChromeFramePersistNPAPIReg); | |
| 244 } | |
| 245 } | |
| 246 return success; | |
| 247 } | 227 } |
| 248 | 228 |
| 249 bool UtilIsPersistentNPAPIMarkerSet() { | |
| 250 BrowserDistribution* cf_dist = BrowserDistribution::GetDistribution(); | |
| 251 std::wstring cf_state_key_path(cf_dist->GetStateKey()); | |
| 252 | |
| 253 RegKey cf_state_key(HKEY_LOCAL_MACHINE, cf_state_key_path.c_str(), | |
| 254 KEY_QUERY_VALUE); | |
| 255 | |
| 256 bool success = false; | |
| 257 if (cf_state_key.Valid()) { | |
| 258 DWORD val = 0; | |
| 259 if (cf_state_key.ReadValueDW(kChromeFramePersistNPAPIReg, &val) == | |
| 260 ERROR_SUCCESS) { | |
| 261 success = (val != 0); | |
| 262 } | |
| 263 } | |
| 264 return success; | |
| 265 } | |
| 266 | |
| 267 | |
| 268 HRESULT UtilGetXUACompatContentValue(const std::wstring& html_string, | 229 HRESULT UtilGetXUACompatContentValue(const std::wstring& html_string, |
| 269 std::wstring* content_value) { | 230 std::wstring* content_value) { |
| 270 if (!content_value) { | 231 if (!content_value) { |
| 271 return E_POINTER; | 232 return E_POINTER; |
| 272 } | 233 } |
| 273 | 234 |
| 274 // Fail fast if the string X-UA-Compatible isn't in html_string | 235 // Fail fast if the string X-UA-Compatible isn't in html_string |
| 275 if (StringToLowerASCII(html_string).find(kXUACompatValue) == | 236 if (StringToLowerASCII(html_string).find(kXUACompatValue) == |
| 276 std::wstring::npos) { | 237 std::wstring::npos) { |
| 277 return E_FAIL; | 238 return E_FAIL; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 | 325 |
| 365 bool IsChrome(RendererType renderer_type) { | 326 bool IsChrome(RendererType renderer_type) { |
| 366 DCHECK_GE(renderer_type, RENDERER_TYPE_UNDETERMINED); | 327 DCHECK_GE(renderer_type, RENDERER_TYPE_UNDETERMINED); |
| 367 DCHECK_LE(renderer_type, RENDERER_TYPE_OTHER); | 328 DCHECK_LE(renderer_type, RENDERER_TYPE_OTHER); |
| 368 return renderer_type >= RENDERER_TYPE_CHROME_MIN && | 329 return renderer_type >= RENDERER_TYPE_CHROME_MIN && |
| 369 renderer_type <= RENDERER_TYPE_CHROME_MAX; | 330 renderer_type <= RENDERER_TYPE_CHROME_MAX; |
| 370 } | 331 } |
| 371 | 332 |
| 372 namespace { | 333 namespace { |
| 373 const char kIEImageName[] = "iexplore.exe"; | 334 const char kIEImageName[] = "iexplore.exe"; |
| 374 const char kFirefoxImageName[] = "firefox.exe"; | |
| 375 const char kOperaImageName[] = "opera.exe"; | |
| 376 } // namespace | 335 } // namespace |
| 377 | 336 |
| 378 std::wstring GetHostProcessName(bool include_extension) { | 337 std::wstring GetHostProcessName(bool include_extension) { |
| 379 FilePath exe; | 338 FilePath exe; |
| 380 if (PathService::Get(base::FILE_EXE, &exe)) | 339 if (PathService::Get(base::FILE_EXE, &exe)) |
| 381 exe = exe.BaseName(); | 340 exe = exe.BaseName(); |
| 382 if (!include_extension) { | 341 if (!include_extension) { |
| 383 exe = exe.RemoveExtension(); | 342 exe = exe.RemoveExtension(); |
| 384 } | 343 } |
| 385 return exe.value(); | 344 return exe.value(); |
| 386 } | 345 } |
| 387 | 346 |
| 388 BrowserType GetBrowserType() { | 347 BrowserType GetBrowserType() { |
| 389 static BrowserType browser_type = BROWSER_INVALID; | 348 static BrowserType browser_type = BROWSER_INVALID; |
| 390 | 349 |
| 391 if (browser_type == BROWSER_INVALID) { | 350 if (browser_type == BROWSER_INVALID) { |
| 392 std::wstring exe(GetHostProcessName(true)); | 351 std::wstring exe(GetHostProcessName(true)); |
| 393 if (!exe.empty()) { | 352 if (!exe.empty()) { |
| 394 std::wstring::const_iterator begin = exe.begin(); | 353 std::wstring::const_iterator begin = exe.begin(); |
| 395 std::wstring::const_iterator end = exe.end(); | 354 std::wstring::const_iterator end = exe.end(); |
| 396 if (LowerCaseEqualsASCII(begin, end, kIEImageName)) { | 355 if (LowerCaseEqualsASCII(begin, end, kIEImageName)) { |
| 397 browser_type = BROWSER_IE; | 356 browser_type = BROWSER_IE; |
| 398 } else if (LowerCaseEqualsASCII(begin, end, kFirefoxImageName)) { | |
| 399 browser_type = BROWSER_FIREFOX; | |
| 400 } else if (LowerCaseEqualsASCII(begin, end, kOperaImageName)) { | |
| 401 browser_type = BROWSER_OPERA; | |
| 402 } else { | 357 } else { |
| 403 browser_type = BROWSER_UNKNOWN; | 358 browser_type = BROWSER_UNKNOWN; |
| 404 } | 359 } |
| 405 } else { | 360 } else { |
| 406 NOTREACHED(); | 361 NOTREACHED(); |
| 407 } | 362 } |
| 408 } | 363 } |
| 409 | 364 |
| 410 return browser_type; | 365 return browser_type; |
| 411 } | 366 } |
| (...skipping 1252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1664 ret = InternetSetOption(NULL, connection_options[option_index], | 1619 ret = InternetSetOption(NULL, connection_options[option_index], |
| 1665 &connections, connection_value_size); | 1620 &connections, connection_value_size); |
| 1666 if (!ret) { | 1621 if (!ret) { |
| 1667 return false; | 1622 return false; |
| 1668 } | 1623 } |
| 1669 } | 1624 } |
| 1670 wininet_connection_count_updated = true; | 1625 wininet_connection_count_updated = true; |
| 1671 return true; | 1626 return true; |
| 1672 } | 1627 } |
| 1673 | 1628 |
| OLD | NEW |