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

Side by Side Diff: ios/chrome/browser/ui/main/browser_view_wrangler.mm

Issue 2660143002: Removing iPad Tab Switcher experimental flag. (Closed)
Patch Set: Created 3 years, 10 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "ios/chrome/browser/ui/main/browser_view_wrangler.h" 5 #import "ios/chrome/browser/ui/main/browser_view_wrangler.h"
6 6
7 #include "base/mac/objc_property_releaser.h" 7 #include "base/mac/objc_property_releaser.h"
8 #import "base/mac/scoped_nsobject.h" 8 #import "base/mac/scoped_nsobject.h"
9 #include "ios/chrome/browser/application_context.h" 9 #include "ios/chrome/browser/application_context.h"
10 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" 10 #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 didChangeActiveTab:(Tab*)newTab 205 didChangeActiveTab:(Tab*)newTab
206 previousTab:(Tab*)previousTab 206 previousTab:(Tab*)previousTab
207 atIndex:(NSUInteger)index { 207 atIndex:(NSUInteger)index {
208 [self updateDeviceSharingManager]; 208 [self updateDeviceSharingManager];
209 } 209 }
210 210
211 - (void)tabModel:(TabModel*)model didChangeTab:(Tab*)tab { 211 - (void)tabModel:(TabModel*)model didChangeTab:(Tab*)tab {
212 [self updateDeviceSharingManager]; 212 [self updateDeviceSharingManager];
213 } 213 }
214 214
215 // Called when the number of tabs changes. Updates the switcher button
216 // visibility in the various modes on tablet.
217 - (void)tabModelDidChangeTabCount:(TabModel*)notifiedTabModel {
218 // If in tablet, update the mode switcher icon based on the number of tabs
219 // in the incognito tab strip. Doing this all the time simplifies a lot
220 // of the state transition logic and setting the property to the same value
221 // incurs no re-layout penalty.
222 [self updateModeToggle];
223 }
224
225 #pragma mark - Other public methods 215 #pragma mark - Other public methods
226 216
227 - (void)updateDeviceSharingManager { 217 - (void)updateDeviceSharingManager {
228 if (!self.deviceSharingManager) { 218 if (!self.deviceSharingManager) {
229 self.deviceSharingManager = [[DeviceSharingManager alloc] init]; 219 self.deviceSharingManager = [[DeviceSharingManager alloc] init];
230 } 220 }
231 [self.deviceSharingManager updateBrowserState:_browserState]; 221 [self.deviceSharingManager updateBrowserState:_browserState];
232 222
233 GURL activeURL; 223 GURL activeURL;
234 Tab* currentTab = [self.currentBVC tabModel].currentTab; 224 Tab* currentTab = [self.currentBVC tabModel].currentTab;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 // be immediately deleted. 273 // be immediately deleted.
284 self.otrTabModel = [self buildOtrTabModel:YES]; 274 self.otrTabModel = [self buildOtrTabModel:YES];
285 DCHECK(![self.otrTabModel count]); 275 DCHECK(![self.otrTabModel count]);
286 DCHECK(_browserState->HasOffTheRecordChromeBrowserState()); 276 DCHECK(_browserState->HasOffTheRecordChromeBrowserState());
287 277
288 if (otrBVCIsCurrent) { 278 if (otrBVCIsCurrent) {
289 _currentBVC = self.otrBVC; 279 _currentBVC = self.otrBVC;
290 } 280 }
291 } 281 }
292 282
293 - (void)updateModeToggle {
294 if (IsIPadIdiom()) {
295 self.mainBVC.hasModeToggleSwitch = self.otrTabModel.count ? YES : NO;
296 self.otrBVC.hasModeToggleSwitch = YES;
297 }
298 }
299
300 #pragma mark - Internal methods 283 #pragma mark - Internal methods
301 284
302 - (TabModel*)buildOtrTabModel:(BOOL)empty { 285 - (TabModel*)buildOtrTabModel:(BOOL)empty {
303 DCHECK(_browserState); 286 DCHECK(_browserState);
304 // Ensure that the OTR ChromeBrowserState is created. 287 // Ensure that the OTR ChromeBrowserState is created.
305 ios::ChromeBrowserState* otrBrowserState = 288 ios::ChromeBrowserState* otrBrowserState =
306 _browserState->GetOffTheRecordChromeBrowserState(); 289 _browserState->GetOffTheRecordChromeBrowserState();
307 DCHECK(otrBrowserState); 290 DCHECK(otrBrowserState);
308 return [self tabModelForBrowserState:otrBrowserState empty:empty]; 291 return [self tabModelForBrowserState:otrBrowserState empty:empty];
309 } 292 }
(...skipping 27 matching lines...) Expand all
337 tabModel:(TabModel*)tabModel { 320 tabModel:(TabModel*)tabModel {
338 base::scoped_nsobject<BrowserViewControllerDependencyFactory> factory( 321 base::scoped_nsobject<BrowserViewControllerDependencyFactory> factory(
339 [[BrowserViewControllerDependencyFactory alloc] 322 [[BrowserViewControllerDependencyFactory alloc]
340 initWithBrowserState:browserState]); 323 initWithBrowserState:browserState]);
341 return [[[BrowserViewController alloc] initWithTabModel:tabModel 324 return [[[BrowserViewController alloc] initWithTabModel:tabModel
342 browserState:browserState 325 browserState:browserState
343 dependencyFactory:factory] autorelease]; 326 dependencyFactory:factory] autorelease];
344 } 327 }
345 328
346 @end 329 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698