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

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

Issue 274883002: Move didReceiveTitle and related stuff to RenderFrame. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
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/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 873
874 std::set<GURL> WebContentsImpl::GetSitesInTab() const { 874 std::set<GURL> WebContentsImpl::GetSitesInTab() const {
875 std::set<GURL> sites; 875 std::set<GURL> sites;
876 frame_tree_.ForEach(base::Bind(&CollectSites, 876 frame_tree_.ForEach(base::Bind(&CollectSites,
877 base::Unretained(GetBrowserContext()), 877 base::Unretained(GetBrowserContext()),
878 base::Unretained(&sites))); 878 base::Unretained(&sites)));
879 return sites; 879 return sites;
880 } 880 }
881 881
882 const std::string& WebContentsImpl::GetEncoding() const { 882 const std::string& WebContentsImpl::GetEncoding() const {
883 return encoding_; 883 return canonical_encoding_;
884 } 884 }
885 885
886 bool WebContentsImpl::DisplayedInsecureContent() const { 886 bool WebContentsImpl::DisplayedInsecureContent() const {
887 return displayed_insecure_content_; 887 return displayed_insecure_content_;
888 } 888 }
889 889
890 void WebContentsImpl::IncrementCapturerCount(const gfx::Size& capture_size) { 890 void WebContentsImpl::IncrementCapturerCount(const gfx::Size& capture_size) {
891 DCHECK(!is_being_destroyed_); 891 DCHECK(!is_being_destroyed_);
892 ++capturer_count_; 892 ++capturer_count_;
893 DVLOG(1) << "There are now " << capturer_count_ 893 DVLOG(1) << "There are now " << capturer_count_
(...skipping 1198 matching lines...) Expand 10 before | Expand all | Expand 10 after
2092 bool WebContentsImpl::WillNotifyDisconnection() const { 2092 bool WebContentsImpl::WillNotifyDisconnection() const {
2093 return notify_disconnection_; 2093 return notify_disconnection_;
2094 } 2094 }
2095 2095
2096 void WebContentsImpl::SetOverrideEncoding(const std::string& encoding) { 2096 void WebContentsImpl::SetOverrideEncoding(const std::string& encoding) {
2097 SetEncoding(encoding); 2097 SetEncoding(encoding);
2098 Send(new ViewMsg_SetPageEncoding(GetRoutingID(), encoding)); 2098 Send(new ViewMsg_SetPageEncoding(GetRoutingID(), encoding));
2099 } 2099 }
2100 2100
2101 void WebContentsImpl::ResetOverrideEncoding() { 2101 void WebContentsImpl::ResetOverrideEncoding() {
2102 encoding_.clear(); 2102 canonical_encoding_.clear();
2103 Send(new ViewMsg_ResetPageEncodingToDefault(GetRoutingID())); 2103 Send(new ViewMsg_ResetPageEncodingToDefault(GetRoutingID()));
2104 } 2104 }
2105 2105
2106 RendererPreferences* WebContentsImpl::GetMutableRendererPrefs() { 2106 RendererPreferences* WebContentsImpl::GetMutableRendererPrefs() {
2107 return &renderer_preferences_; 2107 return &renderer_preferences_;
2108 } 2108 }
2109 2109
2110 void WebContentsImpl::Close() { 2110 void WebContentsImpl::Close() {
2111 Close(GetRenderViewHost()); 2111 Close(GetRenderViewHost());
2112 } 2112 }
(...skipping 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after
3338 if (entry_index < 0) 3338 if (entry_index < 0)
3339 return; 3339 return;
3340 NavigationEntry* entry = controller_.GetEntryAtIndex(entry_index); 3340 NavigationEntry* entry = controller_.GetEntryAtIndex(entry_index);
3341 3341
3342 if (page_state == entry->GetPageState()) 3342 if (page_state == entry->GetPageState())
3343 return; // Nothing to update. 3343 return; // Nothing to update.
3344 entry->SetPageState(page_state); 3344 entry->SetPageState(page_state);
3345 controller_.NotifyEntryChanged(entry, entry_index); 3345 controller_.NotifyEntryChanged(entry, entry_index);
3346 } 3346 }
3347 3347
3348 void WebContentsImpl::UpdateTitle(RenderViewHost* rvh,
3349 int32 page_id,
3350 const base::string16& title,
3351 base::i18n::TextDirection title_direction) {
3352 // If we have a title, that's a pretty good indication that we've started
3353 // getting useful data.
3354 SetNotWaitingForResponse();
3355
3356 // Try to find the navigation entry, which might not be the current one.
3357 // For example, it might be from a pending RVH for the pending entry.
3358 NavigationEntryImpl* entry = controller_.GetEntryWithPageID(
3359 rvh->GetSiteInstance(), page_id);
3360
3361 // We can handle title updates when we don't have an entry in
3362 // UpdateTitleForEntry, but only if the update is from the current RVH.
3363 if (!entry && rvh != GetRenderViewHost())
3364 return;
3365
3366 // TODO(evan): make use of title_direction.
3367 // http://code.google.com/p/chromium/issues/detail?id=27094
3368 if (!UpdateTitleForEntry(entry, title))
3369 return;
3370
3371 // Broadcast notifications when the UI should be updated.
3372 if (entry == controller_.GetEntryAtOffset(0))
3373 NotifyNavigationStateChanged(INVALIDATE_TYPE_TITLE);
3374 }
3375
3376 void WebContentsImpl::UpdateEncoding(RenderViewHost* render_view_host,
3377 const std::string& encoding) {
3378 SetEncoding(encoding);
3379 }
3380
3381 void WebContentsImpl::UpdateTargetURL(int32 page_id, const GURL& url) { 3348 void WebContentsImpl::UpdateTargetURL(int32 page_id, const GURL& url) {
3382 if (delegate_) 3349 if (delegate_)
3383 delegate_->UpdateTargetURL(this, page_id, url); 3350 delegate_->UpdateTargetURL(this, page_id, url);
3384 } 3351 }
3385 3352
3386 void WebContentsImpl::Close(RenderViewHost* rvh) { 3353 void WebContentsImpl::Close(RenderViewHost* rvh) {
3387 #if defined(OS_MACOSX) 3354 #if defined(OS_MACOSX)
3388 // The UI may be in an event-tracking loop, such as between the 3355 // The UI may be in an event-tracking loop, such as between the
3389 // mouse-down and mouse-up in text selection or a button click. 3356 // mouse-down and mouse-up in text selection or a button click.
3390 // Defer the close until after tracking is complete, so that we 3357 // Defer the close until after tracking is complete, so that we
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
3489 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 3456 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
3490 DocumentOnLoadCompletedInMainFrame()); 3457 DocumentOnLoadCompletedInMainFrame());
3491 3458
3492 // TODO(avi): Remove. http://crbug.com/170921 3459 // TODO(avi): Remove. http://crbug.com/170921
3493 NotificationService::current()->Notify( 3460 NotificationService::current()->Notify(
3494 NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, 3461 NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
3495 Source<WebContents>(this), 3462 Source<WebContents>(this),
3496 NotificationService::NoDetails()); 3463 NotificationService::NoDetails());
3497 } 3464 }
3498 3465
3466 void WebContentsImpl::UpdateTitle(RenderFrameHost* render_frame_host,
3467 int32 page_id,
3468 const base::string16& title,
3469 base::i18n::TextDirection title_direction) {
3470 RenderViewHost* rvh = render_frame_host->GetRenderViewHost();
3471
3472 // If we have a title, that's a pretty good indication that we've started
3473 // getting useful data.
3474 SetNotWaitingForResponse();
3475
3476 // Try to find the navigation entry, which might not be the current one.
3477 // For example, it might be from a pending RVH for the pending entry.
3478 NavigationEntryImpl* entry = controller_.GetEntryWithPageID(
3479 rvh->GetSiteInstance(), page_id);
3480
3481 // We can handle title updates when we don't have an entry in
3482 // UpdateTitleForEntry, but only if the update is from the current RVH.
3483 if (!entry && rvh != GetRenderViewHost())
nasko 2014/05/09 16:39:29 Shouldn't this change to check the RFH?
Avi (use Gerrit) 2014/05/09 16:44:07 I'm not good at understanding the current vs pendi
3484 return;
3485
3486 // TODO(evan): make use of title_direction.
3487 // http://code.google.com/p/chromium/issues/detail?id=27094
3488 if (!UpdateTitleForEntry(entry, title))
3489 return;
3490
3491 // Broadcast notifications when the UI should be updated.
3492 if (entry == controller_.GetEntryAtOffset(0))
3493 NotifyNavigationStateChanged(INVALIDATE_TYPE_TITLE);
3494 }
3495
3496 void WebContentsImpl::UpdateEncoding(RenderFrameHost* render_frame_host,
3497 const std::string& encoding) {
3498 SetEncoding(encoding);
3499 }
3500
3499 void WebContentsImpl::DocumentAvailableInMainFrame( 3501 void WebContentsImpl::DocumentAvailableInMainFrame(
3500 RenderViewHost* render_view_host) { 3502 RenderViewHost* render_view_host) {
3501 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 3503 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
3502 DocumentAvailableInMainFrame()); 3504 DocumentAvailableInMainFrame());
3503 } 3505 }
3504 void WebContentsImpl::RouteCloseEvent(RenderViewHost* rvh) { 3506 void WebContentsImpl::RouteCloseEvent(RenderViewHost* rvh) {
3505 // Tell the active RenderViewHost to run unload handlers and close, as long 3507 // Tell the active RenderViewHost to run unload handlers and close, as long
3506 // as the request came from a RenderViewHost in the same BrowsingInstance. 3508 // as the request came from a RenderViewHost in the same BrowsingInstance.
3507 // In most cases, we receive this from a swapped out RenderViewHost. 3509 // In most cases, we receive this from a swapped out RenderViewHost.
3508 // It is possible to receive it from one that has just been swapped in, 3510 // It is possible to receive it from one that has just been swapped in,
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
3901 if (rfh) { 3903 if (rfh) {
3902 rfh->JavaScriptDialogClosed(reply_msg, success, user_input, 3904 rfh->JavaScriptDialogClosed(reply_msg, success, user_input,
3903 dialog_was_suppressed); 3905 dialog_was_suppressed);
3904 } else { 3906 } else {
3905 // Don't leak the sync IPC reply if the RFH or process is gone. 3907 // Don't leak the sync IPC reply if the RFH or process is gone.
3906 delete reply_msg; 3908 delete reply_msg;
3907 } 3909 }
3908 } 3910 }
3909 3911
3910 void WebContentsImpl::SetEncoding(const std::string& encoding) { 3912 void WebContentsImpl::SetEncoding(const std::string& encoding) {
3911 encoding_ = GetContentClient()->browser()-> 3913 if (encoding == last_reported_encoding_)
3914 return;
3915 last_reported_encoding_ = encoding;
3916
3917 canonical_encoding_ = GetContentClient()->browser()->
3912 GetCanonicalEncodingNameByAliasName(encoding); 3918 GetCanonicalEncodingNameByAliasName(encoding);
3913 } 3919 }
3914 3920
3915 void WebContentsImpl::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { 3921 void WebContentsImpl::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) {
3916 RenderWidgetHostViewBase* rwh_view = view_->CreateViewForWidget(rvh); 3922 RenderWidgetHostViewBase* rwh_view = view_->CreateViewForWidget(rvh);
3917 // Can be NULL during tests. 3923 // Can be NULL during tests.
3918 if (rwh_view) 3924 if (rwh_view)
3919 rwh_view->SetSize(GetContainerBounds().size()); 3925 rwh_view->SetSize(GetContainerBounds().size());
3920 } 3926 }
3921 3927
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
3975 3981
3976 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) { 3982 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) {
3977 if (!delegate_) 3983 if (!delegate_)
3978 return; 3984 return;
3979 const gfx::Size new_size = GetPreferredSize(); 3985 const gfx::Size new_size = GetPreferredSize();
3980 if (new_size != old_size) 3986 if (new_size != old_size)
3981 delegate_->UpdatePreferredSize(this, new_size); 3987 delegate_->UpdatePreferredSize(this, new_size);
3982 } 3988 }
3983 3989
3984 } // namespace content 3990 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/browser/web_contents/web_contents_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698