Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(186)

Side by Side Diff: ceee/ie/plugin/bho/web_progress_notifier.cc

Issue 4989002: Firing event to broker without worker thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 // Web progress notifier implementation. 5 // Web progress notifier implementation.
6 #include "ceee/ie/plugin/bho/web_progress_notifier.h" 6 #include "ceee/ie/plugin/bho/web_progress_notifier.h"
7 7
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "ceee/common/com_utils.h" 10 #include "ceee/common/com_utils.h"
11 #include "ceee/ie/plugin/bho/dom_utils.h" 11 #include "ceee/ie/plugin/bho/dom_utils.h"
12 #include "ceee/ie/plugin/bho/webnavigation_events_funnel.h"
12 13
13 namespace { 14 namespace {
14 15
15 // In milliseconds. It defines the "effective period" of user action. A user 16 // In milliseconds. It defines the "effective period" of user action. A user
16 // action is considered as a possible cause of the next navigation if the 17 // action is considered as a possible cause of the next navigation if the
17 // navigation happens in this period. 18 // navigation happens in this period.
18 // This is a number we feel confident of based on past experience. 19 // This is a number we feel confident of based on past experience.
19 const int kUserActionTimeThresholdMs = 500; 20 const int kUserActionTimeThresholdMs = 500;
20 21
21 // String constants for the values of TransitionQualifier. 22 // String constants for the values of TransitionQualifier.
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 return; 115 return;
115 116
116 if (FilterOutWebBrowserEvent(browser, FilteringInfo::BEFORE_NAVIGATE)) 117 if (FilterOutWebBrowserEvent(browser, FilteringInfo::BEFORE_NAVIGATE))
117 return; 118 return;
118 119
119 FrameInfo* frame_info = NULL; 120 FrameInfo* frame_info = NULL;
120 if (!GetFrameInfo(browser, &frame_info)) 121 if (!GetFrameInfo(browser, &frame_info))
121 return; 122 return;
122 123
123 // TODO(yzshen@google.com): add support for requestId. 124 // TODO(yzshen@google.com): add support for requestId.
124 HRESULT hr = webnavigation_events_funnel().OnBeforeNavigate( 125 HRESULT hr = E_POINTER;
125 tab_handle_, url, frame_info->frame_id, -1, base::Time::Now()); 126 if (webnavigation_events_funnel()) {
Sigurður Ásgeirsson 2010/11/19 18:29:30 retrieve pointer to a local and DCHECK? If this is
Vitaly Buka corp 2010/11/19 20:30:38 Done.
127 hr = webnavigation_events_funnel()->OnBeforeNavigate(
128 tab_handle_, url, frame_info->frame_id, -1, base::Time::Now());
129 }
126 DCHECK(SUCCEEDED(hr)) 130 DCHECK(SUCCEEDED(hr))
127 << "Failed to fire the webNavigation.onBeforeNavigate event " 131 << "Failed to fire the webNavigation.onBeforeNavigate event "
128 << com::LogHr(hr); 132 << com::LogHr(hr);
129 133
130 if (frame_info->IsMainFrame()) { 134 if (frame_info->IsMainFrame()) {
131 frame_info->ClearTransition(); 135 frame_info->ClearTransition();
132 136
133 // The order in which we set these transitions is **very important.** 137 // The order in which we set these transitions is **very important.**
134 // If there was no DocumentComplete, then there are two likely options: 138 // If there was no DocumentComplete, then there are two likely options:
135 // the transition was a JavaScript redirect, or the user navigated to a 139 // the transition was a JavaScript redirect, or the user navigated to a
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 if (!GetFrameInfo(browser, &frame_info)) 187 if (!GetFrameInfo(browser, &frame_info))
184 return; 188 return;
185 189
186 if (frame_info->IsMainFrame()) { 190 if (frame_info->IsMainFrame()) {
187 main_frame_document_complete_ = true; 191 main_frame_document_complete_ = true;
188 192
189 has_potential_javascript_redirect_ = 193 has_potential_javascript_redirect_ =
190 HasPotentialJavaScriptRedirect(browser); 194 HasPotentialJavaScriptRedirect(browser);
191 } 195 }
192 196
193 HRESULT hr = webnavigation_events_funnel().OnCompleted( 197 HRESULT hr = E_POINTER;
194 tab_handle_, url, frame_info->frame_id, base::Time::Now()); 198 if (webnavigation_events_funnel()) {
199 hr = webnavigation_events_funnel()->OnCompleted(
200 tab_handle_, url, frame_info->frame_id, base::Time::Now());
201 }
195 DCHECK(SUCCEEDED(hr)) << "Failed to fire the webNavigation.onCompleted event " 202 DCHECK(SUCCEEDED(hr)) << "Failed to fire the webNavigation.onCompleted event "
196 << com::LogHr(hr); 203 << com::LogHr(hr);
197 } 204 }
198 205
199 void WebProgressNotifier::OnNavigateComplete(IWebBrowser2* browser, BSTR url) { 206 void WebProgressNotifier::OnNavigateComplete(IWebBrowser2* browser, BSTR url) {
200 if (browser == NULL || url == NULL) 207 if (browser == NULL || url == NULL)
201 return; 208 return;
202 209
203 if (FilterOutWebBrowserEvent(browser, FilteringInfo::NAVIGATE_COMPLETE)) { 210 if (FilterOutWebBrowserEvent(browser, FilteringInfo::NAVIGATE_COMPLETE)) {
204 filtering_info_.pending_navigate_complete_browser = browser; 211 filtering_info_.pending_navigate_complete_browser = browser;
(...skipping 18 matching lines...) Expand all
223 return; 230 return;
224 231
225 if (frame_info->IsMainFrame()) { 232 if (frame_info->IsMainFrame()) {
226 main_frame_document_complete_ = false; 233 main_frame_document_complete_ = false;
227 234
228 if (IsForwardBack(url)) { 235 if (IsForwardBack(url)) {
229 frame_info->SetTransition(PageTransition::AUTO_BOOKMARK, FORWARD_BACK); 236 frame_info->SetTransition(PageTransition::AUTO_BOOKMARK, FORWARD_BACK);
230 } 237 }
231 } 238 }
232 239
233 HRESULT hr = webnavigation_events_funnel().OnCommitted( 240 HRESULT hr = E_POINTER;
241 if (webnavigation_events_funnel()) {
242 hr = webnavigation_events_funnel()->OnCommitted(
234 tab_handle_, url, frame_info->frame_id, 243 tab_handle_, url, frame_info->frame_id,
235 PageTransition::CoreTransitionString(frame_info->transition_type), 244 PageTransition::CoreTransitionString(frame_info->transition_type),
236 TransitionQualifiersString(frame_info->transition_qualifiers).c_str(), 245 TransitionQualifiersString(frame_info->transition_qualifiers).c_str(),
237 timestamp); 246 timestamp);
247 }
238 DCHECK(SUCCEEDED(hr)) << "Failed to fire the webNavigation.onCommitted event " 248 DCHECK(SUCCEEDED(hr)) << "Failed to fire the webNavigation.onCommitted event "
239 << com::LogHr(hr); 249 << com::LogHr(hr);
240 250
241 if (frame_info->IsMainFrame()) 251 if (frame_info->IsMainFrame())
242 subframe_map_.clear(); 252 subframe_map_.clear();
243 } 253 }
244 254
245 void WebProgressNotifier::OnNavigateError(IWebBrowser2* browser, BSTR url, 255 void WebProgressNotifier::OnNavigateError(IWebBrowser2* browser, BSTR url,
246 long status_code) { 256 long status_code) {
247 if (browser == NULL || url == NULL) 257 if (browser == NULL || url == NULL)
248 return; 258 return;
249 259
250 if (FilterOutWebBrowserEvent(browser, FilteringInfo::NAVIGATE_ERROR)) 260 if (FilterOutWebBrowserEvent(browser, FilteringInfo::NAVIGATE_ERROR))
251 return; 261 return;
252 262
253 FrameInfo* frame_info = NULL; 263 FrameInfo* frame_info = NULL;
254 if (!GetFrameInfo(browser, &frame_info)) 264 if (!GetFrameInfo(browser, &frame_info))
255 return; 265 return;
256 266
257 HRESULT hr = webnavigation_events_funnel().OnErrorOccurred( 267 HRESULT hr = E_POINTER;
258 tab_handle_, url, frame_info->frame_id, CComBSTR(L""), base::Time::Now()); 268 if (webnavigation_events_funnel()) {
269 hr = webnavigation_events_funnel()->OnErrorOccurred(tab_handle_, url,
270 frame_info->frame_id, CComBSTR(L""), base::Time::Now());
271 }
259 DCHECK(SUCCEEDED(hr)) 272 DCHECK(SUCCEEDED(hr))
260 << "Failed to fire the webNavigation.onErrorOccurred event " 273 << "Failed to fire the webNavigation.onErrorOccurred event "
261 << com::LogHr(hr); 274 << com::LogHr(hr);
262 } 275 }
263 276
264 void WebProgressNotifier::OnNewWindow(BSTR url_context, BSTR url) { 277 void WebProgressNotifier::OnNewWindow(BSTR url_context, BSTR url) {
265 if (url_context == NULL || url == NULL) 278 if (url_context == NULL || url == NULL)
266 return; 279 return;
267 280
268 if (FilterOutWebBrowserEvent(NULL, FilteringInfo::NEW_WINDOW)) 281 if (FilterOutWebBrowserEvent(NULL, FilteringInfo::NEW_WINDOW))
269 return; 282 return;
270 283
271 HRESULT hr = webnavigation_events_funnel().OnBeforeRetarget( 284 HRESULT hr = E_POINTER;
272 tab_handle_, url_context, url, base::Time::Now()); 285 if (webnavigation_events_funnel()) {
286 hr = webnavigation_events_funnel()->OnBeforeRetarget(tab_handle_,
287 url_context, url, base::Time::Now());
288 }
273 DCHECK(SUCCEEDED(hr)) 289 DCHECK(SUCCEEDED(hr))
274 << "Failed to fire the webNavigation.onBeforeRetarget event " 290 << "Failed to fire the webNavigation.onBeforeRetarget event "
275 << com::LogHr(hr); 291 << com::LogHr(hr);
276 } 292 }
277 293
278 void WebProgressNotifier::OnHandleMessage( 294 void WebProgressNotifier::OnHandleMessage(
279 WindowMessageSource::MessageType type, 295 WindowMessageSource::MessageType type,
280 const MSG* message_info) { 296 const MSG* message_info) {
281 DCHECK(create_thread_id_ == ::GetCurrentThreadId()); 297 DCHECK(create_thread_id_ == ::GetCurrentThreadId());
282 298
(...skipping 15 matching lines...) Expand all
298 } 314 }
299 break; 315 break;
300 } 316 }
301 default: { 317 default: {
302 NOTREACHED(); 318 NOTREACHED();
303 break; 319 break;
304 } 320 }
305 } 321 }
306 } 322 }
307 323
324 WebNavigationEventsFunnel* WebProgressNotifier::webnavigation_events_funnel() {
325 if (!webnavigation_events_funnel_.get())
326 webnavigation_events_funnel_.reset(new WebNavigationEventsFunnel());
327 return webnavigation_events_funnel_.get();
328 }
329
330 WebRequestNotifier* WebProgressNotifier::webrequest_notifier() {
331 if (cached_webrequest_notifier_ == NULL) {
332 cached_webrequest_notifier_ = ProductionWebRequestNotifier::get();
333 }
334 return cached_webrequest_notifier_;
335 }
336
308 WindowMessageSource* WebProgressNotifier::CreateWindowMessageSource() { 337 WindowMessageSource* WebProgressNotifier::CreateWindowMessageSource() {
309 scoped_ptr<WindowMessageSource> source(new WindowMessageSource()); 338 scoped_ptr<WindowMessageSource> source(new WindowMessageSource());
310 339
311 return source->Initialize() ? source.release() : NULL; 340 return source->Initialize() ? source.release() : NULL;
312 } 341 }
313 342
314 std::string WebProgressNotifier::TransitionQualifiersString( 343 std::string WebProgressNotifier::TransitionQualifiersString(
315 TransitionQualifiers qualifiers) { 344 TransitionQualifiers qualifiers) {
316 std::string result; 345 std::string result;
317 for (unsigned int current_qualifier = FIRST_TRANSITION_QUALIFIER; 346 for (unsigned int current_qualifier = FIRST_TRANSITION_QUALIFIER;
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 break; 674 break;
646 } 675 }
647 default: { 676 default: {
648 NOTREACHED() << "Unknown state type."; 677 NOTREACHED() << "Unknown state type.";
649 break; 678 break;
650 } 679 }
651 } 680 }
652 } 681 }
653 return false; 682 return false;
654 } 683 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698