| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 | 7 |
| 8 #include "chrome_frame/protocol_sink_wrap.h" | 8 #include "chrome_frame/protocol_sink_wrap.h" |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 } | 352 } |
| 353 | 353 |
| 354 if (size_read) | 354 if (size_read) |
| 355 *size_read = bytes_to_copy + new_data; | 355 *size_read = bytes_to_copy + new_data; |
| 356 return hr; | 356 return hr; |
| 357 } | 357 } |
| 358 | 358 |
| 359 return read_fun_(protocol_, buffer, size, size_read); | 359 return read_fun_(protocol_, buffer, size, size_read); |
| 360 } | 360 } |
| 361 | 361 |
| 362 // Attempt to detect ChromeFrame from HTTP headers when |
| 363 // BINDSTATUS_MIMETYPEAVAILABLE is received. |
| 364 // There are three possible outcomes: CHROME/OTHER/UNDETERMINED. |
| 365 // If UNDETERMINED we are going to sniff the content later in ReportData(). |
| 366 // |
| 367 // With not-so-well-written software (mime filters/protocols/protocol patchers) |
| 368 // BINDSTATUS_MIMETYPEAVAILABLE might be fired multiple times with different |
| 369 // values for the same client. |
| 370 // If the renderer_type_ member is: |
| 371 // CHROME - 2nd (and any subsequent) BINDSTATUS_MIMETYPEAVAILABLE is ignored. |
| 372 // OTHER - 2nd (and any subsequent) BINDSTATUS_MIMETYPEAVAILABLE is |
| 373 // passed through. |
| 374 // UNDETERMINED - Try to detect ChromeFrame from HTTP headers (acts as if this |
| 375 // is the first time BINDSTATUS_MIMETYPEAVAILABLE is received). |
| 362 HRESULT ProtData::ReportProgress(IInternetProtocolSink* delegate, | 376 HRESULT ProtData::ReportProgress(IInternetProtocolSink* delegate, |
| 363 ULONG status_code, LPCWSTR status_text) { | 377 ULONG status_code, LPCWSTR status_text) { |
| 364 switch (status_code) { | 378 switch (status_code) { |
| 365 case BINDSTATUS_DIRECTBIND: | 379 case BINDSTATUS_DIRECTBIND: |
| 366 renderer_type_ = OTHER; | 380 renderer_type_ = OTHER; |
| 367 break; | 381 break; |
| 368 | 382 |
| 369 case BINDSTATUS_REDIRECTING: | 383 case BINDSTATUS_REDIRECTING: |
| 370 url_.empty(); | 384 url_.empty(); |
| 371 if (status_text) | 385 if (status_text) |
| 372 url_ = status_text; | 386 url_ = status_text; |
| 373 break; | 387 break; |
| 374 | 388 |
| 375 case BINDSTATUS_SERVER_MIMETYPEAVAILABLE: | 389 case BINDSTATUS_SERVER_MIMETYPEAVAILABLE: |
| 376 has_server_mime_type_ = true; | 390 has_server_mime_type_ = true; |
| 377 SaveSuggestedMimeType(status_text); | 391 SaveSuggestedMimeType(status_text); |
| 378 return S_OK; | 392 return S_OK; |
| 379 | 393 |
| 380 // TODO(stoyan): BINDSTATUS_RAWMIMETYPE | 394 // TODO(stoyan): BINDSTATUS_RAWMIMETYPE |
| 381 case BINDSTATUS_MIMETYPEAVAILABLE: | 395 case BINDSTATUS_MIMETYPEAVAILABLE: |
| 382 case BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE: | 396 case BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE: |
| 397 SaveSuggestedMimeType(status_text); |
| 383 // When Transaction is attached i.e. when existing BTS it terminated | 398 // When Transaction is attached i.e. when existing BTS it terminated |
| 384 // and "converted" to BTO, events will be re-fired for the new sink, | 399 // and "converted" to BTO, events will be re-fired for the new sink, |
| 385 // but we may skip the renderer_type_ determination since it's already | 400 // but we may skip the renderer_type_ determination since it's already |
| 386 // done. | 401 // done. |
| 387 if (renderer_type_ == UNDETERMINED) { | 402 if (renderer_type_ == UNDETERMINED) { |
| 388 SaveSuggestedMimeType(status_text); | |
| 389 // This may seem awkward. CBinding's implementation of IWinInetHttpInfo | 403 // This may seem awkward. CBinding's implementation of IWinInetHttpInfo |
| 390 // will forward to CTransaction that will forward to the real protocol. | 404 // will forward to CTransaction that will forward to the real protocol. |
| 391 // We may ask CTransaction (our protocol_ member) for IWinInetHttpInfo. | 405 // We may ask CTransaction (our protocol_ member) for IWinInetHttpInfo. |
| 392 ScopedComPtr<IWinInetHttpInfo> info; | 406 ScopedComPtr<IWinInetHttpInfo> info; |
| 393 info.QueryFrom(delegate); | 407 info.QueryFrom(delegate); |
| 394 renderer_type_ = DetermineRendererTypeFromMetaData(suggested_mime_type_, | 408 renderer_type_ = DetermineRendererTypeFromMetaData(suggested_mime_type_, |
| 395 url_, info); | 409 url_, info); |
| 396 } | 410 } |
| 397 | 411 |
| 398 if (renderer_type_ == CHROME) { | 412 if (renderer_type_ == CHROME) { |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 848 // Explicit release, otherwise ~CComObjectStackEx will complain about | 862 // Explicit release, otherwise ~CComObjectStackEx will complain about |
| 849 // outstanding reference to us, because it runs before ~FakeProtocol | 863 // outstanding reference to us, because it runs before ~FakeProtocol |
| 850 prot.transaction_.Release(); | 864 prot.transaction_.Release(); |
| 851 } | 865 } |
| 852 } | 866 } |
| 853 | 867 |
| 854 void TransactionHooks::RevertHooks() { | 868 void TransactionHooks::RevertHooks() { |
| 855 vtable_patch::UnpatchInterfaceMethods(CTransaction_PatchInfo); | 869 vtable_patch::UnpatchInterfaceMethods(CTransaction_PatchInfo); |
| 856 vtable_patch::UnpatchInterfaceMethods(CTransaction2_PatchInfo); | 870 vtable_patch::UnpatchInterfaceMethods(CTransaction2_PatchInfo); |
| 857 } | 871 } |
| OLD | NEW |