Chromium Code Reviews| Index: ios/chrome/browser/ui/browser_view_controller.mm |
| diff --git a/ios/chrome/browser/ui/browser_view_controller.mm b/ios/chrome/browser/ui/browser_view_controller.mm |
| index 9b3b3afa3ff9a8cbe9cf40f7fc6d4b47c8adb8b0..be5cf87103a0af952936761974b4caf930bba15d 100644 |
| --- a/ios/chrome/browser/ui/browser_view_controller.mm |
| +++ b/ios/chrome/browser/ui/browser_view_controller.mm |
| @@ -544,6 +544,10 @@ @interface BrowserViewController ()<AppRatingPromptDelegate, |
| @property(nonatomic, retain) |
| ActivityOverlayCoordinator* activityOverlayCoordinator; |
| +// The user agent type used to load the currently visible page. User agent type |
| +// 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.
|
| +@property(nonatomic, assign, readonly) web::UserAgentType userAgentType; |
| + |
| // BVC initialization: |
| // If the BVC is initialized with a valid browser state & tab model immediately, |
| // the path is straightforward: functionality is enabled, and the UI is built |
| @@ -683,8 +687,13 @@ - (CardView*)addCardViewInFullscreen:(BOOL)fullScreen; |
| - (void)tabLoadComplete:(Tab*)tab withSuccess:(BOOL)success; |
| // Evaluates Javascript asynchronously using the current page context. |
| - (void)openJavascript:(NSString*)javascript; |
| + |
| // Sets the desktop user agent flag and reload the current page. |
| - (void)enableDesktopUserAgent; |
| + |
| +// 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.
|
| +- (void)enableMobileUserAgent; |
| + |
| // Helper methods used by ShareToDelegate methods. |
| // Shows an alert with the given title and message id. |
| - (void)showErrorAlert:(int)titleMessageId message:(int)messageId; |
| @@ -1095,6 +1104,17 @@ - (BOOL)canShowFindBar { |
| return YES; |
| } |
| +- (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!
|
| + web::UserAgentType userAgentType = web::UserAgentType::NONE; |
| + web::NavigationManager* navigationManager = |
| + [_model currentTab].webState->GetNavigationManager(); |
| + |
| + 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.
|
| + 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.
|
| + |
| + return userAgentType; |
| +} |
| + |
| - (void)setVisible:(BOOL)visible { |
| if (_visible == visible) |
| return; |
| @@ -3293,9 +3313,8 @@ - (void)showToolsMenuPopup { |
| [toolsPopupController setIsCurrentPageBookmarked:isBookmarked]; |
| [toolsPopupController setCanShowFindBar:self.canShowFindBar]; |
| [toolsPopupController setCanUseReaderMode:self.canUseReaderMode]; |
| - [toolsPopupController |
| - setCanUseDesktopUserAgent:self.canUseDesktopUserAgent]; |
| [toolsPopupController setCanShowShareMenu:self.canShowShareMenu]; |
| + toolsPopupController.userAgentType = self.userAgentType; |
| if (!IsIPadIdiom()) |
| [toolsPopupController setIsTabLoading:_toolbarModelIOS->IsLoading()]; |
| @@ -3928,6 +3947,9 @@ - (IBAction)chromeExecuteCommand:(id)sender { |
| case IDC_REQUEST_DESKTOP_SITE: |
| [self enableDesktopUserAgent]; |
| break; |
| + case IDC_REQUEST_MOBILE_SITE: |
| + [self enableMobileUserAgent]; |
| + break; |
| case IDC_SHOW_TOOLS_MENU: { |
| [self showToolsMenuPopup]; |
| break; |
| @@ -4140,6 +4162,12 @@ - (void)enableDesktopUserAgent { |
| [[_model currentTab] reloadForDesktopUserAgent]; |
| } |
| +// TODO(crbug.com/692303): Implement the actual functionality of |
| +// "Request Mobile Site", and also refactoring the user agent related function |
| +// names to improve readability. |
| +- (void)enableMobileUserAgent { |
| +} |
| + |
| - (void)resetAllWebViews { |
| [_dialogPresenter cancelAllDialogs]; |
| [_model resetAllWebViews]; |