| 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/prefs/pref_service.h" | |
| 8 #include "chrome/browser/profiles/profile.h" | |
| 9 #include "chrome/browser/renderer_host/web_cache_manager.h" | 7 #include "chrome/browser/renderer_host/web_cache_manager.h" |
| 10 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 8 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 11 #include "chrome/common/chrome_notification_types.h" | |
| 12 #include "chrome/common/pref_names.h" | |
| 13 #include "content/browser/renderer_host/render_view_host.h" | 9 #include "content/browser/renderer_host/render_view_host.h" |
| 14 #include "content/public/browser/notification_service.h" | |
| 15 #include "grit/generated_resources.h" | 10 #include "grit/generated_resources.h" |
| 16 #include "ui/base/l10n/l10n_util.h" | 11 #include "ui/base/l10n/l10n_util.h" |
| 17 | 12 |
| 18 CoreTabHelper::CoreTabHelper(TabContentsWrapper* wrapper) | 13 CoreTabHelper::CoreTabHelper(TabContentsWrapper* wrapper) |
| 19 : TabContentsObserver(wrapper->tab_contents()), | 14 : TabContentsObserver(wrapper->tab_contents()), |
| 20 delegate_(NULL), | 15 delegate_(NULL), |
| 21 wrapper_(wrapper) { | 16 wrapper_(wrapper) { |
| 22 PrefService* prefs = wrapper_->profile()->GetPrefs(); | |
| 23 if (prefs) { | |
| 24 pref_change_registrar_.Init(prefs); | |
| 25 pref_change_registrar_.Add(prefs::kDefaultZoomLevel, this); | |
| 26 } | |
| 27 } | 17 } |
| 28 | 18 |
| 29 CoreTabHelper::~CoreTabHelper() { | 19 CoreTabHelper::~CoreTabHelper() { |
| 30 } | 20 } |
| 31 | 21 |
| 32 string16 CoreTabHelper::GetDefaultTitle() { | 22 string16 CoreTabHelper::GetDefaultTitle() { |
| 33 return l10n_util::GetStringUTF16(IDS_DEFAULT_TAB_TITLE); | 23 return l10n_util::GetStringUTF16(IDS_DEFAULT_TAB_TITLE); |
| 34 } | 24 } |
| 35 | 25 |
| 36 string16 CoreTabHelper::GetStatusText() const { | 26 string16 CoreTabHelper::GetStatusText() const { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 return string16(); | 71 return string16(); |
| 82 } | 72 } |
| 83 | 73 |
| 84 //////////////////////////////////////////////////////////////////////////////// | 74 //////////////////////////////////////////////////////////////////////////////// |
| 85 // TabContentsObserver overrides | 75 // TabContentsObserver overrides |
| 86 | 76 |
| 87 void CoreTabHelper::DidBecomeSelected() { | 77 void CoreTabHelper::DidBecomeSelected() { |
| 88 WebCacheManager::GetInstance()->ObserveActivity( | 78 WebCacheManager::GetInstance()->ObserveActivity( |
| 89 tab_contents()->GetRenderProcessHost()->GetID()); | 79 tab_contents()->GetRenderProcessHost()->GetID()); |
| 90 } | 80 } |
| 91 | |
| 92 //////////////////////////////////////////////////////////////////////////////// | |
| 93 // content::NotificationObserver overrides | |
| 94 | |
| 95 void CoreTabHelper::Observe(int type, | |
| 96 const content::NotificationSource& source, | |
| 97 const content::NotificationDetails& details) { | |
| 98 switch (type) { | |
| 99 case chrome::NOTIFICATION_PREF_CHANGED: { | |
| 100 std::string* pref_name = content::Details<std::string>(details).ptr(); | |
| 101 DCHECK(content::Source<PrefService>(source).ptr() == | |
| 102 wrapper_->profile()->GetPrefs()); | |
| 103 if (*pref_name == prefs::kDefaultZoomLevel) { | |
| 104 tab_contents()->render_view_host()->SetZoomLevel( | |
| 105 tab_contents()->GetZoomLevel()); | |
| 106 } else { | |
| 107 NOTREACHED() << "unexpected pref change notification" << *pref_name; | |
| 108 } | |
| 109 break; | |
| 110 } | |
| 111 default: | |
| 112 NOTREACHED(); | |
| 113 } | |
| 114 } | |
| OLD | NEW |