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" |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 [[popup_ animator] setFrame:popup_frame display:YES]; | 329 [[popup_ animator] setFrame:popup_frame display:YES]; |
330 [NSAnimationContext endGrouping]; | 330 [NSAnimationContext endGrouping]; |
331 | 331 |
332 if (!animate) { | 332 if (!animate) { |
333 // Restore the original animations dictionary. This does not reinstate any | 333 // Restore the original animations dictionary. This does not reinstate any |
334 // previously running animations. | 334 // previously running animations. |
335 [popup_ setAnimations:savedAnimations]; | 335 [popup_ setAnimations:savedAnimations]; |
336 } | 336 } |
337 } | 337 } |
338 | 338 |
339 NSImage* OmniboxPopupViewMac::ImageForMatch(const AutocompleteMatch& match, | 339 NSImage* OmniboxPopupViewMac::ImageForMatch( |
340 BOOL ignore_dark_theme) const { | 340 const AutocompleteMatch& match) const { |
341 gfx::Image image = model_->GetIconIfExtensionMatch(match); | 341 gfx::Image image = model_->GetIconIfExtensionMatch(match); |
342 if (!image.IsEmpty()) | 342 if (!image.IsEmpty()) |
343 return image.AsNSImage(); | 343 return image.AsNSImage(); |
344 | 344 |
345 if (!ui::MaterialDesignController::IsModeMaterial()) { | 345 if (!ui::MaterialDesignController::IsModeMaterial()) { |
346 const int resource_id = model_->IsStarredMatch(match) | 346 const int resource_id = model_->IsStarredMatch(match) |
347 ? IDR_OMNIBOX_STAR | 347 ? IDR_OMNIBOX_STAR |
348 : AutocompleteMatch::TypeToIcon(match.type); | 348 : AutocompleteMatch::TypeToIcon(match.type); |
349 return OmniboxViewMac::ImageForResource(resource_id); | 349 return OmniboxViewMac::ImageForResource(resource_id); |
350 } | 350 } |
351 bool is_dark_mode = !ignore_dark_theme && [matrix_ hasDarkTheme]; | 351 bool is_dark_mode = [matrix_ hasDarkTheme]; |
352 const SkColor icon_color = | 352 const SkColor icon_color = |
353 is_dark_mode ? SkColorSetA(SK_ColorWHITE, 0xCC) : gfx::kChromeIconGrey; | 353 is_dark_mode ? SkColorSetA(SK_ColorWHITE, 0xCC) : gfx::kChromeIconGrey; |
354 const gfx::VectorIconId vector_icon_id = | 354 const gfx::VectorIconId vector_icon_id = |
355 model_->IsStarredMatch(match) | 355 model_->IsStarredMatch(match) |
356 ? gfx::VectorIconId::LOCATION_BAR_STAR | 356 ? gfx::VectorIconId::LOCATION_BAR_STAR |
357 : AutocompleteMatch::TypeToVectorIcon(match.type); | 357 : AutocompleteMatch::TypeToVectorIcon(match.type); |
358 const int kIconSize = 16; | 358 const int kIconSize = 16; |
359 return NSImageFromImageSkia( | 359 return NSImageFromImageSkia( |
360 gfx::CreateVectorIcon(vector_icon_id, kIconSize, icon_color)); | 360 gfx::CreateVectorIcon(vector_icon_id, kIconSize, icon_color)); |
361 } | 361 } |
362 | 362 |
363 void OmniboxPopupViewMac::OpenURLForRow(size_t row, | 363 void OmniboxPopupViewMac::OpenURLForRow(size_t row, |
364 WindowOpenDisposition disposition) { | 364 WindowOpenDisposition disposition) { |
365 DCHECK_LT(row, GetResult().size()); | 365 DCHECK_LT(row, GetResult().size()); |
366 omnibox_view_->OpenMatch(GetResult().match_at(row), disposition, GURL(), | 366 omnibox_view_->OpenMatch(GetResult().match_at(row), disposition, GURL(), |
367 base::string16(), row); | 367 base::string16(), row); |
368 } | 368 } |
OLD | NEW |