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

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

Issue 2494633004: 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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 // that weren't reguarly loaded. 313 // that weren't reguarly loaded.
314 if (!navigation_state_.IsValidFrame(render_frame_host)) 314 if (!navigation_state_.IsValidFrame(render_frame_host))
315 return; 315 return;
316 316
317 navigation_state_.SetDocumentLoadCompleted(render_frame_host); 317 navigation_state_.SetDocumentLoadCompleted(render_frame_host);
318 if (!navigation_state_.CanSendEvents(render_frame_host)) 318 if (!navigation_state_.CanSendEvents(render_frame_host))
319 return; 319 return;
320 320
321 // A new navigation might have started before the old one completed. 321 // A new navigation might have started before the old one completed.
322 // Ignore the old navigation completion in that case. 322 // Ignore the old navigation completion in that case.
323 // srcdoc iframes will report a url of about:blank, still let it through. 323 if (navigation_state_.GetUrl(render_frame_host) != validated_url)
324 if (navigation_state_.GetUrl(render_frame_host) != validated_url &&
325 (navigation_state_.GetUrl(render_frame_host) !=
326 content::kAboutSrcDocURL ||
327 validated_url != url::kAboutBlankURL)) {
328 return; 324 return;
329 }
330 325
331 // The load might already have finished by the time we finished parsing. For 326 // The load might already have finished by the time we finished parsing. For
332 // compatibility reasons, we artifically delay the load completed signal until 327 // compatibility reasons, we artifically delay the load completed signal until
333 // after parsing was completed. 328 // after parsing was completed.
334 if (!navigation_state_.GetParsingFinished(render_frame_host)) 329 if (!navigation_state_.GetParsingFinished(render_frame_host))
335 return; 330 return;
336 helpers::DispatchOnCompleted(web_contents(), 331 helpers::DispatchOnCompleted(web_contents(),
337 render_frame_host, 332 render_frame_host,
338 navigation_state_.GetUrl(render_frame_host)); 333 navigation_state_.GetUrl(render_frame_host));
339 } 334 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 } 387 }
393 388
394 void WebNavigationTabObserver::HandleCommit( 389 void WebNavigationTabObserver::HandleCommit(
395 content::NavigationHandle* navigation_handle) { 390 content::NavigationHandle* navigation_handle) {
396 bool is_reference_fragment_navigation = IsReferenceFragmentNavigation( 391 bool is_reference_fragment_navigation = IsReferenceFragmentNavigation(
397 navigation_handle->GetRenderFrameHost(), navigation_handle->GetURL()); 392 navigation_handle->GetRenderFrameHost(), navigation_handle->GetURL());
398 393
399 navigation_state_.StartTrackingDocumentLoad( 394 navigation_state_.StartTrackingDocumentLoad(
400 navigation_handle->GetRenderFrameHost(), navigation_handle->GetURL(), 395 navigation_handle->GetRenderFrameHost(), navigation_handle->GetURL(),
401 navigation_handle->IsSamePage(), 396 navigation_handle->IsSamePage(),
402 false, // is_error_page 397 false); // is_error_page
403 navigation_handle->IsSrcdoc());
404 398
405 events::HistogramValue histogram_value = events::UNKNOWN; 399 events::HistogramValue histogram_value = events::UNKNOWN;
406 std::string event_name; 400 std::string event_name;
407 if (is_reference_fragment_navigation) { 401 if (is_reference_fragment_navigation) {
408 histogram_value = events::WEB_NAVIGATION_ON_REFERENCE_FRAGMENT_UPDATED; 402 histogram_value = events::WEB_NAVIGATION_ON_REFERENCE_FRAGMENT_UPDATED;
409 event_name = web_navigation::OnReferenceFragmentUpdated::kEventName; 403 event_name = web_navigation::OnReferenceFragmentUpdated::kEventName;
410 } else if (navigation_handle->IsSamePage()) { 404 } else if (navigation_handle->IsSamePage()) {
411 histogram_value = events::WEB_NAVIGATION_ON_HISTORY_STATE_UPDATED; 405 histogram_value = events::WEB_NAVIGATION_ON_HISTORY_STATE_UPDATED;
412 event_name = web_navigation::OnHistoryStateUpdated::kEventName; 406 event_name = web_navigation::OnHistoryStateUpdated::kEventName;
413 } else { 407 } else {
414 histogram_value = events::WEB_NAVIGATION_ON_COMMITTED; 408 histogram_value = events::WEB_NAVIGATION_ON_COMMITTED;
415 event_name = web_navigation::OnCommitted::kEventName; 409 event_name = web_navigation::OnCommitted::kEventName;
416 } 410 }
417 helpers::DispatchOnCommitted(histogram_value, event_name, navigation_handle); 411 helpers::DispatchOnCommitted(histogram_value, event_name, navigation_handle);
418 } 412 }
419 413
420 void WebNavigationTabObserver::HandleError( 414 void WebNavigationTabObserver::HandleError(
421 content::NavigationHandle* navigation_handle) { 415 content::NavigationHandle* navigation_handle) {
422 if (navigation_handle->HasCommitted()) { 416 if (navigation_handle->HasCommitted()) {
423 navigation_state_.StartTrackingDocumentLoad( 417 navigation_state_.StartTrackingDocumentLoad(
424 navigation_handle->GetRenderFrameHost(), navigation_handle->GetURL(), 418 navigation_handle->GetRenderFrameHost(), navigation_handle->GetURL(),
425 navigation_handle->IsSamePage(), 419 navigation_handle->IsSamePage(),
426 true, // is_error_page 420 true); // is_error_page
427 navigation_handle->IsSrcdoc());
428 } 421 }
429 422
430 helpers::DispatchOnErrorOccurred(navigation_handle); 423 helpers::DispatchOnErrorOccurred(navigation_handle);
431 } 424 }
432 425
433 // See also NavigationController::IsURLInPageNavigation. 426 // See also NavigationController::IsURLInPageNavigation.
434 bool WebNavigationTabObserver::IsReferenceFragmentNavigation( 427 bool WebNavigationTabObserver::IsReferenceFragmentNavigation(
435 content::RenderFrameHost* render_frame_host, 428 content::RenderFrameHost* render_frame_host,
436 const GURL& url) { 429 const GURL& url) {
437 GURL existing_url = navigation_state_.GetUrl(render_frame_host); 430 GURL existing_url = navigation_state_.GetUrl(render_frame_host);
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 return g_factory.Pointer(); 553 return g_factory.Pointer();
561 } 554 }
562 555
563 void WebNavigationAPI::OnListenerAdded(const EventListenerInfo& details) { 556 void WebNavigationAPI::OnListenerAdded(const EventListenerInfo& details) {
564 web_navigation_event_router_.reset(new WebNavigationEventRouter( 557 web_navigation_event_router_.reset(new WebNavigationEventRouter(
565 Profile::FromBrowserContext(browser_context_))); 558 Profile::FromBrowserContext(browser_context_)));
566 EventRouter::Get(browser_context_)->UnregisterObserver(this); 559 EventRouter::Get(browser_context_)->UnregisterObserver(this);
567 } 560 }
568 561
569 } // namespace extensions 562 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698