Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.mm

Issue 642143004: [Cocoa] Make TabContentsContainerView more testable for interactive_ui_tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/tab_contents/tab_contents_controller.h" 5 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/mac/scoped_cftyperef.h" 9 #include "base/mac/scoped_cftyperef.h"
10 #include "base/mac/scoped_nsobject.h" 10 #include "base/mac/scoped_nsobject.h"
11 #include "chrome/browser/devtools/devtools_window.h" 11 #include "chrome/browser/devtools/devtools_window.h"
12 #import "chrome/browser/themes/theme_properties.h" 12 #import "chrome/browser/themes/theme_properties.h"
13 #import "chrome/browser/themes/theme_service.h" 13 #import "chrome/browser/themes/theme_service.h"
14 #import "chrome/browser/ui/cocoa/themed_window.h" 14 #import "chrome/browser/ui/cocoa/themed_window.h"
15 #include "chrome/browser/ui/view_ids.h"
15 #include "content/public/browser/render_view_host.h" 16 #include "content/public/browser/render_view_host.h"
16 #include "content/public/browser/render_widget_host_view.h" 17 #include "content/public/browser/render_widget_host_view.h"
17 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
18 #include "content/public/browser/web_contents_observer.h" 19 #include "content/public/browser/web_contents_observer.h"
19 #include "ui/base/cocoa/animation_utils.h" 20 #include "ui/base/cocoa/animation_utils.h"
20 #include "ui/gfx/geometry/rect.h" 21 #include "ui/gfx/geometry/rect.h"
21 22
22 using content::WebContents; 23 using content::WebContents;
23 using content::WebContentsObserver; 24 using content::WebContentsObserver;
24 25
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 const NSInteger numberOfComponents = [nsBackgroundColor numberOfComponents]; 159 const NSInteger numberOfComponents = [nsBackgroundColor numberOfComponents];
159 CGFloat components[numberOfComponents]; 160 CGFloat components[numberOfComponents];
160 [nsBackgroundColor getComponents:components]; 161 [nsBackgroundColor getComponents:components];
161 base::ScopedCFTypeRef<CGColorRef> cgBackgroundColor( 162 base::ScopedCFTypeRef<CGColorRef> cgBackgroundColor(
162 CGColorCreate(cgColorSpace, components)); 163 CGColorCreate(cgColorSpace, components));
163 164
164 ScopedCAActionDisabler disabler; 165 ScopedCAActionDisabler disabler;
165 [[self layer] setBackgroundColor:cgBackgroundColor]; 166 [[self layer] setBackgroundColor:cgBackgroundColor];
166 } 167 }
167 168
169 - (ViewID)viewID {
170 return VIEW_ID_TAB_CONTAINER;
171 }
172
173 - (BOOL)acceptsFirstResponder {
174 return [[self subviews] count] > 0 &&
175 [[[self subviews] objectAtIndex:0] acceptsFirstResponder];
176 }
177
178 // When receiving a click-to-focus in the solid color area surrounding the
179 // WebContents' native view, immediately transfer focus to WebContents' native
180 // view.
181 - (BOOL)becomeFirstResponder {
182 if (![self acceptsFirstResponder])
183 return NO;
184 return [[self window] makeFirstResponder:[[self subviews] objectAtIndex:0]];
185 }
186
187 - (BOOL)canBecomeKeyView {
188 return NO; // Tab/Shift-Tab should focus the subview, not this view.
189 }
190
168 @end // @implementation TabContentsContainerView 191 @end // @implementation TabContentsContainerView
169 192
170 @implementation TabContentsController 193 @implementation TabContentsController
171 @synthesize webContents = contents_; 194 @synthesize webContents = contents_;
172 195
173 - (id)initWithContents:(WebContents*)contents { 196 - (id)initWithContents:(WebContents*)contents {
174 if ((self = [super initWithNibName:nil bundle:nil])) { 197 if ((self = [super initWithNibName:nil bundle:nil])) {
175 fullscreenObserver_.reset(new FullscreenObserver(self)); 198 fullscreenObserver_.reset(new FullscreenObserver(self));
176 [self changeWebContents:contents]; 199 [self changeWebContents:contents];
177 } 200 }
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 } else { 360 } else {
338 rect.ClampToCenteredSize(gfx::Size( 361 rect.ClampToCenteredSize(gfx::Size(
339 static_cast<int>(x / captureSize.height()), rect.height())); 362 static_cast<int>(x / captureSize.height()), rect.height()));
340 } 363 }
341 } 364 }
342 365
343 return NSRectFromCGRect(rect.ToCGRect()); 366 return NSRectFromCGRect(rect.ToCGRect());
344 } 367 }
345 368
346 @end 369 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_focus_uitest.cc ('k') | chrome/test/base/interactive_test_utils_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698