| 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 "chrome/browser/ui/zoom/zoom_controller.h" | 5 #include "chrome/browser/ui/zoom/zoom_controller.h" |
| 6 | 6 |
| 7 #include "chrome/browser/prefs/pref_service.h" | 7 #include "chrome/browser/prefs/pref_service.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/ui/browser_finder.h" | 9 #include "chrome/browser/ui/browser_finder.h" |
| 10 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 10 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 default_zoom_level_.Init(prefs::kDefaultZoomLevel, profile->GetPrefs(), this); | 31 default_zoom_level_.Init(prefs::kDefaultZoomLevel, profile->GetPrefs(), this); |
| 32 | 32 |
| 33 content::HostZoomMap* zoom_map = | 33 content::HostZoomMap* zoom_map = |
| 34 content::HostZoomMap::GetForBrowserContext(profile); | 34 content::HostZoomMap::GetForBrowserContext(profile); |
| 35 registrar_.Add(this, content::NOTIFICATION_ZOOM_LEVEL_CHANGED, | 35 registrar_.Add(this, content::NOTIFICATION_ZOOM_LEVEL_CHANGED, |
| 36 content::Source<content::HostZoomMap>(zoom_map)); | 36 content::Source<content::HostZoomMap>(zoom_map)); |
| 37 | 37 |
| 38 UpdateState(std::string()); | 38 UpdateState(std::string()); |
| 39 } | 39 } |
| 40 | 40 |
| 41 ZoomController::~ZoomController() { | 41 ZoomController::~ZoomController() {} |
| 42 default_zoom_level_.Destroy(); | |
| 43 registrar_.RemoveAll(); | |
| 44 } | |
| 45 | 42 |
| 46 bool ZoomController::IsAtDefaultZoom() const { | 43 bool ZoomController::IsAtDefaultZoom() const { |
| 47 return content::ZoomValuesEqual(web_contents()->GetZoomLevel(), | 44 return content::ZoomValuesEqual(web_contents()->GetZoomLevel(), |
| 48 default_zoom_level_.GetValue()); | 45 default_zoom_level_.GetValue()); |
| 49 } | 46 } |
| 50 | 47 |
| 51 int ZoomController::GetResourceForZoomLevel() const { | 48 int ZoomController::GetResourceForZoomLevel() const { |
| 52 DCHECK(!IsAtDefaultZoom()); | 49 DCHECK(!IsAtDefaultZoom()); |
| 53 double zoom = web_contents()->GetZoomLevel(); | 50 double zoom = web_contents()->GetZoomLevel(); |
| 54 return zoom > default_zoom_level_.GetValue() ? IDR_ZOOM_PLUS : IDR_ZOOM_MINUS; | 51 return zoom > default_zoom_level_.GetValue() ? IDR_ZOOM_PLUS : IDR_ZOOM_MINUS; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 return; | 86 return; |
| 90 } | 87 } |
| 91 } | 88 } |
| 92 | 89 |
| 93 bool dummy; | 90 bool dummy; |
| 94 zoom_percent_ = web_contents()->GetZoomPercent(&dummy, &dummy); | 91 zoom_percent_ = web_contents()->GetZoomPercent(&dummy, &dummy); |
| 95 | 92 |
| 96 if (observer_) | 93 if (observer_) |
| 97 observer_->OnZoomChanged(web_contents(), !host.empty()); | 94 observer_->OnZoomChanged(web_contents(), !host.empty()); |
| 98 } | 95 } |
| OLD | NEW |