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/tabs/tab_window_controller.h" | 5 #import "chrome/browser/ui/cocoa/tabs/tab_window_controller.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #import "base/mac/sdk_forward_declarations.h" | 8 #import "base/mac/sdk_forward_declarations.h" |
9 #include "base/memory/ptr_util.h" | |
10 #include "chrome/browser/ui/browser_view_histogram_helper.h" | |
9 #import "chrome/browser/ui/cocoa/browser_window_layout.h" | 11 #import "chrome/browser/ui/cocoa/browser_window_layout.h" |
10 #import "chrome/browser/ui/cocoa/fast_resize_view.h" | 12 #import "chrome/browser/ui/cocoa/fast_resize_view.h" |
11 #import "chrome/browser/ui/cocoa/framed_browser_window.h" | 13 #import "chrome/browser/ui/cocoa/framed_browser_window.h" |
12 #import "chrome/browser/ui/cocoa/tabs/tab_strip_background_view.h" | 14 #import "chrome/browser/ui/cocoa/tabs/tab_strip_background_view.h" |
13 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" | 15 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" |
14 #import "chrome/browser/ui/cocoa/themed_window.h" | 16 #import "chrome/browser/ui/cocoa/themed_window.h" |
15 #import "ui/base/cocoa/focus_tracker.h" | 17 #import "ui/base/cocoa/focus_tracker.h" |
16 #include "ui/base/material_design/material_design_controller.h" | 18 #include "ui/base/material_design/material_design_controller.h" |
17 #include "ui/base/theme_provider.h" | 19 #include "ui/base/theme_provider.h" |
18 | 20 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 return [[self parentWindow] hasDarkTheme]; | 59 return [[self parentWindow] hasDarkTheme]; |
58 } | 60 } |
59 | 61 |
60 - (BOOL)inIncognitoModeWithSystemTheme { | 62 - (BOOL)inIncognitoModeWithSystemTheme { |
61 return [[self parentWindow] inIncognitoModeWithSystemTheme]; | 63 return [[self parentWindow] inIncognitoModeWithSystemTheme]; |
62 } | 64 } |
63 | 65 |
64 @end | 66 @end |
65 | 67 |
66 // Subview of the window's contentView, contains everything but the tab strip. | 68 // Subview of the window's contentView, contains everything but the tab strip. |
67 @interface ChromeContentView : NSView | 69 @interface ChromeContentView : NSView { |
70 @private | |
71 std::unique_ptr<BrowserViewHistogramHelper> histogram_helper_; | |
tapted
2017/04/07 00:49:34
histogramHelper_ (since this is declared between
themblsha
2017/04/10 17:28:18
I'm using unique_ptr in browser_view.h so I can fo
| |
72 } | |
68 @end | 73 @end |
69 | 74 |
70 @implementation ChromeContentView | 75 @implementation ChromeContentView |
71 | 76 |
72 // NSView overrides. | 77 // NSView overrides. |
73 | 78 |
79 - (instancetype)initWithFrame:(NSRect)frameRect { | |
80 if ((self = [super initWithFrame:frameRect])) { | |
81 histogram_helper_ = base::MakeUnique<BrowserViewHistogramHelper>(); | |
82 } | |
83 return self; | |
84 } | |
85 | |
74 // Since Auto Layout and frame-based layout behave differently in small but | 86 // Since Auto Layout and frame-based layout behave differently in small but |
75 // important ways (e.g. Auto Layout can restrict window resizing, frame-based | 87 // important ways (e.g. Auto Layout can restrict window resizing, frame-based |
76 // layout doesn't log a warning when a view's autoresizing mask can't be | 88 // layout doesn't log a warning when a view's autoresizing mask can't be |
77 // maintained), ensure that it's on instead of letting it depend on content. | 89 // maintained), ensure that it's on instead of letting it depend on content. |
78 + (BOOL)requiresConstraintBasedLayout { | 90 + (BOOL)requiresConstraintBasedLayout { |
79 return YES; | 91 return YES; |
80 } | 92 } |
81 | 93 |
94 - (void)drawRect:(NSRect)dirtyRect { | |
95 // -drawRect: is called from -drawLayer:inContext:, which is called before all | |
96 // ChromeContentView's got a chance to paint. But there seems to be no | |
97 // non-hacky way of getting that notification. | |
tapted
2017/04/07 00:49:34
Does void BrowserWindowCocoa::Show() already recor
themblsha
2017/04/10 17:28:18
Thanks for the tip! Moved the code there.
The Bro
| |
98 histogram_helper_->OnDidPaintChildren(nullptr); | |
99 } | |
100 | |
82 @end | 101 @end |
83 | 102 |
84 @implementation TabWindowController | 103 @implementation TabWindowController |
85 | 104 |
86 - (id)initTabWindowControllerWithTabStrip:(BOOL)hasTabStrip | 105 - (id)initTabWindowControllerWithTabStrip:(BOOL)hasTabStrip |
87 titleBar:(BOOL)hasTitleBar { | 106 titleBar:(BOOL)hasTitleBar { |
88 const CGFloat kDefaultWidth = 750; | 107 const CGFloat kDefaultWidth = 750; |
89 const CGFloat kDefaultHeight = 600; | 108 const CGFloat kDefaultHeight = 600; |
90 | 109 |
91 NSRect contentRect = NSMakeRect(60, 229, kDefaultWidth, kDefaultHeight); | 110 NSRect contentRect = NSMakeRect(60, 229, kDefaultWidth, kDefaultHeight); |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
472 | 491 |
473 - (void)windowWillEnterFullScreenNotification:(NSNotification*)notification { | 492 - (void)windowWillEnterFullScreenNotification:(NSNotification*)notification { |
474 [[visualEffectView_ animator] setAlphaValue:0.0]; | 493 [[visualEffectView_ animator] setAlphaValue:0.0]; |
475 } | 494 } |
476 | 495 |
477 - (void)windowWillExitFullScreenNotification:(NSNotification*)notification { | 496 - (void)windowWillExitFullScreenNotification:(NSNotification*)notification { |
478 [[visualEffectView_ animator] setAlphaValue:1.0]; | 497 [[visualEffectView_ animator] setAlphaValue:1.0]; |
479 } | 498 } |
480 | 499 |
481 @end | 500 @end |
OLD | NEW |