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> |
Robert Sesek
2017/02/16 00:25:16
#include <sys/stat.h>
Sidney San Martín
2017/02/16 02:17:42
Done.
| |
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{ | |
Robert Sesek
2017/02/16 00:25:16
naming: nibCrashKey
Sidney San Martín
2017/02/16 02:17:42
Done.
| |
258 crash_keys::mac::kToolbarNibInfo, [&] { | |
259 auto nibPath = | |
260 [self.nibBundle pathForResource:@"Toolbar" ofType:@"nib"]; | |
261 struct stat sb; | |
262 stat(nibPath.UTF8String, &sb); | |
Robert Sesek
2017/02/16 00:25:16
fileSystemRepresentation
Sidney San Martín
2017/02/16 02:17:42
Done.
| |
263 auto nibErrno = errno; | |
Robert Sesek
2017/02/16 00:25:16
errno here may be something unrelated if stat retu
Sidney San Martín
2017/02/16 02:17:42
Done.
| |
264 auto closestPath = nibPath; | |
265 while (closestPath && stat(closestPath.UTF8String, &sb) != 0) { | |
266 closestPath = [closestPath stringByDeletingLastPathComponent]; | |
267 } | |
268 return [NSString stringWithFormat:@"errno: %d nib: %@ closest: %@", | |
269 nibErrno, nibPath, closestPath]; | |
270 }().UTF8String}; | |
271 | |
255 // When linking and running on 10.10+, both -awakeFromNib and -viewDidLoad may | 272 // When linking and running on 10.10+, both -awakeFromNib and -viewDidLoad may |
256 // be called, don't initialize twice. | 273 // be called, don't initialize twice. |
257 if (locationBarView_) { | 274 if (locationBarView_) { |
258 DCHECK(base::mac::IsAtLeastOS10_10()); | 275 DCHECK(base::mac::IsAtLeastOS10_10()); |
259 return; | 276 return; |
260 } | 277 } |
261 | 278 |
262 BOOL isRTL = cocoa_l10n_util::ShouldDoExperimentalRTLLayout(); | 279 BOOL isRTL = cocoa_l10n_util::ShouldDoExperimentalRTLLayout(); |
263 NSAutoresizingMaskOptions leadingButtonMask = | 280 NSAutoresizingMaskOptions leadingButtonMask = |
264 isRTL ? NSViewMinXMargin | NSViewMinYMargin | 281 isRTL ? NSViewMinXMargin | NSViewMinYMargin |
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1085 - (void)hideDropURLsIndicatorInView:(NSView*)view { | 1102 - (void)hideDropURLsIndicatorInView:(NSView*)view { |
1086 // Do nothing. | 1103 // Do nothing. |
1087 } | 1104 } |
1088 | 1105 |
1089 // (URLDropTargetController protocol) | 1106 // (URLDropTargetController protocol) |
1090 - (BOOL)isUnsupportedDropData:(id<NSDraggingInfo>)info { | 1107 - (BOOL)isUnsupportedDropData:(id<NSDraggingInfo>)info { |
1091 return drag_util::IsUnsupportedDropData(profile_, info); | 1108 return drag_util::IsUnsupportedDropData(profile_, info); |
1092 } | 1109 } |
1093 | 1110 |
1094 @end | 1111 @end |
OLD | NEW |