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

Side by Side Diff: content/browser/device_orientation/orientation.h

Issue 10755002: Refactors DeviceOrientation to make it more extensible (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Small changes to appease try bots Created 8 years, 4 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 unified diff | Download patch
OLDNEW
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 #include "content/common/content_export.h"
11
8 namespace device_orientation { 12 namespace device_orientation {
9 class Orientation { 13
14 class Orientation : public DeviceData {
10 public: 15 public:
11 // alpha, beta, gamma and absolute are the rotations around the axes as 16 // 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 17 // specified in http://dev.w3.org/geo/api/spec-source-orientation.html
13 // 18 //
14 // can_provide_{alpha,beta,gamma,absolute} is true if data can be provided 19 // can_provide_{alpha,beta,gamma,absolute} is true if data can be provided
15 // for that variable. 20 // for that variable.
21 CONTENT_EXPORT Orientation();
16 22
17 Orientation() 23 // From DeviceData.
18 : alpha_(0), 24 virtual IPC::Message* CreateIPCMessage(int render_view_id) const OVERRIDE;
19 beta_(0), 25 virtual bool ShouldFireEvent(const DeviceData* old_data) const OVERRIDE;
20 gamma_(0),
21 absolute_(false),
22 can_provide_alpha_(false),
23 can_provide_beta_(false),
24 can_provide_gamma_(false),
25 can_provide_absolute_(false) {
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
48 static Orientation Empty() { return Orientation(); }
49
50 bool is_empty() const {
51 return !can_provide_alpha_ && !can_provide_beta_ && !can_provide_gamma_
52 && !can_provide_absolute_;
53 }
54 26
55 void set_alpha(double alpha) { 27 void set_alpha(double alpha) {
56 can_provide_alpha_ = true; 28 can_provide_alpha_ = true;
57 alpha_ = alpha; 29 alpha_ = alpha;
58 } 30 }
59 bool can_provide_alpha() const { return can_provide_alpha_; } 31 bool can_provide_alpha() const { return can_provide_alpha_; }
60 double alpha() const { return alpha_; } 32 double alpha() const { return alpha_; }
61 33
62 void set_beta(double beta) { 34 void set_beta(double beta) {
63 can_provide_beta_ = true; 35 can_provide_beta_ = true;
(...skipping 10 matching lines...) Expand all
74 double gamma() const { return gamma_; } 46 double gamma() const { return gamma_; }
75 47
76 void set_absolute(bool absolute) { 48 void set_absolute(bool absolute) {
77 can_provide_absolute_ = true; 49 can_provide_absolute_ = true;
78 absolute_ = absolute; 50 absolute_ = absolute;
79 } 51 }
80 bool can_provide_absolute() const { return can_provide_absolute_; } 52 bool can_provide_absolute() const { return can_provide_absolute_; }
81 bool absolute() const { return absolute_; } 53 bool absolute() const { return absolute_; }
82 54
83 private: 55 private:
56 virtual ~Orientation();
57
58 static bool IsElementSignificantlyDifferent(bool can_provide_element1,
59 bool can_provide_element2, double element1, double element2);
60
84 double alpha_; 61 double alpha_;
85 double beta_; 62 double beta_;
86 double gamma_; 63 double gamma_;
87 bool absolute_; 64 bool absolute_;
88 bool can_provide_alpha_; 65 bool can_provide_alpha_;
89 bool can_provide_beta_; 66 bool can_provide_beta_;
90 bool can_provide_gamma_; 67 bool can_provide_gamma_;
91 bool can_provide_absolute_; 68 bool can_provide_absolute_;
92 }; 69 };
93 70
94 } // namespace device_orientation 71 } // namespace device_orientation
95 72
96 #endif // CONTENT_BROWSER_DEVICE_ORIENTATION_ORIENTATION_H_ 73 #endif // CONTENT_BROWSER_DEVICE_ORIENTATION_ORIENTATION_H_
OLDNEW
« no previous file with comments | « content/browser/device_orientation/observer_delegate.cc ('k') | content/browser/device_orientation/orientation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698