- Revision
- 165028
- Author
- [email protected]
- Date
- 2014-03-03 17:29:41 -0800 (Mon, 03 Mar 2014)
Log Message
Forward application suspend resume notifications to the web process.
https://bugs.webkit.org/show_bug.cgi?id=129356
Patch by Jeremy Jones <[email protected]> on 2014-03-03
Reviewed by Eric Carlson.
Source/WebCore:
* platform/audio/ios/MediaSessionManagerIOS.mm:
(-[WebMediaSessionHelper initWithCallback:]):
Observe UIApplicationDidBecomeActiveNotification,
WebUIApplicationDidBecomeActiveNotification,
WebUIApplicationWillEnterForegroundNotification, and
WebUIApplicationWillResignActiveNotification
(-[WebMediaSessionHelper applicationDidBecomeActive:]):
Resume session.
Source/WebKit2:
Repost UIApplicationWillEnterForegroundNotification,
UIApplicationDidBecomeActiveNotification and
UIApplicationWillResignActiveNotification from UIProcess to WebProcess.
As WebUIApplicationWillEnterForegroundNotification,
WebUIApplicationDidBecomeActiveNotification, and
WebUIApplicationWillResignActiveNotification
* UIProcess/WebPageProxy.h:
Add applicationWillEnterForeground()
applicationWillResignActive()
applicationDidBecomeActive()
* UIProcess/ios/WKContentView.mm:
(-[WKContentView initWithFrame:context:WebKit::configuration:WebKit::]):
Observe notifications.
(-[WKContentView dealloc]):
Stop observing notifications.
(-[WKContentView _applicationWillResignActive:]):
Notify WebPageProxy of the event.
(-[WKContentView _applicationWillEnterForeground:]):
Notify WebPageProxy of the event.
(-[WKContentView _applicationDidBecomeActive:]):
Notify WebPageProxy of the event.
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::applicationWillEnterForeground):
Send corresponding Message to WebPage.
(WebKit::WebPageProxy::applicationWillResignActive):
Send corresponding Message to WebPage.
(WebKit::WebPageProxy::applicationDidBecomeActive):
Send corresponding Message to WebPage.
* WebProcess/WebPage/WebPage.h:
Add applicationWillEnterForeground()
applicationWillResignActive()
applicationDidBecomeActive()
* WebProcess/WebPage/WebPage.messages.in:
Add applicationWillEnterForeground()
applicationWillResignActive()
applicationDidBecomeActive()
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::applicationWillResignActive):
Post corresponding NSNotification.
(WebKit::WebPage::applicationWillEnterForeground):
Post corresponding NSNotification.
(WebKit::WebPage::applicationDidBecomeActive):
Post corresponding NSNotification.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (165027 => 165028)
--- trunk/Source/WebCore/ChangeLog 2014-03-04 01:22:01 UTC (rev 165027)
+++ trunk/Source/WebCore/ChangeLog 2014-03-04 01:29:41 UTC (rev 165028)
@@ -1,3 +1,20 @@
+2014-03-03 Jeremy Jones <[email protected]>
+
+ Forward application suspend resume notifications to the web process.
+ https://bugs.webkit.org/show_bug.cgi?id=129356
+
+ Reviewed by Eric Carlson.
+
+ * platform/audio/ios/MediaSessionManagerIOS.mm:
+ (-[WebMediaSessionHelper initWithCallback:]):
+ Observe UIApplicationDidBecomeActiveNotification,
+ WebUIApplicationDidBecomeActiveNotification,
+ WebUIApplicationWillEnterForegroundNotification, and
+ WebUIApplicationWillResignActiveNotification
+
+ (-[WebMediaSessionHelper applicationDidBecomeActive:]):
+ Resume session.
+
2014-03-03 Commit Queue <[email protected]>
Unreviewed, rolling out r165013.
Modified: trunk/Source/WebCore/WebCore.exp.in (165027 => 165028)
--- trunk/Source/WebCore/WebCore.exp.in 2014-03-04 01:22:01 UTC (rev 165027)
+++ trunk/Source/WebCore/WebCore.exp.in 2014-03-04 01:29:41 UTC (rev 165028)
@@ -2379,6 +2379,9 @@
_WebThreadUnlock
_WebThreadUnlockFromAnyThread
_WebThreadUnlockGuardForMail
+_WebUIApplicationDidBecomeActiveNotification
+_WebUIApplicationWillEnterForegroundNotification
+_WebUIApplicationWillResignActiveNotification
__ZN7WebCore10FloatPointC1ERK7CGPoint
__ZN7WebCore10ScrollView15setScrollOffsetERKNS_8IntPointE
__ZN7WebCore10ScrollView27setVisibleExtentContentRectERKNS_7IntRectE
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (165027 => 165028)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2014-03-04 01:22:01 UTC (rev 165027)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2014-03-04 01:29:41 UTC (rev 165028)
@@ -186,7 +186,7 @@
076306E017E16089005A7C4E /* JSSourceInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 076306DE17E16089005A7C4E /* JSSourceInfo.cpp */; };
076306E117E16089005A7C4E /* JSSourceInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 076306DF17E16089005A7C4E /* JSSourceInfo.h */; settings = {ATTRIBUTES = (Private, ); }; };
076306E317E22A43005A7C4E /* MediaStreamTrackSourcesRequestClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 076306E217E22A43005A7C4E /* MediaStreamTrackSourcesRequestClient.h */; };
- 07638A991884487200E15A1B /* MediaSessionManagerIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 07638A971884487200E15A1B /* MediaSessionManagerIOS.h */; };
+ 07638A991884487200E15A1B /* MediaSessionManagerIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 07638A971884487200E15A1B /* MediaSessionManagerIOS.h */; settings = {ATTRIBUTES = (Private, ); }; };
07638A9A1884487200E15A1B /* MediaSessionManagerIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 07638A981884487200E15A1B /* MediaSessionManagerIOS.mm */; };
076970861463AD8700F502CF /* TextTrackList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 076970841463AD8700F502CF /* TextTrackList.cpp */; };
076970871463AD8700F502CF /* TextTrackList.h in Headers */ = {isa = PBXBuildFile; fileRef = 076970851463AD8700F502CF /* TextTrackList.h */; };
Modified: trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h (165027 => 165028)
--- trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h 2014-03-04 01:22:01 UTC (rev 165027)
+++ trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h 2014-03-04 01:29:41 UTC (rev 165028)
@@ -33,6 +33,12 @@
OBJC_CLASS WebMediaSessionHelper;
+#if defined(__OBJC__) && __OBJC__
+extern NSString* WebUIApplicationWillResignActiveNotification;
+extern NSString* WebUIApplicationWillEnterForegroundNotification;
+extern NSString* WebUIApplicationDidBecomeActiveNotification;
+#endif
+
namespace WebCore {
class MediaSessionManageriOS : public MediaSessionManager {
Modified: trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm (165027 => 165028)
--- trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm 2014-03-04 01:22:01 UTC (rev 165027)
+++ trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm 2014-03-04 01:29:41 UTC (rev 165028)
@@ -49,6 +49,7 @@
SOFT_LINK_POINTER(AVFoundation, AVAudioSessionInterruptionOptionKey, NSString *)
SOFT_LINK_POINTER(UIKit, UIApplicationWillResignActiveNotification, NSString *)
SOFT_LINK_POINTER(UIKit, UIApplicationWillEnterForegroundNotification, NSString *)
+SOFT_LINK_POINTER(UIKit, UIApplicationDidBecomeActiveNotification, NSString *)
#define AVAudioSession getAVAudioSessionClass()
#define AVAudioSessionInterruptionNotification getAVAudioSessionInterruptionNotification()
@@ -56,7 +57,12 @@
#define AVAudioSessionInterruptionOptionKey getAVAudioSessionInterruptionOptionKey()
#define UIApplicationWillResignActiveNotification getUIApplicationWillResignActiveNotification()
#define UIApplicationWillEnterForegroundNotification getUIApplicationWillEnterForegroundNotification()
+#define UIApplicationDidBecomeActiveNotification getUIApplicationDidBecomeActiveNotification()
+NSString* WebUIApplicationWillResignActiveNotification = @"WebUIApplicationWillResignActiveNotification";
+NSString* WebUIApplicationWillEnterForegroundNotification = @"WebUIApplicationWillEnterForegroundNotification";
+NSString* WebUIApplicationDidBecomeActiveNotification = @"WebUIApplicationDidBecomeActiveNotification";
+
using namespace WebCore;
@interface WebMediaSessionHelper : NSObject {
@@ -130,7 +136,11 @@
// FIXME: These need to be piped through from the UI process in WK2 mode.
[center addObserver:self selector:@selector(applicationWillEnterForeground:) name:UIApplicationWillEnterForegroundNotification object:nil];
+ [center addObserver:self selector:@selector(applicationWillEnterForeground:) name:WebUIApplicationWillEnterForegroundNotification object:nil];
+ [center addObserver:self selector:@selector(applicationDidBecomeActive:) name:UIApplicationDidBecomeActiveNotification object:nil];
+ [center addObserver:self selector:@selector(applicationDidBecomeActive:) name:WebUIApplicationDidBecomeActiveNotification object:nil];
[center addObserver:self selector:@selector(applicationWillResignActive:) name:UIApplicationWillResignActiveNotification object:nil];
+ [center addObserver:self selector:@selector(applicationWillResignActive:) name:WebUIApplicationWillResignActiveNotification object:nil];
return self;
}
@@ -172,18 +182,33 @@
- (void)applicationWillEnterForeground:(NSNotification *)notification
{
UNUSED_PARAM(notification);
-
+
if (!_callback)
return;
WebThreadRun(^{
if (!_callback)
return;
-
+
_callback->applicationWillEnterForeground();
});
}
+- (void)applicationDidBecomeActive:(NSNotification *)notification
+{
+ UNUSED_PARAM(notification);
+
+ if (!_callback)
+ return;
+
+ WebThreadRun(^{
+ if (!_callback)
+ return;
+
+ _callback->applicationWillEnterForeground();
+ });
+}
+
- (void)applicationWillResignActive:(NSNotification *)notification
{
UNUSED_PARAM(notification);
Modified: trunk/Source/WebKit2/ChangeLog (165027 => 165028)
--- trunk/Source/WebKit2/ChangeLog 2014-03-04 01:22:01 UTC (rev 165027)
+++ trunk/Source/WebKit2/ChangeLog 2014-03-04 01:29:41 UTC (rev 165028)
@@ -1,3 +1,68 @@
+2014-03-03 Jeremy Jones <[email protected]>
+
+ Forward application suspend resume notifications to the web process.
+ https://bugs.webkit.org/show_bug.cgi?id=129356
+
+ Reviewed by Eric Carlson.
+
+ Repost UIApplicationWillEnterForegroundNotification,
+ UIApplicationDidBecomeActiveNotification and
+ UIApplicationWillResignActiveNotification from UIProcess to WebProcess.
+ As WebUIApplicationWillEnterForegroundNotification,
+ WebUIApplicationDidBecomeActiveNotification, and
+ WebUIApplicationWillResignActiveNotification
+
+ * UIProcess/WebPageProxy.h:
+ Add applicationWillEnterForeground()
+ applicationWillResignActive()
+ applicationDidBecomeActive()
+
+ * UIProcess/ios/WKContentView.mm:
+ (-[WKContentView initWithFrame:context:WebKit::configuration:WebKit::]):
+ Observe notifications.
+
+ (-[WKContentView dealloc]):
+ Stop observing notifications.
+
+ (-[WKContentView _applicationWillResignActive:]):
+ Notify WebPageProxy of the event.
+
+ (-[WKContentView _applicationWillEnterForeground:]):
+ Notify WebPageProxy of the event.
+
+ (-[WKContentView _applicationDidBecomeActive:]):
+ Notify WebPageProxy of the event.
+
+ * UIProcess/ios/WebPageProxyIOS.mm:
+ (WebKit::WebPageProxy::applicationWillEnterForeground):
+ Send corresponding Message to WebPage.
+
+ (WebKit::WebPageProxy::applicationWillResignActive):
+ Send corresponding Message to WebPage.
+
+ (WebKit::WebPageProxy::applicationDidBecomeActive):
+ Send corresponding Message to WebPage.
+
+ * WebProcess/WebPage/WebPage.h:
+ Add applicationWillEnterForeground()
+ applicationWillResignActive()
+ applicationDidBecomeActive()
+
+ * WebProcess/WebPage/WebPage.messages.in:
+ Add applicationWillEnterForeground()
+ applicationWillResignActive()
+ applicationDidBecomeActive()
+
+ * WebProcess/WebPage/ios/WebPageIOS.mm:
+ (WebKit::WebPage::applicationWillResignActive):
+ Post corresponding NSNotification.
+
+ (WebKit::WebPage::applicationWillEnterForeground):
+ Post corresponding NSNotification.
+
+ (WebKit::WebPage::applicationDidBecomeActive):
+ Post corresponding NSNotification.
+
2014-03-03 Commit Queue <[email protected]>
Unreviewed, rolling out r165013.
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (165027 => 165028)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2014-03-04 01:22:01 UTC (rev 165027)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2014-03-04 01:29:41 UTC (rev 165028)
@@ -483,6 +483,9 @@
void setAssistedNodeValue(const String&);
void setAssistedNodeValueAsNumber(double);
void setAssistedNodeSelectedIndex(uint32_t index, bool allowMultipleSelection = false);
+ void applicationWillEnterForeground();
+ void applicationWillResignActive();
+ void applicationDidBecomeActive();
#endif
const EditorState& editorState() const { return m_editorState; }
Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentView.mm (165027 => 165028)
--- trunk/Source/WebKit2/UIProcess/ios/WKContentView.mm 2014-03-04 01:22:01 UTC (rev 165027)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentView.mm 2014-03-04 01:29:41 UTC (rev 165028)
@@ -99,6 +99,12 @@
self.layer.hitTestsAsOpaque = YES;
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_applicationWillEnterForeground:) name:UIApplicationWillEnterForegroundNotification object:[UIApplication sharedApplication]];
+
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_applicationWillResignActive:) name:UIApplicationWillResignActiveNotification object:[UIApplication sharedApplication]];
+
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_applicationDidBecomeActive:) name:UIApplicationDidBecomeActiveNotification object:[UIApplication sharedApplication]];
+
return self;
}
@@ -106,6 +112,8 @@
{
[self cleanupInteraction];
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
+
_page->close();
WebContext::statistics().wkViewCount--;
@@ -321,6 +329,21 @@
return [_webView _zoomOutWithOrigin:origin];
}
+- (void)_applicationWillResignActive:(NSNotification*)notification
+{
+ _page->applicationWillResignActive();
+}
+
+- (void)_applicationWillEnterForeground:(NSNotification*)notification
+{
+ _page->applicationWillEnterForeground();
+}
+
+- (void)_applicationDidBecomeActive:(NSNotification*)notification
+{
+ _page->applicationDidBecomeActive();
+}
+
@end
#endif // PLATFORM(IOS)
Modified: trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm (165027 => 165028)
--- trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm 2014-03-04 01:22:01 UTC (rev 165027)
+++ trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm 2014-03-04 01:29:41 UTC (rev 165028)
@@ -385,6 +385,21 @@
m_pageClient.didUpdateBlockSelectionWithTouch(touch, flags, growThreshold, shrinkThreshold);
}
+void WebPageProxy::applicationWillEnterForeground()
+{
+ m_process->send(Messages::WebPage::ApplicationWillEnterForeground(), m_pageID);
+}
+
+void WebPageProxy::applicationWillResignActive()
+{
+ m_process->send(Messages::WebPage::ApplicationWillResignActive(), m_pageID);
+}
+
+void WebPageProxy::applicationDidBecomeActive()
+{
+ m_process->send(Messages::WebPage::ApplicationDidBecomeActive(), m_pageID);
+}
+
void WebPageProxy::notifyRevealedSelection()
{
m_pageClient.selectionDidChange();
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (165027 => 165028)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h 2014-03-04 01:22:01 UTC (rev 165027)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h 2014-03-04 01:29:41 UTC (rev 165028)
@@ -669,6 +669,9 @@
void updateVisibleContentRects(const VisibleContentRectUpdateInfo&);
bool scaleWasSetByUIProcess() const { return m_scaleWasSetByUIProcess; }
void willStartUserTriggeredZooming();
+ void applicationWillResignActive();
+ void applicationWillEnterForeground();
+ void applicationDidBecomeActive();
#endif
#if PLATFORM(GTK) && USE(TEXTURE_MAPPER_GL)
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (165027 => 165028)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in 2014-03-04 01:22:01 UTC (rev 165027)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in 2014-03-04 01:29:41 UTC (rev 165028)
@@ -67,6 +67,9 @@
SetAssistedNodeValue(String value)
SetAssistedNodeValueAsNumber(double value)
SetAssistedNodeSelectedIndex(uint32_t index, bool allowMultipleSelection)
+ ApplicationWillResignActive()
+ ApplicationWillEnterForeground()
+ ApplicationDidBecomeActive()
#endif
#if ENABLE(TOUCH_EVENTS)
Modified: trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm (165027 => 165028)
--- trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm 2014-03-04 01:22:01 UTC (rev 165027)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm 2014-03-04 01:29:41 UTC (rev 165028)
@@ -62,6 +62,7 @@
#import <WebCore/HTMLSelectElement.h>
#import <WebCore/HTMLTextAreaElement.h>
#import <WebCore/MainFrame.h>
+#import <WebCore/MediaSessionManagerIOS.h>
#import <WebCore/Node.h>
#import <WebCore/NotImplemented.h>
#import <WebCore/Page.h>
@@ -1699,6 +1700,21 @@
scalePage(scale, m_page->mainFrame().view()->scrollPosition());
}
+void WebPage::applicationWillResignActive()
+{
+ [[NSNotificationCenter defaultCenter] postNotificationName:WebUIApplicationWillResignActiveNotification object:nil];
+}
+
+void WebPage::applicationWillEnterForeground()
+{
+ [[NSNotificationCenter defaultCenter] postNotificationName:WebUIApplicationWillEnterForegroundNotification object:nil];
+}
+
+void WebPage::applicationDidBecomeActive()
+{
+ [[NSNotificationCenter defaultCenter] postNotificationName:WebUIApplicationDidBecomeActiveNotification object:nil];
+}
+
void WebPage::updateVisibleContentRects(const VisibleContentRectUpdateInfo& visibleContentRectUpdateInfo)
{
FloatRect exposedRect = visibleContentRectUpdateInfo.exposedRect();