| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #import "chrome/browser/ui/cocoa/location_bar/zoom_decoration.h" | 5 #import "chrome/browser/ui/cocoa/location_bar/zoom_decoration.h" |
| 6 | 6 |
| 7 #include "base/strings/string16.h" | 7 #include "base/strings/string16.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
| 10 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h" | 10 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h" |
| 11 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" | 11 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" |
| 12 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" | 12 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" |
| 13 #import "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" | 13 #import "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" |
| 14 #include "chrome/grit/generated_resources.h" | 14 #include "chrome/grit/generated_resources.h" |
| 15 #include "components/ui/zoom/zoom_controller.h" | 15 #include "components/ui/zoom/zoom_controller.h" |
| 16 #include "grit/theme_resources.h" | 16 #include "grit/theme_resources.h" |
| 17 #include "ui/base/cocoa/cocoa_base_utils.h" |
| 17 #include "ui/base/l10n/l10n_util_mac.h" | 18 #include "ui/base/l10n/l10n_util_mac.h" |
| 18 | 19 |
| 19 ZoomDecoration::ZoomDecoration(LocationBarViewMac* owner) | 20 ZoomDecoration::ZoomDecoration(LocationBarViewMac* owner) |
| 20 : owner_(owner), | 21 : owner_(owner), |
| 21 bubble_(nil) { | 22 bubble_(nil) { |
| 22 } | 23 } |
| 23 | 24 |
| 24 ZoomDecoration::~ZoomDecoration() { | 25 ZoomDecoration::~ZoomDecoration() { |
| 25 [bubble_ closeWithoutAnimation]; | 26 [bubble_ closeWithoutAnimation]; |
| 26 bubble_.delegate = nil; | 27 bubble_.delegate = nil; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 return; | 64 return; |
| 64 | 65 |
| 65 // Get the frame of the decoration. | 66 // Get the frame of the decoration. |
| 66 AutocompleteTextField* field = owner_->GetAutocompleteTextField(); | 67 AutocompleteTextField* field = owner_->GetAutocompleteTextField(); |
| 67 const NSRect frame = | 68 const NSRect frame = |
| 68 [[field cell] frameForDecoration:this inFrame:[field bounds]]; | 69 [[field cell] frameForDecoration:this inFrame:[field bounds]]; |
| 69 | 70 |
| 70 // Find point for bubble's arrow in screen coordinates. | 71 // Find point for bubble's arrow in screen coordinates. |
| 71 NSPoint anchor = GetBubblePointInFrame(frame); | 72 NSPoint anchor = GetBubblePointInFrame(frame); |
| 72 anchor = [field convertPoint:anchor toView:nil]; | 73 anchor = [field convertPoint:anchor toView:nil]; |
| 73 anchor = [[field window] convertBaseToScreen:anchor]; | 74 anchor = ui::ConvertPointFromWindowToScreen([field window], anchor); |
| 74 | 75 |
| 75 bubble_ = [[ZoomBubbleController alloc] initWithParentWindow:[field window] | 76 bubble_ = [[ZoomBubbleController alloc] initWithParentWindow:[field window] |
| 76 delegate:this]; | 77 delegate:this]; |
| 77 [bubble_ showAnchoredAt:anchor autoClose:auto_close]; | 78 [bubble_ showAnchoredAt:anchor autoClose:auto_close]; |
| 78 } | 79 } |
| 79 | 80 |
| 80 void ZoomDecoration::CloseBubble() { | 81 void ZoomDecoration::CloseBubble() { |
| 81 [bubble_ close]; | 82 [bubble_ close]; |
| 82 } | 83 } |
| 83 | 84 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 bubble_ = nil; | 150 bubble_ = nil; |
| 150 | 151 |
| 151 // If the page is at default zoom then hiding the zoom decoration | 152 // If the page is at default zoom then hiding the zoom decoration |
| 152 // was suppressed while the bubble was open. Now that the bubble is | 153 // was suppressed while the bubble was open. Now that the bubble is |
| 153 // closed the decoration can be hidden. | 154 // closed the decoration can be hidden. |
| 154 if (IsAtDefaultZoom() && IsVisible()) { | 155 if (IsAtDefaultZoom() && IsVisible()) { |
| 155 SetVisible(false); | 156 SetVisible(false); |
| 156 owner_->OnDecorationsChanged(); | 157 owner_->OnDecorationsChanged(); |
| 157 } | 158 } |
| 158 } | 159 } |
| OLD | NEW |