| 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 #ifndef CHROME_FRAME_BHO_H_ | 5 #ifndef CHROME_FRAME_BHO_H_ |
| 6 #define CHROME_FRAME_BHO_H_ | 6 #define CHROME_FRAME_BHO_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include <atlbase.h> | 10 #include <atlbase.h> |
| 11 #include <atlcom.h> | 11 #include <atlcom.h> |
| 12 #include <exdisp.h> | 12 #include <exdisp.h> |
| 13 #include <exdispid.h> | 13 #include <exdispid.h> |
| 14 #include <mshtml.h> | 14 #include <mshtml.h> |
| 15 #include <shdeprecated.h> | 15 #include <shdeprecated.h> |
| 16 | 16 |
| 17 #include "base/lazy_instance.h" |
| 18 #include "base/thread_local.h" |
| 17 #include "chrome_tab.h" // NOLINT | 19 #include "chrome_tab.h" // NOLINT |
| 18 #include "chrome_frame/resource.h" | 20 #include "chrome_frame/resource.h" |
| 19 #include "grit/chrome_frame_resources.h" | 21 #include "grit/chrome_frame_resources.h" |
| 20 | 22 |
| 21 class PatchHelper { | 23 class PatchHelper { |
| 22 public: | 24 public: |
| 23 enum State { UNKNOWN, PATCH_IBROWSER, PATCH_IBROWSER_OK, PATCH_PROTOCOL }; | 25 enum State { UNKNOWN, PATCH_IBROWSER, PATCH_IBROWSER_OK, PATCH_PROTOCOL }; |
| 24 PatchHelper() : state_(UNKNOWN) { | 26 PatchHelper() : state_(UNKNOWN) { |
| 25 } | 27 } |
| 26 | 28 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 // It also sends contents of the meta tag as an argument. IEFrame | 80 // It also sends contents of the meta tag as an argument. IEFrame |
| 79 // handles this in IBrowserService::OnHttpEquiv. So this allows | 81 // handles this in IBrowserService::OnHttpEquiv. So this allows |
| 80 // us to sniff the META tag by simply patching it. The renderer | 82 // us to sniff the META tag by simply patching it. The renderer |
| 81 // switching can be achieved by cancelling original navigation | 83 // switching can be achieved by cancelling original navigation |
| 82 // and issuing a new one using IWebBrowser2->Navigate2. | 84 // and issuing a new one using IWebBrowser2->Navigate2. |
| 83 static HRESULT STDMETHODCALLTYPE OnHttpEquiv( | 85 static HRESULT STDMETHODCALLTYPE OnHttpEquiv( |
| 84 IBrowserService_OnHttpEquiv_Fn original_httpequiv, | 86 IBrowserService_OnHttpEquiv_Fn original_httpequiv, |
| 85 IBrowserService* browser, IShellView* shell_view, BOOL done, | 87 IBrowserService* browser, IShellView* shell_view, BOOL done, |
| 86 VARIANT* in_arg, VARIANT* out_arg); | 88 VARIANT* in_arg, VARIANT* out_arg); |
| 87 | 89 |
| 90 std::string referrer() const { |
| 91 return referrer_; |
| 92 } |
| 93 |
| 94 // Returns the Bho instance for the current thread. This is returned from |
| 95 // TLS. |
| 96 static Bho* GetCurrentThreadBhoInstance(); |
| 97 |
| 88 protected: | 98 protected: |
| 89 bool PatchProtocolHandler(const CLSID& handler_clsid); | 99 bool PatchProtocolHandler(const CLSID& handler_clsid); |
| 90 static bool HasSubFrames(IWebBrowser2* web_browser2); | 100 static bool HasSubFrames(IWebBrowser2* web_browser2); |
| 91 static HRESULT SwitchRenderer(IWebBrowser2* web_browser2, | 101 static HRESULT SwitchRenderer(IWebBrowser2* web_browser2, |
| 92 IBrowserService* browser, IShellView* shell_view, | 102 IBrowserService* browser, IShellView* shell_view, |
| 93 const wchar_t* meta_tag); | 103 const wchar_t* meta_tag); |
| 104 std::string referrer_; |
| 94 | 105 |
| 106 static base::LazyInstance<base::ThreadLocalPointer<Bho> > |
| 107 bho_current_thread_instance_; |
| 95 static _ATL_FUNC_INFO kBeforeNavigate2Info; | 108 static _ATL_FUNC_INFO kBeforeNavigate2Info; |
| 96 }; | 109 }; |
| 97 | 110 |
| 98 // Add Bho to class library table so IE can CoCreate it. | 111 // Add Bho to class library table so IE can CoCreate it. |
| 99 OBJECT_ENTRY_AUTO(CLSID_ChromeFrameBHO, Bho); | 112 OBJECT_ENTRY_AUTO(CLSID_ChromeFrameBHO, Bho); |
| 100 | 113 |
| 101 #endif // CHROME_FRAME_BHO_H_ | 114 #endif // CHROME_FRAME_BHO_H_ |
| 102 | 115 |
| OLD | NEW |