Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1398)

Unified Diff: Source/modules/vibration/NavigatorVibration.h

Issue 18777003: Extract simpler classes for observing context lifecycle and observe Page lifecycle inNavigatorVibra… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Ensure m_scriptExecutionContext is maintained and not just null. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/modules/vibration/NavigatorVibration.h
diff --git a/Source/modules/vibration/NavigatorVibration.h b/Source/modules/vibration/NavigatorVibration.h
index 86ebf08ef76eca3a29dc6e6234c3d3347057b7b5..9812918ce9dfe167c6e79d3b1cc1a1398a0a7e17 100644
--- a/Source/modules/vibration/NavigatorVibration.h
+++ b/Source/modules/vibration/NavigatorVibration.h
@@ -20,36 +20,41 @@
#ifndef NavigatorVibration_h
#define NavigatorVibration_h
-#include "core/page/Navigator.h"
+#include "core/page/Page.h"
+#include "core/page/PageLifecycleObserver.h"
#include "core/platform/Timer.h"
#include "wtf/PassOwnPtr.h"
#include "wtf/Vector.h"
namespace WebCore {
-class NavigatorVibration : public Supplement<Navigator> {
+class Navigator;
+
+class NavigatorVibration
+ : public Supplement<Page>
+ , public PageLifecycleObserver {
public:
typedef Vector<unsigned> VibrationPattern;
- ~NavigatorVibration();
+ virtual ~NavigatorVibration();
bool vibrate(const VibrationPattern&);
void cancelVibration();
- // FIXME : Hook suspendVibration() and resumeVibration() into the page
- // visibility feature, when the document.hidden attribute is changed.
- void suspendVibration();
- void resumeVibration();
void timerStartFired(Timer<NavigatorVibration>*);
void timerStopFired(Timer<NavigatorVibration>*);
+ // Inherited from PageLifecycleObserver
+ virtual void pageVisibilityChanged() OVERRIDE;
+
static bool vibrate(Navigator*, unsigned time);
static bool vibrate(Navigator*, const VibrationPattern&);
- static NavigatorVibration* from(Navigator*);
+ static NavigatorVibration* from(Page*);
private:
- NavigatorVibration();
+ explicit NavigatorVibration(Page*);
static const char* supplementName();
+ Page* m_page;
abarth-chromium 2013/07/09 18:27:52 We should be able to avoid this raw pointer by get
Michael van Ouwerkerk 2013/07/10 13:25:09 Done.
Timer<NavigatorVibration> m_timerStart;
Timer<NavigatorVibration> m_timerStop;
bool m_isVibrating;

Powered by Google App Engine
This is Rietveld 408576698