| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/cocoa/browser/zoom_bubble_controller.h" | 5 #include "chrome/browser/ui/cocoa/browser/zoom_bubble_controller.h" |
| 6 | 6 |
| 7 #include "base/i18n/number_formatting.h" | 7 #include "base/i18n/number_formatting.h" |
| 8 #include "base/mac/foundation_util.h" | 8 #include "base/mac/foundation_util.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
| 11 #import "chrome/browser/ui/cocoa/info_bubble_view.h" | 11 #import "chrome/browser/ui/cocoa/info_bubble_view.h" |
| 12 #import "chrome/browser/ui/cocoa/info_bubble_window.h" | 12 #import "chrome/browser/ui/cocoa/info_bubble_window.h" |
| 13 #include "chrome/grit/generated_resources.h" | 13 #include "chrome/grit/generated_resources.h" |
| 14 #include "components/ui/zoom/page_zoom.h" | 14 #include "components/zoom/page_zoom.h" |
| 15 #include "components/ui/zoom/zoom_controller.h" | 15 #include "components/zoom/zoom_controller.h" |
| 16 #include "content/public/common/page_zoom.h" | 16 #include "content/public/common/page_zoom.h" |
| 17 #include "skia/ext/skia_utils_mac.h" | 17 #include "skia/ext/skia_utils_mac.h" |
| 18 #import "ui/base/cocoa/hover_button.h" | 18 #import "ui/base/cocoa/hover_button.h" |
| 19 #import "ui/base/cocoa/window_size_constants.h" | 19 #import "ui/base/cocoa/window_size_constants.h" |
| 20 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
| 21 #include "ui/native_theme/native_theme.h" | 21 #include "ui/native_theme/native_theme.h" |
| 22 #include "ui/native_theme/native_theme_mac.h" | 22 #include "ui/native_theme/native_theme_mac.h" |
| 23 | 23 |
| 24 @interface ZoomBubbleController (Private) | 24 @interface ZoomBubbleController (Private) |
| 25 - (void)performLayout; | 25 - (void)performLayout; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 return; | 136 return; |
| 137 | 137 |
| 138 // TODO(shess): It may be appropriate to close the window if | 138 // TODO(shess): It may be appropriate to close the window if |
| 139 // |contents| or |zoomController| are NULL. But they can be NULL in | 139 // |contents| or |zoomController| are NULL. But they can be NULL in |
| 140 // tests. | 140 // tests. |
| 141 | 141 |
| 142 content::WebContents* contents = delegate_->GetWebContents(); | 142 content::WebContents* contents = delegate_->GetWebContents(); |
| 143 if (!contents) | 143 if (!contents) |
| 144 return; | 144 return; |
| 145 | 145 |
| 146 ui_zoom::ZoomController* zoomController = | 146 zoom::ZoomController* zoomController = |
| 147 ui_zoom::ZoomController::FromWebContents(contents); | 147 zoom::ZoomController::FromWebContents(contents); |
| 148 if (!zoomController) | 148 if (!zoomController) |
| 149 return; | 149 return; |
| 150 | 150 |
| 151 int percent = zoomController->GetZoomPercent(); | 151 int percent = zoomController->GetZoomPercent(); |
| 152 NSString* string = base::SysUTF16ToNSString(base::FormatPercent(percent)); | 152 NSString* string = base::SysUTF16ToNSString(base::FormatPercent(percent)); |
| 153 [zoomPercent_ setAttributedStringValue: | 153 [zoomPercent_ setAttributedStringValue: |
| 154 [self attributedStringWithString:string | 154 [self attributedStringWithString:string |
| 155 fontSize:kTextFontSize]]; | 155 fontSize:kTextFontSize]]; |
| 156 | 156 |
| 157 [self updateAutoCloseTimer]; | 157 [self updateAutoCloseTimer]; |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 - (void)zoomHelper:(content::PageZoom)alterPageZoom { | 318 - (void)zoomHelper:(content::PageZoom)alterPageZoom { |
| 319 // |delegate| can be null after -windowWillClose:. | 319 // |delegate| can be null after -windowWillClose:. |
| 320 if (!delegate_) | 320 if (!delegate_) |
| 321 return; | 321 return; |
| 322 content::WebContents* webContents = delegate_->GetWebContents(); | 322 content::WebContents* webContents = delegate_->GetWebContents(); |
| 323 | 323 |
| 324 // TODO(shess): Zoom() immediately dereferences |webContents|, and | 324 // TODO(shess): Zoom() immediately dereferences |webContents|, and |
| 325 // there haven't been associated crashes in the wild, so it seems | 325 // there haven't been associated crashes in the wild, so it seems |
| 326 // fine in practice. It might make sense to close the bubble in | 326 // fine in practice. It might make sense to close the bubble in |
| 327 // that case, though. | 327 // that case, though. |
| 328 ui_zoom::PageZoom::Zoom(webContents, alterPageZoom); | 328 zoom::PageZoom::Zoom(webContents, alterPageZoom); |
| 329 } | 329 } |
| 330 | 330 |
| 331 @end | 331 @end |
| 332 | 332 |
| 333 @implementation ZoomHoverButton | 333 @implementation ZoomHoverButton |
| 334 | 334 |
| 335 - (void)drawRect:(NSRect)rect { | 335 - (void)drawRect:(NSRect)rect { |
| 336 NSRect bounds = [self bounds]; | 336 NSRect bounds = [self bounds]; |
| 337 NSAttributedString* title = [self attributedTitle]; | 337 NSAttributedString* title = [self attributedTitle]; |
| 338 if ([self hoverState] != kHoverStateNone) { | 338 if ([self hoverState] != kHoverStateNone) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 352 range:NSMakeRange(0, [title length])]; | 352 range:NSMakeRange(0, [title length])]; |
| 353 title = selectedTitle.autorelease(); | 353 title = selectedTitle.autorelease(); |
| 354 } | 354 } |
| 355 | 355 |
| 356 [[self cell] drawTitle:title | 356 [[self cell] drawTitle:title |
| 357 withFrame:bounds | 357 withFrame:bounds |
| 358 inView:self]; | 358 inView:self]; |
| 359 } | 359 } |
| 360 | 360 |
| 361 @end | 361 @end |
| OLD | NEW |