diff options
author | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-22 17:02:58 +0000 |
---|---|---|
committer | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-22 17:02:58 +0000 |
commit | d8e135173589b4d88f5d24dce9b81d7278d9c18a (patch) | |
tree | 67e4ca492ae31ad7e8c293575bcae9d777464519 /chrome_frame | |
parent | 3d75a0c7627845e03ee87e82a5da40e133f55cc7 (diff) | |
download | chromium_src-d8e135173589b4d88f5d24dce9b81d7278d9c18a.zip chromium_src-d8e135173589b4d88f5d24dce9b81d7278d9c18a.tar.gz chromium_src-d8e135173589b4d88f5d24dce9b81d7278d9c18a.tar.bz2 |
Committing http://codereview.chromium.org/3420004/show for grt@
Original description:
- added detection of IE9 for ChromeFrame.IEVersion metric
- replaced ChromeFrame.FullTabLaunchType metric with ChromeFrame.LaunchType metric,
which logs more info regarding how it came to be that GCF rendered a page
(but only for the CTransaction patch)
BUG=43885
TEST=none
Review URL: http://codereview.chromium.org/3443017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60188 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-rw-r--r-- | chrome_frame/bho.cc | 2 | ||||
-rw-r--r-- | chrome_frame/chrome_active_document.cc | 20 | ||||
-rw-r--r-- | chrome_frame/chrome_frame_activex.cc | 3 | ||||
-rw-r--r-- | chrome_frame/chrome_frame_activex_base.h | 4 | ||||
-rw-r--r-- | chrome_frame/http_negotiate.cc | 3 | ||||
-rw-r--r-- | chrome_frame/protocol_sink_wrap.cc | 88 | ||||
-rw-r--r-- | chrome_frame/protocol_sink_wrap.h | 8 | ||||
-rw-r--r-- | chrome_frame/test/chrome_frame_test_utils.cc | 4 | ||||
-rw-r--r-- | chrome_frame/test/util_unittests.cc | 11 | ||||
-rw-r--r-- | chrome_frame/urlmon_bind_status_callback.cc | 2 | ||||
-rw-r--r-- | chrome_frame/utils.cc | 37 | ||||
-rw-r--r-- | chrome_frame/utils.h | 34 |
12 files changed, 143 insertions, 73 deletions
diff --git a/chrome_frame/bho.cc b/chrome_frame/bho.cc index 5e0c7f6..58c5dc5 100644 --- a/chrome_frame/bho.cc +++ b/chrome_frame/bho.cc @@ -302,7 +302,7 @@ void Bho::ProcessOptInUrls(IWebBrowser2* browser, BSTR url) { std::wstring current_url(url, SysStringLen(url)); if (IsValidUrlScheme(GURL(current_url), false)) { bool cf_protocol = StartsWith(current_url, kChromeProtocolPrefix, false); - if (!cf_protocol && IsOptInUrl(current_url.c_str())) { + if (!cf_protocol && IsChrome(RendererTypeForUrl(current_url))) { DLOG(INFO) << "Opt-in URL. Switching to cf."; ScopedComPtr<IBrowserService> browser_service; DoQueryService(SID_SShellBrowser, browser, browser_service.Receive()); diff --git a/chrome_frame/chrome_active_document.cc b/chrome_frame/chrome_active_document.cc index d5c4250..516dd09 100644 --- a/chrome_frame/chrome_active_document.cc +++ b/chrome_frame/chrome_active_document.cc @@ -260,14 +260,19 @@ STDMETHODIMP ChromeActiveDocument::Load(BOOL fully_avalable, } std::string referrer(mgr ? mgr->referrer() : EmptyString()); + RendererType renderer_type = cf_url.is_chrome_protocol() ? + RENDERER_TYPE_CHROME_GCF_PROTOCOL : RENDERER_TYPE_UNDETERMINED; // With CTransaction patch we have more robust way to grab the referrer for // each top-level-switch-to-CF request by peeking at our sniffing data - // object that lives inside the bind context. + // object that lives inside the bind context. We also remember the reason + // we're rendering the document in Chrome. if (g_patch_helper.state() == PatchHelper::PATCH_PROTOCOL && info) { scoped_refptr<ProtData> prot_data = info->get_prot_data(); - if (prot_data) + if (prot_data) { referrer = prot_data->referrer(); + renderer_type = prot_data->renderer_type(); + } } // For gcf: URLs allow only about and view-source schemes to pass through for @@ -288,9 +293,14 @@ STDMETHODIMP ChromeActiveDocument::Load(BOOL fully_avalable, if (!cf_url.is_chrome_protocol() && !cf_url.attach_to_external_tab()) url_fetcher_->SetInfoForUrl(url.c_str(), moniker_name, bind_context); - THREAD_SAFE_UMA_HISTOGRAM_CUSTOM_COUNTS("ChromeFrame.FullTabLaunchType", - cf_url.is_chrome_protocol(), - 0, 1, 2); + // Log a metric indicating why GCF is rendering in Chrome. + // (Note: we only track the renderer type when using the CTransaction patch. + // When the code for the browser service patch and for the moniker patch is + // removed, this conditional can also go away.) + if (RENDERER_TYPE_UNDETERMINED != renderer_type) { + THREAD_SAFE_UMA_LAUNCH_TYPE_COUNT(renderer_type); + } + return S_OK; } diff --git a/chrome_frame/chrome_frame_activex.cc b/chrome_frame/chrome_frame_activex.cc index e2d9b3a..7690119 100644 --- a/chrome_frame/chrome_frame_activex.cc +++ b/chrome_frame/chrome_frame_activex.cc @@ -473,6 +473,9 @@ HRESULT ChromeFrameActivex::IOleObject_SetClientSite( DLOG(ERROR) << "Failed to navigate to url:" << utf8_url; return E_FAIL; } + + // Log a metric that Chrome Frame is being used in Widget mode + THREAD_SAFE_UMA_LAUNCH_TYPE_COUNT(RENDERER_TYPE_CHROME_WIDGET); } return hr; diff --git a/chrome_frame/chrome_frame_activex_base.h b/chrome_frame/chrome_frame_activex_base.h index 5f281f3..611f3ae 100644 --- a/chrome_frame/chrome_frame_activex_base.h +++ b/chrome_frame/chrome_frame_activex_base.h @@ -262,8 +262,8 @@ END_MSG_MAP() THREAD_SAFE_UMA_HISTOGRAM_CUSTOM_COUNTS("ChromeFrame.IEVersion", GetIEVersion(), IE_INVALID, - IE_8, - IE_8 + 1); + IE_9, + IE_9 + 1); } return S_OK; diff --git a/chrome_frame/http_negotiate.cc b/chrome_frame/http_negotiate.cc index 403a313..8a1146e 100644 --- a/chrome_frame/http_negotiate.cc +++ b/chrome_frame/http_negotiate.cc @@ -443,7 +443,8 @@ STDMETHODIMP UserAgentAddOn::BeginningTransaction(LPCWSTR url, LPCWSTR headers, if (hr == S_OK) { std::string updated_headers; - if (IsGcfDefaultRenderer() && IsOptInUrl(url)) { + if (IsGcfDefaultRenderer() && + RENDERER_TYPE_CHROME_DEFAULT_RENDERER == RendererTypeForUrl(url)) { // Replace the user-agent header with Chrome's. updated_headers = ReplaceOrAddUserAgent(*additional_headers, http_utils::GetChromeUserAgent()); diff --git a/chrome_frame/protocol_sink_wrap.cc b/chrome_frame/protocol_sink_wrap.cc index f0f358e..3160855 100644 --- a/chrome_frame/protocol_sink_wrap.cc +++ b/chrome_frame/protocol_sink_wrap.cc @@ -273,11 +273,15 @@ bool IsAdditionallySupportedContentType(const wchar_t* status_text) { } // Returns: -// CHROME: if suggested mime type is a supported one and at least one of the -// following is true: 1) X-UA-Compatible tag is in HTTP headers. -// 2) Url is listed in OptInURLs registry key. -// OTHER: if suggested mime type is not text/html. -// UNDETERMINED: if suggested mime type is text/html. +// RENDERER_TYPE_OTHER: if suggested mime type is not text/html. +// RENDERER_TYPE_UNDETERMINED: if suggested mime type is text/html. +// RENDERER_TYPE_CHROME_RESPONSE_HEADER: X-UA-Compatible tag is in HTTP headers. +// RENDERER_TYPE_CHROME_DEFAULT_RENDERER: GCF is the default renderer and the +// Url is not listed in the +// RenderInHostUrls registry key. +// RENDERER_TYPE_CHROME_OPT_IN_URL: GCF is not the default renderer and the Url +// is listed in the RenderInGcfUrls registry +// key. RendererType DetermineRendererTypeFromMetaData( const wchar_t* suggested_mime_type, const std::wstring& url, @@ -288,10 +292,13 @@ RendererType DetermineRendererTypeFromMetaData( IsAdditionallySupportedContentType(suggested_mime_type); if (!is_supported_content_type) - return OTHER; + return RENDERER_TYPE_OTHER; - if (!url.empty() && IsOptInUrl(url.c_str())) { - return CHROME; + if (!url.empty()) { + RendererType renderer_type = RendererTypeForUrl(url); + if (IsChrome(renderer_type)) { + return renderer_type; + } } if (info) { @@ -301,24 +308,24 @@ RendererType DetermineRendererTypeFromMetaData( HRESULT hr = info->QueryInfo(HTTP_QUERY_CUSTOM, buffer, &len, &flags, NULL); if (hr == S_OK && len > 0) { if (StrStrIA(buffer, "chrome=1")) { - return CHROME; + return RENDERER_TYPE_CHROME_RESPONSE_HEADER; } } } // We can (and want) to sniff the content. if (is_text_html) { - return UNDETERMINED; + return RENDERER_TYPE_UNDETERMINED; } // We cannot sniff the content. - return OTHER; + return RENDERER_TYPE_OTHER; } RendererType DetermineRendererType(void* buffer, DWORD size, bool last_chance) { - RendererType type = UNDETERMINED; + RendererType renderer_type = RENDERER_TYPE_UNDETERMINED; if (last_chance) - type = OTHER; + renderer_type = RENDERER_TYPE_OTHER; std::wstring html_contents; // TODO(joshia): detect and handle different content encodings @@ -330,10 +337,10 @@ RendererType DetermineRendererType(void* buffer, DWORD size, bool last_chance) { std::wstring xua_compat_content; UtilGetXUACompatContentValue(html_contents, &xua_compat_content); if (StrStrI(xua_compat_content.c_str(), kChromeContentPrefix)) { - type = CHROME; + renderer_type = RENDERER_TYPE_CHROME_HTTP_EQUIV; } - return type; + return renderer_type; } // ProtData @@ -341,8 +348,8 @@ ProtData::ProtData(IInternetProtocol* protocol, InternetProtocol_Read_Fn read_fun, const wchar_t* url) : has_suggested_mime_type_(false), has_server_mime_type_(false), buffer_size_(0), buffer_pos_(0), - renderer_type_(UNDETERMINED), protocol_(protocol), read_fun_(read_fun), - url_(url) { + renderer_type_(RENDERER_TYPE_UNDETERMINED), protocol_(protocol), + read_fun_(read_fun), url_(url) { memset(buffer_, 0, arraysize(buffer_)); DLOG(INFO) << __FUNCTION__ << " " << this; @@ -358,7 +365,7 @@ ProtData::~ProtData() { } HRESULT ProtData::Read(void* buffer, ULONG size, ULONG* size_read) { - if (renderer_type_ == UNDETERMINED) { + if (renderer_type_ == RENDERER_TYPE_UNDETERMINED) { return E_PENDING; } @@ -389,23 +396,26 @@ HRESULT ProtData::Read(void* buffer, ULONG size, ULONG* size_read) { // Attempt to detect ChromeFrame from HTTP headers when // BINDSTATUS_MIMETYPEAVAILABLE is received. -// There are three possible outcomes: CHROME/OTHER/UNDETERMINED. -// If UNDETERMINED we are going to sniff the content later in ReportData(). +// There are three possible outcomes: CHROME_*/OTHER/UNDETERMINED. +// If RENDERER_TYPE_UNDETERMINED we are going to sniff the content later in +// ReportData(). // // With not-so-well-written software (mime filters/protocols/protocol patchers) // BINDSTATUS_MIMETYPEAVAILABLE might be fired multiple times with different // values for the same client. // If the renderer_type_ member is: -// CHROME - 2nd (and any subsequent) BINDSTATUS_MIMETYPEAVAILABLE is ignored. -// OTHER - 2nd (and any subsequent) BINDSTATUS_MIMETYPEAVAILABLE is -// passed through. -// UNDETERMINED - Try to detect ChromeFrame from HTTP headers (acts as if this -// is the first time BINDSTATUS_MIMETYPEAVAILABLE is received). +// RENDERER_TYPE_CHROME_* - 2nd (and any subsequent) +// BINDSTATUS_MIMETYPEAVAILABLE is ignored. +// RENDERER_TYPE_OTHER - 2nd (and any subsequent) BINDSTATUS_MIMETYPEAVAILABLE +// is passed through. +// RENDERER_TYPE_UNDETERMINED - Try to detect ChromeFrame from HTTP headers +// (acts as if this is the first time +// BINDSTATUS_MIMETYPEAVAILABLE is received). HRESULT ProtData::ReportProgress(IInternetProtocolSink* delegate, ULONG status_code, LPCWSTR status_text) { switch (status_code) { case BINDSTATUS_DIRECTBIND: - renderer_type_ = OTHER; + renderer_type_ = RENDERER_TYPE_OTHER; break; case BINDSTATUS_REDIRECTING: @@ -427,7 +437,7 @@ HRESULT ProtData::ReportProgress(IInternetProtocolSink* delegate, // and "converted" to BTO, events will be re-fired for the new sink, // but we may skip the renderer_type_ determination since it's already // done. - if (renderer_type_ == UNDETERMINED) { + if (renderer_type_ == RENDERER_TYPE_UNDETERMINED) { // This may seem awkward. CBinding's implementation of IWinInetHttpInfo // will forward to CTransaction that will forward to the real protocol. // We may ask CTransaction (our protocol_ member) for IWinInetHttpInfo. @@ -437,21 +447,21 @@ HRESULT ProtData::ReportProgress(IInternetProtocolSink* delegate, url_, info); } - if (renderer_type_ == CHROME) { - // Suggested mime type is "text/html" and we either have OptInUrl - // or X-UA-Compatible HTTP headers. + if (IsChrome(renderer_type_)) { + // Suggested mime type is "text/html" and we have DEFAULT_RENDERER, + // OPT_IN_URL, or RESPONSE_HEADER. DLOG(INFO) << "Forwarding BINDSTATUS_MIMETYPEAVAILABLE " << kChromeMimeType; SaveReferrer(delegate); delegate->ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE, kChromeMimeType); - } else if (renderer_type_ == OTHER) { + } else if (renderer_type_ == RENDERER_TYPE_OTHER) { // Suggested mime type is not "text/html" - we are not interested in // this request anymore. FireSuggestedMimeType(delegate); } else { // Suggested mime type is "text/html"; We will try to sniff the // HTML content in ReportData. - DCHECK_EQ(UNDETERMINED, renderer_type_); + DCHECK_EQ(RENDERER_TYPE_UNDETERMINED, renderer_type_); } return S_OK; } @@ -463,7 +473,7 @@ HRESULT ProtData::ReportProgress(IInternetProtocolSink* delegate, HRESULT ProtData::ReportData(IInternetProtocolSink* delegate, DWORD flags, ULONG progress, ULONG max_progress) { - if (renderer_type_ != UNDETERMINED) { + if (renderer_type_ != RENDERER_TYPE_UNDETERMINED) { // We are just pass through now, avoid false positive crash reports. ExceptionBarrierReportOnlyModule barrier; return delegate->ReportData(flags, progress, max_progress); @@ -478,19 +488,19 @@ HRESULT ProtData::ReportData(IInternetProtocolSink* delegate, renderer_type_ = DetermineRendererType(buffer_, buffer_size_, last_chance); - if (renderer_type_ == UNDETERMINED) { + if (renderer_type_ == RENDERER_TYPE_UNDETERMINED) { // do not report anything, we need more data. return S_OK; } - if (renderer_type_ == CHROME) { + if (IsChrome(renderer_type_)) { DLOG(INFO) << "Forwarding BINDSTATUS_MIMETYPEAVAILABLE " << kChromeMimeType; SaveReferrer(delegate); delegate->ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE, kChromeMimeType); } - if (renderer_type_ == OTHER) { + if (renderer_type_ == RENDERER_TYPE_OTHER) { FireSuggestedMimeType(delegate); } @@ -509,9 +519,9 @@ HRESULT ProtData::ReportResult(IInternetProtocolSink* delegate, HRESULT result, DWORD error, LPCWSTR result_text) { // We may receive ReportResult without ReportData, if the connection fails // for example. - if (renderer_type_ == UNDETERMINED) { + if (renderer_type_ == RENDERER_TYPE_UNDETERMINED) { DLOG(INFO) << "ReportResult received but renderer type is yet unknown."; - renderer_type_ = OTHER; + renderer_type_ = RENDERER_TYPE_OTHER; FireSuggestedMimeType(delegate); } @@ -565,7 +575,7 @@ void ProtData::FireSuggestedMimeType(IInternetProtocolSink* delegate) { } void ProtData::SaveReferrer(IInternetProtocolSink* delegate) { - DCHECK_EQ(CHROME, renderer_type_); + DCHECK(IsChrome(renderer_type_)); ScopedComPtr<IWinInetHttpInfo> info; info.QueryFrom(delegate); if (info) { diff --git a/chrome_frame/protocol_sink_wrap.h b/chrome_frame/protocol_sink_wrap.h index 1d6c178..17f06bc 100644 --- a/chrome_frame/protocol_sink_wrap.h +++ b/chrome_frame/protocol_sink_wrap.h @@ -42,12 +42,6 @@ typedef HRESULT (STDMETHODCALLTYPE* InternetProtocol_UnlockRequest_Fn)( IInternetProtocol* this_object); -enum RendererType { - UNDETERMINED, - CHROME, - OTHER -}; - class ProtData; // A class to wrap protocol sink in IInternetProtocol::Start[Ex] for @@ -144,7 +138,7 @@ class ProtData : public base::RefCounted<ProtData> { static ProtocolDataMap datamap_; static Lock datamap_lock_; - // Url we are retrieving. Used for IsOptInUrl() only. + // Url we are retrieving. Used for RendererTypeForUrl() only. std::wstring url_; // HTTP "Referrer" header if we detect are going to switch. // We have to save and pass it to Chrome, so scripts can read it via DOM. diff --git a/chrome_frame/test/chrome_frame_test_utils.cc b/chrome_frame/test/chrome_frame_test_utils.cc index f4bc556..c0670fe 100644 --- a/chrome_frame/test/chrome_frame_test_utils.cc +++ b/chrome_frame/test/chrome_frame_test_utils.cc @@ -408,6 +408,8 @@ IEVersion GetInstalledIEVersion() { return IE_7; case '8': return IE_8; + case '9': + return IE_9; default: break; } @@ -421,7 +423,7 @@ FilePath GetProfilePathForIE() { // have their profiles moved into "Temporary Internet Files". // The code below basically retrieves the version of IE and computes // the profile directory accordingly. - if (GetInstalledIEVersion() == IE_8) { + if (GetInstalledIEVersion() >= IE_8) { profile_path = GetProfilePath(kIEProfileName); } else { profile_path = GetIETemporaryFilesFolder(); diff --git a/chrome_frame/test/util_unittests.cc b/chrome_frame/test/util_unittests.cc index e265567..055bae9 100644 --- a/chrome_frame/test/util_unittests.cc +++ b/chrome_frame/test/util_unittests.cc @@ -310,7 +310,7 @@ TEST(UtilTests, IsDefaultRendererTest) { config_key.WriteValue(kEnableGCFRendererByDefault, saved_default_renderer); } -TEST(UtilTests, IsOptInUrlTest) { +TEST(UtilTests, RendererTypeForUrlTest) { // Open all the keys we need. RegKey config_key(HKEY_CURRENT_USER, kChromeFrameConfigKey, KEY_ALL_ACCESS); EXPECT_TRUE(config_key.Valid()); @@ -334,18 +334,19 @@ TEST(UtilTests, IsOptInUrlTest) { EXPECT_FALSE(IsGcfDefaultRenderer()); opt_for_gcf.DeleteValue(kTestFilter); // Just in case this exists - EXPECT_FALSE(IsOptInUrl(kTestUrl)); + EXPECT_EQ(RENDERER_TYPE_UNDETERMINED, RendererTypeForUrl(kTestUrl)); opt_for_gcf.WriteValue(kTestFilter, L""); - EXPECT_TRUE(IsOptInUrl(kTestUrl)); + EXPECT_EQ(RENDERER_TYPE_CHROME_OPT_IN_URL, RendererTypeForUrl(kTestUrl)); // Now set GCF as the default renderer. config_key.WriteValue(kEnableGCFRendererByDefault, static_cast<DWORD>(1)); EXPECT_TRUE(IsGcfDefaultRenderer()); opt_for_host.DeleteValue(kTestFilter); // Just in case this exists - EXPECT_TRUE(IsOptInUrl(kTestUrl)); + EXPECT_EQ(RENDERER_TYPE_CHROME_DEFAULT_RENDERER, + RendererTypeForUrl(kTestUrl)); opt_for_host.WriteValue(kTestFilter, L""); - EXPECT_FALSE(IsOptInUrl(kTestUrl)); + EXPECT_EQ(RENDERER_TYPE_UNDETERMINED, RendererTypeForUrl(kTestUrl)); // Cleanup. opt_for_gcf.DeleteValue(kTestFilter); diff --git a/chrome_frame/urlmon_bind_status_callback.cc b/chrome_frame/urlmon_bind_status_callback.cc index da21576..5faf05a 100644 --- a/chrome_frame/urlmon_bind_status_callback.cc +++ b/chrome_frame/urlmon_bind_status_callback.cc @@ -171,7 +171,7 @@ void SniffData::DetermineRendererType(bool last_chance) { if (is_undetermined()) { if (last_chance) renderer_type_ = OTHER; - if (IsOptInUrl(url_.c_str())) { + if (IsChrome(RendererTypeForUrl(url_.c_str()))) { renderer_type_ = CHROME; } else { if (is_cache_valid() && cache_) { diff --git a/chrome_frame/utils.cc b/chrome_frame/utils.cc index 2ddc3c9..8ed1d31 100644 --- a/chrome_frame/utils.cc +++ b/chrome_frame/utils.cc @@ -358,6 +358,13 @@ AddRefModule::~AddRefModule() { _pAtlModule->Unlock(); } +bool IsChrome(RendererType renderer_type) { + DCHECK_GE(renderer_type, RENDERER_TYPE_UNDETERMINED); + DCHECK_LE(renderer_type, RENDERER_TYPE_OTHER); + return renderer_type >= RENDERER_TYPE_CHROME_MIN && + renderer_type <= RENDERER_TYPE_CHROME_MAX; +} + namespace { const char kIEImageName[] = "iexplore.exe"; const char kFirefoxImageName[] = "firefox.exe"; @@ -420,8 +427,11 @@ IEVersion GetIEVersion() { case 7: ie_version = IE_7; break; + case 8: + ie_version = IE_8; + break; default: - ie_version = HIWORD(high) >= 8 ? IE_8 : IE_UNSUPPORTED; + ie_version = HIWORD(high) >= 9 ? IE_9 : IE_UNSUPPORTED; break; } } else { @@ -710,20 +720,26 @@ bool IsGcfDefaultRenderer() { return is_default != 0; } -bool IsOptInUrl(const wchar_t* url) { +RendererType RendererTypeForUrl(const std::wstring& url) { // First check if the default renderer settings are specified by policy. // If so, then that overrides the user settings. Singleton<PolicySettings> policy; - PolicySettings::RendererForUrl renderer = policy->GetRendererForUrl(url); + PolicySettings::RendererForUrl renderer = policy->GetRendererForUrl( + url.c_str()); if (renderer != PolicySettings::RENDERER_NOT_SPECIFIED) { - return (renderer == PolicySettings::RENDER_IN_CHROME_FRAME); + // We may know at this point that policy says do NOT render in Chrome Frame. + // To maintain consistency, we return RENDERER_TYPE_UNDETERMINED so that + // content sniffing, etc. still take place. + // TODO(tommi): Clarify the intent here. + return (renderer == PolicySettings::RENDER_IN_CHROME_FRAME) ? + RENDERER_TYPE_CHROME_OPT_IN_URL : RENDERER_TYPE_UNDETERMINED; } RegKey config_key; if (!config_key.Open(HKEY_CURRENT_USER, kChromeFrameConfigKey, KEY_READ)) - return false; + return RENDERER_TYPE_UNDETERMINED; - bool load_in_chrome_frame = false; + RendererType renderer_type = RENDERER_TYPE_UNDETERMINED; const wchar_t* url_list_name = NULL; int render_in_cf_by_default = FALSE; @@ -731,7 +747,7 @@ bool IsOptInUrl(const wchar_t* url) { reinterpret_cast<DWORD*>(&render_in_cf_by_default)); if (render_in_cf_by_default) { url_list_name = kRenderInHostUrlList; - load_in_chrome_frame = true; // change the default to true. + renderer_type = RENDERER_TYPE_CHROME_DEFAULT_RENDERER; } else { url_list_name = kRenderInGCFUrlList; } @@ -747,11 +763,12 @@ bool IsOptInUrl(const wchar_t* url) { } if (match_found) { - // The lists are there to opt out of whatever is the default. - load_in_chrome_frame = !load_in_chrome_frame; + renderer_type = render_in_cf_by_default ? + RENDERER_TYPE_UNDETERMINED : + RENDERER_TYPE_CHROME_OPT_IN_URL; } - return load_in_chrome_frame; + return renderer_type; } HRESULT NavigateBrowserToMoniker(IUnknown* browser, IMoniker* moniker, diff --git a/chrome_frame/utils.h b/chrome_frame/utils.h index d4781e1..665ebca 100644 --- a/chrome_frame/utils.h +++ b/chrome_frame/utils.h @@ -180,8 +180,36 @@ typedef enum IEVersion { IE_6, IE_7, IE_8, + IE_9, }; +// The renderer to be used for a page. Values for Chrome also convey the +// reason why Chrome is used. +enum RendererType { + RENDERER_TYPE_UNDETERMINED = 0, + RENDERER_TYPE_CHROME_MIN, + // NOTE: group all _CHROME_ values together below here, as they are used for + // generating metrics reported via UMA (adjust MIN/MAX as needed). + RENDERER_TYPE_CHROME_GCF_PROTOCOL = RENDERER_TYPE_CHROME_MIN, + RENDERER_TYPE_CHROME_HTTP_EQUIV, + RENDERER_TYPE_CHROME_RESPONSE_HEADER, + RENDERER_TYPE_CHROME_DEFAULT_RENDERER, + RENDERER_TYPE_CHROME_OPT_IN_URL, + RENDERER_TYPE_CHROME_WIDGET, + // NOTE: all _CHOME_ values must go above here (adjust MIN/MAX as needed). + RENDERER_TYPE_CHROME_MAX = RENDERER_TYPE_CHROME_WIDGET, + RENDERER_TYPE_OTHER, +}; + +// Returns true if the given RendererType represents Chrome. +bool IsChrome(RendererType renderer_type); + +// Convenience macro for logging a sample for the launch type metric. +#define THREAD_SAFE_UMA_LAUNCH_TYPE_COUNT(sample) \ + THREAD_SAFE_UMA_HISTOGRAM_CUSTOM_COUNTS("ChromeFrame.LaunchType", sample, \ + RENDERER_TYPE_CHROME_MIN, RENDERER_TYPE_CHROME_MAX, \ + RENDERER_TYPE_CHROME_MAX + 1 - RENDERER_TYPE_CHROME_MIN) + // To get the IE version when Chrome Frame is hosted in IE. Make sure that // the hosting browser is IE before calling this function, otherwise NON_IE // will be returned. @@ -252,7 +280,11 @@ bool IsUnpinnedMode(); bool IsGcfDefaultRenderer(); // Check if this url is opting into Chrome Frame based on static settings. -bool IsOptInUrl(const wchar_t* url); +// Returns one of: +// - RENDERER_TYPE_UNDETERMINED if not opt-in or if explicit opt-out +// - RENDERER_TYPE_CHROME_DEFAULT_RENDERER +// - RENDERER_TYPE_CHROME_OPT_IN_URL +RendererType RendererTypeForUrl(const std::wstring& url); // A shortcut for QueryService template <typename T> |