OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_CHROME_FRAME_ACTIVEX_BASE_H_ | 5 #ifndef CHROME_FRAME_CHROME_FRAME_ACTIVEX_BASE_H_ |
6 #define CHROME_FRAME_CHROME_FRAME_ACTIVEX_BASE_H_ | 6 #define CHROME_FRAME_CHROME_FRAME_ACTIVEX_BASE_H_ |
7 | 7 |
8 #include <atlbase.h> | 8 #include <atlbase.h> |
9 #include <atlcom.h> | 9 #include <atlcom.h> |
10 #include <atlctl.h> | 10 #include <atlctl.h> |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "base/utf_string_conversions.h" | 22 #include "base/utf_string_conversions.h" |
23 #include "base/win/scoped_bstr.h" | 23 #include "base/win/scoped_bstr.h" |
24 #include "base/win/scoped_comptr.h" | 24 #include "base/win/scoped_comptr.h" |
25 #include "base/win/scoped_variant.h" | 25 #include "base/win/scoped_variant.h" |
26 #include "grit/chrome_frame_resources.h" | 26 #include "grit/chrome_frame_resources.h" |
27 #include "ceee/ie/common/ceee_util.h" | 27 #include "ceee/ie/common/ceee_util.h" |
28 #include "chrome/common/url_constants.h" | 28 #include "chrome/common/url_constants.h" |
29 #include "chrome_frame/chrome_frame_plugin.h" | 29 #include "chrome_frame/chrome_frame_plugin.h" |
30 #include "chrome_frame/com_message_event.h" | 30 #include "chrome_frame/com_message_event.h" |
31 #include "chrome_frame/com_type_info_holder.h" | 31 #include "chrome_frame/com_type_info_holder.h" |
| 32 #include "chrome_frame/navigation_constraints.h" |
32 #include "chrome_frame/simple_resource_loader.h" | 33 #include "chrome_frame/simple_resource_loader.h" |
33 #include "chrome_frame/urlmon_url_request.h" | 34 #include "chrome_frame/urlmon_url_request.h" |
34 #include "chrome_frame/urlmon_url_request_private.h" | 35 #include "chrome_frame/urlmon_url_request_private.h" |
35 #include "chrome_frame/utils.h" | 36 #include "chrome_frame/utils.h" |
36 #include "grit/generated_resources.h" | 37 #include "grit/generated_resources.h" |
37 #include "net/base/cookie_monster.h" | 38 #include "net/base/cookie_monster.h" |
38 | 39 |
39 // Include without path to make GYP build see it. | 40 // Include without path to make GYP build see it. |
40 #include "chrome_tab.h" // NOLINT | 41 #include "chrome_tab.h" // NOLINT |
41 | 42 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 FireMethodWithParams(CF_EVENT_DISPID_ONCHANNELERROR, NULL, 0); | 143 FireMethodWithParams(CF_EVENT_DISPID_ONCHANNELERROR, NULL, 0); |
143 } | 144 } |
144 | 145 |
145 void Fire_onclose() { // NOLINT | 146 void Fire_onclose() { // NOLINT |
146 FireMethodWithParams(CF_EVENT_DISPID_ONCLOSE, NULL, 0); | 147 FireMethodWithParams(CF_EVENT_DISPID_ONCLOSE, NULL, 0); |
147 } | 148 } |
148 }; | 149 }; |
149 | 150 |
150 extern bool g_first_launch_by_process_; | 151 extern bool g_first_launch_by_process_; |
151 | 152 |
152 // Posted when the worker thread used for handling URL requests in IE finishes | |
153 // uninitialization. | |
154 #define WM_WORKER_THREAD_UNINITIALIZED_MSG (WM_APP + 1) | |
155 | |
156 // Common implementation for ActiveX and Active Document | 153 // Common implementation for ActiveX and Active Document |
157 template <class T, const CLSID& class_id> | 154 template <class T, const CLSID& class_id> |
158 class ATL_NO_VTABLE ChromeFrameActivexBase : // NOLINT | 155 class ATL_NO_VTABLE ChromeFrameActivexBase : // NOLINT |
159 public CComObjectRootEx<CComMultiThreadModel>, | 156 public CComObjectRootEx<CComMultiThreadModel>, |
160 public IOleControlImpl<T>, | 157 public IOleControlImpl<T>, |
161 public IOleObjectImpl<T>, | 158 public IOleObjectImpl<T>, |
162 public IOleInPlaceActiveObjectImpl<T>, | 159 public IOleInPlaceActiveObjectImpl<T>, |
163 public IViewObjectExImpl<T>, | 160 public IViewObjectExImpl<T>, |
164 public IOleInPlaceObjectWindowlessImpl<T>, | 161 public IOleInPlaceObjectWindowlessImpl<T>, |
165 public ISupportErrorInfo, | 162 public ISupportErrorInfo, |
166 public IQuickActivateImpl<T>, | 163 public IQuickActivateImpl<T>, |
167 public com_util::IProvideClassInfo2Impl<class_id, | 164 public com_util::IProvideClassInfo2Impl<class_id, |
168 DIID_DIChromeFrameEvents>, | 165 DIID_DIChromeFrameEvents>, |
169 public com_util::IDispatchImpl<IChromeFrame>, | 166 public com_util::IDispatchImpl<IChromeFrame>, |
170 public IChromeFrameInternal, | 167 public IChromeFrameInternal, |
171 public IConnectionPointContainerImpl<T>, | 168 public IConnectionPointContainerImpl<T>, |
172 public ProxyDIChromeFrameEvents<T>, | 169 public ProxyDIChromeFrameEvents<T>, |
173 public IPropertyNotifySinkCP<T>, | 170 public IPropertyNotifySinkCP<T>, |
174 public CComCoClass<T, &class_id>, | 171 public CComCoClass<T, &class_id>, |
175 public CComControl<T>, | 172 public CComControl<T>, |
176 public ChromeFramePlugin<T> { | 173 public ChromeFramePlugin<T>, |
| 174 public NavigationConstraintsImpl { |
177 protected: | 175 protected: |
178 typedef std::set<base::win::ScopedComPtr<IDispatch> > EventHandlers; | 176 typedef std::set<base::win::ScopedComPtr<IDispatch> > EventHandlers; |
179 typedef ChromeFrameActivexBase<T, class_id> BasePlugin; | 177 typedef ChromeFrameActivexBase<T, class_id> BasePlugin; |
180 | 178 |
181 public: | 179 public: |
182 ChromeFrameActivexBase() | 180 ChromeFrameActivexBase() |
183 : ready_state_(READYSTATE_UNINITIALIZED), | 181 : ready_state_(READYSTATE_UNINITIALIZED), |
184 url_fetcher_(new UrlmonUrlRequestManager()), | 182 url_fetcher_(new UrlmonUrlRequestManager()), |
185 failed_to_fetch_in_place_frame_(false), | 183 failed_to_fetch_in_place_frame_(false), |
186 draw_sad_tab_(false), | 184 draw_sad_tab_(false), |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 draw_sad_tab_ = true; | 566 draw_sad_tab_ = true; |
569 | 567 |
570 ready_state_ = READYSTATE_UNINITIALIZED; | 568 ready_state_ = READYSTATE_UNINITIALIZED; |
571 FireOnChanged(DISPID_READYSTATE); | 569 FireOnChanged(DISPID_READYSTATE); |
572 } | 570 } |
573 | 571 |
574 virtual void OnCloseTab(int tab_handle) { | 572 virtual void OnCloseTab(int tab_handle) { |
575 Fire_onclose(); | 573 Fire_onclose(); |
576 } | 574 } |
577 | 575 |
| 576 // NavigationConstraints overrides. |
| 577 virtual bool IsSchemeAllowed(const GURL& url) { |
| 578 bool allowed = NavigationConstraintsImpl::IsSchemeAllowed(url); |
| 579 if (allowed) |
| 580 return true; |
| 581 |
| 582 if (is_privileged_ && |
| 583 (url.SchemeIs(chrome::kDataScheme) || |
| 584 url.SchemeIs(chrome::kExtensionScheme))) { |
| 585 return true; |
| 586 } |
| 587 return false; |
| 588 } |
| 589 |
578 // Overridden to take advantage of readystate prop changes and send those | 590 // Overridden to take advantage of readystate prop changes and send those |
579 // to potential listeners. | 591 // to potential listeners. |
580 HRESULT FireOnChanged(DISPID dispid) { | 592 HRESULT FireOnChanged(DISPID dispid) { |
581 if (dispid == DISPID_READYSTATE) { | 593 if (dispid == DISPID_READYSTATE) { |
582 Fire_onreadystatechanged(ready_state_); | 594 Fire_onreadystatechanged(ready_state_); |
583 } | 595 } |
584 return __super::FireOnChanged(dispid); | 596 return __super::FireOnChanged(dispid); |
585 } | 597 } |
586 | 598 |
587 // IChromeFrame | 599 // IChromeFrame |
(...skipping 16 matching lines...) Expand all Loading... |
604 // Switch the src to UTF8 and try to expand to full URL | 616 // Switch the src to UTF8 and try to expand to full URL |
605 std::string src_utf8; | 617 std::string src_utf8; |
606 WideToUTF8(src, SysStringLen(src), &src_utf8); | 618 WideToUTF8(src, SysStringLen(src), &src_utf8); |
607 std::string full_url = ResolveURL(GetDocumentUrl(), src_utf8); | 619 std::string full_url = ResolveURL(GetDocumentUrl(), src_utf8); |
608 | 620 |
609 // We can initiate navigation here even if ready_state is not complete. | 621 // We can initiate navigation here even if ready_state is not complete. |
610 // We do not have to set proxy, and AutomationClient will take care | 622 // We do not have to set proxy, and AutomationClient will take care |
611 // of navigation just after CreateExternalTab is done. | 623 // of navigation just after CreateExternalTab is done. |
612 if (!automation_client_->InitiateNavigation(full_url, | 624 if (!automation_client_->InitiateNavigation(full_url, |
613 GetDocumentUrl(), | 625 GetDocumentUrl(), |
614 is_privileged_)) { | 626 this)) { |
615 // TODO(robertshield): Make InitiateNavigation return more useful | 627 // TODO(robertshield): Make InitiateNavigation return more useful |
616 // error information. | 628 // error information. |
617 return E_INVALIDARG; | 629 return E_INVALIDARG; |
618 } | 630 } |
619 | 631 |
620 // Save full URL in BSTR member | 632 // Save full URL in BSTR member |
621 url_.Reset(::SysAllocString(UTF8ToWide(full_url).c_str())); | 633 url_.Reset(::SysAllocString(UTF8ToWide(full_url).c_str())); |
622 | 634 |
623 return S_OK; | 635 return S_OK; |
624 } | 636 } |
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1275 EventHandlers onextensionready_; | 1287 EventHandlers onextensionready_; |
1276 | 1288 |
1277 // Handle network requests when host network stack is used. Passed to the | 1289 // Handle network requests when host network stack is used. Passed to the |
1278 // automation client on initialization. | 1290 // automation client on initialization. |
1279 scoped_ptr<UrlmonUrlRequestManager> url_fetcher_; | 1291 scoped_ptr<UrlmonUrlRequestManager> url_fetcher_; |
1280 | 1292 |
1281 HINSTANCE prev_resource_instance_; | 1293 HINSTANCE prev_resource_instance_; |
1282 }; | 1294 }; |
1283 | 1295 |
1284 #endif // CHROME_FRAME_CHROME_FRAME_ACTIVEX_BASE_H_ | 1296 #endif // CHROME_FRAME_CHROME_FRAME_ACTIVEX_BASE_H_ |
OLD | NEW |