OLD | NEW |
---|---|
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/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
391 << "render_frame_host=" << render_frame_host | 391 << "render_frame_host=" << render_frame_host |
392 << ", frame_num=" << render_frame_host->GetRoutingID() | 392 << ", frame_num=" << render_frame_host->GetRoutingID() |
393 << ", url=" << validated_url << ")"; | 393 << ", url=" << validated_url << ")"; |
394 // When showing replacement content, we might get load signals for frames | 394 // When showing replacement content, we might get load signals for frames |
395 // that weren't reguarly loaded. | 395 // that weren't reguarly loaded. |
396 if (!navigation_state_.IsValidFrame(render_frame_host)) | 396 if (!navigation_state_.IsValidFrame(render_frame_host)) |
397 return; | 397 return; |
398 navigation_state_.SetNavigationCompleted(render_frame_host); | 398 navigation_state_.SetNavigationCompleted(render_frame_host); |
399 if (!navigation_state_.CanSendEvents(render_frame_host)) | 399 if (!navigation_state_.CanSendEvents(render_frame_host)) |
400 return; | 400 return; |
401 DCHECK(navigation_state_.GetUrl(render_frame_host) == validated_url || | 401 |
402 (navigation_state_.GetUrl(render_frame_host) == | 402 // A new navigation might have started before the old one completed. |
403 GURL(content::kAboutSrcDocURL) && | 403 // Ignore the old navigation completion in that case. |
404 validated_url == GURL(url::kAboutBlankURL))) | 404 // srcdoc iframes will report a url of about:blank, still let it through. |
405 << "validated URL is " << validated_url << " but we expected " | 405 if (navigation_state_.GetUrl(render_frame_host) != validated_url && |
406 << navigation_state_.GetUrl(render_frame_host); | 406 (navigation_state_.GetUrl(render_frame_host) != |
407 GURL(content::kAboutSrcDocURL) || | |
408 validated_url != GURL(url::kAboutBlankURL))) { | |
409 return; | |
nasko
2015/10/12 23:48:24
Does your change imply that a DidFailLoad will be
| |
410 } | |
407 | 411 |
408 // The load might already have finished by the time we finished parsing. For | 412 // The load might already have finished by the time we finished parsing. For |
409 // compatibility reasons, we artifically delay the load completed signal until | 413 // compatibility reasons, we artifically delay the load completed signal until |
410 // after parsing was completed. | 414 // after parsing was completed. |
411 if (!navigation_state_.GetParsingFinished(render_frame_host)) | 415 if (!navigation_state_.GetParsingFinished(render_frame_host)) |
412 return; | 416 return; |
413 helpers::DispatchOnCompleted(web_contents(), | 417 helpers::DispatchOnCompleted(web_contents(), |
414 render_frame_host, | 418 render_frame_host, |
415 navigation_state_.GetUrl(render_frame_host)); | 419 navigation_state_.GetUrl(render_frame_host)); |
416 } | 420 } |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
625 return g_factory.Pointer(); | 629 return g_factory.Pointer(); |
626 } | 630 } |
627 | 631 |
628 void WebNavigationAPI::OnListenerAdded(const EventListenerInfo& details) { | 632 void WebNavigationAPI::OnListenerAdded(const EventListenerInfo& details) { |
629 web_navigation_event_router_.reset(new WebNavigationEventRouter( | 633 web_navigation_event_router_.reset(new WebNavigationEventRouter( |
630 Profile::FromBrowserContext(browser_context_))); | 634 Profile::FromBrowserContext(browser_context_))); |
631 EventRouter::Get(browser_context_)->UnregisterObserver(this); | 635 EventRouter::Get(browser_context_)->UnregisterObserver(this); |
632 } | 636 } |
633 | 637 |
634 } // namespace extensions | 638 } // namespace extensions |
OLD | NEW |