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 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 << "render_frame_host=" << render_frame_host | 379 << "render_frame_host=" << render_frame_host |
380 << ", frame_num=" << render_frame_host->GetRoutingID() | 380 << ", frame_num=" << render_frame_host->GetRoutingID() |
381 << ", url=" << validated_url << ")"; | 381 << ", url=" << validated_url << ")"; |
382 // When showing replacement content, we might get load signals for frames | 382 // When showing replacement content, we might get load signals for frames |
383 // that weren't reguarly loaded. | 383 // that weren't reguarly loaded. |
384 if (!navigation_state_.IsValidFrame(render_frame_host)) | 384 if (!navigation_state_.IsValidFrame(render_frame_host)) |
385 return; | 385 return; |
386 navigation_state_.SetNavigationCompleted(render_frame_host); | 386 navigation_state_.SetNavigationCompleted(render_frame_host); |
387 if (!navigation_state_.CanSendEvents(render_frame_host)) | 387 if (!navigation_state_.CanSendEvents(render_frame_host)) |
388 return; | 388 return; |
389 DCHECK(navigation_state_.GetUrl(render_frame_host) == validated_url || | 389 |
390 (navigation_state_.GetUrl(render_frame_host) == | 390 // A new navigation might have started before the old one completed. |
391 GURL(content::kAboutSrcDocURL) && | 391 // Ignore the old navigation completion in that case. |
392 validated_url == GURL(url::kAboutBlankURL))) | 392 // srcdoc iframes will report a url of about:blank, still let it through. |
393 << "validated URL is " << validated_url << " but we expected " | 393 if (navigation_state_.GetUrl(render_frame_host) != validated_url && |
394 << navigation_state_.GetUrl(render_frame_host); | 394 (navigation_state_.GetUrl(render_frame_host) != |
| 395 GURL(content::kAboutSrcDocURL) || |
| 396 validated_url != GURL(url::kAboutBlankURL))) { |
| 397 return; |
| 398 } |
395 | 399 |
396 // The load might already have finished by the time we finished parsing. For | 400 // The load might already have finished by the time we finished parsing. For |
397 // compatibility reasons, we artifically delay the load completed signal until | 401 // compatibility reasons, we artifically delay the load completed signal until |
398 // after parsing was completed. | 402 // after parsing was completed. |
399 if (!navigation_state_.GetParsingFinished(render_frame_host)) | 403 if (!navigation_state_.GetParsingFinished(render_frame_host)) |
400 return; | 404 return; |
401 helpers::DispatchOnCompleted(web_contents(), | 405 helpers::DispatchOnCompleted(web_contents(), |
402 render_frame_host, | 406 render_frame_host, |
403 navigation_state_.GetUrl(render_frame_host)); | 407 navigation_state_.GetUrl(render_frame_host)); |
404 } | 408 } |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 return g_factory.Pointer(); | 617 return g_factory.Pointer(); |
614 } | 618 } |
615 | 619 |
616 void WebNavigationAPI::OnListenerAdded(const EventListenerInfo& details) { | 620 void WebNavigationAPI::OnListenerAdded(const EventListenerInfo& details) { |
617 web_navigation_event_router_.reset(new WebNavigationEventRouter( | 621 web_navigation_event_router_.reset(new WebNavigationEventRouter( |
618 Profile::FromBrowserContext(browser_context_))); | 622 Profile::FromBrowserContext(browser_context_))); |
619 EventRouter::Get(browser_context_)->UnregisterObserver(this); | 623 EventRouter::Get(browser_context_)->UnregisterObserver(this); |
620 } | 624 } |
621 | 625 |
622 } // namespace extensions | 626 } // namespace extensions |
OLD | NEW |