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

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: fix mac Created 8 years, 5 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 ce77e5c4e63a00b0a4c1140f94ef3ee82dfb4299..249120a84fba865d93935ef75ebdc86440264bde 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
@@ -46,6 +46,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"
@@ -101,6 +102,7 @@ LocationBarViewMac::LocationBarViewMac(
plus_decoration_(NULL),
star_decoration_(new StarDecoration(command_updater)),
chrome_to_mobile_decoration_(nil),
+ zoom_decoration_(new ZoomDecoration(toolbar_model)),
keyword_hint_decoration_(
new KeywordHintDecoration(OmniboxViewMac::GetFieldFont())),
profile_(profile),
@@ -248,6 +250,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.
@@ -460,6 +463,7 @@ void LocationBarViewMac::SetEditable(bool editable) {
[field_ setEditable:editable ? YES : NO];
star_decoration_->SetVisible(IsStarEnabled());
UpdateChromeToMobileEnabled();
+ UpdateZoomDecoration();
UpdatePageActions();
Layout();
}
@@ -468,9 +472,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];
@@ -478,14 +480,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 the wrench menu's not open and it's
+ // appropriate to do so.
}
NSPoint LocationBarViewMac::GetBookmarkBubblePoint() const {
@@ -651,6 +661,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()];
@@ -735,3 +746,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