| 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 2878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3862 IPC::Message* reply_msg) { | 3859 IPC::Message* reply_msg) { |
| 3863 // Suppress JavaScript dialogs when requested. Also suppress messages when | 3860 // Suppress JavaScript dialogs when requested. Also suppress messages when |
| 3864 // showing an interstitial as it's shown over the previous page and we don't | 3861 // showing an interstitial as it's shown over the previous page and we don't |
| 3865 // want the hidden page's dialogs to interfere with the interstitial. | 3862 // want the hidden page's dialogs to interfere with the interstitial. |
| 3866 bool suppress_this_message = | 3863 bool suppress_this_message = |
| 3867 ShowingInterstitialPage() || !delegate_ || | 3864 ShowingInterstitialPage() || !delegate_ || |
| 3868 delegate_->ShouldSuppressDialogs(this) || | 3865 delegate_->ShouldSuppressDialogs(this) || |
| 3869 !delegate_->GetJavaScriptDialogManager(this); | 3866 !delegate_->GetJavaScriptDialogManager(this); |
| 3870 | 3867 |
| 3871 if (!suppress_this_message) { | 3868 if (!suppress_this_message) { |
| 3872 std::string accept_lang = GetContentClient()->browser()-> | |
| 3873 GetAcceptLangs(GetBrowserContext()); | |
| 3874 dialog_manager_ = delegate_->GetJavaScriptDialogManager(this); | 3869 dialog_manager_ = delegate_->GetJavaScriptDialogManager(this); |
| 3875 dialog_manager_->RunJavaScriptDialog( | 3870 dialog_manager_->RunJavaScriptDialog( |
| 3876 this, frame_url, accept_lang, javascript_message_type, message, | 3871 this, frame_url, javascript_message_type, message, default_prompt, |
| 3877 default_prompt, | |
| 3878 base::Bind(&WebContentsImpl::OnDialogClosed, base::Unretained(this), | 3872 base::Bind(&WebContentsImpl::OnDialogClosed, base::Unretained(this), |
| 3879 render_frame_host->GetProcess()->GetID(), | 3873 render_frame_host->GetProcess()->GetID(), |
| 3880 render_frame_host->GetRoutingID(), reply_msg, false), | 3874 render_frame_host->GetRoutingID(), reply_msg, false), |
| 3881 &suppress_this_message); | 3875 &suppress_this_message); |
| 3882 } | 3876 } |
| 3883 | 3877 |
| 3884 if (suppress_this_message) { | 3878 if (suppress_this_message) { |
| 3885 // If we are suppressing messages, just reply as if the user immediately | 3879 // If we are suppressing messages, just reply as if the user immediately |
| 3886 // pressed "Cancel", passing true to |dialog_was_suppressed|. | 3880 // pressed "Cancel", passing true to |dialog_was_suppressed|. |
| 3887 OnDialogClosed(render_frame_host->GetProcess()->GetID(), | 3881 OnDialogClosed(render_frame_host->GetProcess()->GetID(), |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4457 uint64_t upload_position, | 4451 uint64_t upload_position, |
| 4458 uint64_t upload_size) { | 4452 uint64_t upload_size) { |
| 4459 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466285 | 4453 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466285 |
| 4460 // is fixed. | 4454 // is fixed. |
| 4461 tracked_objects::ScopedTracker tracking_profile1( | 4455 tracked_objects::ScopedTracker tracking_profile1( |
| 4462 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 4456 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 4463 "466285 WebContentsImpl::LoadStateChanged::Start")); | 4457 "466285 WebContentsImpl::LoadStateChanged::Start")); |
| 4464 load_state_ = load_state; | 4458 load_state_ = load_state; |
| 4465 upload_position_ = upload_position; | 4459 upload_position_ = upload_position; |
| 4466 upload_size_ = upload_size; | 4460 upload_size_ = upload_size; |
| 4467 load_state_host_ = url_formatter::IDNToUnicode( | 4461 load_state_host_ = url_formatter::IDNToUnicode(url.host()); |
| 4468 url.host(), | |
| 4469 GetContentClient()->browser()->GetAcceptLangs(GetBrowserContext())); | |
| 4470 if (load_state_.state == net::LOAD_STATE_READING_RESPONSE) | 4462 if (load_state_.state == net::LOAD_STATE_READING_RESPONSE) |
| 4471 SetNotWaitingForResponse(); | 4463 SetNotWaitingForResponse(); |
| 4472 if (IsLoading()) { | 4464 if (IsLoading()) { |
| 4473 NotifyNavigationStateChanged(static_cast<InvalidateTypes>( | 4465 NotifyNavigationStateChanged(static_cast<InvalidateTypes>( |
| 4474 INVALIDATE_TYPE_LOAD | INVALIDATE_TYPE_TAB)); | 4466 INVALIDATE_TYPE_LOAD | INVALIDATE_TYPE_TAB)); |
| 4475 } | 4467 } |
| 4476 } | 4468 } |
| 4477 | 4469 |
| 4478 void WebContentsImpl::BeforeUnloadFiredFromRenderManager( | 4470 void WebContentsImpl::BeforeUnloadFiredFromRenderManager( |
| 4479 bool proceed, const base::TimeTicks& proceed_time, | 4471 bool proceed, const base::TimeTicks& proceed_time, |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4846 else | 4838 else |
| 4847 WasHidden(); | 4839 WasHidden(); |
| 4848 } | 4840 } |
| 4849 | 4841 |
| 4850 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( | 4842 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( |
| 4851 JavaScriptDialogManager* dialog_manager) { | 4843 JavaScriptDialogManager* dialog_manager) { |
| 4852 dialog_manager_ = dialog_manager; | 4844 dialog_manager_ = dialog_manager; |
| 4853 } | 4845 } |
| 4854 | 4846 |
| 4855 } // namespace content | 4847 } // namespace content |
| OLD | NEW |