OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_DEVICE_ORIENTATION_ORIENTATION_H_ | 5 #ifndef CONTENT_BROWSER_DEVICE_ORIENTATION_ORIENTATION_H_ |
6 #define CONTENT_BROWSER_DEVICE_ORIENTATION_ORIENTATION_H_ | 6 #define CONTENT_BROWSER_DEVICE_ORIENTATION_ORIENTATION_H_ |
7 | 7 |
| 8 #include "base/compiler_specific.h" |
| 9 #include "content/browser/device_orientation/device_data.h" |
| 10 |
8 namespace device_orientation { | 11 namespace device_orientation { |
9 class Orientation { | 12 |
| 13 class Orientation : public DeviceData { |
10 public: | 14 public: |
11 // alpha, beta, gamma and absolute are the rotations around the axes as | 15 // alpha, beta, gamma and absolute are the rotations around the axes as |
12 // specified in http://dev.w3.org/geo/api/spec-source-orientation.html | 16 // specified in http://dev.w3.org/geo/api/spec-source-orientation.html |
13 // | 17 // |
14 // can_provide_{alpha,beta,gamma,absolute} is true if data can be provided | 18 // can_provide_{alpha,beta,gamma,absolute} is true if data can be provided |
15 // for that variable. | 19 // for that variable. |
16 | 20 |
17 Orientation() | 21 Orientation() |
18 : alpha_(0), | 22 : can_provide_alpha_(false), |
19 beta_(0), | |
20 gamma_(0), | |
21 absolute_(false), | |
22 can_provide_alpha_(false), | |
23 can_provide_beta_(false), | 23 can_provide_beta_(false), |
24 can_provide_gamma_(false), | 24 can_provide_gamma_(false), |
25 can_provide_absolute_(false) { | 25 can_provide_absolute_(false) { |
26 } | 26 } |
27 Orientation(const Orientation& orientation) | |
28 : alpha_(orientation.alpha()), | |
29 beta_(orientation.beta()), | |
30 gamma_(orientation.gamma()), | |
31 absolute_(orientation.absolute()), | |
32 can_provide_alpha_(orientation.can_provide_alpha()), | |
33 can_provide_beta_(orientation.can_provide_beta()), | |
34 can_provide_gamma_(orientation.can_provide_gamma()), | |
35 can_provide_absolute_(orientation.can_provide_absolute()) { | |
36 } | |
37 void operator=(const Orientation& source) { | |
38 alpha_ = source.alpha(); | |
39 beta_ = source.beta(); | |
40 gamma_ = source.gamma(); | |
41 absolute_ = source.absolute(); | |
42 can_provide_alpha_ = source.can_provide_alpha(); | |
43 can_provide_beta_ = source.can_provide_beta(); | |
44 can_provide_gamma_ = source.can_provide_gamma(); | |
45 can_provide_absolute_ = source.can_provide_absolute(); | |
46 } | |
47 | 27 |
48 static Orientation Empty() { return Orientation(); } | 28 virtual DeviceData* Clone() const OVERRIDE; |
49 | 29 virtual bool IsEmpty() const OVERRIDE; |
50 bool is_empty() const { | 30 virtual bool SignificantlyDifferentFrom( |
51 return !can_provide_alpha_ && !can_provide_beta_ && !can_provide_gamma_ | 31 const DeviceData& other) const OVERRIDE; |
52 && !can_provide_absolute_; | 32 virtual IPC::Message* CreateIPCMessage(int render_view_id) const OVERRIDE; |
53 } | |
54 | 33 |
55 void set_alpha(double alpha) { | 34 void set_alpha(double alpha) { |
56 can_provide_alpha_ = true; | 35 can_provide_alpha_ = true; |
57 alpha_ = alpha; | 36 alpha_ = alpha; |
58 } | 37 } |
59 bool can_provide_alpha() const { return can_provide_alpha_; } | 38 bool can_provide_alpha() const { return can_provide_alpha_; } |
60 double alpha() const { return alpha_; } | 39 double alpha() const { return alpha_; } |
61 | 40 |
62 void set_beta(double beta) { | 41 void set_beta(double beta) { |
63 can_provide_beta_ = true; | 42 can_provide_beta_ = true; |
(...skipping 23 matching lines...) Expand all Loading... |
87 bool absolute_; | 66 bool absolute_; |
88 bool can_provide_alpha_; | 67 bool can_provide_alpha_; |
89 bool can_provide_beta_; | 68 bool can_provide_beta_; |
90 bool can_provide_gamma_; | 69 bool can_provide_gamma_; |
91 bool can_provide_absolute_; | 70 bool can_provide_absolute_; |
92 }; | 71 }; |
93 | 72 |
94 } // namespace device_orientation | 73 } // namespace device_orientation |
95 | 74 |
96 #endif // CONTENT_BROWSER_DEVICE_ORIENTATION_ORIENTATION_H_ | 75 #endif // CONTENT_BROWSER_DEVICE_ORIENTATION_ORIENTATION_H_ |
OLD | NEW |