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 // Implementation of ChromeActiveDocument | 5 // Implementation of ChromeActiveDocument |
6 #include "chrome_frame/chrome_active_document.h" | 6 #include "chrome_frame/chrome_active_document.h" |
7 | 7 |
8 #include <hlink.h> | 8 #include <hlink.h> |
9 #include <htiface.h> | 9 #include <htiface.h> |
10 #include <initguid.h> | 10 #include <initguid.h> |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 0x46); | 47 0x46); |
48 | 48 |
49 | 49 |
50 base::ThreadLocalPointer<ChromeActiveDocument> g_active_doc_cache; | 50 base::ThreadLocalPointer<ChromeActiveDocument> g_active_doc_cache; |
51 | 51 |
52 bool g_first_launch_by_process_ = true; | 52 bool g_first_launch_by_process_ = true; |
53 | 53 |
54 ChromeActiveDocument::ChromeActiveDocument() | 54 ChromeActiveDocument::ChromeActiveDocument() |
55 : first_navigation_(true), | 55 : first_navigation_(true), |
56 is_automation_client_reused_(false) { | 56 is_automation_client_reused_(false) { |
| 57 url_fetcher_.set_frame_busting(false); |
57 memset(&navigation_info_, 0, sizeof(navigation_info_)); | 58 memset(&navigation_info_, 0, sizeof(navigation_info_)); |
58 } | 59 } |
59 | 60 |
60 HRESULT ChromeActiveDocument::FinalConstruct() { | 61 HRESULT ChromeActiveDocument::FinalConstruct() { |
61 // If we have a cached ChromeActiveDocument instance in TLS, then grab | 62 // If we have a cached ChromeActiveDocument instance in TLS, then grab |
62 // ownership of the cached document's automation client. This is an | 63 // ownership of the cached document's automation client. This is an |
63 // optimization to get Chrome active documents to load faster. | 64 // optimization to get Chrome active documents to load faster. |
64 ChromeActiveDocument* cached_document = g_active_doc_cache.Get(); | 65 ChromeActiveDocument* cached_document = g_active_doc_cache.Get(); |
65 if (cached_document) { | 66 if (cached_document) { |
66 DCHECK(automation_client_.get() == NULL); | 67 DCHECK(automation_client_.get() == NULL); |
67 automation_client_ = cached_document->automation_client_.release(); | 68 automation_client_ = cached_document->automation_client_.release(); |
68 DLOG(INFO) << "Reusing automation client instance from " | 69 DLOG(INFO) << "Reusing automation client instance from " |
69 << cached_document; | 70 << cached_document; |
70 DCHECK(automation_client_.get() != NULL); | 71 DCHECK(automation_client_.get() != NULL); |
71 automation_client_->Reinitialize(this); | 72 automation_client_->Reinitialize(this, &url_fetcher_); |
72 is_automation_client_reused_ = true; | 73 is_automation_client_reused_ = true; |
73 } else { | 74 } else { |
74 // The FinalConstruct implementation in the ChromeFrameActivexBase class | 75 // The FinalConstruct implementation in the ChromeFrameActivexBase class |
75 // i.e. Base creates an instance of the ChromeFrameAutomationClient class | 76 // i.e. Base creates an instance of the ChromeFrameAutomationClient class |
76 // and initializes it, which would spawn a new Chrome process, etc. | 77 // and initializes it, which would spawn a new Chrome process, etc. |
77 // We don't want to be doing this if we have a cached document, whose | 78 // We don't want to be doing this if we have a cached document, whose |
78 // automation client instance can be reused. | 79 // automation client instance can be reused. |
79 HRESULT hr = Base::FinalConstruct(); | 80 HRESULT hr = Base::FinalConstruct(); |
80 if (FAILED(hr)) | 81 if (FAILED(hr)) |
81 return hr; | 82 return hr; |
(...skipping 13 matching lines...) Expand all Loading... |
95 enabled_commands_map_[OLECMDID_PASTE] = true; | 96 enabled_commands_map_[OLECMDID_PASTE] = true; |
96 enabled_commands_map_[OLECMDID_SELECTALL] = true; | 97 enabled_commands_map_[OLECMDID_SELECTALL] = true; |
97 return S_OK; | 98 return S_OK; |
98 } | 99 } |
99 | 100 |
100 ChromeActiveDocument::~ChromeActiveDocument() { | 101 ChromeActiveDocument::~ChromeActiveDocument() { |
101 DLOG(INFO) << __FUNCTION__; | 102 DLOG(INFO) << __FUNCTION__; |
102 if (find_dialog_.IsWindow()) { | 103 if (find_dialog_.IsWindow()) { |
103 find_dialog_.DestroyWindow(); | 104 find_dialog_.DestroyWindow(); |
104 } | 105 } |
| 106 // ChromeFramePlugin |
| 107 Base::Uninitialize(); |
105 } | 108 } |
106 | 109 |
107 // Override DoVerb | 110 // Override DoVerb |
108 STDMETHODIMP ChromeActiveDocument::DoVerb(LONG verb, | 111 STDMETHODIMP ChromeActiveDocument::DoVerb(LONG verb, |
109 LPMSG msg, | 112 LPMSG msg, |
110 IOleClientSite* active_site, | 113 IOleClientSite* active_site, |
111 LONG index, | 114 LONG index, |
112 HWND parent_window, | 115 HWND parent_window, |
113 LPCRECT pos) { | 116 LPCRECT pos) { |
114 // IE will try and in-place activate us in some cases. This happens when | 117 // IE will try and in-place activate us in some cases. This happens when |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 } | 170 } |
168 | 171 |
169 return S_FALSE; | 172 return S_FALSE; |
170 } | 173 } |
171 // Override IPersistStorageImpl::IsDirty | 174 // Override IPersistStorageImpl::IsDirty |
172 STDMETHODIMP ChromeActiveDocument::IsDirty() { | 175 STDMETHODIMP ChromeActiveDocument::IsDirty() { |
173 DLOG(INFO) << __FUNCTION__; | 176 DLOG(INFO) << __FUNCTION__; |
174 return S_FALSE; | 177 return S_FALSE; |
175 } | 178 } |
176 | 179 |
177 bool ChromeActiveDocument::is_frame_busting_enabled() { | |
178 return false; | |
179 } | |
180 | |
181 void ChromeActiveDocument::OnAutomationServerReady() { | 180 void ChromeActiveDocument::OnAutomationServerReady() { |
182 Base::OnAutomationServerReady(); | 181 Base::OnAutomationServerReady(); |
183 Base::GiveFocusToChrome(); | 182 Base::GiveFocusToChrome(); |
184 } | 183 } |
185 | 184 |
186 STDMETHODIMP ChromeActiveDocument::Load(BOOL fully_avalable, | 185 STDMETHODIMP ChromeActiveDocument::Load(BOOL fully_avalable, |
187 IMoniker* moniker_name, | 186 IMoniker* moniker_name, |
188 LPBC bind_context, | 187 LPBC bind_context, |
189 DWORD mode) { | 188 DWORD mode) { |
190 if (NULL == moniker_name) { | 189 if (NULL == moniker_name) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 DLOG(WARNING) << __FUNCTION__ << " Failed to parse url:" << url; | 223 DLOG(WARNING) << __FUNCTION__ << " Failed to parse url:" << url; |
225 return E_INVALIDARG; | 224 return E_INVALIDARG; |
226 } | 225 } |
227 | 226 |
228 if (!LaunchUrl(url, is_new_navigation)) { | 227 if (!LaunchUrl(url, is_new_navigation)) { |
229 NOTREACHED() << __FUNCTION__ << " Failed to launch url:" << url; | 228 NOTREACHED() << __FUNCTION__ << " Failed to launch url:" << url; |
230 return E_INVALIDARG; | 229 return E_INVALIDARG; |
231 } | 230 } |
232 | 231 |
233 if (!is_chrome_protocol) { | 232 if (!is_chrome_protocol) { |
234 CComObject<UrlmonUrlRequest>* new_request = NULL; | 233 url_fetcher_.UseMonikerForUrl(moniker_name, bind_context, url); |
235 CComObject<UrlmonUrlRequest>::CreateInstance(&new_request); | |
236 new_request->AddRef(); | |
237 | |
238 if (SUCCEEDED(new_request->ConnectToExistingMoniker(moniker_name, | |
239 bind_context, | |
240 url))) { | |
241 base_url_request_.swap(&new_request); | |
242 DCHECK(new_request == NULL); | |
243 } else { | |
244 new_request->Release(); | |
245 } | |
246 } | 234 } |
247 | 235 |
248 UMA_HISTOGRAM_CUSTOM_COUNTS("ChromeFrame.FullTabLaunchType", | 236 UMA_HISTOGRAM_CUSTOM_COUNTS("ChromeFrame.FullTabLaunchType", |
249 is_chrome_protocol, 0, 1, 2); | 237 is_chrome_protocol, 0, 1, 2); |
250 return S_OK; | 238 return S_OK; |
251 } | 239 } |
252 | 240 |
253 STDMETHODIMP ChromeActiveDocument::Save(IMoniker* moniker_name, | 241 STDMETHODIMP ChromeActiveDocument::Save(IMoniker* moniker_name, |
254 LPBC bind_context, | 242 LPBC bind_context, |
255 BOOL remember) { | 243 BOOL remember) { |
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 DLOG(ERROR) << "Invalid URL: " << url; | 854 DLOG(ERROR) << "Invalid URL: " << url; |
867 Error(L"Invalid URL"); | 855 Error(L"Invalid URL"); |
868 url_.Reset(); | 856 url_.Reset(); |
869 return false; | 857 return false; |
870 } | 858 } |
871 | 859 |
872 DLOG(INFO) << "Url is " << url_; | 860 DLOG(INFO) << "Url is " << url_; |
873 } | 861 } |
874 } | 862 } |
875 | 863 |
876 if (!is_automation_client_reused_ && | 864 if (is_automation_client_reused_) |
877 !InitializeAutomation(GetHostProcessName(false), L"", IsIEInPrivate())) { | 865 return true; |
878 return false; | |
879 } | |
880 | 866 |
881 return true; | 867 automation_client_->SetUrlFetcher(&url_fetcher_); |
| 868 |
| 869 if (InitializeAutomation(GetHostProcessName(false), L"", IsIEInPrivate())) |
| 870 return true; |
| 871 |
| 872 return false; |
882 } | 873 } |
883 | 874 |
884 HRESULT ChromeActiveDocument::SetPageFontSize(const GUID* cmd_group_guid, | 875 HRESULT ChromeActiveDocument::SetPageFontSize(const GUID* cmd_group_guid, |
885 DWORD command_id, | 876 DWORD command_id, |
886 DWORD cmd_exec_opt, | 877 DWORD cmd_exec_opt, |
887 VARIANT* in_args, | 878 VARIANT* in_args, |
888 VARIANT* out_args) { | 879 VARIANT* out_args) { |
889 if (!automation_client_.get()) { | 880 if (!automation_client_.get()) { |
890 NOTREACHED() << "Invalid automtion client"; | 881 NOTREACHED() << "Invalid automtion client"; |
891 return E_FAIL; | 882 return E_FAIL; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
956 hr = browser_service_local->GetTravelLog(travel_log); | 947 hr = browser_service_local->GetTravelLog(travel_log); |
957 DLOG_IF(INFO, !travel_log) << "browser_service->GetTravelLog failed: " | 948 DLOG_IF(INFO, !travel_log) << "browser_service->GetTravelLog failed: " |
958 << hr; | 949 << hr; |
959 } | 950 } |
960 | 951 |
961 if (browser_service) | 952 if (browser_service) |
962 *browser_service = browser_service_local.Detach(); | 953 *browser_service = browser_service_local.Detach(); |
963 | 954 |
964 return hr; | 955 return hr; |
965 } | 956 } |
OLD | NEW |