| 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 "base/prefs/pref_service.h" | 7 #include "base/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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 47       browser_context_)->RemoveZoomLevelChangedCallback( | 47       browser_context_)->RemoveZoomLevelChangedCallback( | 
| 48           zoom_callback_); | 48           zoom_callback_); | 
| 49 } | 49 } | 
| 50 | 50 | 
| 51 bool ZoomController::IsAtDefaultZoom() const { | 51 bool ZoomController::IsAtDefaultZoom() const { | 
| 52   return content::ZoomValuesEqual(web_contents()->GetZoomLevel(), | 52   return content::ZoomValuesEqual(web_contents()->GetZoomLevel(), | 
| 53                                   default_zoom_level_.GetValue()); | 53                                   default_zoom_level_.GetValue()); | 
| 54 } | 54 } | 
| 55 | 55 | 
| 56 int ZoomController::GetResourceForZoomLevel() const { | 56 int ZoomController::GetResourceForZoomLevel() const { | 
| 57   DCHECK(!IsAtDefaultZoom()); | 57   if (IsAtDefaultZoom()) | 
|  | 58     return IDR_ZOOM_NORMAL; | 
| 58   double zoom = web_contents()->GetZoomLevel(); | 59   double zoom = web_contents()->GetZoomLevel(); | 
| 59   return zoom > default_zoom_level_.GetValue() ? IDR_ZOOM_PLUS : IDR_ZOOM_MINUS; | 60   return zoom > default_zoom_level_.GetValue() ? IDR_ZOOM_PLUS : IDR_ZOOM_MINUS; | 
| 60 } | 61 } | 
| 61 | 62 | 
| 62 void ZoomController::DidNavigateMainFrame( | 63 void ZoomController::DidNavigateMainFrame( | 
| 63     const content::LoadCommittedDetails& details, | 64     const content::LoadCommittedDetails& details, | 
| 64     const content::FrameNavigateParams& params) { | 65     const content::FrameNavigateParams& params) { | 
| 65   // If the main frame's content has changed, the new page may have a different | 66   // If the main frame's content has changed, the new page may have a different | 
| 66   // zoom level from the old one. | 67   // zoom level from the old one. | 
| 67   UpdateState(std::string()); | 68   UpdateState(std::string()); | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
| 83       return; | 84       return; | 
| 84     } | 85     } | 
| 85   } | 86   } | 
| 86 | 87 | 
| 87   bool dummy; | 88   bool dummy; | 
| 88   zoom_percent_ = web_contents()->GetZoomPercent(&dummy, &dummy); | 89   zoom_percent_ = web_contents()->GetZoomPercent(&dummy, &dummy); | 
| 89 | 90 | 
| 90   if (observer_) | 91   if (observer_) | 
| 91     observer_->OnZoomChanged(web_contents(), !host.empty()); | 92     observer_->OnZoomChanged(web_contents(), !host.empty()); | 
| 92 } | 93 } | 
| OLD | NEW | 
|---|