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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <cmath> | 9 #include <cmath> |
10 #include <utility> | 10 #include <utility> |
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
918 } | 918 } |
919 | 919 |
920 const PageImportanceSignals& WebContentsImpl::GetPageImportanceSignals() const { | 920 const PageImportanceSignals& WebContentsImpl::GetPageImportanceSignals() const { |
921 return page_importance_signals_; | 921 return page_importance_signals_; |
922 } | 922 } |
923 | 923 |
924 const base::string16& WebContentsImpl::GetTitle() const { | 924 const base::string16& WebContentsImpl::GetTitle() const { |
925 // Transient entries take precedence. They are used for interstitial pages | 925 // Transient entries take precedence. They are used for interstitial pages |
926 // that are shown on top of existing pages. | 926 // that are shown on top of existing pages. |
927 NavigationEntry* entry = controller_.GetTransientEntry(); | 927 NavigationEntry* entry = controller_.GetTransientEntry(); |
928 std::string accept_languages = | |
929 GetContentClient()->browser()->GetAcceptLangs( | |
930 GetBrowserContext()); | |
931 if (entry) { | 928 if (entry) { |
932 return entry->GetTitleForDisplay(accept_languages); | 929 return entry->GetTitleForDisplay(); |
933 } | 930 } |
934 | 931 |
935 WebUI* navigating_web_ui = GetRenderManager()->GetNavigatingWebUI(); | 932 WebUI* navigating_web_ui = GetRenderManager()->GetNavigatingWebUI(); |
936 WebUI* our_web_ui = navigating_web_ui | 933 WebUI* our_web_ui = navigating_web_ui |
937 ? navigating_web_ui | 934 ? navigating_web_ui |
938 : GetRenderManager()->current_frame_host()->web_ui(); | 935 : GetRenderManager()->current_frame_host()->web_ui(); |
939 | 936 |
940 if (our_web_ui) { | 937 if (our_web_ui) { |
941 // Don't override the title in view source mode. | 938 // Don't override the title in view source mode. |
942 entry = controller_.GetVisibleEntry(); | 939 entry = controller_.GetVisibleEntry(); |
(...skipping 20 matching lines...) Expand all Loading... |
963 // Otherwise, we want to stick with the last committed entry's title during | 960 // Otherwise, we want to stick with the last committed entry's title during |
964 // new navigations, which have pending entries at index -1 with no title. | 961 // new navigations, which have pending entries at index -1 with no title. |
965 if (controller_.IsInitialNavigation() && | 962 if (controller_.IsInitialNavigation() && |
966 ((controller_.GetVisibleEntry() && | 963 ((controller_.GetVisibleEntry() && |
967 !controller_.GetVisibleEntry()->GetTitle().empty()) || | 964 !controller_.GetVisibleEntry()->GetTitle().empty()) || |
968 controller_.GetPendingEntryIndex() != -1)) { | 965 controller_.GetPendingEntryIndex() != -1)) { |
969 entry = controller_.GetVisibleEntry(); | 966 entry = controller_.GetVisibleEntry(); |
970 } | 967 } |
971 | 968 |
972 if (entry) { | 969 if (entry) { |
973 return entry->GetTitleForDisplay(accept_languages); | 970 return entry->GetTitleForDisplay(); |
974 } | 971 } |
975 | 972 |
976 // |page_title_when_no_navigation_entry_| is finally used | 973 // |page_title_when_no_navigation_entry_| is finally used |
977 // if no title cannot be retrieved. | 974 // if no title cannot be retrieved. |
978 return page_title_when_no_navigation_entry_; | 975 return page_title_when_no_navigation_entry_; |
979 } | 976 } |
980 | 977 |
981 int32_t WebContentsImpl::GetMaxPageID() { | 978 int32_t WebContentsImpl::GetMaxPageID() { |
982 return GetMaxPageIDForSiteInstance(GetSiteInstance()); | 979 return GetMaxPageIDForSiteInstance(GetSiteInstance()); |
983 } | 980 } |
(...skipping 2871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3855 IPC::Message* reply_msg) { | 3852 IPC::Message* reply_msg) { |
3856 // Suppress JavaScript dialogs when requested. Also suppress messages when | 3853 // Suppress JavaScript dialogs when requested. Also suppress messages when |
3857 // showing an interstitial as it's shown over the previous page and we don't | 3854 // showing an interstitial as it's shown over the previous page and we don't |
3858 // want the hidden page's dialogs to interfere with the interstitial. | 3855 // want the hidden page's dialogs to interfere with the interstitial. |
3859 bool suppress_this_message = | 3856 bool suppress_this_message = |
3860 ShowingInterstitialPage() || !delegate_ || | 3857 ShowingInterstitialPage() || !delegate_ || |
3861 delegate_->ShouldSuppressDialogs(this) || | 3858 delegate_->ShouldSuppressDialogs(this) || |
3862 !delegate_->GetJavaScriptDialogManager(this); | 3859 !delegate_->GetJavaScriptDialogManager(this); |
3863 | 3860 |
3864 if (!suppress_this_message) { | 3861 if (!suppress_this_message) { |
3865 std::string accept_lang = GetContentClient()->browser()-> | |
3866 GetAcceptLangs(GetBrowserContext()); | |
3867 dialog_manager_ = delegate_->GetJavaScriptDialogManager(this); | 3862 dialog_manager_ = delegate_->GetJavaScriptDialogManager(this); |
3868 dialog_manager_->RunJavaScriptDialog( | 3863 dialog_manager_->RunJavaScriptDialog( |
3869 this, frame_url, accept_lang, javascript_message_type, message, | 3864 this, frame_url, javascript_message_type, message, default_prompt, |
3870 default_prompt, | |
3871 base::Bind(&WebContentsImpl::OnDialogClosed, base::Unretained(this), | 3865 base::Bind(&WebContentsImpl::OnDialogClosed, base::Unretained(this), |
3872 render_frame_host->GetProcess()->GetID(), | 3866 render_frame_host->GetProcess()->GetID(), |
3873 render_frame_host->GetRoutingID(), reply_msg, false), | 3867 render_frame_host->GetRoutingID(), reply_msg, false), |
3874 &suppress_this_message); | 3868 &suppress_this_message); |
3875 } | 3869 } |
3876 | 3870 |
3877 if (suppress_this_message) { | 3871 if (suppress_this_message) { |
3878 // If we are suppressing messages, just reply as if the user immediately | 3872 // If we are suppressing messages, just reply as if the user immediately |
3879 // pressed "Cancel", passing true to |dialog_was_suppressed|. | 3873 // pressed "Cancel", passing true to |dialog_was_suppressed|. |
3880 OnDialogClosed(render_frame_host->GetProcess()->GetID(), | 3874 OnDialogClosed(render_frame_host->GetProcess()->GetID(), |
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4450 uint64_t upload_position, | 4444 uint64_t upload_position, |
4451 uint64_t upload_size) { | 4445 uint64_t upload_size) { |
4452 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466285 | 4446 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466285 |
4453 // is fixed. | 4447 // is fixed. |
4454 tracked_objects::ScopedTracker tracking_profile1( | 4448 tracked_objects::ScopedTracker tracking_profile1( |
4455 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 4449 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
4456 "466285 WebContentsImpl::LoadStateChanged::Start")); | 4450 "466285 WebContentsImpl::LoadStateChanged::Start")); |
4457 load_state_ = load_state; | 4451 load_state_ = load_state; |
4458 upload_position_ = upload_position; | 4452 upload_position_ = upload_position; |
4459 upload_size_ = upload_size; | 4453 upload_size_ = upload_size; |
4460 load_state_host_ = url_formatter::IDNToUnicode( | 4454 load_state_host_ = url_formatter::IDNToUnicode(url.host()); |
4461 url.host(), | |
4462 GetContentClient()->browser()->GetAcceptLangs(GetBrowserContext())); | |
4463 if (load_state_.state == net::LOAD_STATE_READING_RESPONSE) | 4455 if (load_state_.state == net::LOAD_STATE_READING_RESPONSE) |
4464 SetNotWaitingForResponse(); | 4456 SetNotWaitingForResponse(); |
4465 if (IsLoading()) { | 4457 if (IsLoading()) { |
4466 NotifyNavigationStateChanged(static_cast<InvalidateTypes>( | 4458 NotifyNavigationStateChanged(static_cast<InvalidateTypes>( |
4467 INVALIDATE_TYPE_LOAD | INVALIDATE_TYPE_TAB)); | 4459 INVALIDATE_TYPE_LOAD | INVALIDATE_TYPE_TAB)); |
4468 } | 4460 } |
4469 } | 4461 } |
4470 | 4462 |
4471 void WebContentsImpl::BeforeUnloadFiredFromRenderManager( | 4463 void WebContentsImpl::BeforeUnloadFiredFromRenderManager( |
4472 bool proceed, const base::TimeTicks& proceed_time, | 4464 bool proceed, const base::TimeTicks& proceed_time, |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4839 else | 4831 else |
4840 WasHidden(); | 4832 WasHidden(); |
4841 } | 4833 } |
4842 | 4834 |
4843 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( | 4835 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( |
4844 JavaScriptDialogManager* dialog_manager) { | 4836 JavaScriptDialogManager* dialog_manager) { |
4845 dialog_manager_ = dialog_manager; | 4837 dialog_manager_ = dialog_manager; |
4846 } | 4838 } |
4847 | 4839 |
4848 } // namespace content | 4840 } // namespace content |
OLD | NEW |