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

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

Issue 2534393003: (Reland) Remove about:srcdoc url conversion. (Closed)
Patch Set: Rebase. Created 4 years 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
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/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 // that weren't reguarly loaded. 336 // that weren't reguarly loaded.
337 if (!navigation_state_.IsValidFrame(render_frame_host)) 337 if (!navigation_state_.IsValidFrame(render_frame_host))
338 return; 338 return;
339 339
340 navigation_state_.SetDocumentLoadCompleted(render_frame_host); 340 navigation_state_.SetDocumentLoadCompleted(render_frame_host);
341 if (!navigation_state_.CanSendEvents(render_frame_host)) 341 if (!navigation_state_.CanSendEvents(render_frame_host))
342 return; 342 return;
343 343
344 // A new navigation might have started before the old one completed. 344 // A new navigation might have started before the old one completed.
345 // Ignore the old navigation completion in that case. 345 // Ignore the old navigation completion in that case.
346 // srcdoc iframes will report a url of about:blank, still let it through. 346 if (navigation_state_.GetUrl(render_frame_host) != validated_url)
347 if (navigation_state_.GetUrl(render_frame_host) != validated_url &&
348 (navigation_state_.GetUrl(render_frame_host) !=
349 content::kAboutSrcDocURL ||
350 validated_url != url::kAboutBlankURL)) {
351 return; 347 return;
352 }
353 348
354 // The load might already have finished by the time we finished parsing. For 349 // The load might already have finished by the time we finished parsing. For
355 // compatibility reasons, we artifically delay the load completed signal until 350 // compatibility reasons, we artifically delay the load completed signal until
356 // after parsing was completed. 351 // after parsing was completed.
357 if (!navigation_state_.GetParsingFinished(render_frame_host)) 352 if (!navigation_state_.GetParsingFinished(render_frame_host))
358 return; 353 return;
359 helpers::DispatchOnCompleted(web_contents(), 354 helpers::DispatchOnCompleted(web_contents(),
360 render_frame_host, 355 render_frame_host,
361 navigation_state_.GetUrl(render_frame_host)); 356 navigation_state_.GetUrl(render_frame_host));
362 } 357 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 } 421 }
427 422
428 void WebNavigationTabObserver::HandleCommit( 423 void WebNavigationTabObserver::HandleCommit(
429 content::NavigationHandle* navigation_handle) { 424 content::NavigationHandle* navigation_handle) {
430 bool is_reference_fragment_navigation = IsReferenceFragmentNavigation( 425 bool is_reference_fragment_navigation = IsReferenceFragmentNavigation(
431 navigation_handle->GetRenderFrameHost(), navigation_handle->GetURL()); 426 navigation_handle->GetRenderFrameHost(), navigation_handle->GetURL());
432 427
433 navigation_state_.StartTrackingDocumentLoad( 428 navigation_state_.StartTrackingDocumentLoad(
434 navigation_handle->GetRenderFrameHost(), navigation_handle->GetURL(), 429 navigation_handle->GetRenderFrameHost(), navigation_handle->GetURL(),
435 navigation_handle->IsSamePage(), 430 navigation_handle->IsSamePage(),
436 false, // is_error_page 431 false); // is_error_page
437 navigation_handle->IsSrcdoc());
438 432
439 events::HistogramValue histogram_value = events::UNKNOWN; 433 events::HistogramValue histogram_value = events::UNKNOWN;
440 std::string event_name; 434 std::string event_name;
441 if (is_reference_fragment_navigation) { 435 if (is_reference_fragment_navigation) {
442 histogram_value = events::WEB_NAVIGATION_ON_REFERENCE_FRAGMENT_UPDATED; 436 histogram_value = events::WEB_NAVIGATION_ON_REFERENCE_FRAGMENT_UPDATED;
443 event_name = web_navigation::OnReferenceFragmentUpdated::kEventName; 437 event_name = web_navigation::OnReferenceFragmentUpdated::kEventName;
444 } else if (navigation_handle->IsSamePage()) { 438 } else if (navigation_handle->IsSamePage()) {
445 histogram_value = events::WEB_NAVIGATION_ON_HISTORY_STATE_UPDATED; 439 histogram_value = events::WEB_NAVIGATION_ON_HISTORY_STATE_UPDATED;
446 event_name = web_navigation::OnHistoryStateUpdated::kEventName; 440 event_name = web_navigation::OnHistoryStateUpdated::kEventName;
447 } else { 441 } else {
448 histogram_value = events::WEB_NAVIGATION_ON_COMMITTED; 442 histogram_value = events::WEB_NAVIGATION_ON_COMMITTED;
449 event_name = web_navigation::OnCommitted::kEventName; 443 event_name = web_navigation::OnCommitted::kEventName;
450 } 444 }
451 helpers::DispatchOnCommitted(histogram_value, event_name, navigation_handle); 445 helpers::DispatchOnCommitted(histogram_value, event_name, navigation_handle);
452 } 446 }
453 447
454 void WebNavigationTabObserver::HandleError( 448 void WebNavigationTabObserver::HandleError(
455 content::NavigationHandle* navigation_handle) { 449 content::NavigationHandle* navigation_handle) {
456 if (navigation_handle->HasCommitted()) { 450 if (navigation_handle->HasCommitted()) {
457 navigation_state_.StartTrackingDocumentLoad( 451 navigation_state_.StartTrackingDocumentLoad(
458 navigation_handle->GetRenderFrameHost(), navigation_handle->GetURL(), 452 navigation_handle->GetRenderFrameHost(), navigation_handle->GetURL(),
459 navigation_handle->IsSamePage(), 453 navigation_handle->IsSamePage(),
460 true, // is_error_page 454 true); // is_error_page
461 navigation_handle->IsSrcdoc());
462 } 455 }
463 456
464 helpers::DispatchOnErrorOccurred(navigation_handle); 457 helpers::DispatchOnErrorOccurred(navigation_handle);
465 } 458 }
466 459
467 // See also NavigationController::IsURLInPageNavigation. 460 // See also NavigationController::IsURLInPageNavigation.
468 bool WebNavigationTabObserver::IsReferenceFragmentNavigation( 461 bool WebNavigationTabObserver::IsReferenceFragmentNavigation(
469 content::RenderFrameHost* render_frame_host, 462 content::RenderFrameHost* render_frame_host,
470 const GURL& url) { 463 const GURL& url) {
471 GURL existing_url = navigation_state_.GetUrl(render_frame_host); 464 GURL existing_url = navigation_state_.GetUrl(render_frame_host);
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 return g_factory.Pointer(); 587 return g_factory.Pointer();
595 } 588 }
596 589
597 void WebNavigationAPI::OnListenerAdded(const EventListenerInfo& details) { 590 void WebNavigationAPI::OnListenerAdded(const EventListenerInfo& details) {
598 web_navigation_event_router_.reset(new WebNavigationEventRouter( 591 web_navigation_event_router_.reset(new WebNavigationEventRouter(
599 Profile::FromBrowserContext(browser_context_))); 592 Profile::FromBrowserContext(browser_context_)));
600 EventRouter::Get(browser_context_)->UnregisterObserver(this); 593 EventRouter::Get(browser_context_)->UnregisterObserver(this);
601 } 594 }
602 595
603 } // namespace extensions 596 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698