OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/tab_contents/tab_contents.h" | 5 #include "chrome/browser/tab_contents/tab_contents.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 // Always display a throbber during pending loads. | 712 // Always display a throbber during pending loads. |
713 if (controller_.GetLastCommittedEntry() && controller_.pending_entry()) | 713 if (controller_.GetLastCommittedEntry() && controller_.pending_entry()) |
714 return true; | 714 return true; |
715 | 715 |
716 DOMUI* dom_ui = GetDOMUIForCurrentState(); | 716 DOMUI* dom_ui = GetDOMUIForCurrentState(); |
717 if (dom_ui) | 717 if (dom_ui) |
718 return !dom_ui->hide_favicon(); | 718 return !dom_ui->hide_favicon(); |
719 return true; | 719 return true; |
720 } | 720 } |
721 | 721 |
722 std::wstring TabContents::GetStatusText() const { | 722 string16 TabContents::GetStatusText() const { |
723 if (!is_loading() || load_state_ == net::LOAD_STATE_IDLE) | 723 if (!is_loading() || load_state_ == net::LOAD_STATE_IDLE) |
724 return std::wstring(); | 724 return string16(); |
725 | 725 |
726 switch (load_state_) { | 726 switch (load_state_) { |
727 case net::LOAD_STATE_WAITING_FOR_CACHE: | 727 case net::LOAD_STATE_WAITING_FOR_CACHE: |
728 return l10n_util::GetString(IDS_LOAD_STATE_WAITING_FOR_CACHE); | 728 return l10n_util::GetStringUTF16(IDS_LOAD_STATE_WAITING_FOR_CACHE); |
729 case net::LOAD_STATE_ESTABLISHING_PROXY_TUNNEL: | 729 case net::LOAD_STATE_ESTABLISHING_PROXY_TUNNEL: |
730 return l10n_util::GetString(IDS_LOAD_STATE_ESTABLISHING_PROXY_TUNNEL); | 730 return |
| 731 l10n_util::GetStringUTF16(IDS_LOAD_STATE_ESTABLISHING_PROXY_TUNNEL); |
731 case net::LOAD_STATE_RESOLVING_PROXY_FOR_URL: | 732 case net::LOAD_STATE_RESOLVING_PROXY_FOR_URL: |
732 return l10n_util::GetString(IDS_LOAD_STATE_RESOLVING_PROXY_FOR_URL); | 733 return l10n_util::GetStringUTF16(IDS_LOAD_STATE_RESOLVING_PROXY_FOR_URL); |
733 case net::LOAD_STATE_RESOLVING_HOST: | 734 case net::LOAD_STATE_RESOLVING_HOST: |
734 return l10n_util::GetString(IDS_LOAD_STATE_RESOLVING_HOST); | 735 return l10n_util::GetStringUTF16(IDS_LOAD_STATE_RESOLVING_HOST); |
735 case net::LOAD_STATE_CONNECTING: | 736 case net::LOAD_STATE_CONNECTING: |
736 return l10n_util::GetString(IDS_LOAD_STATE_CONNECTING); | 737 return l10n_util::GetStringUTF16(IDS_LOAD_STATE_CONNECTING); |
737 case net::LOAD_STATE_SSL_HANDSHAKE: | 738 case net::LOAD_STATE_SSL_HANDSHAKE: |
738 return l10n_util::GetString(IDS_LOAD_STATE_SSL_HANDSHAKE); | 739 return l10n_util::GetStringUTF16(IDS_LOAD_STATE_SSL_HANDSHAKE); |
739 case net::LOAD_STATE_SENDING_REQUEST: | 740 case net::LOAD_STATE_SENDING_REQUEST: |
740 if (upload_size_) | 741 if (upload_size_) |
741 return l10n_util::GetStringF( | 742 return l10n_util::GetStringFUTF16Int( |
742 IDS_LOAD_STATE_SENDING_REQUEST_WITH_PROGRESS, | 743 IDS_LOAD_STATE_SENDING_REQUEST_WITH_PROGRESS, |
743 static_cast<int>((100 * upload_position_) / upload_size_)); | 744 static_cast<int>((100 * upload_position_) / upload_size_)); |
744 else | 745 else |
745 return l10n_util::GetString(IDS_LOAD_STATE_SENDING_REQUEST); | 746 return l10n_util::GetStringUTF16(IDS_LOAD_STATE_SENDING_REQUEST); |
746 case net::LOAD_STATE_WAITING_FOR_RESPONSE: | 747 case net::LOAD_STATE_WAITING_FOR_RESPONSE: |
747 return l10n_util::GetStringF(IDS_LOAD_STATE_WAITING_FOR_RESPONSE, | 748 return l10n_util::GetStringFUTF16(IDS_LOAD_STATE_WAITING_FOR_RESPONSE, |
748 load_state_host_); | 749 load_state_host_); |
749 // Ignore net::LOAD_STATE_READING_RESPONSE and net::LOAD_STATE_IDLE | 750 // Ignore net::LOAD_STATE_READING_RESPONSE and net::LOAD_STATE_IDLE |
750 case net::LOAD_STATE_IDLE: | 751 case net::LOAD_STATE_IDLE: |
751 case net::LOAD_STATE_READING_RESPONSE: | 752 case net::LOAD_STATE_READING_RESPONSE: |
752 break; | 753 break; |
753 } | 754 } |
754 | 755 |
755 return std::wstring(); | 756 return string16(); |
756 } | 757 } |
757 | 758 |
758 void TabContents::AddNavigationObserver(WebNavigationObserver* observer) { | 759 void TabContents::AddNavigationObserver(WebNavigationObserver* observer) { |
759 web_navigation_observers_.AddObserver(observer); | 760 web_navigation_observers_.AddObserver(observer); |
760 } | 761 } |
761 | 762 |
762 void TabContents::RemoveNavigationObserver(WebNavigationObserver* observer) { | 763 void TabContents::RemoveNavigationObserver(WebNavigationObserver* observer) { |
763 web_navigation_observers_.RemoveObserver(observer); | 764 web_navigation_observers_.RemoveObserver(observer); |
764 } | 765 } |
765 | 766 |
(...skipping 2303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3069 void TabContents::LoadStateChanged(const GURL& url, | 3070 void TabContents::LoadStateChanged(const GURL& url, |
3070 net::LoadState load_state, | 3071 net::LoadState load_state, |
3071 uint64 upload_position, | 3072 uint64 upload_position, |
3072 uint64 upload_size) { | 3073 uint64 upload_size) { |
3073 load_state_ = load_state; | 3074 load_state_ = load_state; |
3074 upload_position_ = upload_position; | 3075 upload_position_ = upload_position; |
3075 upload_size_ = upload_size; | 3076 upload_size_ = upload_size; |
3076 std::wstring languages = | 3077 std::wstring languages = |
3077 UTF8ToWide(profile()->GetPrefs()->GetString(prefs::kAcceptLanguages)); | 3078 UTF8ToWide(profile()->GetPrefs()->GetString(prefs::kAcceptLanguages)); |
3078 std::string host = url.host(); | 3079 std::string host = url.host(); |
3079 load_state_host_ = | 3080 load_state_host_ = WideToUTF16Hack( |
3080 net::IDNToUnicode(host.c_str(), host.size(), languages, NULL); | 3081 net::IDNToUnicode(host.c_str(), host.size(), languages, NULL)); |
3081 if (load_state_ == net::LOAD_STATE_READING_RESPONSE) | 3082 if (load_state_ == net::LOAD_STATE_READING_RESPONSE) |
3082 SetNotWaitingForResponse(); | 3083 SetNotWaitingForResponse(); |
3083 if (is_loading()) | 3084 if (is_loading()) |
3084 NotifyNavigationStateChanged(INVALIDATE_LOAD | INVALIDATE_TAB); | 3085 NotifyNavigationStateChanged(INVALIDATE_LOAD | INVALIDATE_TAB); |
3085 } | 3086 } |
3086 | 3087 |
3087 bool TabContents::IsExternalTabContainer() const { | 3088 bool TabContents::IsExternalTabContainer() const { |
3088 if (!delegate()) | 3089 if (!delegate()) |
3089 return false; | 3090 return false; |
3090 | 3091 |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3339 } | 3340 } |
3340 | 3341 |
3341 void TabContents::SwapInRenderViewHost(RenderViewHost* rvh) { | 3342 void TabContents::SwapInRenderViewHost(RenderViewHost* rvh) { |
3342 render_manager_.SwapInRenderViewHost(rvh); | 3343 render_manager_.SwapInRenderViewHost(rvh); |
3343 } | 3344 } |
3344 | 3345 |
3345 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 3346 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
3346 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); | 3347 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); |
3347 rwh_view->SetSize(view()->GetContainerSize()); | 3348 rwh_view->SetSize(view()->GetContainerSize()); |
3348 } | 3349 } |
OLD | NEW |