[Metrics] Make MetricsStateManager take a callback param to check if UMA is enabled.
[chromium-blink-merge.git] / chrome / browser / ui / views / frame / minimize_button_metrics_win.h
blob6fb6d353f5a3c983e795eba606204f0653b71933
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 CHROME_BROWSER_UI_VIEWS_FRAME_MINIMIZE_BUTTON_METRICS_WIN_H_
6 #define CHROME_BROWSER_UI_VIEWS_FRAME_MINIMIZE_BUTTON_METRICS_WIN_H_
8 #include <windows.h>
10 #include "base/basictypes.h"
12 // Class that implements obtaining the X coordinate of the native minimize
13 // button for the native frame on Windows.
14 // This is a separate class because obtaining it is somewhat tricky and this
15 // code is shared between BrowserDesktopWindowTreeHostWin and BrowserFrameWin.
16 class MinimizeButtonMetrics {
17 public:
18 MinimizeButtonMetrics();
19 ~MinimizeButtonMetrics();
21 void Init(HWND hwnd);
23 // Obtain the X offset of the native minimize button. Since Windows can lie
24 // to us if we call this at the wrong moment, this might come from a cached
25 // value rather than read when called.
26 int GetMinimizeButtonOffsetX() const;
28 // Must be called when hwnd_ is activated to update the minimize button
29 // position cache.
30 void OnHWNDActivated();
32 private:
33 // Gets the value for GetMinimizeButtonOffsetX(), caching if found.
34 int GetAndCacheMinimizeButtonOffsetX() const;
36 HWND hwnd_;
38 // Cached offset of the minimize button. If RTL this is the location of the
39 // minimize button, if LTR this is the offset from the right edge of the
40 // client area to the minimize button.
41 mutable int cached_minimize_button_x_delta_;
43 // Static cache of |cached_minimize_button_x_delta_|.
44 static int last_cached_minimize_button_x_delta_;
46 // Has OnHWNDActivated() been invoked?
47 bool was_activated_;
49 DISALLOW_COPY_AND_ASSIGN(MinimizeButtonMetrics);
52 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_MINIMIZE_BUTTON_METRICS_WIN_H_