| 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/common/chrome_notification_types.h" | 10 #include "chrome/common/chrome_notification_types.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 std::string())); | 33 std::string())); |
| 34 | 34 |
| 35 content::HostZoomMap* zoom_map = | 35 content::HostZoomMap* zoom_map = |
| 36 content::HostZoomMap::GetForBrowserContext(profile); | 36 content::HostZoomMap::GetForBrowserContext(profile); |
| 37 registrar_.Add(this, content::NOTIFICATION_ZOOM_LEVEL_CHANGED, | 37 registrar_.Add(this, content::NOTIFICATION_ZOOM_LEVEL_CHANGED, |
| 38 content::Source<content::HostZoomMap>(zoom_map)); | 38 content::Source<content::HostZoomMap>(zoom_map)); |
| 39 | 39 |
| 40 UpdateState(std::string()); | 40 UpdateState(std::string()); |
| 41 } | 41 } |
| 42 | 42 |
| 43 ZoomController::~ZoomController() { | 43 ZoomController::~ZoomController() {} |
| 44 default_zoom_level_.Destroy(); | |
| 45 registrar_.RemoveAll(); | |
| 46 } | |
| 47 | 44 |
| 48 bool ZoomController::IsAtDefaultZoom() const { | 45 bool ZoomController::IsAtDefaultZoom() const { |
| 49 return content::ZoomValuesEqual(web_contents()->GetZoomLevel(), | 46 return content::ZoomValuesEqual(web_contents()->GetZoomLevel(), |
| 50 default_zoom_level_.GetValue()); | 47 default_zoom_level_.GetValue()); |
| 51 } | 48 } |
| 52 | 49 |
| 53 int ZoomController::GetResourceForZoomLevel() const { | 50 int ZoomController::GetResourceForZoomLevel() const { |
| 54 DCHECK(!IsAtDefaultZoom()); | 51 DCHECK(!IsAtDefaultZoom()); |
| 55 double zoom = web_contents()->GetZoomLevel(); | 52 double zoom = web_contents()->GetZoomLevel(); |
| 56 return zoom > default_zoom_level_.GetValue() ? IDR_ZOOM_PLUS : IDR_ZOOM_MINUS; | 53 return zoom > default_zoom_level_.GetValue() ? IDR_ZOOM_PLUS : IDR_ZOOM_MINUS; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 85 return; | 82 return; |
| 86 } | 83 } |
| 87 } | 84 } |
| 88 | 85 |
| 89 bool dummy; | 86 bool dummy; |
| 90 zoom_percent_ = web_contents()->GetZoomPercent(&dummy, &dummy); | 87 zoom_percent_ = web_contents()->GetZoomPercent(&dummy, &dummy); |
| 91 | 88 |
| 92 if (observer_) | 89 if (observer_) |
| 93 observer_->OnZoomChanged(web_contents(), !host.empty()); | 90 observer_->OnZoomChanged(web_contents(), !host.empty()); |
| 94 } | 91 } |
| OLD | NEW |