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

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 1008913002: Remove RenderViewHost parameter from WebContentsObserver::Did{Start|Stop}Loading. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 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 #include "content/browser/web_contents/web_contents_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 3370 matching lines...) Expand 10 before | Expand all | Expand 10 after
3381 if (delegate_) 3381 if (delegate_)
3382 delegate_->ShowRepostFormWarningDialog(this); 3382 delegate_->ShowRepostFormWarningDialog(this);
3383 } 3383 }
3384 3384
3385 bool WebContentsImpl::HasAccessedInitialDocument() { 3385 bool WebContentsImpl::HasAccessedInitialDocument() {
3386 return has_accessed_initial_document_; 3386 return has_accessed_initial_document_;
3387 } 3387 }
3388 3388
3389 // Notifies the RenderWidgetHost instance about the fact that the page is 3389 // Notifies the RenderWidgetHost instance about the fact that the page is
3390 // loading, or done loading. 3390 // loading, or done loading.
3391 void WebContentsImpl::SetIsLoading(RenderViewHost* render_view_host, 3391 void WebContentsImpl::SetIsLoading(bool is_loading,
3392 bool is_loading,
3393 bool to_different_document, 3392 bool to_different_document,
3394 LoadNotificationDetails* details) { 3393 LoadNotificationDetails* details) {
3395 if (is_loading == is_loading_) 3394 if (is_loading == is_loading_)
3396 return; 3395 return;
3397 3396
3398 if (!is_loading) { 3397 if (!is_loading) {
3399 load_state_ = net::LoadStateWithParam(net::LOAD_STATE_IDLE, 3398 load_state_ = net::LoadStateWithParam(net::LOAD_STATE_IDLE,
3400 base::string16()); 3399 base::string16());
3401 load_state_host_.clear(); 3400 load_state_host_.clear();
3402 upload_size_ = 0; 3401 upload_size_ = 0;
3403 upload_position_ = 0; 3402 upload_position_ = 0;
3404 } 3403 }
3405 3404
3406 GetRenderManager()->SetIsLoading(is_loading); 3405 GetRenderManager()->SetIsLoading(is_loading);
3407 3406
3408 is_loading_ = is_loading; 3407 is_loading_ = is_loading;
3409 waiting_for_response_ = is_loading; 3408 waiting_for_response_ = is_loading;
3410 is_load_to_different_document_ = to_different_document; 3409 is_load_to_different_document_ = to_different_document;
3411 3410
3412 if (delegate_) 3411 if (delegate_)
3413 delegate_->LoadingStateChanged(this, to_different_document); 3412 delegate_->LoadingStateChanged(this, to_different_document);
3414 NotifyNavigationStateChanged(INVALIDATE_TYPE_LOAD); 3413 NotifyNavigationStateChanged(INVALIDATE_TYPE_LOAD);
3415 3414
3416 std::string url = (details ? details->url.possibly_invalid_spec() : "NULL"); 3415 std::string url = (details ? details->url.possibly_invalid_spec() : "NULL");
3417 if (is_loading) { 3416 if (is_loading) {
3418 TRACE_EVENT_ASYNC_BEGIN1("browser,navigation", "WebContentsImpl Loading", 3417 TRACE_EVENT_ASYNC_BEGIN1("browser,navigation", "WebContentsImpl Loading",
3419 this, "URL", url); 3418 this, "URL", url);
3420 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 3419 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidStartLoading());
3421 DidStartLoading(render_view_host));
3422 } else { 3420 } else {
3423 TRACE_EVENT_ASYNC_END1("browser,navigation", "WebContentsImpl Loading", 3421 TRACE_EVENT_ASYNC_END1("browser,navigation", "WebContentsImpl Loading",
3424 this, "URL", url); 3422 this, "URL", url);
3425 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 3423 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidStopLoading());
3426 DidStopLoading(render_view_host));
3427 } 3424 }
3428 3425
3429 // TODO(avi): Remove. http://crbug.com/170921 3426 // TODO(avi): Remove. http://crbug.com/170921
3430 int type = is_loading ? NOTIFICATION_LOAD_START : NOTIFICATION_LOAD_STOP; 3427 int type = is_loading ? NOTIFICATION_LOAD_START : NOTIFICATION_LOAD_STOP;
3431 NotificationDetails det = NotificationService::NoDetails(); 3428 NotificationDetails det = NotificationService::NoDetails();
3432 if (details) 3429 if (details)
3433 det = Details<LoadNotificationDetails>(details); 3430 det = Details<LoadNotificationDetails>(details);
3434 NotificationService::current()->Notify( 3431 NotificationService::current()->Notify(
3435 type, Source<NavigationController>(&controller_), det); 3432 type, Source<NavigationController>(&controller_), det);
3436 } 3433 }
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
3824 if (IsFullscreenForCurrentTab()) 3821 if (IsFullscreenForCurrentTab())
3825 ExitFullscreenMode(); 3822 ExitFullscreenMode();
3826 3823
3827 // Cancel any visible dialogs so they are not left dangling over the sad tab. 3824 // Cancel any visible dialogs so they are not left dangling over the sad tab.
3828 if (dialog_manager_) 3825 if (dialog_manager_)
3829 dialog_manager_->CancelActiveAndPendingDialogs(this); 3826 dialog_manager_->CancelActiveAndPendingDialogs(this);
3830 3827
3831 if (delegate_) 3828 if (delegate_)
3832 delegate_->HideValidationMessage(this); 3829 delegate_->HideValidationMessage(this);
3833 3830
3834 SetIsLoading(rvh, false, true, NULL); 3831 SetIsLoading(false, true, NULL);
nasko 2015/03/14 00:01:04 nit: nullptr
Fabrice (no longer in Chrome) 2015/03/16 11:01:46 Done.
3835 NotifyDisconnected(); 3832 NotifyDisconnected();
3836 SetIsCrashed(status, error_code); 3833 SetIsCrashed(status, error_code);
3837 3834
3838 // Reset the loading progress. TODO(avi): What does it mean to have a 3835 // Reset the loading progress. TODO(avi): What does it mean to have a
3839 // "renderer crash" when there is more than one renderer process serving a 3836 // "renderer crash" when there is more than one renderer process serving a
3840 // webpage? Once this function is called at a more granular frame level, we 3837 // webpage? Once this function is called at a more granular frame level, we
3841 // probably will need to more granularly reset the state here. 3838 // probably will need to more granularly reset the state here.
3842 ResetLoadProgressState(); 3839 ResetLoadProgressState();
3843 3840
3844 FOR_EACH_OBSERVER(WebContentsObserver, 3841 FOR_EACH_OBSERVER(WebContentsObserver,
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
3932 #endif 3929 #endif
3933 } 3930 }
3934 3931
3935 void WebContentsImpl::RequestMove(const gfx::Rect& new_bounds) { 3932 void WebContentsImpl::RequestMove(const gfx::Rect& new_bounds) {
3936 if (delegate_ && delegate_->IsPopupOrPanel(this)) 3933 if (delegate_ && delegate_->IsPopupOrPanel(this))
3937 delegate_->MoveContents(this, new_bounds); 3934 delegate_->MoveContents(this, new_bounds);
3938 } 3935 }
3939 3936
3940 void WebContentsImpl::DidStartLoading(RenderFrameHost* render_frame_host, 3937 void WebContentsImpl::DidStartLoading(RenderFrameHost* render_frame_host,
3941 bool to_different_document) { 3938 bool to_different_document) {
3942 SetIsLoading(render_frame_host->GetRenderViewHost(), true, 3939 SetIsLoading(true, to_different_document, NULL);
nasko 2015/03/14 00:01:04 nit: nullptr
Fabrice (no longer in Chrome) 2015/03/16 11:01:46 Done.
3943 to_different_document, NULL);
3944 3940
3945 // Notify accessibility that the user is navigating away from the 3941 // Notify accessibility that the user is navigating away from the
3946 // current document. 3942 // current document.
3947 // 3943 //
3948 // TODO(dmazzoni): do this using a WebContentsObserver. 3944 // TODO(dmazzoni): do this using a WebContentsObserver.
3949 FrameTreeNode* ftn = static_cast<RenderFrameHostImpl*>(render_frame_host)-> 3945 FrameTreeNode* ftn = static_cast<RenderFrameHostImpl*>(render_frame_host)->
3950 frame_tree_node(); 3946 frame_tree_node();
3951 BrowserAccessibilityManager* manager = 3947 BrowserAccessibilityManager* manager =
3952 ftn->current_frame_host()->browser_accessibility_manager(); 3948 ftn->current_frame_host()->browser_accessibility_manager();
3953 if (manager) 3949 if (manager)
(...skipping 15 matching lines...) Expand all
3969 base::TimeTicks::Now() - navigator->GetCurrentLoadStart(); 3965 base::TimeTicks::Now() - navigator->GetCurrentLoadStart();
3970 3966
3971 details.reset(new LoadNotificationDetails( 3967 details.reset(new LoadNotificationDetails(
3972 entry->GetVirtualURL(), 3968 entry->GetVirtualURL(),
3973 entry->GetTransitionType(), 3969 entry->GetTransitionType(),
3974 elapsed, 3970 elapsed,
3975 &controller_, 3971 &controller_,
3976 controller_.GetCurrentEntryIndex())); 3972 controller_.GetCurrentEntryIndex()));
3977 } 3973 }
3978 3974
3979 SetIsLoading(render_frame_host->GetRenderViewHost(), false, true, 3975 SetIsLoading(false, true, details.get());
3980 details.get());
3981 } 3976 }
3982 3977
3983 void WebContentsImpl::DidCancelLoading() { 3978 void WebContentsImpl::DidCancelLoading() {
3984 controller_.DiscardNonCommittedEntries(); 3979 controller_.DiscardNonCommittedEntries();
3985 3980
3986 // Update the URL display. 3981 // Update the URL display.
3987 NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); 3982 NotifyNavigationStateChanged(INVALIDATE_TYPE_URL);
3988 } 3983 }
3989 3984
3990 void WebContentsImpl::DidAccessInitialDocument() { 3985 void WebContentsImpl::DidAccessInitialDocument() {
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
4648 node->render_manager()->ResumeResponseDeferredAtStart(); 4643 node->render_manager()->ResumeResponseDeferredAtStart();
4649 } 4644 }
4650 4645
4651 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { 4646 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) {
4652 force_disable_overscroll_content_ = force_disable; 4647 force_disable_overscroll_content_ = force_disable;
4653 if (view_) 4648 if (view_)
4654 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); 4649 view_->SetOverscrollControllerEnabled(CanOverscrollContent());
4655 } 4650 }
4656 4651
4657 } // namespace content 4652 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698