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/toolbar/toolbar_controller.h" | 5 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/debug/crash_logging.h" | |
9 #include "base/mac/bundle_locations.h" | 10 #include "base/mac/bundle_locations.h" |
10 #include "base/mac/foundation_util.h" | 11 #include "base/mac/foundation_util.h" |
11 #include "base/mac/mac_util.h" | 12 #include "base/mac/mac_util.h" |
12 #include "base/mac/sdk_forward_declarations.h" | 13 #include "base/mac/sdk_forward_declarations.h" |
13 #include "base/macros.h" | 14 #include "base/macros.h" |
14 #include "base/memory/singleton.h" | 15 #include "base/memory/singleton.h" |
15 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
16 #include "base/strings/sys_string_conversions.h" | 17 #include "base/strings/sys_string_conversions.h" |
17 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
18 #include "chrome/app/chrome_command_ids.h" | 19 #include "chrome/app/chrome_command_ids.h" |
(...skipping 26 matching lines...) Expand all Loading... | |
45 #import "chrome/browser/ui/cocoa/toolbar/app_toolbar_button.h" | 46 #import "chrome/browser/ui/cocoa/toolbar/app_toolbar_button.h" |
46 #import "chrome/browser/ui/cocoa/toolbar/app_toolbar_button_cell.h" | 47 #import "chrome/browser/ui/cocoa/toolbar/app_toolbar_button_cell.h" |
47 #import "chrome/browser/ui/cocoa/toolbar/back_forward_menu_controller.h" | 48 #import "chrome/browser/ui/cocoa/toolbar/back_forward_menu_controller.h" |
48 #import "chrome/browser/ui/cocoa/toolbar/reload_button_cocoa.h" | 49 #import "chrome/browser/ui/cocoa/toolbar/reload_button_cocoa.h" |
49 #import "chrome/browser/ui/cocoa/toolbar/toolbar_button_cocoa.h" | 50 #import "chrome/browser/ui/cocoa/toolbar/toolbar_button_cocoa.h" |
50 #import "chrome/browser/ui/cocoa/toolbar/toolbar_view_cocoa.h" | 51 #import "chrome/browser/ui/cocoa/toolbar/toolbar_view_cocoa.h" |
51 #import "chrome/browser/ui/cocoa/view_id_util.h" | 52 #import "chrome/browser/ui/cocoa/view_id_util.h" |
52 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 53 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
53 #include "chrome/browser/ui/toolbar/app_menu_icon_controller.h" | 54 #include "chrome/browser/ui/toolbar/app_menu_icon_controller.h" |
54 #include "chrome/browser/ui/toolbar/app_menu_model.h" | 55 #include "chrome/browser/ui/toolbar/app_menu_model.h" |
56 #include "chrome/common/crash_keys.h" | |
55 #include "chrome/common/pref_names.h" | 57 #include "chrome/common/pref_names.h" |
56 #include "chrome/grit/chromium_strings.h" | 58 #include "chrome/grit/chromium_strings.h" |
57 #include "chrome/grit/generated_resources.h" | 59 #include "chrome/grit/generated_resources.h" |
58 #include "chrome/grit/theme_resources.h" | 60 #include "chrome/grit/theme_resources.h" |
59 #include "components/metrics/proto/omnibox_event.pb.h" | 61 #include "components/metrics/proto/omnibox_event.pb.h" |
60 #include "components/omnibox/browser/autocomplete_classifier.h" | 62 #include "components/omnibox/browser/autocomplete_classifier.h" |
61 #include "components/omnibox/browser/autocomplete_match.h" | 63 #include "components/omnibox/browser/autocomplete_match.h" |
62 #include "components/omnibox/browser/omnibox_edit_model.h" | 64 #include "components/omnibox/browser/omnibox_edit_model.h" |
63 #include "components/omnibox/browser/omnibox_view.h" | 65 #include "components/omnibox/browser/omnibox_view.h" |
64 #include "components/prefs/pref_service.h" | 66 #include "components/prefs/pref_service.h" |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
245 // Now we can hook up bridges that rely on UI objects such as the location bar | 247 // Now we can hook up bridges that rely on UI objects such as the location bar |
246 // and button state. -viewDidLoad is the recommended way to do this in 10.10 | 248 // and button state. -viewDidLoad is the recommended way to do this in 10.10 |
247 // SDK. When running on 10.10 or above -awakeFromNib still works but for some | 249 // SDK. When running on 10.10 or above -awakeFromNib still works but for some |
248 // reason is not guaranteed to be called (http://crbug.com/526276), so implement | 250 // reason is not guaranteed to be called (http://crbug.com/526276), so implement |
249 // both. | 251 // both. |
250 - (void)awakeFromNib { | 252 - (void)awakeFromNib { |
251 [self viewDidLoad]; | 253 [self viewDidLoad]; |
252 } | 254 } |
253 | 255 |
254 - (void)viewDidLoad { | 256 - (void)viewDidLoad { |
257 base::debug::ScopedCrashKey nib_crash_key{ | |
258 crash_keys::mac::kToolbarNibInfo, [&] { | |
Robert Sesek
2017/02/15 20:20:18
I don't see any advantage of a lambda here. Can yo
Sidney San Martín
2017/02/15 22:45:19
Trying not to leak locals. What would you do inste
Sidney San Martín
2017/02/15 23:15:01
I didn't change this yet (because I'm trying to ke
Robert Sesek
2017/02/16 00:25:16
It's temporary code, so I don't feel strongly, but
| |
259 auto nibPath = | |
260 [self.nibBundle pathForResource:@"Toolbar" ofType:@"nib"]; | |
261 auto closestPath = nibPath; | |
262 auto fileManager = [NSFileManager defaultManager]; | |
263 while (closestPath && ![fileManager fileExistsAtPath:closestPath]) { | |
Robert Sesek
2017/02/15 20:20:18
I would use actual stat on the nib file so that we
Sidney San Martín
2017/02/15 23:15:01
Done, let me know if it makes sense.
| |
264 closestPath = [closestPath stringByDeletingLastPathComponent]; | |
265 } | |
266 return [NSString | |
267 stringWithFormat:@"nib: %@ closest: %@", nibPath, closestPath]; | |
268 }().UTF8String}; | |
269 | |
255 // When linking and running on 10.10+, both -awakeFromNib and -viewDidLoad may | 270 // When linking and running on 10.10+, both -awakeFromNib and -viewDidLoad may |
256 // be called, don't initialize twice. | 271 // be called, don't initialize twice. |
257 if (locationBarView_) { | 272 if (locationBarView_) { |
258 DCHECK(base::mac::IsAtLeastOS10_10()); | 273 DCHECK(base::mac::IsAtLeastOS10_10()); |
259 return; | 274 return; |
260 } | 275 } |
261 | 276 |
262 BOOL isRTL = cocoa_l10n_util::ShouldDoExperimentalRTLLayout(); | 277 BOOL isRTL = cocoa_l10n_util::ShouldDoExperimentalRTLLayout(); |
263 NSAutoresizingMaskOptions leadingButtonMask = | 278 NSAutoresizingMaskOptions leadingButtonMask = |
264 isRTL ? NSViewMinXMargin | NSViewMinYMargin | 279 isRTL ? NSViewMinXMargin | NSViewMinYMargin |
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1085 - (void)hideDropURLsIndicatorInView:(NSView*)view { | 1100 - (void)hideDropURLsIndicatorInView:(NSView*)view { |
1086 // Do nothing. | 1101 // Do nothing. |
1087 } | 1102 } |
1088 | 1103 |
1089 // (URLDropTargetController protocol) | 1104 // (URLDropTargetController protocol) |
1090 - (BOOL)isUnsupportedDropData:(id<NSDraggingInfo>)info { | 1105 - (BOOL)isUnsupportedDropData:(id<NSDraggingInfo>)info { |
1091 return drag_util::IsUnsupportedDropData(profile_, info); | 1106 return drag_util::IsUnsupportedDropData(profile_, info); |
1092 } | 1107 } |
1093 | 1108 |
1094 @end | 1109 @end |
OLD | NEW |