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

[ios] Handle deprecated orientation changed notification

UIApplicationDidChangeStatusBarOrientationNotification is deprecated in
iOS 13.  Instead the BVC method
viewWillTransitionToSize:withTransitionCoordinator:
Set the orientation for crash_keys and notifies the CrwWebController
of orientation/size change.

Bug: 1131852
Change-Id: Ia2b26e8aa9b8e58d0e5a4401f2a4049b221f599b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2620263Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Reviewed-by: default avatarJohn Wu <jzw@chromium.org>
Commit-Queue: David Jean <djean@chromium.org>
Cr-Commit-Position: refs/heads/master@{#843452}
parent 2fb0d515
......@@ -724,18 +724,13 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
}
- (void)registerForOrientationChangeNotifications {
// Register to both device orientation and UI orientation did change
// notification as these two events may be triggered independantely.
// Register device orientation. UI orientation will be registered by
// each window BVC. These two events may be triggered independantely.
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(orientationDidChange:)
name:UIDeviceOrientationDidChangeNotification
object:nil];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(orientationDidChange:)
name:UIApplicationDidChangeStatusBarOrientationNotification
object:nil];
}
- (void)schedulePrefObserverInitialization {
......
......@@ -42,6 +42,7 @@ source_set("browser_view") {
"//ios/chrome/browser/autofill:autofill_internal",
"//ios/chrome/browser/bookmarks",
"//ios/chrome/browser/browser_state",
"//ios/chrome/browser/crash_report",
"//ios/chrome/browser/download",
"//ios/chrome/browser/feature_engagement",
"//ios/chrome/browser/find_in_page",
......
......@@ -31,6 +31,7 @@
#import "ios/chrome/app/application_delegate/app_state.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/chrome/browser/chrome_url_constants.h"
#include "ios/chrome/browser/crash_report/crash_keys_helper.h"
#import "ios/chrome/browser/download/download_manager_tab_helper.h"
#include "ios/chrome/browser/feature_engagement/tracker_factory.h"
#include "ios/chrome/browser/feature_engagement/tracker_util.h"
......@@ -1705,6 +1706,12 @@ NSString* const kBrowserViewControllerSnackbarCategory =
0, self.thumbStripPanHandler.revealedHeight);
}
}
id<CRWWebViewProxy> webViewProxy = self.currentWebState->GetWebViewProxy();
[webViewProxy surfaceSizeChanged];
crash_keys::SetCurrentOrientation(GetInterfaceOrientation(),
[[UIDevice currentDevice] orientation]);
}
- (void)dismissViewControllerAnimated:(BOOL)flag
......
......@@ -69,6 +69,10 @@
// Wrapper around the becomeFirstResponder method of the webview.
- (BOOL)becomeFirstResponder;
// Notifies the web view controller that the surface size has changed due to
// multiwindow action or orientation change.
- (void)surfaceSizeChanged;
@end
#endif // IOS_WEB_PUBLIC_UI_CRW_WEB_VIEW_PROXY_H_
......@@ -191,6 +191,10 @@ class WebStateImpl;
// Adds the webView back in the view hierarchy.
- (void)addWebViewToViewHierarchy;
// Notifies this controller that the surface size has changed due to
// multiwindow action or orientation change.
- (void)surfaceSizeChanged;
@end
#pragma mark Testing
......
......@@ -255,8 +255,6 @@ NSString* const kSessionRestoreScriptMessageName = @"session_restore";
// |completion| is called with nullptr.
typedef void (^ViewportStateCompletion)(const web::PageViewportState*);
- (void)extractViewportTagWithCompletion:(ViewportStateCompletion)completion;
// Called by NSNotificationCenter upon orientation changes.
- (void)orientationDidChange;
// Queries the web view for the user-scalable meta tag and calls
// |-applyPageDisplayState:userScalable:| with the result.
- (void)applyPageDisplayState:(const web::PageDisplayState&)displayState;
......@@ -318,11 +316,6 @@ typedef void (^ViewportStateCompletion)(const web::PageViewportState*);
std::make_unique<web::JsWindowErrorManager>(_webStateImpl);
_cookieBlockingErrorLogger =
std::make_unique<web::CookieBlockingErrorLogger>(_webStateImpl);
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(orientationDidChange)
name:UIApplicationDidChangeStatusBarOrientationNotification
object:nil];
_navigationHandler = [[CRWWKNavigationHandler alloc] initWithDelegate:self];
......@@ -1315,7 +1308,7 @@ typedef void (^ViewportStateCompletion)(const web::PageViewportState*);
}];
}
- (void)orientationDidChange {
- (void)surfaceSizeChanged {
// When rotating, the available zoom scale range may change, zoomScale's
// percentage into this range should remain constant. However, there are
// two known bugs with respect to adjusting the zoomScale on rotation:
......
......@@ -186,4 +186,8 @@ UIView* GetFirstResponderSubview(UIView* view) {
return [_contentView becomeFirstResponder];
}
- (void)surfaceSizeChanged {
[_webController surfaceSizeChanged];
}
@end
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