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

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

Issue 13929020: Artifically delay the load finished signal until after dom content loaded (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 7 years, 8 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
« no previous file with comments | « chrome/browser/extensions/api/web_navigation/frame_navigation_state.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 int64 frame_num, 521 int64 frame_num,
522 content::RenderViewHost* render_view_host) { 522 content::RenderViewHost* render_view_host) {
523 DVLOG(2) << "DocumentLoadedInFrame(" 523 DVLOG(2) << "DocumentLoadedInFrame("
524 << "render_view_host=" << render_view_host 524 << "render_view_host=" << render_view_host
525 << ", frame_num=" << frame_num << ")"; 525 << ", frame_num=" << frame_num << ")";
526 if (render_view_host != render_view_host_) 526 if (render_view_host != render_view_host_)
527 return; 527 return;
528 FrameNavigationState::FrameID frame_id(frame_num, render_view_host); 528 FrameNavigationState::FrameID frame_id(frame_num, render_view_host);
529 if (!navigation_state_.CanSendEvents(frame_id)) 529 if (!navigation_state_.CanSendEvents(frame_id))
530 return; 530 return;
531 navigation_state_.SetParsingFinished(frame_id);
531 helpers::DispatchOnDOMContentLoaded(web_contents(), 532 helpers::DispatchOnDOMContentLoaded(web_contents(),
532 navigation_state_.GetUrl(frame_id), 533 navigation_state_.GetUrl(frame_id),
533 navigation_state_.IsMainFrame(frame_id), 534 navigation_state_.IsMainFrame(frame_id),
534 frame_num); 535 frame_num);
536
537 if (!navigation_state_.GetNavigationCompleted(frame_id))
538 return;
539
540 // The load might already have finished by the time we finished parsing. For
541 // compatibility reasons, we artifically delay the load completed signal until
542 // after parsing was completed.
543 helpers::DispatchOnCompleted(web_contents(),
544 navigation_state_.GetUrl(frame_id),
545 navigation_state_.IsMainFrame(frame_id),
546 frame_num);
535 } 547 }
536 548
537 void WebNavigationTabObserver::DidFinishLoad( 549 void WebNavigationTabObserver::DidFinishLoad(
538 int64 frame_num, 550 int64 frame_num,
539 const GURL& validated_url, 551 const GURL& validated_url,
540 bool is_main_frame, 552 bool is_main_frame,
541 content::RenderViewHost* render_view_host) { 553 content::RenderViewHost* render_view_host) {
542 DVLOG(2) << "DidFinishLoad(" 554 DVLOG(2) << "DidFinishLoad("
543 << "render_view_host=" << render_view_host 555 << "render_view_host=" << render_view_host
544 << ", frame_num=" << frame_num 556 << ", frame_num=" << frame_num
545 << ", url=" << validated_url << ")"; 557 << ", url=" << validated_url << ")";
546 if (render_view_host != render_view_host_) 558 if (render_view_host != render_view_host_)
547 return; 559 return;
548 FrameNavigationState::FrameID frame_id(frame_num, render_view_host); 560 FrameNavigationState::FrameID frame_id(frame_num, render_view_host);
549 // When showing replacement content, we might get load signals for frames 561 // When showing replacement content, we might get load signals for frames
550 // that weren't reguarly loaded. 562 // that weren't reguarly loaded.
551 if (!navigation_state_.IsValidFrame(frame_id)) 563 if (!navigation_state_.IsValidFrame(frame_id))
552 return; 564 return;
553 navigation_state_.SetNavigationCompleted(frame_id); 565 navigation_state_.SetNavigationCompleted(frame_id);
554 if (!navigation_state_.CanSendEvents(frame_id)) 566 if (!navigation_state_.CanSendEvents(frame_id))
555 return; 567 return;
556 DCHECK(navigation_state_.GetUrl(frame_id) == validated_url || 568 DCHECK(navigation_state_.GetUrl(frame_id) == validated_url ||
557 (navigation_state_.GetUrl(frame_id) == GURL(chrome::kAboutSrcDocURL) && 569 (navigation_state_.GetUrl(frame_id) == GURL(chrome::kAboutSrcDocURL) &&
558 validated_url == GURL(chrome::kAboutBlankURL))) 570 validated_url == GURL(chrome::kAboutBlankURL)))
559 << "validated URL is " << validated_url << " but we expected " 571 << "validated URL is " << validated_url << " but we expected "
560 << navigation_state_.GetUrl(frame_id); 572 << navigation_state_.GetUrl(frame_id);
561 DCHECK_EQ(navigation_state_.IsMainFrame(frame_id), is_main_frame); 573 DCHECK_EQ(navigation_state_.IsMainFrame(frame_id), is_main_frame);
574
575 // The load might already have finished by the time we finished parsing. For
576 // compatibility reasons, we artifically delay the load completed signal until
577 // after parsing was completed.
578 if (!navigation_state_.GetParsingFinished(frame_id))
579 return;
562 helpers::DispatchOnCompleted(web_contents(), 580 helpers::DispatchOnCompleted(web_contents(),
563 navigation_state_.GetUrl(frame_id), 581 navigation_state_.GetUrl(frame_id),
564 is_main_frame, 582 is_main_frame,
565 frame_num); 583 frame_num);
566 } 584 }
567 585
568 void WebNavigationTabObserver::DidFailLoad( 586 void WebNavigationTabObserver::DidFailLoad(
569 int64 frame_num, 587 int64 frame_num,
570 const GURL& validated_url, 588 const GURL& validated_url,
571 bool is_main_frame, 589 bool is_main_frame,
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 WebNavigationAPI::GetFactoryInstance() { 851 WebNavigationAPI::GetFactoryInstance() {
834 return &g_factory.Get(); 852 return &g_factory.Get();
835 } 853 }
836 854
837 void WebNavigationAPI::OnListenerAdded(const EventListenerInfo& details) { 855 void WebNavigationAPI::OnListenerAdded(const EventListenerInfo& details) {
838 web_navigation_event_router_.reset(new WebNavigationEventRouter(profile_)); 856 web_navigation_event_router_.reset(new WebNavigationEventRouter(profile_));
839 ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this); 857 ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this);
840 } 858 }
841 859
842 } // namespace extensions 860 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/web_navigation/frame_navigation_state.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698