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

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 3374 matching lines...) Expand 10 before | Expand all | Expand 10 after
3385 if (delegate_) 3385 if (delegate_)
3386 delegate_->ShowRepostFormWarningDialog(this); 3386 delegate_->ShowRepostFormWarningDialog(this);
3387 } 3387 }
3388 3388
3389 bool WebContentsImpl::HasAccessedInitialDocument() { 3389 bool WebContentsImpl::HasAccessedInitialDocument() {
3390 return has_accessed_initial_document_; 3390 return has_accessed_initial_document_;
3391 } 3391 }
3392 3392
3393 // Notifies the RenderWidgetHost instance about the fact that the page is 3393 // Notifies the RenderWidgetHost instance about the fact that the page is
3394 // loading, or done loading. 3394 // loading, or done loading.
3395 void WebContentsImpl::SetIsLoading(RenderViewHost* render_view_host, 3395 void WebContentsImpl::SetIsLoading(bool is_loading,
3396 bool is_loading,
3397 bool to_different_document, 3396 bool to_different_document,
3398 LoadNotificationDetails* details) { 3397 LoadNotificationDetails* details) {
3399 if (is_loading == is_loading_) 3398 if (is_loading == is_loading_)
3400 return; 3399 return;
3401 3400
3402 if (!is_loading) { 3401 if (!is_loading) {
3403 load_state_ = net::LoadStateWithParam(net::LOAD_STATE_IDLE, 3402 load_state_ = net::LoadStateWithParam(net::LOAD_STATE_IDLE,
3404 base::string16()); 3403 base::string16());
3405 load_state_host_.clear(); 3404 load_state_host_.clear();
3406 upload_size_ = 0; 3405 upload_size_ = 0;
3407 upload_position_ = 0; 3406 upload_position_ = 0;
3408 } 3407 }
3409 3408
3410 GetRenderManager()->SetIsLoading(is_loading); 3409 GetRenderManager()->SetIsLoading(is_loading);
3411 3410
3412 is_loading_ = is_loading; 3411 is_loading_ = is_loading;
3413 waiting_for_response_ = is_loading; 3412 waiting_for_response_ = is_loading;
3414 is_load_to_different_document_ = to_different_document; 3413 is_load_to_different_document_ = to_different_document;
3415 3414
3416 if (delegate_) 3415 if (delegate_)
3417 delegate_->LoadingStateChanged(this, to_different_document); 3416 delegate_->LoadingStateChanged(this, to_different_document);
3418 NotifyNavigationStateChanged(INVALIDATE_TYPE_LOAD); 3417 NotifyNavigationStateChanged(INVALIDATE_TYPE_LOAD);
3419 3418
3420 std::string url = (details ? details->url.possibly_invalid_spec() : "NULL"); 3419 std::string url = (details ? details->url.possibly_invalid_spec() : "NULL");
3421 if (is_loading) { 3420 if (is_loading) {
3422 TRACE_EVENT_ASYNC_BEGIN1("browser,navigation", "WebContentsImpl Loading", 3421 TRACE_EVENT_ASYNC_BEGIN1("browser,navigation", "WebContentsImpl Loading",
3423 this, "URL", url); 3422 this, "URL", url);
3424 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 3423 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidStartLoading());
3425 DidStartLoading(render_view_host));
3426 } else { 3424 } else {
3427 TRACE_EVENT_ASYNC_END1("browser,navigation", "WebContentsImpl Loading", 3425 TRACE_EVENT_ASYNC_END1("browser,navigation", "WebContentsImpl Loading",
3428 this, "URL", url); 3426 this, "URL", url);
3429 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 3427 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidStopLoading());
3430 DidStopLoading(render_view_host));
3431 } 3428 }
3432 3429
3433 // TODO(avi): Remove. http://crbug.com/170921 3430 // TODO(avi): Remove. http://crbug.com/170921
3434 int type = is_loading ? NOTIFICATION_LOAD_START : NOTIFICATION_LOAD_STOP; 3431 int type = is_loading ? NOTIFICATION_LOAD_START : NOTIFICATION_LOAD_STOP;
3435 NotificationDetails det = NotificationService::NoDetails(); 3432 NotificationDetails det = NotificationService::NoDetails();
3436 if (details) 3433 if (details)
3437 det = Details<LoadNotificationDetails>(details); 3434 det = Details<LoadNotificationDetails>(details);
3438 NotificationService::current()->Notify( 3435 NotificationService::current()->Notify(
3439 type, Source<NavigationController>(&controller_), det); 3436 type, Source<NavigationController>(&controller_), det);
3440 } 3437 }
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
3828 if (IsFullscreenForCurrentTab()) 3825 if (IsFullscreenForCurrentTab())
3829 ExitFullscreenMode(); 3826 ExitFullscreenMode();
3830 3827
3831 // Cancel any visible dialogs so they are not left dangling over the sad tab. 3828 // Cancel any visible dialogs so they are not left dangling over the sad tab.
3832 if (dialog_manager_) 3829 if (dialog_manager_)
3833 dialog_manager_->CancelActiveAndPendingDialogs(this); 3830 dialog_manager_->CancelActiveAndPendingDialogs(this);
3834 3831
3835 if (delegate_) 3832 if (delegate_)
3836 delegate_->HideValidationMessage(this); 3833 delegate_->HideValidationMessage(this);
3837 3834
3838 SetIsLoading(rvh, false, true, NULL); 3835 SetIsLoading(false, true, nullptr);
3839 NotifyDisconnected(); 3836 NotifyDisconnected();
3840 SetIsCrashed(status, error_code); 3837 SetIsCrashed(status, error_code);
3841 3838
3842 // Reset the loading progress. TODO(avi): What does it mean to have a 3839 // Reset the loading progress. TODO(avi): What does it mean to have a
3843 // "renderer crash" when there is more than one renderer process serving a 3840 // "renderer crash" when there is more than one renderer process serving a
3844 // webpage? Once this function is called at a more granular frame level, we 3841 // webpage? Once this function is called at a more granular frame level, we
3845 // probably will need to more granularly reset the state here. 3842 // probably will need to more granularly reset the state here.
3846 ResetLoadProgressState(); 3843 ResetLoadProgressState();
3847 3844
3848 FOR_EACH_OBSERVER(WebContentsObserver, 3845 FOR_EACH_OBSERVER(WebContentsObserver,
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
3936 #endif 3933 #endif
3937 } 3934 }
3938 3935
3939 void WebContentsImpl::RequestMove(const gfx::Rect& new_bounds) { 3936 void WebContentsImpl::RequestMove(const gfx::Rect& new_bounds) {
3940 if (delegate_ && delegate_->IsPopupOrPanel(this)) 3937 if (delegate_ && delegate_->IsPopupOrPanel(this))
3941 delegate_->MoveContents(this, new_bounds); 3938 delegate_->MoveContents(this, new_bounds);
3942 } 3939 }
3943 3940
3944 void WebContentsImpl::DidStartLoading(RenderFrameHost* render_frame_host, 3941 void WebContentsImpl::DidStartLoading(RenderFrameHost* render_frame_host,
3945 bool to_different_document) { 3942 bool to_different_document) {
3946 SetIsLoading(render_frame_host->GetRenderViewHost(), true, 3943 SetIsLoading(true, to_different_document, nullptr);
3947 to_different_document, NULL);
3948 3944
3949 // Notify accessibility that the user is navigating away from the 3945 // Notify accessibility that the user is navigating away from the
3950 // current document. 3946 // current document.
3951 // 3947 //
3952 // TODO(dmazzoni): do this using a WebContentsObserver. 3948 // TODO(dmazzoni): do this using a WebContentsObserver.
3953 FrameTreeNode* ftn = static_cast<RenderFrameHostImpl*>(render_frame_host)-> 3949 FrameTreeNode* ftn = static_cast<RenderFrameHostImpl*>(render_frame_host)->
3954 frame_tree_node(); 3950 frame_tree_node();
3955 BrowserAccessibilityManager* manager = 3951 BrowserAccessibilityManager* manager =
3956 ftn->current_frame_host()->browser_accessibility_manager(); 3952 ftn->current_frame_host()->browser_accessibility_manager();
3957 if (manager) 3953 if (manager)
(...skipping 15 matching lines...) Expand all
3973 base::TimeTicks::Now() - navigator->GetCurrentLoadStart(); 3969 base::TimeTicks::Now() - navigator->GetCurrentLoadStart();
3974 3970
3975 details.reset(new LoadNotificationDetails( 3971 details.reset(new LoadNotificationDetails(
3976 entry->GetVirtualURL(), 3972 entry->GetVirtualURL(),
3977 entry->GetTransitionType(), 3973 entry->GetTransitionType(),
3978 elapsed, 3974 elapsed,
3979 &controller_, 3975 &controller_,
3980 controller_.GetCurrentEntryIndex())); 3976 controller_.GetCurrentEntryIndex()));
3981 } 3977 }
3982 3978
3983 SetIsLoading(render_frame_host->GetRenderViewHost(), false, true, 3979 SetIsLoading(false, true, details.get());
3984 details.get());
3985 } 3980 }
3986 3981
3987 void WebContentsImpl::DidCancelLoading() { 3982 void WebContentsImpl::DidCancelLoading() {
3988 controller_.DiscardNonCommittedEntries(); 3983 controller_.DiscardNonCommittedEntries();
3989 3984
3990 // Update the URL display. 3985 // Update the URL display.
3991 NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); 3986 NotifyNavigationStateChanged(INVALIDATE_TYPE_URL);
3992 } 3987 }
3993 3988
3994 void WebContentsImpl::DidAccessInitialDocument() { 3989 void WebContentsImpl::DidAccessInitialDocument() {
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
4652 node->render_manager()->ResumeResponseDeferredAtStart(); 4647 node->render_manager()->ResumeResponseDeferredAtStart();
4653 } 4648 }
4654 4649
4655 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { 4650 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) {
4656 force_disable_overscroll_content_ = force_disable; 4651 force_disable_overscroll_content_ = force_disable;
4657 if (view_) 4652 if (view_)
4658 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); 4653 view_->SetOverscrollControllerEnabled(CanOverscrollContent());
4659 } 4654 }
4660 4655
4661 } // namespace content 4656 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/browser/web_contents/web_contents_impl_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698