OLD | NEW |
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/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 2565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2576 void WebContentsImpl::SwappedOut(RenderViewHost* rvh) { | 2576 void WebContentsImpl::SwappedOut(RenderViewHost* rvh) { |
2577 if (delegate_ && rvh == GetRenderViewHost()) | 2577 if (delegate_ && rvh == GetRenderViewHost()) |
2578 delegate_->SwappedOut(this); | 2578 delegate_->SwappedOut(this); |
2579 } | 2579 } |
2580 | 2580 |
2581 void WebContentsImpl::RequestMove(const gfx::Rect& new_bounds) { | 2581 void WebContentsImpl::RequestMove(const gfx::Rect& new_bounds) { |
2582 if (delegate_ && delegate_->IsPopupOrPanel(this)) | 2582 if (delegate_ && delegate_->IsPopupOrPanel(this)) |
2583 delegate_->MoveContents(this, new_bounds); | 2583 delegate_->MoveContents(this, new_bounds); |
2584 } | 2584 } |
2585 | 2585 |
2586 void WebContentsImpl::DidStartLoading() { | 2586 void WebContentsImpl::DidStartLoading( |
| 2587 content::RenderViewHost* render_view_host) { |
2587 SetIsLoading(true, NULL); | 2588 SetIsLoading(true, NULL); |
2588 | 2589 |
2589 if (delegate_ && content_restrictions_) | 2590 if (delegate_ && content_restrictions_) |
2590 OnUpdateContentRestrictions(0); | 2591 OnUpdateContentRestrictions(0); |
2591 | 2592 |
2592 // Notify observers about navigation. | 2593 // Notify observers about navigation. |
2593 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidStartLoading()); | 2594 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 2595 DidStartLoading(render_view_host)); |
2594 } | 2596 } |
2595 | 2597 |
2596 void WebContentsImpl::DidStopLoading() { | 2598 void WebContentsImpl::DidStopLoading( |
| 2599 content::RenderViewHost* render_view_host) { |
2597 scoped_ptr<LoadNotificationDetails> details; | 2600 scoped_ptr<LoadNotificationDetails> details; |
2598 | 2601 |
2599 NavigationEntry* entry = controller_.GetActiveEntry(); | 2602 NavigationEntry* entry = controller_.GetActiveEntry(); |
2600 // An entry may not exist for a stop when loading an initial blank page or | 2603 // An entry may not exist for a stop when loading an initial blank page or |
2601 // if an iframe injected by script into a blank page finishes loading. | 2604 // if an iframe injected by script into a blank page finishes loading. |
2602 if (entry) { | 2605 if (entry) { |
2603 base::TimeDelta elapsed = base::TimeTicks::Now() - current_load_start_; | 2606 base::TimeDelta elapsed = base::TimeTicks::Now() - current_load_start_; |
2604 | 2607 |
2605 details.reset(new LoadNotificationDetails( | 2608 details.reset(new LoadNotificationDetails( |
2606 entry->GetVirtualURL(), | 2609 entry->GetVirtualURL(), |
2607 entry->GetTransitionType(), | 2610 entry->GetTransitionType(), |
2608 elapsed, | 2611 elapsed, |
2609 &controller_, | 2612 &controller_, |
2610 controller_.GetCurrentEntryIndex())); | 2613 controller_.GetCurrentEntryIndex())); |
2611 } | 2614 } |
2612 | 2615 |
2613 SetIsLoading(false, details.get()); | 2616 SetIsLoading(false, details.get()); |
2614 | 2617 |
2615 // Notify observers about navigation. | 2618 // Notify observers about navigation. |
2616 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidStopLoading()); | 2619 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 2620 DidStopLoading(render_view_host)); |
2617 } | 2621 } |
2618 | 2622 |
2619 void WebContentsImpl::DidCancelLoading() { | 2623 void WebContentsImpl::DidCancelLoading() { |
2620 controller_.DiscardNonCommittedEntries(); | 2624 controller_.DiscardNonCommittedEntries(); |
2621 | 2625 |
2622 // Update the URL display. | 2626 // Update the URL display. |
2623 NotifyNavigationStateChanged(content::INVALIDATE_TYPE_URL); | 2627 NotifyNavigationStateChanged(content::INVALIDATE_TYPE_URL); |
2624 } | 2628 } |
2625 | 2629 |
2626 void WebContentsImpl::DidChangeLoadProgress(double progress) { | 2630 void WebContentsImpl::DidChangeLoadProgress(double progress) { |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2925 delegate_->WorkerCrashed(this); | 2929 delegate_->WorkerCrashed(this); |
2926 } | 2930 } |
2927 | 2931 |
2928 void WebContentsImpl::BeforeUnloadFiredFromRenderManager( | 2932 void WebContentsImpl::BeforeUnloadFiredFromRenderManager( |
2929 bool proceed, | 2933 bool proceed, |
2930 bool* proceed_to_fire_unload) { | 2934 bool* proceed_to_fire_unload) { |
2931 if (delegate_) | 2935 if (delegate_) |
2932 delegate_->BeforeUnloadFired(this, proceed, proceed_to_fire_unload); | 2936 delegate_->BeforeUnloadFired(this, proceed, proceed_to_fire_unload); |
2933 } | 2937 } |
2934 | 2938 |
2935 void WebContentsImpl::DidStartLoadingFromRenderManager( | |
2936 RenderViewHost* render_view_host) { | |
2937 DidStartLoading(); | |
2938 } | |
2939 | |
2940 void WebContentsImpl::RenderViewGoneFromRenderManager( | 2939 void WebContentsImpl::RenderViewGoneFromRenderManager( |
2941 RenderViewHost* render_view_host) { | 2940 RenderViewHost* render_view_host) { |
2942 DCHECK(crashed_status_ != base::TERMINATION_STATUS_STILL_RUNNING); | 2941 DCHECK(crashed_status_ != base::TERMINATION_STATUS_STILL_RUNNING); |
2943 RenderViewGone(render_view_host, crashed_status_, crashed_error_code_); | 2942 RenderViewGone(render_view_host, crashed_status_, crashed_error_code_); |
2944 } | 2943 } |
2945 | 2944 |
2946 void WebContentsImpl::UpdateRenderViewSizeForRenderManager() { | 2945 void WebContentsImpl::UpdateRenderViewSizeForRenderManager() { |
2947 // TODO(brettw) this is a hack. See WebContentsView::SizeContents. | 2946 // TODO(brettw) this is a hack. See WebContentsView::SizeContents. |
2948 gfx::Size size = view_->GetContainerSize(); | 2947 gfx::Size size = view_->GetContainerSize(); |
2949 // 0x0 isn't a valid window size (minimal window size is 1x1) but it may be | 2948 // 0x0 isn't a valid window size (minimal window size is 1x1) but it may be |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3033 return true; | 3032 return true; |
3034 } | 3033 } |
3035 | 3034 |
3036 void WebContentsImpl::OnDialogClosed(RenderViewHost* rvh, | 3035 void WebContentsImpl::OnDialogClosed(RenderViewHost* rvh, |
3037 IPC::Message* reply_msg, | 3036 IPC::Message* reply_msg, |
3038 bool success, | 3037 bool success, |
3039 const string16& user_input) { | 3038 const string16& user_input) { |
3040 if (is_showing_before_unload_dialog_ && !success) { | 3039 if (is_showing_before_unload_dialog_ && !success) { |
3041 // If a beforeunload dialog is canceled, we need to stop the throbber from | 3040 // If a beforeunload dialog is canceled, we need to stop the throbber from |
3042 // spinning, since we forced it to start spinning in Navigate. | 3041 // spinning, since we forced it to start spinning in Navigate. |
3043 DidStopLoading(); | 3042 DidStopLoading(rvh); |
3044 controller_.DiscardNonCommittedEntries(); | 3043 controller_.DiscardNonCommittedEntries(); |
3045 | 3044 |
3046 close_start_time_ = base::TimeTicks(); | 3045 close_start_time_ = base::TimeTicks(); |
3047 } | 3046 } |
3048 is_showing_before_unload_dialog_ = false; | 3047 is_showing_before_unload_dialog_ = false; |
3049 static_cast<RenderViewHostImpl*>( | 3048 static_cast<RenderViewHostImpl*>( |
3050 rvh)->JavaScriptDialogClosed(reply_msg, success, user_input); | 3049 rvh)->JavaScriptDialogClosed(reply_msg, success, user_input); |
3051 } | 3050 } |
3052 | 3051 |
3053 void WebContentsImpl::SetEncoding(const std::string& encoding) { | 3052 void WebContentsImpl::SetEncoding(const std::string& encoding) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3099 browser_plugin_host()->embedder_render_process_host(); | 3098 browser_plugin_host()->embedder_render_process_host(); |
3100 *embedder_container_id = browser_plugin_host()->instance_id(); | 3099 *embedder_container_id = browser_plugin_host()->instance_id(); |
3101 int embedder_process_id = | 3100 int embedder_process_id = |
3102 embedder_render_process_host ? embedder_render_process_host->GetID() : -1; | 3101 embedder_render_process_host ? embedder_render_process_host->GetID() : -1; |
3103 if (embedder_process_id != -1) { | 3102 if (embedder_process_id != -1) { |
3104 *embedder_channel_name = | 3103 *embedder_channel_name = |
3105 StringPrintf("%d.r%d", render_view_host->GetProcess()->GetID(), | 3104 StringPrintf("%d.r%d", render_view_host->GetProcess()->GetID(), |
3106 embedder_process_id); | 3105 embedder_process_id); |
3107 } | 3106 } |
3108 } | 3107 } |
OLD | NEW |