| 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/i18n/number_formatting.h" | 7 #include "base/i18n/number_formatting.h" |
| 8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
| 11 #import "chrome/browser/ui/cocoa/l10n_util.h" |
| 11 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h" | 12 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h" |
| 12 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" | 13 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" |
| 13 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" | 14 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" |
| 14 #import "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" | 15 #import "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" |
| 15 #include "chrome/grit/generated_resources.h" | 16 #include "chrome/grit/generated_resources.h" |
| 16 #include "chrome/grit/theme_resources.h" | 17 #include "chrome/grit/theme_resources.h" |
| 17 #include "components/zoom/zoom_controller.h" | 18 #include "components/zoom/zoom_controller.h" |
| 18 #include "ui/base/cocoa/cocoa_base_utils.h" | 19 #include "ui/base/cocoa/cocoa_base_utils.h" |
| 19 #include "ui/base/l10n/l10n_util_mac.h" | 20 #include "ui/base/l10n/l10n_util_mac.h" |
| 20 #include "ui/base/material_design/material_design_controller.h" | 21 #include "ui/base/material_design/material_design_controller.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 | 110 |
| 110 SetImage(GetMaterialIcon(location_bar_is_dark)); | 111 SetImage(GetMaterialIcon(location_bar_is_dark)); |
| 111 | 112 |
| 112 tooltip_.reset([tooltip_string retain]); | 113 tooltip_.reset([tooltip_string retain]); |
| 113 | 114 |
| 114 SetVisible(true); | 115 SetVisible(true); |
| 115 [bubble_ onZoomChanged]; | 116 [bubble_ onZoomChanged]; |
| 116 } | 117 } |
| 117 | 118 |
| 118 NSPoint ZoomDecoration::GetBubblePointInFrame(NSRect frame) { | 119 NSPoint ZoomDecoration::GetBubblePointInFrame(NSRect frame) { |
| 119 return NSMakePoint(NSMaxX(frame), NSMaxY(frame)); | 120 return NSMakePoint(cocoa_l10n_util::ShouldDoExperimentalRTLLayout() |
| 121 ? NSMinX(frame) |
| 122 : NSMaxX(frame), |
| 123 NSMaxY(frame)); |
| 120 } | 124 } |
| 121 | 125 |
| 122 bool ZoomDecoration::IsAtDefaultZoom() const { | 126 bool ZoomDecoration::IsAtDefaultZoom() const { |
| 123 content::WebContents* web_contents = owner_->GetWebContents(); | 127 content::WebContents* web_contents = owner_->GetWebContents(); |
| 124 if (!web_contents) | 128 if (!web_contents) |
| 125 return false; | 129 return false; |
| 126 | 130 |
| 127 zoom::ZoomController* zoomController = | 131 zoom::ZoomController* zoomController = |
| 128 zoom::ZoomController::FromWebContents(web_contents); | 132 zoom::ZoomController::FromWebContents(web_contents); |
| 129 return zoomController && zoomController->IsAtDefaultZoom(); | 133 return zoomController && zoomController->IsAtDefaultZoom(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 // closed the decoration can be hidden. | 168 // closed the decoration can be hidden. |
| 165 if (IsAtDefaultZoom() && IsVisible()) { | 169 if (IsAtDefaultZoom() && IsVisible()) { |
| 166 SetVisible(false); | 170 SetVisible(false); |
| 167 owner_->OnDecorationsChanged(); | 171 owner_->OnDecorationsChanged(); |
| 168 } | 172 } |
| 169 } | 173 } |
| 170 | 174 |
| 171 gfx::VectorIconId ZoomDecoration::GetMaterialVectorIconId() const { | 175 gfx::VectorIconId ZoomDecoration::GetMaterialVectorIconId() const { |
| 172 return vector_icon_id_; | 176 return vector_icon_id_; |
| 173 } | 177 } |
| OLD | NEW |