| 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..967cd59b773616b83dd18ea41fc75b95ce565c16 100644
|
| --- a/ios/chrome/browser/ui/browser_view_controller.mm
|
| +++ b/ios/chrome/browser/ui/browser_view_controller.mm
|
| @@ -516,6 +516,8 @@ @interface BrowserViewController ()<AppRatingPromptDelegate,
|
| @property(nonatomic, assign, readonly) BOOL canUseReaderMode;
|
| // Whether the current tab can enable the request desktop menu item.
|
| @property(nonatomic, assign, readonly) BOOL canUseDesktopUserAgent;
|
| +// Whether the current tab can enable the request mobile menu item.
|
| +@property(nonatomic, assign, readonly) BOOL canUseMobileUserAgent;
|
| // Whether the sharing menu should be enabled.
|
| @property(nonatomic, assign, readonly) BOOL canShowShareMenu;
|
| // Helper method to check web controller canShowFindBar method.
|
| @@ -625,8 +627,17 @@ - (void)dismissRateThisAppDialog;
|
| // Shows the source of the current page.
|
| - (void)viewSource;
|
| #endif
|
| -// Whether the given tab's url begins with the chrome prefix.
|
| -- (BOOL)isTabNativePage:(Tab*)tab;
|
| +
|
| +// True if "Request Desktop Site" should be visible in tools menu, otherwise,
|
| +// make "Request Mobile Site" visible.
|
| +- (BOOL)shouldShowRequestDesktopSite;
|
| +
|
| +// Whether the current tab is using desktop user agent.
|
| +- (BOOL)isCurrentTabUsingDesktopUserAgent;
|
| +
|
| +// Whether the current tab's url begins with the chrome prefix.
|
| +- (BOOL)isCurrentTabNativePage;
|
| +
|
| // Returns the view to use when animating a page in or out, positioning it to
|
| // fill the content area but not actually adding it to the view hierarchy.
|
| - (UIImageView*)pageOpenCloseAnimationView;
|
| @@ -683,8 +694,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;
|
| +- (void)reloadPageWithDesktopUserAgent;
|
| +
|
| +// Sets the mobile user agent flag and reload the current page.
|
| +- (void)reloadPageWithMobileUserAgent;
|
| +
|
| // Helper methods used by ShareToDelegate methods.
|
| // Shows an alert with the given title and message id.
|
| - (void)showErrorAlert:(int)titleMessageId message:(int)messageId;
|
| @@ -1063,13 +1079,27 @@ - (BOOL)canUseReaderMode {
|
| return [tab canSwitchToReaderMode];
|
| }
|
|
|
| +- (BOOL)shouldShowRequestDesktopSite {
|
| + return [self isCurrentTabNativePage] ||
|
| + ![self isCurrentTabUsingDesktopUserAgent];
|
| +}
|
| +
|
| - (BOOL)canUseDesktopUserAgent {
|
| - Tab* tab = [_model currentTab];
|
| - if ([self isTabNativePage:tab])
|
| - return NO;
|
| + return ![self isCurrentTabNativePage] &&
|
| + ![self isCurrentTabUsingDesktopUserAgent];
|
| +}
|
| +
|
| +- (BOOL)canUseMobileUserAgent {
|
| + return ![self isCurrentTabNativePage] &&
|
| + [self isCurrentTabUsingDesktopUserAgent];
|
| +}
|
|
|
| - // If |useDesktopUserAgent| is |NO|, allow useDesktopUserAgent.
|
| - return !tab.usesDesktopUserAgent;
|
| +- (BOOL)isCurrentTabNativePage {
|
| + return [self isTabNativePage:[_model currentTab]];
|
| +}
|
| +
|
| +- (BOOL)isCurrentTabUsingDesktopUserAgent {
|
| + return [_model currentTab].usesDesktopUserAgent;
|
| }
|
|
|
| // Whether the sharing menu should be shown.
|
| @@ -3289,12 +3319,20 @@ - (void)showToolsMenuPopup {
|
| ToolsPopupController* toolsPopupController =
|
| [_toolbarController toolsPopupController];
|
| if ([_model currentTab]) {
|
| + // Both "Request Desktop Site" and "Request Mobile Site" are visible by
|
| + // default, needs to hide exactly one of them.
|
| + if ([self shouldShowRequestDesktopSite])
|
| + [toolsPopupController hideRequestMobileSite];
|
| + else
|
| + [toolsPopupController hideRequestDesktopSite];
|
| +
|
| BOOL isBookmarked = _toolbarModelIOS->IsCurrentTabBookmarked();
|
| [toolsPopupController setIsCurrentPageBookmarked:isBookmarked];
|
| [toolsPopupController setCanShowFindBar:self.canShowFindBar];
|
| [toolsPopupController setCanUseReaderMode:self.canUseReaderMode];
|
| [toolsPopupController
|
| setCanUseDesktopUserAgent:self.canUseDesktopUserAgent];
|
| + [toolsPopupController setCanUseMobileUserAgent:self.canUseMobileUserAgent];
|
| [toolsPopupController setCanShowShareMenu:self.canShowShareMenu];
|
|
|
| if (!IsIPadIdiom())
|
| @@ -3926,7 +3964,10 @@ - (IBAction)chromeExecuteCommand:(id)sender {
|
| [[_model currentTab] switchToReaderMode];
|
| break;
|
| case IDC_REQUEST_DESKTOP_SITE:
|
| - [self enableDesktopUserAgent];
|
| + [self reloadPageWithDesktopUserAgent];
|
| + break;
|
| + case IDC_REQUEST_MOBILE_SITE:
|
| + [self reloadPageWithMobileUserAgent];
|
| break;
|
| case IDC_SHOW_TOOLS_MENU: {
|
| [self showToolsMenuPopup];
|
| @@ -4135,9 +4176,12 @@ - (void)showHelpPage {
|
| appendTo:kCurrentTab];
|
| }
|
|
|
| -- (void)enableDesktopUserAgent {
|
| - [[_model currentTab] enableDesktopUserAgent];
|
| - [[_model currentTab] reloadForDesktopUserAgent];
|
| +- (void)reloadPageWithDesktopUserAgent {
|
| + [[_model currentTab] activateDesktopUserAgent];
|
| + [[_model currentTab] reloadForUpdatedUserAgent];
|
| +}
|
| +
|
| +- (void)reloadPageWithMobileUserAgent {
|
| }
|
|
|
| - (void)resetAllWebViews {
|
|
|