| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <htiframe.h> | 5 #include <htiframe.h> |
| 6 #include <mshtml.h> | 6 #include <mshtml.h> |
| 7 #include <shlobj.h> | 7 #include <shlobj.h> |
| 8 #include <wininet.h> | 8 #include <wininet.h> |
| 9 | 9 |
| 10 #include <atlsecurity.h> | 10 #include <atlsecurity.h> |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 // while the module's refcount is > 0. Only do this when we're being | 351 // while the module's refcount is > 0. Only do this when we're being |
| 352 // used as an NPAPI module. | 352 // used as an NPAPI module. |
| 353 _pAtlModule->Lock(); | 353 _pAtlModule->Lock(); |
| 354 } | 354 } |
| 355 | 355 |
| 356 | 356 |
| 357 AddRefModule::~AddRefModule() { | 357 AddRefModule::~AddRefModule() { |
| 358 _pAtlModule->Unlock(); | 358 _pAtlModule->Unlock(); |
| 359 } | 359 } |
| 360 | 360 |
| 361 bool IsChrome(RendererType renderer_type) { |
| 362 DCHECK_GE(renderer_type, RENDERER_TYPE_UNDETERMINED); |
| 363 DCHECK_LE(renderer_type, RENDERER_TYPE_OTHER); |
| 364 return renderer_type >= RENDERER_TYPE_CHROME_MIN && |
| 365 renderer_type <= RENDERER_TYPE_CHROME_MAX; |
| 366 } |
| 367 |
| 361 namespace { | 368 namespace { |
| 362 const char kIEImageName[] = "iexplore.exe"; | 369 const char kIEImageName[] = "iexplore.exe"; |
| 363 const char kFirefoxImageName[] = "firefox.exe"; | 370 const char kFirefoxImageName[] = "firefox.exe"; |
| 364 const char kOperaImageName[] = "opera.exe"; | 371 const char kOperaImageName[] = "opera.exe"; |
| 365 } // namespace | 372 } // namespace |
| 366 | 373 |
| 367 std::wstring GetHostProcessName(bool include_extension) { | 374 std::wstring GetHostProcessName(bool include_extension) { |
| 368 FilePath exe; | 375 FilePath exe; |
| 369 if (PathService::Get(base::FILE_EXE, &exe)) | 376 if (PathService::Get(base::FILE_EXE, &exe)) |
| 370 exe = exe.BaseName(); | 377 exe = exe.BaseName(); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 uint32 high = 0; | 420 uint32 high = 0; |
| 414 uint32 low = 0; | 421 uint32 low = 0; |
| 415 if (GetModuleVersion(mod, &high, &low)) { | 422 if (GetModuleVersion(mod, &high, &low)) { |
| 416 switch (HIWORD(high)) { | 423 switch (HIWORD(high)) { |
| 417 case 6: | 424 case 6: |
| 418 ie_version = IE_6; | 425 ie_version = IE_6; |
| 419 break; | 426 break; |
| 420 case 7: | 427 case 7: |
| 421 ie_version = IE_7; | 428 ie_version = IE_7; |
| 422 break; | 429 break; |
| 430 case 8: |
| 431 ie_version = IE_8; |
| 432 break; |
| 423 default: | 433 default: |
| 424 ie_version = HIWORD(high) >= 8 ? IE_8 : IE_UNSUPPORTED; | 434 ie_version = HIWORD(high) >= 9 ? IE_9 : IE_UNSUPPORTED; |
| 425 break; | 435 break; |
| 426 } | 436 } |
| 427 } else { | 437 } else { |
| 428 NOTREACHED() << "Can't get IE version"; | 438 NOTREACHED() << "Can't get IE version"; |
| 429 } | 439 } |
| 430 } | 440 } |
| 431 } | 441 } |
| 432 | 442 |
| 433 return ie_version; | 443 return ie_version; |
| 434 } | 444 } |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 // checked frequently. | 713 // checked frequently. |
| 704 RegKey config_key; | 714 RegKey config_key; |
| 705 if (config_key.Open(HKEY_CURRENT_USER, kChromeFrameConfigKey, KEY_READ)) { | 715 if (config_key.Open(HKEY_CURRENT_USER, kChromeFrameConfigKey, KEY_READ)) { |
| 706 config_key.ReadValueDW(kEnableGCFRendererByDefault, &is_default); | 716 config_key.ReadValueDW(kEnableGCFRendererByDefault, &is_default); |
| 707 } | 717 } |
| 708 } | 718 } |
| 709 | 719 |
| 710 return is_default != 0; | 720 return is_default != 0; |
| 711 } | 721 } |
| 712 | 722 |
| 713 bool IsOptInUrl(const wchar_t* url) { | 723 RendererType RendererTypeForUrl(const std::wstring& url) { |
| 714 // First check if the default renderer settings are specified by policy. | 724 // First check if the default renderer settings are specified by policy. |
| 715 // If so, then that overrides the user settings. | 725 // If so, then that overrides the user settings. |
| 716 Singleton<PolicySettings> policy; | 726 Singleton<PolicySettings> policy; |
| 717 PolicySettings::RendererForUrl renderer = policy->GetRendererForUrl(url); | 727 PolicySettings::RendererForUrl renderer = policy->GetRendererForUrl( |
| 728 url.c_str()); |
| 718 if (renderer != PolicySettings::RENDERER_NOT_SPECIFIED) { | 729 if (renderer != PolicySettings::RENDERER_NOT_SPECIFIED) { |
| 719 return (renderer == PolicySettings::RENDER_IN_CHROME_FRAME); | 730 // We may know at this point that policy says do NOT render in Chrome Frame. |
| 731 // To maintain consistency, we return RENDERER_TYPE_UNDETERMINED so that |
| 732 // content sniffing, etc. still take place. |
| 733 // TODO(tommi): Clarify the intent here. |
| 734 return (renderer == PolicySettings::RENDER_IN_CHROME_FRAME) ? |
| 735 RENDERER_TYPE_CHROME_OPT_IN_URL : RENDERER_TYPE_UNDETERMINED; |
| 720 } | 736 } |
| 721 | 737 |
| 722 RegKey config_key; | 738 RegKey config_key; |
| 723 if (!config_key.Open(HKEY_CURRENT_USER, kChromeFrameConfigKey, KEY_READ)) | 739 if (!config_key.Open(HKEY_CURRENT_USER, kChromeFrameConfigKey, KEY_READ)) |
| 724 return false; | 740 return RENDERER_TYPE_UNDETERMINED; |
| 725 | 741 |
| 726 bool load_in_chrome_frame = false; | 742 RendererType renderer_type = RENDERER_TYPE_UNDETERMINED; |
| 727 | 743 |
| 728 const wchar_t* url_list_name = NULL; | 744 const wchar_t* url_list_name = NULL; |
| 729 int render_in_cf_by_default = FALSE; | 745 int render_in_cf_by_default = FALSE; |
| 730 config_key.ReadValueDW(kEnableGCFRendererByDefault, | 746 config_key.ReadValueDW(kEnableGCFRendererByDefault, |
| 731 reinterpret_cast<DWORD*>(&render_in_cf_by_default)); | 747 reinterpret_cast<DWORD*>(&render_in_cf_by_default)); |
| 732 if (render_in_cf_by_default) { | 748 if (render_in_cf_by_default) { |
| 733 url_list_name = kRenderInHostUrlList; | 749 url_list_name = kRenderInHostUrlList; |
| 734 load_in_chrome_frame = true; // change the default to true. | 750 renderer_type = RENDERER_TYPE_CHROME_DEFAULT_RENDERER; |
| 735 } else { | 751 } else { |
| 736 url_list_name = kRenderInGCFUrlList; | 752 url_list_name = kRenderInGCFUrlList; |
| 737 } | 753 } |
| 738 | 754 |
| 739 bool match_found = false; | 755 bool match_found = false; |
| 740 RegistryValueIterator url_list(config_key.Handle(), url_list_name); | 756 RegistryValueIterator url_list(config_key.Handle(), url_list_name); |
| 741 while (!match_found && url_list.Valid()) { | 757 while (!match_found && url_list.Valid()) { |
| 742 if (MatchPattern(url, url_list.Name())) { | 758 if (MatchPattern(url, url_list.Name())) { |
| 743 match_found = true; | 759 match_found = true; |
| 744 } else { | 760 } else { |
| 745 ++url_list; | 761 ++url_list; |
| 746 } | 762 } |
| 747 } | 763 } |
| 748 | 764 |
| 749 if (match_found) { | 765 if (match_found) { |
| 750 // The lists are there to opt out of whatever is the default. | 766 renderer_type = render_in_cf_by_default ? |
| 751 load_in_chrome_frame = !load_in_chrome_frame; | 767 RENDERER_TYPE_UNDETERMINED : |
| 768 RENDERER_TYPE_CHROME_OPT_IN_URL; |
| 752 } | 769 } |
| 753 | 770 |
| 754 return load_in_chrome_frame; | 771 return renderer_type; |
| 755 } | 772 } |
| 756 | 773 |
| 757 HRESULT NavigateBrowserToMoniker(IUnknown* browser, IMoniker* moniker, | 774 HRESULT NavigateBrowserToMoniker(IUnknown* browser, IMoniker* moniker, |
| 758 const wchar_t* headers, IBindCtx* bind_ctx, | 775 const wchar_t* headers, IBindCtx* bind_ctx, |
| 759 const wchar_t* fragment) { | 776 const wchar_t* fragment) { |
| 760 DCHECK(browser); | 777 DCHECK(browser); |
| 761 DCHECK(moniker); | 778 DCHECK(moniker); |
| 762 DCHECK(bind_ctx); | 779 DCHECK(bind_ctx); |
| 763 | 780 |
| 764 ScopedComPtr<IWebBrowser2> web_browser2; | 781 ScopedComPtr<IWebBrowser2> web_browser2; |
| (...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1489 default: { | 1506 default: { |
| 1490 NOTREACHED() << "Unexpected return from MsgWaitForMultipleObjects :" | 1507 NOTREACHED() << "Unexpected return from MsgWaitForMultipleObjects :" |
| 1491 << wait; | 1508 << wait; |
| 1492 return; | 1509 return; |
| 1493 } | 1510 } |
| 1494 } | 1511 } |
| 1495 now = base::Time::Now(); | 1512 now = base::Time::Now(); |
| 1496 } | 1513 } |
| 1497 } | 1514 } |
| 1498 | 1515 |
| OLD | NEW |