| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <cmath> | 5 #include <cmath> |
| 6 | 6 |
| 7 #import "chrome/browser/cocoa/location_bar/location_icon_decoration.h" | 7 #import "chrome/browser/cocoa/location_bar/location_icon_decoration.h" |
| 8 | 8 |
| 9 #include "base/sys_string_conversions.h" | 9 #include "base/sys_string_conversions.h" |
| 10 #import "chrome/browser/cocoa/image_utils.h" | 10 #import "chrome/browser/cocoa/image_utils.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 } | 23 } |
| 24 | 24 |
| 25 void LocationIconDecoration::SetImage(NSImage* image) { | 25 void LocationIconDecoration::SetImage(NSImage* image) { |
| 26 image_.reset([image retain]); | 26 image_.reset([image retain]); |
| 27 } | 27 } |
| 28 | 28 |
| 29 CGFloat LocationIconDecoration::GetWidthForSpace(CGFloat width) { | 29 CGFloat LocationIconDecoration::GetWidthForSpace(CGFloat width) { |
| 30 NSImage* image = GetImage(); | 30 NSImage* image = GetImage(); |
| 31 if (image) { | 31 if (image) { |
| 32 const CGFloat image_width = [image size].width; | 32 const CGFloat image_width = [image size].width; |
| 33 if (image_width >= width) | 33 if (image_width <= width) |
| 34 return image_width; | 34 return image_width; |
| 35 } | 35 } |
| 36 return kOmittedWidth; | 36 return kOmittedWidth; |
| 37 } | 37 } |
| 38 | 38 |
| 39 void LocationIconDecoration::DrawInFrame(NSRect frame, NSView* control_view) { | 39 void LocationIconDecoration::DrawInFrame(NSRect frame, NSView* control_view) { |
| 40 NSImage* image = GetImage(); | 40 NSImage* image = GetImage(); |
| 41 const CGFloat delta_height = NSHeight(frame) - [image size].height; | 41 const CGFloat delta_height = NSHeight(frame) - [image size].height; |
| 42 const CGFloat y_inset = std::floor(delta_height / 2.0); | 42 const CGFloat y_inset = std::floor(delta_height / 2.0); |
| 43 [image drawInRect:NSInsetRect(frame, 0.0, y_inset) | 43 [image drawInRect:NSInsetRect(frame, 0.0, y_inset) |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 | 83 |
| 84 TabContents* tab = owner_->GetTabContents(); | 84 TabContents* tab = owner_->GetTabContents(); |
| 85 NavigationEntry* nav_entry = tab->controller().GetActiveEntry(); | 85 NavigationEntry* nav_entry = tab->controller().GetActiveEntry(); |
| 86 if (!nav_entry) { | 86 if (!nav_entry) { |
| 87 NOTREACHED(); | 87 NOTREACHED(); |
| 88 return true; | 88 return true; |
| 89 } | 89 } |
| 90 tab->ShowPageInfo(nav_entry->url(), nav_entry->ssl(), true); | 90 tab->ShowPageInfo(nav_entry->url(), nav_entry->ssl(), true); |
| 91 return true; | 91 return true; |
| 92 } | 92 } |
| OLD | NEW |