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/bho.h" | 5 #include "chrome_frame/bho.h" |
6 | 6 |
7 #include <shlguid.h> | 7 #include <shlguid.h> |
8 | 8 |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 public: | 77 public: |
78 ReadyModeDelegateImpl() {} | 78 ReadyModeDelegateImpl() {} |
79 | 79 |
80 // ready_mode::Delegate implementation | 80 // ready_mode::Delegate implementation |
81 virtual void DisableChromeFrame(); | 81 virtual void DisableChromeFrame(); |
82 | 82 |
83 private: | 83 private: |
84 DISALLOW_COPY_AND_ASSIGN(ReadyModeDelegateImpl); | 84 DISALLOW_COPY_AND_ASSIGN(ReadyModeDelegateImpl); |
85 }; // class ReadyModeDelegateImpl | 85 }; // class ReadyModeDelegateImpl |
86 | 86 |
87 void SynchronizeEnablementState() { | |
88 std::string user_agent(http_utils::GetDefaultUserAgent()); | |
89 bool enabled = user_agent.find("chromeframe") != std::string::npos; | |
90 ProtocolSinkWrap::set_ignore_xua(!enabled); | |
91 } | |
92 | |
93 void ReadyModeDelegateImpl::DisableChromeFrame() { | 87 void ReadyModeDelegateImpl::DisableChromeFrame() { |
94 if (GetIEVersion() != IE_9) { | 88 HttpNegotiatePatch::set_modify_user_agent(false); |
95 SynchronizeEnablementState(); | 89 ProtocolSinkWrap::set_ignore_xua(true); |
96 } else { | |
97 HttpNegotiatePatch::set_modify_user_agent(false); | |
98 ProtocolSinkWrap::set_ignore_xua(true); | |
99 } | |
100 } | 90 } |
101 | 91 |
102 } // namespace | 92 } // namespace |
103 | 93 |
104 STDMETHODIMP Bho::SetSite(IUnknown* site) { | 94 STDMETHODIMP Bho::SetSite(IUnknown* site) { |
105 HRESULT hr = S_OK; | 95 HRESULT hr = S_OK; |
106 if (site) { | 96 if (site) { |
107 ScopedComPtr<IWebBrowser2> web_browser2; | 97 ScopedComPtr<IWebBrowser2> web_browser2; |
108 web_browser2.QueryFrom(site); | 98 web_browser2.QueryFrom(site); |
109 if (web_browser2) { | 99 if (web_browser2) { |
110 hr = DispEventAdvise(web_browser2, &DIID_DWebBrowserEvents2); | 100 hr = DispEventAdvise(web_browser2, &DIID_DWebBrowserEvents2); |
111 DCHECK(SUCCEEDED(hr)) << "DispEventAdvise failed. Error: " << hr; | 101 DCHECK(SUCCEEDED(hr)) << "DispEventAdvise failed. Error: " << hr; |
112 | 102 |
113 ready_mode::Configure(new ReadyModeDelegateImpl(), web_browser2); | 103 ready_mode::Configure(new ReadyModeDelegateImpl(), web_browser2); |
114 | |
115 // At this time, the user agent has been updated to reflect the Ready Mode | |
116 // state. We should make sure to modify our recognition of meta tags | |
117 // accordingly. On IE 9, another method is used to manage meta tags. | |
118 if (GetIEVersion() != IE_9) { | |
119 SynchronizeEnablementState(); | |
120 } | |
121 } | 104 } |
122 | 105 |
123 if (g_patch_helper.state() == PatchHelper::PATCH_IBROWSER) { | 106 if (g_patch_helper.state() == PatchHelper::PATCH_IBROWSER) { |
124 ScopedComPtr<IBrowserService> browser_service; | 107 ScopedComPtr<IBrowserService> browser_service; |
125 hr = DoQueryService(SID_SShellBrowser, site, browser_service.Receive()); | 108 hr = DoQueryService(SID_SShellBrowser, site, browser_service.Receive()); |
126 DCHECK(browser_service) << "DoQueryService - SID_SShellBrowser failed." | 109 DCHECK(browser_service) << "DoQueryService - SID_SShellBrowser failed." |
127 << " Site: " << site << " Error: " << hr; | 110 << " Site: " << site << " Error: " << hr; |
128 if (browser_service) { | 111 if (browser_service) { |
129 g_patch_helper.PatchBrowserService(browser_service); | 112 g_patch_helper.PatchBrowserService(browser_service); |
130 DCHECK(SUCCEEDED(hr)) << "vtable_patch::PatchInterfaceMethods failed." | 113 DCHECK(SUCCEEDED(hr)) << "vtable_patch::PatchInterfaceMethods failed." |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 } | 373 } |
391 } | 374 } |
392 | 375 |
393 void PatchHelper::UnpatchIfNeeded() { | 376 void PatchHelper::UnpatchIfNeeded() { |
394 if (state_ == PATCH_PROTOCOL) { | 377 if (state_ == PATCH_PROTOCOL) { |
395 g_trans_hooks.RevertHooks(); | 378 g_trans_hooks.RevertHooks(); |
396 HttpNegotiatePatch::Uninitialize(); | 379 HttpNegotiatePatch::Uninitialize(); |
397 } | 380 } |
398 state_ = UNKNOWN; | 381 state_ = UNKNOWN; |
399 } | 382 } |
OLD | NEW |