| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/browser_window_touch_bar.h" | 5 #import "chrome/browser/ui/cocoa/browser_window_touch_bar.h" |
| 6 | 6 |
| 7 #include "base/mac/mac_util.h" | 7 #include "base/mac/mac_util.h" |
| 8 #import "base/mac/scoped_nsobject.h" | 8 #import "base/mac/scoped_nsobject.h" |
| 9 #import "base/mac/sdk_forward_declarations.h" | 9 #import "base/mac/sdk_forward_declarations.h" |
| 10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
| 11 #include "chrome/app/chrome_command_ids.h" | 11 #include "chrome/app/chrome_command_ids.h" |
| 12 #include "chrome/app/vector_icons/vector_icons.h" | 12 #include "chrome/app/vector_icons/vector_icons.h" |
| 13 #include "chrome/browser/command_updater.h" | 13 #include "chrome/browser/command_updater.h" |
| 14 #include "chrome/browser/search_engines/template_url_service_factory.h" | 14 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 15 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/browser_command_controller.h" | 16 #include "chrome/browser/ui/browser_command_controller.h" |
| 17 #include "chrome/common/chrome_features.h" | 17 #include "chrome/common/chrome_features.h" |
| 18 #include "chrome/grit/generated_resources.h" | 18 #include "chrome/grit/generated_resources.h" |
| 19 #include "components/omnibox/browser/vector_icons.h" | 19 #include "components/omnibox/browser/vector_icons.h" |
| 20 #include "components/search_engines/util.h" | 20 #include "components/search_engines/util.h" |
| 21 #include "components/toolbar/vector_icons.h" | 21 #include "components/toolbar/vector_icons.h" |
| 22 #include "ui/base/l10n/l10n_util.h" | 22 #include "ui/base/l10n/l10n_util.h" |
| 23 #include "ui/gfx/color_palette.h" | 23 #include "ui/gfx/color_palette.h" |
| 24 #include "ui/gfx/color_utils.h" | 24 #include "ui/gfx/color_utils.h" |
| 25 #include "ui/gfx/image/image.h" | 25 #include "ui/gfx/image/image.h" |
| 26 #include "ui/gfx/image/image_skia_util_mac.h" | 26 #include "ui/gfx/image/image_skia_util_mac.h" |
| 27 #include "ui/gfx/paint_vector_icon.h" | 27 #include "ui/gfx/paint_vector_icon.h" |
| 28 #include "ui/gfx/vector_icons_public.h" | |
| 29 #include "ui/vector_icons/vector_icons.h" | 28 #include "ui/vector_icons/vector_icons.h" |
| 30 | 29 |
| 31 namespace { | 30 namespace { |
| 32 | 31 |
| 33 // The touch bar's identifier. | 32 // The touch bar's identifier. |
| 34 const NSTouchBarCustomizationIdentifier kBrowserWindowTouchBarId = | 33 const NSTouchBarCustomizationIdentifier kBrowserWindowTouchBarId = |
| 35 @"BrowserWindowTouchBarId"; | 34 @"BrowserWindowTouchBarId"; |
| 36 | 35 |
| 37 // Touch bar items identifiers. | 36 // Touch bar items identifiers. |
| 38 const NSTouchBarItemIdentifier kBackForwardTouchId = @"BackForwardTouchId"; | 37 const NSTouchBarItemIdentifier kBackForwardTouchId = @"BackForwardTouchId"; |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 SEARCH_ENGINE_GOOGLE; | 185 SEARCH_ENGINE_GOOGLE; |
| 187 | 186 |
| 188 base::string16 title = | 187 base::string16 title = |
| 189 isGoogle ? l10n_util::GetStringUTF16(IDS_TOUCH_BAR_GOOGLE_SEARCH) | 188 isGoogle ? l10n_util::GetStringUTF16(IDS_TOUCH_BAR_GOOGLE_SEARCH) |
| 190 : l10n_util::GetStringFUTF16(IDS_TOUCH_BAR_SEARCH, | 189 : l10n_util::GetStringFUTF16(IDS_TOUCH_BAR_SEARCH, |
| 191 defaultProvider->short_name()); | 190 defaultProvider->short_name()); |
| 192 | 191 |
| 193 NSImage* image; | 192 NSImage* image; |
| 194 if (isGoogle) { | 193 if (isGoogle) { |
| 195 image = NSImageFromImageSkiaWithColorSpace( | 194 image = NSImageFromImageSkiaWithColorSpace( |
| 196 gfx::CreateVectorIcon(gfx::VectorIconId::GOOGLE_SEARCH_MAC_TOUCHBAR, | 195 gfx::CreateVectorIcon(kGoogleSearchMacTouchbarIcon, kTouchBarIconSize, |
| 197 kTouchBarIconSize, gfx::kPlaceholderColor), | 196 gfx::kPlaceholderColor), |
| 198 base::mac::GetSRGBColorSpace()); | 197 base::mac::GetSRGBColorSpace()); |
| 199 } else { | 198 } else { |
| 200 image = CreateNSImageFromIcon(omnibox::kSearchIcon); | 199 image = CreateNSImageFromIcon(ui::kSearchIcon); |
| 201 } | 200 } |
| 202 | 201 |
| 203 NSButton* searchButton = | 202 NSButton* searchButton = |
| 204 [NSButton buttonWithTitle:base::SysUTF16ToNSString(title) | 203 [NSButton buttonWithTitle:base::SysUTF16ToNSString(title) |
| 205 image:image | 204 image:image |
| 206 target:self | 205 target:self |
| 207 action:@selector(executeCommand:)]; | 206 action:@selector(executeCommand:)]; |
| 208 searchButton.imageHugsTitle = YES; | 207 searchButton.imageHugsTitle = YES; |
| 209 searchButton.tag = IDC_FOCUS_LOCATION; | 208 searchButton.tag = IDC_FOCUS_LOCATION; |
| 210 [searchButton.widthAnchor | 209 [searchButton.widthAnchor |
| 211 constraintEqualToConstant:kTouchBarSearchButtonWidth] | 210 constraintEqualToConstant:kTouchBarSearchButtonWidth] |
| 212 .active = YES; | 211 .active = YES; |
| 213 return searchButton; | 212 return searchButton; |
| 214 } | 213 } |
| 215 | 214 |
| 216 - (void)backOrForward:(id)sender { | 215 - (void)backOrForward:(id)sender { |
| 217 NSSegmentedControl* control = sender; | 216 NSSegmentedControl* control = sender; |
| 218 if ([control selectedSegment] == kBackSegmentIndex) | 217 if ([control selectedSegment] == kBackSegmentIndex) |
| 219 commandUpdater_->ExecuteCommand(IDC_BACK); | 218 commandUpdater_->ExecuteCommand(IDC_BACK); |
| 220 else | 219 else |
| 221 commandUpdater_->ExecuteCommand(IDC_FORWARD); | 220 commandUpdater_->ExecuteCommand(IDC_FORWARD); |
| 222 } | 221 } |
| 223 | 222 |
| 224 - (void)executeCommand:(id)sender { | 223 - (void)executeCommand:(id)sender { |
| 225 commandUpdater_->ExecuteCommand([sender tag]); | 224 commandUpdater_->ExecuteCommand([sender tag]); |
| 226 } | 225 } |
| 227 | 226 |
| 228 @end | 227 @end |
| OLD | NEW |