Commit 99dff50a authored by David Jean's avatar David Jean Committed by Chromium LUCI CQ

[ios] Fix orientation issues for ios 12 deprecation

Also includes two #ifdef-out of deprecated code unrelated
to orientation.

Bug: 1131852
Change-Id: Ia229a421d0b9f9e9d655791d43b0cb59c0b0e75c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2612898
Commit-Queue: David Jean <djean@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#841433}
parent 9ec63731
......@@ -95,6 +95,7 @@
#import "ios/chrome/browser/ui/main/scene_delegate.h"
#import "ios/chrome/browser/ui/ui_feature_flags.h"
#include "ios/chrome/browser/ui/util/multi_window_support.h"
#include "ios/chrome/browser/ui/util/uikit_ui_util.h"
#import "ios/chrome/browser/ui/webui/chrome_web_ui_ios_controller_factory.h"
#import "ios/chrome/browser/url_loading/url_loading_params.h"
#import "ios/chrome/browser/web_state_list/web_state_list.h"
......@@ -733,8 +734,7 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
}
- (void)orientationDidChange:(NSNotification*)notification {
crash_keys::SetCurrentOrientation(
[[UIApplication sharedApplication] statusBarOrientation],
crash_keys::SetCurrentOrientation(GetInterfaceOrientation(),
[[UIDevice currentDevice] orientation]);
}
......
......@@ -23,6 +23,7 @@
#import "ios/chrome/browser/ui/authentication/unified_consent/unified_consent_coordinator.h"
#import "ios/chrome/browser/ui/commands/browsing_data_commands.h"
#import "ios/chrome/browser/ui/commands/command_dispatcher.h"
#import "ios/chrome/browser/ui/util/uikit_ui_util.h"
#import "ios/chrome/browser/unified_consent/unified_consent_service_factory.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
......@@ -432,8 +433,7 @@ const CGFloat kFadeOutAnimationDuration = 0.16f;
// Avoid presenting the promo if the current device orientation is not
// supported. The promo will be presented at a later moment, when the
// device orientation is supported.
UIInterfaceOrientation orientation =
[UIApplication sharedApplication].statusBarOrientation;
UIInterfaceOrientation orientation = GetInterfaceOrientation();
NSUInteger supportedOrientationsMask =
[self.viewController supportedInterfaceOrientations];
if (!((1 << orientation) & supportedOrientationsMask)) {
......
......@@ -22,6 +22,7 @@
#import "ios/chrome/browser/ui/collection_view/collection_view_controller.h"
#import "ios/chrome/browser/ui/collection_view/collection_view_model.h"
#import "ios/chrome/browser/ui/util/rtl_geometry.h"
#import "ios/chrome/browser/ui/util/uikit_ui_util.h"
#import "ios/chrome/common/ui/colors/semantic_color_names.h"
#include "ui/base/l10n/l10n_util.h"
......@@ -363,8 +364,7 @@ void CardUnmaskPromptViewBridge::DeleteSelf() {
// Focus the first visible input, unless the orientation is landscape. In
// landscape, the keyboard covers up the storage checkbox shown below this
// view and the user might never see it.
if (UIInterfaceOrientationIsPortrait(
[UIApplication sharedApplication].statusBarOrientation)) {
if (UIInterfaceOrientationIsPortrait(GetInterfaceOrientation())) {
// Also check whether any of the inputs are already the first responder and
// are non-empty, in which case the focus should be left there.
if ((!CVC.monthInput.isFirstResponder || CVC.monthInput.text.length == 0) &&
......
......@@ -8,6 +8,7 @@
#include "base/mac/foundation_util.h"
#include "base/notreached.h"
#include "base/strings/stringprintf.h"
#include "ios/chrome/browser/ui/util/uikit_ui_util.h"
#include "ios/chrome/common/ios_app_bundle_id_prefix_buildflags.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
......@@ -329,8 +330,7 @@
}
- (AVCaptureVideoOrientation)videoOrientationForCurrentInterfaceOrientation {
UIInterfaceOrientation orientation =
[[UIApplication sharedApplication] statusBarOrientation];
UIInterfaceOrientation orientation = GetInterfaceOrientation();
switch (orientation) {
case UIInterfaceOrientationUnknown:
return AVCaptureVideoOrientationPortrait;
......
......@@ -118,11 +118,13 @@
- (void)keyboardWillHide:(NSNotification*)notification {
self.keyboardOnScreen = NO;
#if !defined(__IPHONE_13_0) || __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_13_0
dispatch_async(dispatch_get_main_queue(), ^{
if (self.keyboardOnScreen) {
[self.consumer keyboardDidStayOnScreen];
}
});
#endif
}
#pragma mark - Private
......
......@@ -69,6 +69,7 @@ source_set("agents") {
"//ios/chrome/browser/main:public",
"//ios/chrome/browser/sessions:restoration_agent",
"//ios/chrome/browser/sessions:restoration_observer",
"//ios/chrome/browser/ui/util",
"//ios/web/public",
]
frameworks = [ "Foundation.framework" ]
......
......@@ -14,6 +14,7 @@
#include "ios/chrome/browser/chrome_url_constants.h"
#include "ios/chrome/browser/crash_report/crash_loop_detection_util.h"
#import "ios/chrome/browser/sessions/session_restoration_browser_agent.h"
#include "ios/chrome/browser/ui/util/uikit_ui_util.h"
#include "ios/chrome/browser/web_state_list/session_metrics.h"
#import "ios/chrome/browser/web_state_list/web_state_list.h"
#include "ios/web/public/browser_state.h"
......@@ -157,7 +158,7 @@ void WebStateListMetricsBrowserAgent::DidFinishNavigation(
void WebStateListMetricsBrowserAgent::PageLoaded(
web::WebState* web_state,
web::PageLoadCompletionStatus load_completion_status) {
switch ([[UIApplication sharedApplication] statusBarOrientation]) {
switch (GetInterfaceOrientation()) {
case UIInterfaceOrientationPortrait:
case UIInterfaceOrientationPortraitUpsideDown:
UMA_HISTOGRAM_BOOLEAN("Tab.PageLoadInPortrait", YES);
......
......@@ -11,4 +11,8 @@
// Use only if the context of which window doesn't matter.
UIWindow* GetAnyKeyWindow();
// Returns interface orientation for the current window, returned by
// GetAnyKeyWindow().
UIInterfaceOrientation GetInterfaceOrientation();
#endif // IOS_WEB_COMMON_UIKIT_UI_UTIL_H_
......@@ -22,3 +22,11 @@ UIWindow* GetAnyKeyWindow() {
return nil;
#endif
}
UIInterfaceOrientation GetInterfaceOrientation() {
#if !defined(__IPHONE_13_0) || __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_13_0
return [[UIApplication sharedApplication] statusBarOrientation];
#else
return GetAnyKeyWindow().windowScene.interfaceOrientation;
#endif
}
......@@ -168,6 +168,9 @@
}];
}
#if !defined(__IPHONE_13_0) || __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_13_0
// TODO(crbug.com/1131852): Preview depracted is iOS13+
- (BOOL)webView:(WKWebView*)webView
shouldPreviewElement:(WKPreviewElementInfo*)elementInfo {
return self.webStateImpl->ShouldPreviewLink(
......@@ -211,6 +214,8 @@
completionHandler);
}
#endif // End of >iOS13 deprecated block.
- (void)webView:(WKWebView*)webView
contextMenuDidEndForElement:(WKContextMenuElementInfo*)elementInfo
API_AVAILABLE(ios(13.0)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment