| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/tab_contents/core_tab_helper.h" | 5 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
| 6 | 6 |
| 7 #include "chrome/browser/renderer_host/web_cache_manager.h" | 7 #include "chrome/browser/renderer_host/web_cache_manager.h" |
| 8 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 8 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 9 #include "content/browser/renderer_host/render_view_host.h" | 9 #include "content/browser/renderer_host/render_view_host.h" |
| 10 #include "content/browser/tab_contents/tab_contents.h" | 10 #include "content/browser/tab_contents/tab_contents.h" |
| 11 #include "grit/generated_resources.h" | 11 #include "grit/generated_resources.h" |
| 12 #include "ui/base/l10n/l10n_util.h" | 12 #include "ui/base/l10n/l10n_util.h" |
| 13 | 13 |
| 14 CoreTabHelper::CoreTabHelper(TabContentsWrapper* wrapper) | 14 CoreTabHelper::CoreTabHelper(TabContentsWrapper* wrapper) |
| 15 : TabContentsObserver(wrapper->tab_contents()), | 15 : TabContentsObserver(wrapper->tab_contents()), |
| 16 delegate_(NULL), | 16 delegate_(NULL), |
| 17 wrapper_(wrapper) { | 17 wrapper_(wrapper) { |
| 18 } | 18 } |
| 19 | 19 |
| 20 CoreTabHelper::~CoreTabHelper() { | 20 CoreTabHelper::~CoreTabHelper() { |
| 21 } | 21 } |
| 22 | 22 |
| 23 string16 CoreTabHelper::GetDefaultTitle() { | 23 string16 CoreTabHelper::GetDefaultTitle() { |
| 24 return l10n_util::GetStringUTF16(IDS_DEFAULT_TAB_TITLE); | 24 return l10n_util::GetStringUTF16(IDS_DEFAULT_TAB_TITLE); |
| 25 } | 25 } |
| 26 | 26 |
| 27 string16 CoreTabHelper::GetStatusText() const { | 27 string16 CoreTabHelper::GetStatusText() const { |
| 28 if (!tab_contents()->IsLoading() || | 28 if (!tab_contents()->IsLoading() || |
| 29 tab_contents()->load_state().state == net::LOAD_STATE_IDLE) { | 29 tab_contents()->GetLoadState().state == net::LOAD_STATE_IDLE) { |
| 30 return string16(); | 30 return string16(); |
| 31 } | 31 } |
| 32 | 32 |
| 33 switch (tab_contents()->load_state().state) { | 33 switch (tab_contents()->GetLoadState().state) { |
| 34 case net::LOAD_STATE_WAITING_FOR_DELEGATE: | 34 case net::LOAD_STATE_WAITING_FOR_DELEGATE: |
| 35 return l10n_util::GetStringFUTF16(IDS_LOAD_STATE_WAITING_FOR_DELEGATE, | 35 return l10n_util::GetStringFUTF16(IDS_LOAD_STATE_WAITING_FOR_DELEGATE, |
| 36 tab_contents()->load_state().param); | 36 tab_contents()->GetLoadState().param); |
| 37 case net::LOAD_STATE_WAITING_FOR_CACHE: | 37 case net::LOAD_STATE_WAITING_FOR_CACHE: |
| 38 return l10n_util::GetStringUTF16(IDS_LOAD_STATE_WAITING_FOR_CACHE); | 38 return l10n_util::GetStringUTF16(IDS_LOAD_STATE_WAITING_FOR_CACHE); |
| 39 case net::LOAD_STATE_WAITING_FOR_APPCACHE: | 39 case net::LOAD_STATE_WAITING_FOR_APPCACHE: |
| 40 return l10n_util::GetStringUTF16(IDS_LOAD_STATE_WAITING_FOR_APPCACHE); | 40 return l10n_util::GetStringUTF16(IDS_LOAD_STATE_WAITING_FOR_APPCACHE); |
| 41 case net::LOAD_STATE_ESTABLISHING_PROXY_TUNNEL: | 41 case net::LOAD_STATE_ESTABLISHING_PROXY_TUNNEL: |
| 42 return | 42 return |
| 43 l10n_util::GetStringUTF16(IDS_LOAD_STATE_ESTABLISHING_PROXY_TUNNEL); | 43 l10n_util::GetStringUTF16(IDS_LOAD_STATE_ESTABLISHING_PROXY_TUNNEL); |
| 44 case net::LOAD_STATE_RESOLVING_PROXY_FOR_URL: | 44 case net::LOAD_STATE_RESOLVING_PROXY_FOR_URL: |
| 45 return l10n_util::GetStringUTF16(IDS_LOAD_STATE_RESOLVING_PROXY_FOR_URL); | 45 return l10n_util::GetStringUTF16(IDS_LOAD_STATE_RESOLVING_PROXY_FOR_URL); |
| 46 case net::LOAD_STATE_RESOLVING_HOST_IN_PROXY_SCRIPT: | 46 case net::LOAD_STATE_RESOLVING_HOST_IN_PROXY_SCRIPT: |
| 47 return l10n_util::GetStringUTF16( | 47 return l10n_util::GetStringUTF16( |
| 48 IDS_LOAD_STATE_RESOLVING_HOST_IN_PROXY_SCRIPT); | 48 IDS_LOAD_STATE_RESOLVING_HOST_IN_PROXY_SCRIPT); |
| 49 case net::LOAD_STATE_RESOLVING_HOST: | 49 case net::LOAD_STATE_RESOLVING_HOST: |
| 50 return l10n_util::GetStringUTF16(IDS_LOAD_STATE_RESOLVING_HOST); | 50 return l10n_util::GetStringUTF16(IDS_LOAD_STATE_RESOLVING_HOST); |
| 51 case net::LOAD_STATE_CONNECTING: | 51 case net::LOAD_STATE_CONNECTING: |
| 52 return l10n_util::GetStringUTF16(IDS_LOAD_STATE_CONNECTING); | 52 return l10n_util::GetStringUTF16(IDS_LOAD_STATE_CONNECTING); |
| 53 case net::LOAD_STATE_SSL_HANDSHAKE: | 53 case net::LOAD_STATE_SSL_HANDSHAKE: |
| 54 return l10n_util::GetStringUTF16(IDS_LOAD_STATE_SSL_HANDSHAKE); | 54 return l10n_util::GetStringUTF16(IDS_LOAD_STATE_SSL_HANDSHAKE); |
| 55 case net::LOAD_STATE_SENDING_REQUEST: | 55 case net::LOAD_STATE_SENDING_REQUEST: |
| 56 if (tab_contents()->upload_size()) | 56 if (tab_contents()->GetUploadSize()) { |
| 57 return l10n_util::GetStringFUTF16Int( | 57 return l10n_util::GetStringFUTF16Int( |
| 58 IDS_LOAD_STATE_SENDING_REQUEST_WITH_PROGRESS, | 58 IDS_LOAD_STATE_SENDING_REQUEST_WITH_PROGRESS, |
| 59 static_cast<int>((100 * tab_contents()->upload_position()) / | 59 static_cast<int>((100 * tab_contents()->GetUploadPosition()) / |
| 60 tab_contents()->upload_size())); | 60 tab_contents()->GetUploadSize())); |
| 61 else | 61 } else { |
| 62 return l10n_util::GetStringUTF16(IDS_LOAD_STATE_SENDING_REQUEST); | 62 return l10n_util::GetStringUTF16(IDS_LOAD_STATE_SENDING_REQUEST); |
| 63 } |
| 63 case net::LOAD_STATE_WAITING_FOR_RESPONSE: | 64 case net::LOAD_STATE_WAITING_FOR_RESPONSE: |
| 64 return l10n_util::GetStringFUTF16(IDS_LOAD_STATE_WAITING_FOR_RESPONSE, | 65 return l10n_util::GetStringFUTF16(IDS_LOAD_STATE_WAITING_FOR_RESPONSE, |
| 65 tab_contents()->load_state_host()); | 66 tab_contents()->GetLoadStateHost()); |
| 66 // Ignore net::LOAD_STATE_READING_RESPONSE and net::LOAD_STATE_IDLE | 67 // Ignore net::LOAD_STATE_READING_RESPONSE and net::LOAD_STATE_IDLE |
| 67 case net::LOAD_STATE_IDLE: | 68 case net::LOAD_STATE_IDLE: |
| 68 case net::LOAD_STATE_READING_RESPONSE: | 69 case net::LOAD_STATE_READING_RESPONSE: |
| 69 break; | 70 break; |
| 70 } | 71 } |
| 71 | 72 |
| 72 return string16(); | 73 return string16(); |
| 73 } | 74 } |
| 74 | 75 |
| 75 //////////////////////////////////////////////////////////////////////////////// | 76 //////////////////////////////////////////////////////////////////////////////// |
| 76 // TabContentsObserver overrides | 77 // TabContentsObserver overrides |
| 77 | 78 |
| 78 void CoreTabHelper::DidBecomeSelected() { | 79 void CoreTabHelper::DidBecomeSelected() { |
| 79 WebCacheManager::GetInstance()->ObserveActivity( | 80 WebCacheManager::GetInstance()->ObserveActivity( |
| 80 tab_contents()->GetRenderProcessHost()->GetID()); | 81 tab_contents()->GetRenderProcessHost()->GetID()); |
| 81 } | 82 } |
| OLD | NEW |