| 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 "chrome_frame/http_negotiate.h" | 5 #include "chrome_frame/http_negotiate.h" |
| 6 | 6 |
| 7 #include <atlbase.h> | 7 #include <atlbase.h> |
| 8 #include <atlcom.h> | 8 #include <atlcom.h> |
| 9 #include <htiframe.h> | 9 #include <htiframe.h> |
| 10 | 10 |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 DWORD reserved, | 436 DWORD reserved, |
| 437 LPWSTR* additional_headers) { | 437 LPWSTR* additional_headers) { |
| 438 HRESULT hr = S_OK; | 438 HRESULT hr = S_OK; |
| 439 if (delegate_) { | 439 if (delegate_) { |
| 440 hr = delegate_->BeginningTransaction(url, headers, reserved, | 440 hr = delegate_->BeginningTransaction(url, headers, reserved, |
| 441 additional_headers); | 441 additional_headers); |
| 442 } | 442 } |
| 443 | 443 |
| 444 if (hr == S_OK) { | 444 if (hr == S_OK) { |
| 445 std::string updated_headers; | 445 std::string updated_headers; |
| 446 if (IsGcfDefaultRenderer() && IsOptInUrl(url)) { | 446 if (IsGcfDefaultRenderer() && |
| 447 RENDERER_TYPE_CHROME_DEFAULT_RENDERER == RendererTypeForUrl(url)) { |
| 447 // Replace the user-agent header with Chrome's. | 448 // Replace the user-agent header with Chrome's. |
| 448 updated_headers = ReplaceOrAddUserAgent(*additional_headers, | 449 updated_headers = ReplaceOrAddUserAgent(*additional_headers, |
| 449 http_utils::GetChromeUserAgent()); | 450 http_utils::GetChromeUserAgent()); |
| 450 } else { | 451 } else { |
| 451 // Add "chromeframe" user-agent string. | 452 // Add "chromeframe" user-agent string. |
| 452 updated_headers = AppendCFUserAgentString(headers, *additional_headers); | 453 updated_headers = AppendCFUserAgentString(headers, *additional_headers); |
| 453 } | 454 } |
| 454 | 455 |
| 455 *additional_headers = reinterpret_cast<wchar_t*>(::CoTaskMemRealloc( | 456 *additional_headers = reinterpret_cast<wchar_t*>(::CoTaskMemRealloc( |
| 456 *additional_headers, (updated_headers.length() + 1) * sizeof(wchar_t))); | 457 *additional_headers, (updated_headers.length() + 1) * sizeof(wchar_t))); |
| 457 lstrcpyW(*additional_headers, ASCIIToWide(updated_headers).c_str()); | 458 lstrcpyW(*additional_headers, ASCIIToWide(updated_headers).c_str()); |
| 458 } | 459 } |
| 459 return hr; | 460 return hr; |
| 460 } | 461 } |
| 461 | 462 |
| 462 STDMETHODIMP UserAgentAddOn::OnResponse(DWORD response_code, | 463 STDMETHODIMP UserAgentAddOn::OnResponse(DWORD response_code, |
| 463 LPCWSTR response_headers, LPCWSTR request_headers, | 464 LPCWSTR response_headers, LPCWSTR request_headers, |
| 464 LPWSTR* additional_headers) { | 465 LPWSTR* additional_headers) { |
| 465 HRESULT hr = S_OK; | 466 HRESULT hr = S_OK; |
| 466 if (delegate_) { | 467 if (delegate_) { |
| 467 hr = delegate_->OnResponse(response_code, response_headers, request_headers, | 468 hr = delegate_->OnResponse(response_code, response_headers, request_headers, |
| 468 additional_headers); | 469 additional_headers); |
| 469 } | 470 } |
| 470 return hr; | 471 return hr; |
| 471 } | 472 } |
| OLD | NEW |