| 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 #include "chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h" | 5 #include "chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/mac/mac_util.h" | 9 #include "base/mac/mac_util.h" |
| 10 #import "base/mac/sdk_forward_declarations.h" | 10 #import "base/mac/sdk_forward_declarations.h" |
| 11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 12 #include "base/strings/sys_string_conversions.h" | 12 #include "base/strings/sys_string_conversions.h" |
| 13 #include "chrome/browser/search/search.h" | 13 #include "chrome/browser/search/search.h" |
| 14 #include "chrome/browser/ui/cocoa/browser_window_controller.h" | 14 #include "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 15 #import "chrome/browser/ui/cocoa/omnibox/omnibox_popup_cell.h" | 15 #import "chrome/browser/ui/cocoa/omnibox/omnibox_popup_cell.h" |
| 16 #import "chrome/browser/ui/cocoa/omnibox/omnibox_popup_separator_view.h" | 16 #import "chrome/browser/ui/cocoa/omnibox/omnibox_popup_separator_view.h" |
| 17 #include "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" | 17 #include "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" |
| 18 #include "chrome/grit/theme_resources.h" | 18 #include "chrome/grit/theme_resources.h" |
| 19 #include "components/omnibox/browser/autocomplete_match.h" | 19 #include "components/omnibox/browser/autocomplete_match.h" |
| 20 #include "components/omnibox/browser/autocomplete_match_type.h" | 20 #include "components/omnibox/browser/autocomplete_match_type.h" |
| 21 #include "components/omnibox/browser/omnibox_edit_model.h" | 21 #include "components/omnibox/browser/omnibox_edit_model.h" |
| 22 #include "components/omnibox/browser/omnibox_popup_model.h" | 22 #include "components/omnibox/browser/omnibox_popup_model.h" |
| 23 #include "components/toolbar/vector_icons.h" |
| 23 #include "skia/ext/skia_utils_mac.h" | 24 #include "skia/ext/skia_utils_mac.h" |
| 24 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSAnimation+Duration.h
" | 25 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSAnimation+Duration.h
" |
| 25 #import "ui/base/cocoa/cocoa_base_utils.h" | 26 #import "ui/base/cocoa/cocoa_base_utils.h" |
| 26 #import "ui/base/cocoa/flipped_view.h" | 27 #import "ui/base/cocoa/flipped_view.h" |
| 27 #include "ui/base/cocoa/window_size_constants.h" | 28 #include "ui/base/cocoa/window_size_constants.h" |
| 28 #include "ui/base/material_design/material_design_controller.h" | 29 #include "ui/base/material_design/material_design_controller.h" |
| 29 #include "ui/gfx/color_palette.h" | 30 #include "ui/gfx/color_palette.h" |
| 30 #include "ui/gfx/geometry/rect.h" | 31 #include "ui/gfx/geometry/rect.h" |
| 31 #include "ui/gfx/image/image_skia_util_mac.h" | 32 #include "ui/gfx/image/image_skia_util_mac.h" |
| 32 #include "ui/gfx/paint_vector_icon.h" | 33 #include "ui/gfx/paint_vector_icon.h" |
| 33 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" | 34 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" |
| 34 #include "ui/gfx/text_elider.h" | 35 #include "ui/gfx/text_elider.h" |
| 35 #include "ui/gfx/vector_icons_public.h" | |
| 36 | 36 |
| 37 namespace { | 37 namespace { |
| 38 | 38 |
| 39 const int kMaterialPopupPaddingVertical = 4; | 39 const int kMaterialPopupPaddingVertical = 4; |
| 40 | 40 |
| 41 // Padding between matrix and the top and bottom of the popup window. | 41 // Padding between matrix and the top and bottom of the popup window. |
| 42 CGFloat PopupPaddingVertical() { | 42 CGFloat PopupPaddingVertical() { |
| 43 return kMaterialPopupPaddingVertical; | 43 return kMaterialPopupPaddingVertical; |
| 44 } | 44 } |
| 45 | 45 |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 | 325 |
| 326 NSImage* OmniboxPopupViewMac::ImageForMatch( | 326 NSImage* OmniboxPopupViewMac::ImageForMatch( |
| 327 const AutocompleteMatch& match) const { | 327 const AutocompleteMatch& match) const { |
| 328 gfx::Image image = model_->GetIconIfExtensionMatch(match); | 328 gfx::Image image = model_->GetIconIfExtensionMatch(match); |
| 329 if (!image.IsEmpty()) | 329 if (!image.IsEmpty()) |
| 330 return image.AsNSImage(); | 330 return image.AsNSImage(); |
| 331 | 331 |
| 332 bool is_dark_mode = [matrix_ hasDarkTheme]; | 332 bool is_dark_mode = [matrix_ hasDarkTheme]; |
| 333 const SkColor icon_color = | 333 const SkColor icon_color = |
| 334 is_dark_mode ? SkColorSetA(SK_ColorWHITE, 0xCC) : gfx::kChromeIconGrey; | 334 is_dark_mode ? SkColorSetA(SK_ColorWHITE, 0xCC) : gfx::kChromeIconGrey; |
| 335 const gfx::VectorIconId vector_icon_id = | 335 const gfx::VectorIcon& vector_icon = |
| 336 model_->IsStarredMatch(match) | 336 model_->IsStarredMatch(match) |
| 337 ? gfx::VectorIconId::LOCATION_BAR_STAR | 337 ? toolbar::kStarIcon |
| 338 : AutocompleteMatch::TypeToVectorIcon(match.type); | 338 : AutocompleteMatch::TypeToVectorIcon(match.type); |
| 339 const int kIconSize = 16; | 339 const int kIconSize = 16; |
| 340 return NSImageFromImageSkia( | 340 return NSImageFromImageSkia( |
| 341 gfx::CreateVectorIcon(vector_icon_id, kIconSize, icon_color)); | 341 gfx::CreateVectorIcon(vector_icon, kIconSize, icon_color)); |
| 342 } | 342 } |
| 343 | 343 |
| 344 void OmniboxPopupViewMac::OpenURLForRow(size_t row, | 344 void OmniboxPopupViewMac::OpenURLForRow(size_t row, |
| 345 WindowOpenDisposition disposition) { | 345 WindowOpenDisposition disposition) { |
| 346 DCHECK_LT(row, GetResult().size()); | 346 DCHECK_LT(row, GetResult().size()); |
| 347 omnibox_view_->OpenMatch(GetResult().match_at(row), disposition, GURL(), | 347 omnibox_view_->OpenMatch(GetResult().match_at(row), disposition, GURL(), |
| 348 base::string16(), row); | 348 base::string16(), row); |
| 349 } | 349 } |
| OLD | NEW |