1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_DEVICE_ORIENTATION_ORIENTATION_H_
6 #define CONTENT_BROWSER_DEVICE_ORIENTATION_ORIENTATION_H_
8 #include "base/compiler_specific.h"
9 #include "content/browser/device_orientation/device_data.h"
10 #include "content/common/content_export.h"
14 class Orientation
: public DeviceData
{
16 // alpha, beta, gamma and absolute are the rotations around the axes as
17 // specified in http://dev.w3.org/geo/api/spec-source-orientation.html
19 // can_provide_{alpha,beta,gamma,absolute} is true if data can be provided
21 CONTENT_EXPORT
Orientation();
24 virtual IPC::Message
* CreateIPCMessage(int render_view_id
) const OVERRIDE
;
25 virtual bool ShouldFireEvent(const DeviceData
* old_data
) const OVERRIDE
;
27 void set_alpha(double alpha
) {
28 can_provide_alpha_
= true;
31 bool can_provide_alpha() const { return can_provide_alpha_
; }
32 double alpha() const { return alpha_
; }
34 void set_beta(double beta
) {
35 can_provide_beta_
= true;
38 bool can_provide_beta() const { return can_provide_beta_
; }
39 double beta() const { return beta_
; }
41 void set_gamma(double gamma
) {
42 can_provide_gamma_
= true;
45 bool can_provide_gamma() const { return can_provide_gamma_
; }
46 double gamma() const { return gamma_
; }
48 void set_absolute(bool absolute
) {
49 can_provide_absolute_
= true;
52 bool can_provide_absolute() const { return can_provide_absolute_
; }
53 bool absolute() const { return absolute_
; }
56 virtual ~Orientation();
58 static bool IsElementSignificantlyDifferent(bool can_provide_element1
,
59 bool can_provide_element2
, double element1
, double element2
);
65 bool can_provide_alpha_
;
66 bool can_provide_beta_
;
67 bool can_provide_gamma_
;
68 bool can_provide_absolute_
;
71 } // namespace content
73 #endif // CONTENT_BROWSER_DEVICE_ORIENTATION_ORIENTATION_H_