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

Side by Side Diff: chrome/browser/extensions/api/web_navigation/web_navigation_api.cc

Issue 10823169: Another attempt at fixing dead frames being tracked by webNavigation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch for landing Created 8 years, 4 months 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // Implements the Chrome Extensions WebNavigation API. 5 // Implements the Chrome Extensions WebNavigation API.
6 6
7 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h" 7 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h"
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api_consta nts.h" 10 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api_consta nts.h"
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 void WebNavigationTabObserver::DidCommitProvisionalLoadForFrame( 370 void WebNavigationTabObserver::DidCommitProvisionalLoadForFrame(
371 int64 frame_num, 371 int64 frame_num,
372 bool is_main_frame, 372 bool is_main_frame,
373 const GURL& url, 373 const GURL& url,
374 content::PageTransition transition_type, 374 content::PageTransition transition_type,
375 content::RenderViewHost* render_view_host) { 375 content::RenderViewHost* render_view_host) {
376 if (render_view_host != render_view_host_ && 376 if (render_view_host != render_view_host_ &&
377 render_view_host != pending_render_view_host_) 377 render_view_host != pending_render_view_host_)
378 return; 378 return;
379 FrameNavigationState::FrameID frame_id(frame_num, render_view_host); 379 FrameNavigationState::FrameID frame_id(frame_num, render_view_host);
380 FrameNavigationState::FrameID id_to_skip;
381 if (render_view_host == render_view_host_)
382 id_to_skip = frame_id;
383 if (is_main_frame)
384 SendErrorEvents(web_contents(), render_view_host_, id_to_skip);
385 render_view_host_ = render_view_host;
386 pending_render_view_host_ = NULL;
387
388 if (!navigation_state_.CanSendEvents(frame_id))
389 return;
390 380
391 bool is_reference_fragment_navigation = 381 bool is_reference_fragment_navigation =
392 IsReferenceFragmentNavigation(frame_id, url); 382 IsReferenceFragmentNavigation(frame_id, url);
393 bool is_history_navigation = 383 bool is_history_state_modification =
394 navigation_state_.GetNavigationCommitted(frame_id); 384 navigation_state_.GetNavigationCommitted(frame_id);
395 385
386 if (is_main_frame && render_view_host_ == render_view_host) {
387 // Changing the reference fragment or the history state using
388 // history.pushState or history.replaceState does not cancel on-going
389 // iframe navigations.
390 if (!is_reference_fragment_navigation && !is_history_state_modification)
391 SendErrorEvents(web_contents(), render_view_host_, frame_id);
392 if (pending_render_view_host_) {
393 SendErrorEvents(web_contents(),
394 pending_render_view_host_,
395 FrameNavigationState::FrameID());
396 pending_render_view_host_ = NULL;
397 }
398 } else if (pending_render_view_host_ == render_view_host) {
399 SendErrorEvents(
400 web_contents(), render_view_host_, FrameNavigationState::FrameID());
401 render_view_host_ = pending_render_view_host_;
402 pending_render_view_host_ = NULL;
403 }
404
396 // Update the URL as it might have changed. 405 // Update the URL as it might have changed.
397 navigation_state_.UpdateFrame(frame_id, url); 406 navigation_state_.UpdateFrame(frame_id, url);
398 navigation_state_.SetNavigationCommitted(frame_id); 407 navigation_state_.SetNavigationCommitted(frame_id);
399 408
409 if (!navigation_state_.CanSendEvents(frame_id))
410 return;
411
400 if (is_reference_fragment_navigation) { 412 if (is_reference_fragment_navigation) {
401 helpers::DispatchOnCommitted( 413 helpers::DispatchOnCommitted(
402 keys::kOnReferenceFragmentUpdated, 414 keys::kOnReferenceFragmentUpdated,
403 web_contents(), 415 web_contents(),
404 frame_num, 416 frame_num,
405 is_main_frame, 417 is_main_frame,
406 url, 418 url,
407 transition_type); 419 transition_type);
408 navigation_state_.SetNavigationCompleted(frame_id); 420 navigation_state_.SetNavigationCompleted(frame_id);
409 } else if (is_history_navigation) { 421 } else if (is_history_state_modification) {
410 // Make the transition type match the one for reference fragment updates.
411 transition_type = static_cast<content::PageTransition>(
412 transition_type | content::PAGE_TRANSITION_CLIENT_REDIRECT);
413 helpers::DispatchOnCommitted( 422 helpers::DispatchOnCommitted(
414 keys::kOnHistoryStateUpdated, 423 keys::kOnHistoryStateUpdated,
415 web_contents(), 424 web_contents(),
416 frame_num, 425 frame_num,
417 is_main_frame, 426 is_main_frame,
418 url, 427 url,
419 transition_type); 428 transition_type);
420 navigation_state_.SetNavigationCompleted(frame_id); 429 navigation_state_.SetNavigationCompleted(frame_id);
421 } else { 430 } else {
422 if (navigation_state_.GetIsServerRedirected(frame_id)) { 431 if (navigation_state_.GetIsServerRedirected(frame_id)) {
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 navigation_state.IsMainFrame(frame_id), frame_id.frame_num); 688 navigation_state.IsMainFrame(frame_id), frame_id.frame_num);
680 frame->process_id = frame_id.render_view_host->GetProcess()->GetID(); 689 frame->process_id = frame_id.render_view_host->GetProcess()->GetID();
681 frame->error_occurred = navigation_state.GetErrorOccurredInFrame(frame_id); 690 frame->error_occurred = navigation_state.GetErrorOccurredInFrame(frame_id);
682 result_list.push_back(frame); 691 result_list.push_back(frame);
683 } 692 }
684 results_ = GetAllFrames::Results::Create(result_list); 693 results_ = GetAllFrames::Results::Create(result_list);
685 return true; 694 return true;
686 } 695 }
687 696
688 } // namespace extensions 697 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698