Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4485)

Unified Diff: chrome/browser/ui/zoom/zoom_controller.cc

Issue 10831372: Revert 152080 - Refactor browser window zoom handling and enable zoom icon on all platforms. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/zoom/zoom_controller.h ('k') | chrome/browser/ui/zoom/zoom_observer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/zoom/zoom_controller.cc
===================================================================
--- chrome/browser/ui/zoom/zoom_controller.cc (revision 152086)
+++ chrome/browser/ui/zoom/zoom_controller.cc (working copy)
@@ -14,10 +14,10 @@
#include "content/public/browser/notification_service.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/page_zoom.h"
-#include "grit/theme_resources.h"
ZoomController::ZoomController(TabContents* tab_contents)
: content::WebContentsObserver(tab_contents->web_contents()),
+ zoom_icon_state_(NONE),
zoom_percent_(100),
tab_contents_(tab_contents),
observer_(NULL) {
@@ -34,17 +34,6 @@
registrar_.RemoveAll();
}
-bool ZoomController::IsAtDefaultZoom() const {
- return content::ZoomValuesEqual(tab_contents_->web_contents()->GetZoomLevel(),
- default_zoom_level_.GetValue());
-}
-
-int ZoomController::GetResourceForZoomLevel() const {
- DCHECK(!IsAtDefaultZoom());
- double zoom = tab_contents_->web_contents()->GetZoomLevel();
- return zoom > default_zoom_level_.GetValue() ? IDR_ZOOM_PLUS : IDR_ZOOM_MINUS;
-}
-
void ZoomController::DidNavigateMainFrame(
const content::LoadCommittedDetails& details,
const content::FrameNavigateParams& params) {
@@ -72,9 +61,32 @@
}
void ZoomController::UpdateState(bool can_show_bubble) {
+ double current_zoom_level = tab_contents_->web_contents()->GetZoomLevel();
+ double default_zoom_level = default_zoom_level_.GetValue();
+
+ ZoomIconState state;
+ if (content::ZoomValuesEqual(current_zoom_level, default_zoom_level))
+ state = NONE;
+ else if (current_zoom_level > default_zoom_level)
+ state = ZOOM_PLUS_ICON;
+ else
+ state = ZOOM_MINUS_ICON;
+
bool dummy;
- zoom_percent_ = tab_contents_->web_contents()->GetZoomPercent(&dummy, &dummy);
+ int zoom_percent = tab_contents_->web_contents()->
+ GetZoomPercent(&dummy, &dummy);
- if (observer_)
- observer_->OnZoomChanged(tab_contents_, can_show_bubble);
+ if (state != zoom_icon_state_) {
+ zoom_icon_state_ = state;
+ if (observer_)
+ observer_->OnZoomIconChanged(tab_contents_, state);
+ }
+
+ if (zoom_percent != zoom_percent_) {
+ zoom_percent_ = zoom_percent;
+ if (observer_)
+ observer_->OnZoomChanged(tab_contents_,
+ zoom_percent,
+ can_show_bubble && state != NONE);
+ }
}
« no previous file with comments | « chrome/browser/ui/zoom/zoom_controller.h ('k') | chrome/browser/ui/zoom/zoom_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698