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

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

Issue 2716493004: Renamed NavigationHandle::IsSamePage to NavigationHandle::IsSameDocument (Closed)
Patch Set: Rebased Created 3 years, 9 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
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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 if (old_host) { 247 if (old_host) {
248 RenderFrameDeleted(old_host); 248 RenderFrameDeleted(old_host);
249 navigation_state_.FrameHostDeleted(old_host); 249 navigation_state_.FrameHostDeleted(old_host);
250 } 250 }
251 251
252 navigation_state_.FrameHostCreated(new_host); 252 navigation_state_.FrameHostCreated(new_host);
253 } 253 }
254 254
255 void WebNavigationTabObserver::DidStartNavigation( 255 void WebNavigationTabObserver::DidStartNavigation(
256 content::NavigationHandle* navigation_handle) { 256 content::NavigationHandle* navigation_handle) {
257 if (navigation_handle->IsSamePage() || 257 if (navigation_handle->IsSameDocument() ||
258 !FrameNavigationState::IsValidUrl(navigation_handle->GetURL())) { 258 !FrameNavigationState::IsValidUrl(navigation_handle->GetURL())) {
259 return; 259 return;
260 } 260 }
261 261
262 pending_on_before_navigate_event_ = 262 pending_on_before_navigate_event_ =
263 helpers::CreateOnBeforeNavigateEvent(navigation_handle); 263 helpers::CreateOnBeforeNavigateEvent(navigation_handle);
264 264
265 // Only dispatch the onBeforeNavigate event if the associated WebContents 265 // Only dispatch the onBeforeNavigate event if the associated WebContents
266 // is already added to the tab strip. Otherwise the event should be delayed 266 // is already added to the tab strip. Otherwise the event should be delayed
267 // and sent after the addition, to preserve the ordering of events. 267 // and sent after the addition, to preserve the ordering of events.
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 event_router->BroadcastEvent(std::move(pending_on_before_navigate_event_)); 415 event_router->BroadcastEvent(std::move(pending_on_before_navigate_event_));
416 } 416 }
417 417
418 void WebNavigationTabObserver::HandleCommit( 418 void WebNavigationTabObserver::HandleCommit(
419 content::NavigationHandle* navigation_handle) { 419 content::NavigationHandle* navigation_handle) {
420 bool is_reference_fragment_navigation = IsReferenceFragmentNavigation( 420 bool is_reference_fragment_navigation = IsReferenceFragmentNavigation(
421 navigation_handle->GetRenderFrameHost(), navigation_handle->GetURL()); 421 navigation_handle->GetRenderFrameHost(), navigation_handle->GetURL());
422 422
423 navigation_state_.StartTrackingDocumentLoad( 423 navigation_state_.StartTrackingDocumentLoad(
424 navigation_handle->GetRenderFrameHost(), navigation_handle->GetURL(), 424 navigation_handle->GetRenderFrameHost(), navigation_handle->GetURL(),
425 navigation_handle->IsSamePage(), 425 navigation_handle->IsSameDocument(),
426 false); // is_error_page 426 false); // is_error_page
427 427
428 events::HistogramValue histogram_value = events::UNKNOWN; 428 events::HistogramValue histogram_value = events::UNKNOWN;
429 std::string event_name; 429 std::string event_name;
430 if (is_reference_fragment_navigation) { 430 if (is_reference_fragment_navigation) {
431 histogram_value = events::WEB_NAVIGATION_ON_REFERENCE_FRAGMENT_UPDATED; 431 histogram_value = events::WEB_NAVIGATION_ON_REFERENCE_FRAGMENT_UPDATED;
432 event_name = web_navigation::OnReferenceFragmentUpdated::kEventName; 432 event_name = web_navigation::OnReferenceFragmentUpdated::kEventName;
433 } else if (navigation_handle->IsSamePage()) { 433 } else if (navigation_handle->IsSameDocument()) {
434 histogram_value = events::WEB_NAVIGATION_ON_HISTORY_STATE_UPDATED; 434 histogram_value = events::WEB_NAVIGATION_ON_HISTORY_STATE_UPDATED;
435 event_name = web_navigation::OnHistoryStateUpdated::kEventName; 435 event_name = web_navigation::OnHistoryStateUpdated::kEventName;
436 } else { 436 } else {
437 histogram_value = events::WEB_NAVIGATION_ON_COMMITTED; 437 histogram_value = events::WEB_NAVIGATION_ON_COMMITTED;
438 event_name = web_navigation::OnCommitted::kEventName; 438 event_name = web_navigation::OnCommitted::kEventName;
439 } 439 }
440 helpers::DispatchOnCommitted(histogram_value, event_name, navigation_handle); 440 helpers::DispatchOnCommitted(histogram_value, event_name, navigation_handle);
441 } 441 }
442 442
443 void WebNavigationTabObserver::HandleError( 443 void WebNavigationTabObserver::HandleError(
444 content::NavigationHandle* navigation_handle) { 444 content::NavigationHandle* navigation_handle) {
445 if (navigation_handle->HasCommitted()) { 445 if (navigation_handle->HasCommitted()) {
446 navigation_state_.StartTrackingDocumentLoad( 446 navigation_state_.StartTrackingDocumentLoad(
447 navigation_handle->GetRenderFrameHost(), navigation_handle->GetURL(), 447 navigation_handle->GetRenderFrameHost(), navigation_handle->GetURL(),
448 navigation_handle->IsSamePage(), 448 navigation_handle->IsSameDocument(),
449 true); // is_error_page 449 true); // is_error_page
450 } 450 }
451 451
452 helpers::DispatchOnErrorOccurred(navigation_handle); 452 helpers::DispatchOnErrorOccurred(navigation_handle);
453 } 453 }
454 454
455 // See also NavigationController::IsURLInPageNavigation. 455 // See also NavigationController::IsURLInPageNavigation.
456 bool WebNavigationTabObserver::IsReferenceFragmentNavigation( 456 bool WebNavigationTabObserver::IsReferenceFragmentNavigation(
457 content::RenderFrameHost* render_frame_host, 457 content::RenderFrameHost* render_frame_host,
458 const GURL& url) { 458 const GURL& url) {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 return g_factory.Pointer(); 582 return g_factory.Pointer();
583 } 583 }
584 584
585 void WebNavigationAPI::OnListenerAdded(const EventListenerInfo& details) { 585 void WebNavigationAPI::OnListenerAdded(const EventListenerInfo& details) {
586 web_navigation_event_router_.reset(new WebNavigationEventRouter( 586 web_navigation_event_router_.reset(new WebNavigationEventRouter(
587 Profile::FromBrowserContext(browser_context_))); 587 Profile::FromBrowserContext(browser_context_)));
588 EventRouter::Get(browser_context_)->UnregisterObserver(this); 588 EventRouter::Get(browser_context_)->UnregisterObserver(this);
589 } 589 }
590 590
591 } // namespace extensions 591 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698