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

Side by Side Diff: ios/chrome/browser/ui/browser_view_controller.mm

Issue 2714813002: [iOS] Add Request Mobile Site cell to tools menu (Closed)
Patch Set: Update setUserAgentType implementation and Add TODO Created 3 years, 9 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "ios/chrome/browser/ui/browser_view_controller.h" 5 #import "ios/chrome/browser/ui/browser_view_controller.h"
6 6
7 #import <AssetsLibrary/AssetsLibrary.h> 7 #import <AssetsLibrary/AssetsLibrary.h>
8 #import <MobileCoreServices/MobileCoreServices.h> 8 #import <MobileCoreServices/MobileCoreServices.h>
9 #import <PassKit/PassKit.h> 9 #import <PassKit/PassKit.h>
10 #import <Photos/Photos.h> 10 #import <Photos/Photos.h>
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 // Whether BVC prefers to hide the status bar. This value is used to determine 537 // Whether BVC prefers to hide the status bar. This value is used to determine
538 // the response from the |prefersStatusBarHidden| method. 538 // the response from the |prefersStatusBarHidden| method.
539 @property(nonatomic, assign) BOOL hideStatusBar; 539 @property(nonatomic, assign) BOOL hideStatusBar;
540 // Whether the VoiceSearchBar should be displayed. 540 // Whether the VoiceSearchBar should be displayed.
541 @property(nonatomic, readonly) BOOL shouldShowVoiceSearchBar; 541 @property(nonatomic, readonly) BOOL shouldShowVoiceSearchBar;
542 // Coordinator for displaying a modal overlay with activity indicator to prevent 542 // Coordinator for displaying a modal overlay with activity indicator to prevent
543 // the user from interacting with the browser view. 543 // the user from interacting with the browser view.
544 @property(nonatomic, retain) 544 @property(nonatomic, retain)
545 ActivityOverlayCoordinator* activityOverlayCoordinator; 545 ActivityOverlayCoordinator* activityOverlayCoordinator;
546 546
547 // The user agent type used to load the currently visible page. User agent type
548 // is NONE if there is no visible page.
Eugene But (OOO till 7-30) 2017/03/01 19:12:55 Is this also NONE for pages where UA is not applic
liaoyuke 2017/03/03 01:04:06 Done.
549 @property(nonatomic, assign, readonly) web::UserAgentType userAgentType;
550
547 // BVC initialization: 551 // BVC initialization:
548 // If the BVC is initialized with a valid browser state & tab model immediately, 552 // If the BVC is initialized with a valid browser state & tab model immediately,
549 // the path is straightforward: functionality is enabled, and the UI is built 553 // the path is straightforward: functionality is enabled, and the UI is built
550 // when -viewDidLoad is called. 554 // when -viewDidLoad is called.
551 // If the BVC is initialized without a browser state or tab model, the tab model 555 // If the BVC is initialized without a browser state or tab model, the tab model
552 // and browser state may or may not be provided before -viewDidLoad is called. 556 // and browser state may or may not be provided before -viewDidLoad is called.
553 // In most cases, they will not, to improve startup performance. 557 // In most cases, they will not, to improve startup performance.
554 // In order to handle this, initialization of various aspects of BVC have been 558 // In order to handle this, initialization of various aspects of BVC have been
555 // broken out into the following functions, which have expectations (enforced 559 // broken out into the following functions, which have expectations (enforced
556 // with DCHECKs) regarding |_browserState|, |_model|, and [self isViewLoaded]. 560 // with DCHECKs) regarding |_browserState|, |_model|, and [self isViewLoaded].
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 // Adds a CardView on top of the contentArea either taking the size of the full 680 // Adds a CardView on top of the contentArea either taking the size of the full
677 // screen or just the size of the space under the header. 681 // screen or just the size of the space under the header.
678 // Returns the CardView that was added. 682 // Returns the CardView that was added.
679 - (CardView*)addCardViewInFullscreen:(BOOL)fullScreen; 683 - (CardView*)addCardViewInFullscreen:(BOOL)fullScreen;
680 // Called when either a tab finishes loading or when a tab with finished content 684 // Called when either a tab finishes loading or when a tab with finished content
681 // is added directly to the model via pre-rendering. The tab must be non-nil and 685 // is added directly to the model via pre-rendering. The tab must be non-nil and
682 // must be a member of the tab model controlled by this BrowserViewController. 686 // must be a member of the tab model controlled by this BrowserViewController.
683 - (void)tabLoadComplete:(Tab*)tab withSuccess:(BOOL)success; 687 - (void)tabLoadComplete:(Tab*)tab withSuccess:(BOOL)success;
684 // Evaluates Javascript asynchronously using the current page context. 688 // Evaluates Javascript asynchronously using the current page context.
685 - (void)openJavascript:(NSString*)javascript; 689 - (void)openJavascript:(NSString*)javascript;
690
686 // Sets the desktop user agent flag and reload the current page. 691 // Sets the desktop user agent flag and reload the current page.
687 - (void)enableDesktopUserAgent; 692 - (void)enableDesktopUserAgent;
693
694 // Sets the desktop user agent flag and reload the current page.
Eugene But (OOO till 7-30) 2017/03/01 19:12:54 s/reload/reloads
liaoyuke 2017/03/03 01:04:06 Done.
695 - (void)enableMobileUserAgent;
696
688 // Helper methods used by ShareToDelegate methods. 697 // Helper methods used by ShareToDelegate methods.
689 // Shows an alert with the given title and message id. 698 // Shows an alert with the given title and message id.
690 - (void)showErrorAlert:(int)titleMessageId message:(int)messageId; 699 - (void)showErrorAlert:(int)titleMessageId message:(int)messageId;
691 // Helper method displaying an alert with the given title and message. 700 // Helper method displaying an alert with the given title and message.
692 // Dismisses previous alert if it has not been dismissed yet. 701 // Dismisses previous alert if it has not been dismissed yet.
693 - (void)showErrorAlertWithStringTitle:(NSString*)title 702 - (void)showErrorAlertWithStringTitle:(NSString*)title
694 message:(NSString*)message; 703 message:(NSString*)message;
695 // Shows a self-dismissing snackbar displaying |message|. 704 // Shows a self-dismissing snackbar displaying |message|.
696 - (void)showSnackbar:(NSString*)message; 705 - (void)showSnackbar:(NSString*)message;
697 // Induces an intentional crash in the browser process. 706 // Induces an intentional crash in the browser process.
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
1088 if (![controller canFindInPage]) 1097 if (![controller canFindInPage])
1089 return NO; 1098 return NO;
1090 1099
1091 // Don't show twice. 1100 // Don't show twice.
1092 if (controller.findInPageModel.enabled) 1101 if (controller.findInPageModel.enabled)
1093 return NO; 1102 return NO;
1094 1103
1095 return YES; 1104 return YES;
1096 } 1105 }
1097 1106
1107 - (web::UserAgentType)getUserAgentType {
Eugene But (OOO till 7-30) 2017/03/01 19:12:55 s/getUserAgentType/userAgentType From "Coding Gui
liaoyuke 2017/03/03 01:04:05 Done. Thank you for explaining with the reference!
1108 web::UserAgentType userAgentType = web::UserAgentType::NONE;
1109 web::NavigationManager* navigationManager =
1110 [_model currentTab].webState->GetNavigationManager();
1111
1112 if (navigationManager && navigationManager->GetVisibleItem())
Eugene But (OOO till 7-30) 2017/03/01 19:12:55 navigationManager can not be null. webState can.
liaoyuke 2017/03/03 01:04:05 Done.
1113 userAgentType = navigationManager->GetVisibleItem()->GetUserAgentType();
Eugene But (OOO till 7-30) 2017/03/01 19:12:55 I don't think there is a guarantee that VisibleIte
liaoyuke 2017/03/03 01:04:06 Done.
1114
1115 return userAgentType;
1116 }
1117
1098 - (void)setVisible:(BOOL)visible { 1118 - (void)setVisible:(BOOL)visible {
1099 if (_visible == visible) 1119 if (_visible == visible)
1100 return; 1120 return;
1101 _visible = visible; 1121 _visible = visible;
1102 } 1122 }
1103 1123
1104 - (void)setViewVisible:(BOOL)viewVisible { 1124 - (void)setViewVisible:(BOOL)viewVisible {
1105 if (_viewVisible == viewVisible) 1125 if (_viewVisible == viewVisible)
1106 return; 1126 return;
1107 _viewVisible = viewVisible; 1127 _viewVisible = viewVisible;
(...skipping 2178 matching lines...) Expand 10 before | Expand all | Expand 10 after
3286 } 3306 }
3287 3307
3288 [_toolbarController showToolsMenuPopupWithContext:context]; 3308 [_toolbarController showToolsMenuPopupWithContext:context];
3289 ToolsPopupController* toolsPopupController = 3309 ToolsPopupController* toolsPopupController =
3290 [_toolbarController toolsPopupController]; 3310 [_toolbarController toolsPopupController];
3291 if ([_model currentTab]) { 3311 if ([_model currentTab]) {
3292 BOOL isBookmarked = _toolbarModelIOS->IsCurrentTabBookmarked(); 3312 BOOL isBookmarked = _toolbarModelIOS->IsCurrentTabBookmarked();
3293 [toolsPopupController setIsCurrentPageBookmarked:isBookmarked]; 3313 [toolsPopupController setIsCurrentPageBookmarked:isBookmarked];
3294 [toolsPopupController setCanShowFindBar:self.canShowFindBar]; 3314 [toolsPopupController setCanShowFindBar:self.canShowFindBar];
3295 [toolsPopupController setCanUseReaderMode:self.canUseReaderMode]; 3315 [toolsPopupController setCanUseReaderMode:self.canUseReaderMode];
3296 [toolsPopupController
3297 setCanUseDesktopUserAgent:self.canUseDesktopUserAgent];
3298 [toolsPopupController setCanShowShareMenu:self.canShowShareMenu]; 3316 [toolsPopupController setCanShowShareMenu:self.canShowShareMenu];
3317 toolsPopupController.userAgentType = self.userAgentType;
3299 3318
3300 if (!IsIPadIdiom()) 3319 if (!IsIPadIdiom())
3301 [toolsPopupController setIsTabLoading:_toolbarModelIOS->IsLoading()]; 3320 [toolsPopupController setIsTabLoading:_toolbarModelIOS->IsLoading()];
3302 } 3321 }
3303 } 3322 }
3304 3323
3305 - (void)showPageInfoPopupForView:(UIView*)sourceView { 3324 - (void)showPageInfoPopupForView:(UIView*)sourceView {
3306 Tab* tab = [_model currentTab]; 3325 Tab* tab = [_model currentTab];
3307 DCHECK([tab navigationManager]); 3326 DCHECK([tab navigationManager]);
3308 web::NavigationItem* navItem = [tab navigationManager]->GetVisibleItem(); 3327 web::NavigationItem* navItem = [tab navigationManager]->GetVisibleItem();
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
3921 break; 3940 break;
3922 case IDC_SHOW_MAIL_COMPOSER: 3941 case IDC_SHOW_MAIL_COMPOSER:
3923 [self showMailComposer:sender]; 3942 [self showMailComposer:sender];
3924 break; 3943 break;
3925 case IDC_READER_MODE: 3944 case IDC_READER_MODE:
3926 [[_model currentTab] switchToReaderMode]; 3945 [[_model currentTab] switchToReaderMode];
3927 break; 3946 break;
3928 case IDC_REQUEST_DESKTOP_SITE: 3947 case IDC_REQUEST_DESKTOP_SITE:
3929 [self enableDesktopUserAgent]; 3948 [self enableDesktopUserAgent];
3930 break; 3949 break;
3950 case IDC_REQUEST_MOBILE_SITE:
3951 [self enableMobileUserAgent];
3952 break;
3931 case IDC_SHOW_TOOLS_MENU: { 3953 case IDC_SHOW_TOOLS_MENU: {
3932 [self showToolsMenuPopup]; 3954 [self showToolsMenuPopup];
3933 break; 3955 break;
3934 } 3956 }
3935 case IDC_SHOW_BOOKMARK_MANAGER: { 3957 case IDC_SHOW_BOOKMARK_MANAGER: {
3936 if (IsIPadIdiom()) { 3958 if (IsIPadIdiom()) {
3937 [self showAllBookmarks]; 3959 [self showAllBookmarks];
3938 } else { 3960 } else {
3939 [self initializeBookmarkInteractionController]; 3961 [self initializeBookmarkInteractionController];
3940 [_bookmarkInteractionController presentBookmarks]; 3962 [_bookmarkInteractionController presentBookmarks];
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
4133 windowName:nil 4155 windowName:nil
4134 inBackground:NO 4156 inBackground:NO
4135 appendTo:kCurrentTab]; 4157 appendTo:kCurrentTab];
4136 } 4158 }
4137 4159
4138 - (void)enableDesktopUserAgent { 4160 - (void)enableDesktopUserAgent {
4139 [[_model currentTab] enableDesktopUserAgent]; 4161 [[_model currentTab] enableDesktopUserAgent];
4140 [[_model currentTab] reloadForDesktopUserAgent]; 4162 [[_model currentTab] reloadForDesktopUserAgent];
4141 } 4163 }
4142 4164
4165 // TODO(crbug.com/692303): Implement the actual functionality of
4166 // "Request Mobile Site", and also refactoring the user agent related function
4167 // names to improve readability.
4168 - (void)enableMobileUserAgent {
4169 }
4170
4143 - (void)resetAllWebViews { 4171 - (void)resetAllWebViews {
4144 [_dialogPresenter cancelAllDialogs]; 4172 [_dialogPresenter cancelAllDialogs];
4145 [_model resetAllWebViews]; 4173 [_model resetAllWebViews];
4146 } 4174 }
4147 4175
4148 #pragma mark - Find Bar 4176 #pragma mark - Find Bar
4149 4177
4150 - (void)hideFindBarWithAnimation:(BOOL)animate { 4178 - (void)hideFindBarWithAnimation:(BOOL)animate {
4151 [_findBarController hideFindBarView:animate]; 4179 [_findBarController hideFindBarView:animate];
4152 } 4180 }
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after
5025 5053
5026 - (UIView*)voiceSearchButton { 5054 - (UIView*)voiceSearchButton {
5027 return _voiceSearchButton; 5055 return _voiceSearchButton;
5028 } 5056 }
5029 5057
5030 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner { 5058 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner {
5031 return [self currentLogoAnimationControllerOwner]; 5059 return [self currentLogoAnimationControllerOwner];
5032 } 5060 }
5033 5061
5034 @end 5062 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698