| 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/bookmarks/bookmark_bar_controller.h" | 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #import "base/mac/bundle_locations.h" | 9 #import "base/mac/bundle_locations.h" |
| 10 #import "base/mac/foundation_util.h" | 10 #import "base/mac/foundation_util.h" |
| 11 #include "base/mac/mac_util.h" | 11 #include "base/mac/mac_util.h" |
| 12 #import "base/mac/sdk_forward_declarations.h" | 12 #import "base/mac/sdk_forward_declarations.h" |
| 13 #include "base/metrics/histogram_macros.h" | 13 #include "base/metrics/histogram_macros.h" |
| 14 #include "base/strings/sys_string_conversions.h" | 14 #include "base/strings/sys_string_conversions.h" |
| 15 #include "chrome/app/vector_icons/vector_icons.h" |
| 15 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 16 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 16 #include "chrome/browser/bookmarks/bookmark_stats.h" | 17 #include "chrome/browser/bookmarks/bookmark_stats.h" |
| 17 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h" | 18 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h" |
| 18 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 19 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 19 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/browser/themes/theme_properties.h" | 21 #include "chrome/browser/themes/theme_properties.h" |
| 21 #include "chrome/browser/themes/theme_service.h" | 22 #include "chrome/browser/themes/theme_service.h" |
| 22 #import "chrome/browser/themes/theme_service_factory.h" | 23 #import "chrome/browser/themes/theme_service_factory.h" |
| 23 #include "chrome/browser/ui/bookmarks/bookmark_editor.h" | 24 #include "chrome/browser/ui/bookmarks/bookmark_editor.h" |
| 24 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" | 25 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 50 #include "chrome/common/extensions/extension_constants.h" | 51 #include "chrome/common/extensions/extension_constants.h" |
| 51 #include "chrome/common/extensions/extension_metrics.h" | 52 #include "chrome/common/extensions/extension_metrics.h" |
| 52 #include "chrome/common/url_constants.h" | 53 #include "chrome/common/url_constants.h" |
| 53 #include "chrome/grit/generated_resources.h" | 54 #include "chrome/grit/generated_resources.h" |
| 54 #include "chrome/grit/theme_resources.h" | 55 #include "chrome/grit/theme_resources.h" |
| 55 #include "components/bookmarks/browser/bookmark_model.h" | 56 #include "components/bookmarks/browser/bookmark_model.h" |
| 56 #include "components/bookmarks/browser/bookmark_node_data.h" | 57 #include "components/bookmarks/browser/bookmark_node_data.h" |
| 57 #include "components/bookmarks/browser/bookmark_utils.h" | 58 #include "components/bookmarks/browser/bookmark_utils.h" |
| 58 #include "components/bookmarks/common/bookmark_pref_names.h" | 59 #include "components/bookmarks/common/bookmark_pref_names.h" |
| 59 #include "components/bookmarks/managed/managed_bookmark_service.h" | 60 #include "components/bookmarks/managed/managed_bookmark_service.h" |
| 61 #include "components/omnibox/browser/vector_icons.h" |
| 60 #include "components/prefs/pref_service.h" | 62 #include "components/prefs/pref_service.h" |
| 61 #include "content/public/browser/user_metrics.h" | 63 #include "content/public/browser/user_metrics.h" |
| 62 #include "content/public/browser/web_contents.h" | 64 #include "content/public/browser/web_contents.h" |
| 63 #include "extensions/browser/extension_registry.h" | 65 #include "extensions/browser/extension_registry.h" |
| 64 #include "extensions/common/extension.h" | 66 #include "extensions/common/extension.h" |
| 65 #include "extensions/common/extension_set.h" | 67 #include "extensions/common/extension_set.h" |
| 66 #include "ui/base/clipboard/clipboard_util_mac.h" | 68 #include "ui/base/clipboard/clipboard_util_mac.h" |
| 67 #import "ui/base/cocoa/cocoa_base_utils.h" | 69 #import "ui/base/cocoa/cocoa_base_utils.h" |
| 68 #import "ui/base/cocoa/nsview_additions.h" | 70 #import "ui/base/cocoa/nsview_additions.h" |
| 69 #include "ui/base/l10n/l10n_util_mac.h" | 71 #include "ui/base/l10n/l10n_util_mac.h" |
| 70 #include "ui/base/material_design/material_design_controller.h" | 72 #include "ui/base/material_design/material_design_controller.h" |
| 71 #include "ui/base/resource/resource_bundle.h" | 73 #include "ui/base/resource/resource_bundle.h" |
| 72 #include "ui/gfx/color_palette.h" | 74 #include "ui/gfx/color_palette.h" |
| 73 #include "ui/gfx/image/image.h" | 75 #include "ui/gfx/image/image.h" |
| 74 #include "ui/gfx/image/image_skia_util_mac.h" | 76 #include "ui/gfx/image/image_skia_util_mac.h" |
| 75 #include "ui/gfx/paint_vector_icon.h" | 77 #include "ui/gfx/paint_vector_icon.h" |
| 76 #include "ui/gfx/vector_icons_public.h" | |
| 77 #include "ui/resources/grit/ui_resources.h" | 78 #include "ui/resources/grit/ui_resources.h" |
| 78 | 79 |
| 79 using base::UserMetricsAction; | 80 using base::UserMetricsAction; |
| 80 using bookmarks::BookmarkModel; | 81 using bookmarks::BookmarkModel; |
| 81 using bookmarks::BookmarkNode; | 82 using bookmarks::BookmarkNode; |
| 82 using bookmarks::BookmarkNodeData; | 83 using bookmarks::BookmarkNodeData; |
| 83 using content::OpenURLParams; | 84 using content::OpenURLParams; |
| 84 using content::Referrer; | 85 using content::Referrer; |
| 85 using content::WebContents; | 86 using content::WebContents; |
| 86 | 87 |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 [[BookmarkFolderTarget alloc] initWithController:self | 282 [[BookmarkFolderTarget alloc] initWithController:self |
| 282 profile:browser_->profile()]); | 283 profile:browser_->profile()]); |
| 283 | 284 |
| 284 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 285 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 285 folderImage_.reset( | 286 folderImage_.reset( |
| 286 rb.GetNativeImageNamed(IDR_BOOKMARK_BAR_FOLDER).CopyNSImage()); | 287 rb.GetNativeImageNamed(IDR_BOOKMARK_BAR_FOLDER).CopyNSImage()); |
| 287 folderImageWhite_.reset( | 288 folderImageWhite_.reset( |
| 288 rb.GetNativeImageNamed(IDR_BOOKMARK_BAR_FOLDER_WHITE).CopyNSImage()); | 289 rb.GetNativeImageNamed(IDR_BOOKMARK_BAR_FOLDER_WHITE).CopyNSImage()); |
| 289 | 290 |
| 290 const int kIconSize = 16; | 291 const int kIconSize = 16; |
| 291 defaultImage_.reset([NSImageFromImageSkia( | 292 defaultImage_.reset([NSImageFromImageSkia(gfx::CreateVectorIcon( |
| 292 gfx::CreateVectorIcon(gfx::VectorIconId::OMNIBOX_HTTP, | 293 omnibox::kHttpIcon, kIconSize, gfx::kChromeIconGrey)) retain]); |
| 293 kIconSize, | 294 defaultImageIncognito_.reset([NSImageFromImageSkia(gfx::CreateVectorIcon( |
| 294 gfx::kChromeIconGrey)) retain]); | 295 omnibox::kHttpIcon, kIconSize, SkColorSetA(SK_ColorWHITE, 0xCC))) |
| 295 defaultImageIncognito_.reset([NSImageFromImageSkia( | 296 retain]); |
| 296 gfx::CreateVectorIcon(gfx::VectorIconId::OMNIBOX_HTTP, | |
| 297 kIconSize, | |
| 298 SkColorSetA(SK_ColorWHITE, 0xCC))) retain]); | |
| 299 | 297 |
| 300 innerContentAnimationsEnabled_ = YES; | 298 innerContentAnimationsEnabled_ = YES; |
| 301 stateAnimationsEnabled_ = YES; | 299 stateAnimationsEnabled_ = YES; |
| 302 | 300 |
| 303 // Register for theme changes, bookmark button pulsing, ... | 301 // Register for theme changes, bookmark button pulsing, ... |
| 304 NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter]; | 302 NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter]; |
| 305 [defaultCenter addObserver:self | 303 [defaultCenter addObserver:self |
| 306 selector:@selector(themeDidChangeNotification:) | 304 selector:@selector(themeDidChangeNotification:) |
| 307 name:kBrowserThemeDidChangeNotification | 305 name:kBrowserThemeDidChangeNotification |
| 308 object:nil]; | 306 object:nil]; |
| (...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 883 | 881 |
| 884 - (NSButton*)offTheSideButton { | 882 - (NSButton*)offTheSideButton { |
| 885 return offTheSideButton_; | 883 return offTheSideButton_; |
| 886 } | 884 } |
| 887 | 885 |
| 888 - (NSImage*)offTheSideButtonImage:(BOOL)forDarkMode { | 886 - (NSImage*)offTheSideButtonImage:(BOOL)forDarkMode { |
| 889 const int kIconSize = 8; | 887 const int kIconSize = 8; |
| 890 SkColor vectorIconColor = forDarkMode ? SkColorSetA(SK_ColorWHITE, 0xCC) | 888 SkColor vectorIconColor = forDarkMode ? SkColorSetA(SK_ColorWHITE, 0xCC) |
| 891 : gfx::kChromeIconGrey; | 889 : gfx::kChromeIconGrey; |
| 892 return NSImageFromImageSkia( | 890 return NSImageFromImageSkia( |
| 893 gfx::CreateVectorIcon(gfx::VectorIconId::OVERFLOW_CHEVRON, | 891 gfx::CreateVectorIcon(kOverflowChevronIcon, kIconSize, vectorIconColor)); |
| 894 kIconSize, | |
| 895 vectorIconColor)); | |
| 896 } | 892 } |
| 897 | 893 |
| 898 #pragma mark Private Methods | 894 #pragma mark Private Methods |
| 899 | 895 |
| 900 // Called after a theme change took place, possibly for a different profile. | 896 // Called after a theme change took place, possibly for a different profile. |
| 901 - (void)themeDidChangeNotification:(NSNotification*)notification { | 897 - (void)themeDidChangeNotification:(NSNotification*)notification { |
| 902 [self updateTheme:[[[self view] window] themeProvider]]; | 898 [self updateTheme:[[[self view] window] themeProvider]]; |
| 903 } | 899 } |
| 904 | 900 |
| 905 - (BookmarkLaunchLocation)bookmarkLaunchLocation { | 901 - (BookmarkLaunchLocation)bookmarkLaunchLocation { |
| (...skipping 2100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3006 - (id<BookmarkButtonControllerProtocol>)controllerForNode: | 3002 - (id<BookmarkButtonControllerProtocol>)controllerForNode: |
| 3007 (const BookmarkNode*)node { | 3003 (const BookmarkNode*)node { |
| 3008 // See if it's in the bar, then if it is in the hierarchy of visible | 3004 // See if it's in the bar, then if it is in the hierarchy of visible |
| 3009 // folder menus. | 3005 // folder menus. |
| 3010 if (bookmarkModel_->bookmark_bar_node() == node) | 3006 if (bookmarkModel_->bookmark_bar_node() == node) |
| 3011 return self; | 3007 return self; |
| 3012 return [folderController_ controllerForNode:node]; | 3008 return [folderController_ controllerForNode:node]; |
| 3013 } | 3009 } |
| 3014 | 3010 |
| 3015 @end | 3011 @end |
| OLD | NEW |