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

Unified Diff: chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm

Issue 10736028: 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
Index: chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm
diff --git a/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm b/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm
index ff0579130307dba0c2df59c78101475f616c1c82..a7587a564a2696ac7c939b7a53fcafcb30400ac4 100644
--- a/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm
+++ b/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm
@@ -44,6 +44,7 @@
#import "chrome/browser/ui/cocoa/location_bar/plus_decoration.h"
#import "chrome/browser/ui/cocoa/location_bar/selected_keyword_decoration.h"
#import "chrome/browser/ui/cocoa/location_bar/star_decoration.h"
+#import "chrome/browser/ui/cocoa/location_bar/zoom_decoration.h"
#import "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h"
#include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
#include "chrome/browser/ui/content_settings/content_setting_image_model.h"
@@ -99,6 +100,7 @@ LocationBarViewMac::LocationBarViewMac(
plus_decoration_(NULL),
star_decoration_(new StarDecoration(command_updater)),
chrome_to_mobile_decoration_(NULL),
+ zoom_decoration_(new ZoomDecoration(toolbar_model)),
keyword_hint_decoration_(
new KeywordHintDecoration(OmniboxViewMac::GetFieldFont())),
profile_(profile),
@@ -246,6 +248,7 @@ void LocationBarViewMac::Update(const WebContents* contents,
command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled);
star_decoration_->SetVisible(star_enabled);
UpdateChromeToMobileEnabled();
+ UpdateZoomDecoration();
RefreshPageActionDecorations();
RefreshContentSettingsDecorations();
// OmniboxView restores state if the tab is non-NULL.
@@ -458,6 +461,7 @@ void LocationBarViewMac::SetEditable(bool editable) {
[field_ setEditable:editable ? YES : NO];
star_decoration_->SetVisible(IsStarEnabled());
UpdateChromeToMobileEnabled();
+ UpdateZoomDecoration();
UpdatePageActions();
Layout();
}
@@ -466,9 +470,7 @@ bool LocationBarViewMac::IsEditable() {
return [field_ isEditable] ? true : false;
}
-void LocationBarViewMac::SetStarred(bool starred) {
- star_decoration_->SetStarred(starred);
-
+void LocationBarViewMac::OnImageDecorationsChanged() {
// TODO(shess): The field-editor frame and cursor rects should not
// change, here.
[field_ updateCursorAndToolTipRects];
@@ -476,14 +478,22 @@ void LocationBarViewMac::SetStarred(bool starred) {
[field_ setNeedsDisplay:YES];
}
+void LocationBarViewMac::SetStarred(bool starred) {
+ star_decoration_->SetStarred(starred);
+ OnImageDecorationsChanged();
+}
+
void LocationBarViewMac::SetChromeToMobileDecorationLit(bool lit) {
chrome_to_mobile_decoration_->SetLit(lit);
+ OnImageDecorationsChanged();
+}
- // TODO(shess): The field-editor frame and cursor rects should not
- // change, here.
- [field_ updateCursorAndToolTipRects];
- [field_ resetFieldEditorFrameIfNeeded];
- [field_ setNeedsDisplay:YES];
+void LocationBarViewMac::ZoomChangedForActiveTab(bool can_show_bubble) {
+ UpdateZoomDecoration();
+ OnImageDecorationsChanged();
+
+ // TODO(dbeam): show a zoom bubble when |can_show_bubble| is true, the zoom
+ // decoration is showing and the wrench menu isn't showing.
}
NSPoint LocationBarViewMac::GetBookmarkBubblePoint() const {
@@ -649,6 +659,7 @@ void LocationBarViewMac::Layout() {
if (plus_decoration_.get())
[cell addRightDecoration:plus_decoration_.get()];
[cell addRightDecoration:star_decoration_.get()];
+ [cell addRightDecoration:zoom_decoration_.get()];
if (chrome_to_mobile_decoration_.get())
[cell addRightDecoration:chrome_to_mobile_decoration_.get()];
@@ -733,3 +744,11 @@ void LocationBarViewMac::UpdateChromeToMobileEnabled() {
chrome_to_mobile_decoration_->SetVisible(enabled);
command_updater_->UpdateCommandEnabled(IDC_CHROME_TO_MOBILE_PAGE, enabled);
}
+
+void LocationBarViewMac::UpdateZoomDecoration() {
+ TabContents* tab_contents = GetTabContents();
+ if (!zoom_decoration_.get() || !tab_contents)
+ return;
+
+ zoom_decoration_->Update(tab_contents->zoom_controller());
+}

Powered by Google App Engine
This is Rietveld 408576698