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 CHROME_BROWSER_CHROMEOS_STATUS_MEMORY_MENU_BUTTON_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_STATUS_MEMORY_MENU_BUTTON_H_ |
6 #define CHROME_BROWSER_CHROMEOS_STATUS_MEMORY_MENU_BUTTON_H_ | 6 #define CHROME_BROWSER_CHROMEOS_STATUS_MEMORY_MENU_BUTTON_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/timer.h" | 10 #include "base/timer.h" |
11 #include "chrome/browser/chromeos/status/status_area_button.h" | 11 #include "chrome/browser/chromeos/status/status_area_button.h" |
12 #include "content/public/browser/notification_observer.h" | 12 #include "content/public/browser/notification_observer.h" |
13 #include "content/public/browser/notification_registrar.h" | 13 #include "content/public/browser/notification_registrar.h" |
14 #include "ui/views/controls/button/menu_button_delegate.h" | 14 #include "ui/views/controls/button/menu_button_listener.h" |
15 #include "ui/views/controls/menu/menu_delegate.h" | 15 #include "ui/views/controls/menu/menu_delegate.h" |
16 | 16 |
17 namespace base { | 17 namespace base { |
18 struct SystemMemoryInfoKB; | 18 struct SystemMemoryInfoKB; |
19 } | 19 } |
20 | 20 |
21 namespace views { | 21 namespace views { |
22 class MenuItemView; | 22 class MenuItemView; |
23 class MenuRunner; | 23 class MenuRunner; |
24 } | 24 } |
25 | 25 |
26 // Memory debugging display that lives in the status area. | 26 // Memory debugging display that lives in the status area. |
27 class MemoryMenuButton : public StatusAreaButton, | 27 class MemoryMenuButton : public StatusAreaButton, |
28 public views::MenuDelegate, | 28 public views::MenuDelegate, |
29 public views::MenuButtonDelegate, | 29 public views::MenuButtonListener, |
30 public content::NotificationObserver { | 30 public content::NotificationObserver { |
31 public: | 31 public: |
32 explicit MemoryMenuButton(StatusAreaButton::Delegate* delegate); | 32 explicit MemoryMenuButton(StatusAreaButton::Delegate* delegate); |
33 virtual ~MemoryMenuButton(); | 33 virtual ~MemoryMenuButton(); |
34 | 34 |
35 // views::MenuDelegate implementation | 35 // views::MenuDelegate implementation |
36 virtual string16 GetLabel(int id) const OVERRIDE; | 36 virtual string16 GetLabel(int id) const OVERRIDE; |
37 virtual bool IsCommandEnabled(int id) const OVERRIDE; | 37 virtual bool IsCommandEnabled(int id) const OVERRIDE; |
38 virtual void ExecuteCommand(int id) OVERRIDE; | 38 virtual void ExecuteCommand(int id) OVERRIDE; |
39 | 39 |
40 // views::MenuButtonDelegate implementation. | 40 // views::MenuButtonListener implementation. |
41 virtual void RunMenu(views::View* source, const gfx::Point& pt) OVERRIDE; | 41 virtual void OnMenuButtonClicked(views::View* source, |
| 42 const gfx::Point& point) OVERRIDE; |
42 | 43 |
43 // content::NotificationObserver overrides. | 44 // content::NotificationObserver overrides. |
44 virtual void Observe(int type, | 45 virtual void Observe(int type, |
45 const content::NotificationSource& source, | 46 const content::NotificationSource& source, |
46 const content::NotificationDetails& details) OVERRIDE; | 47 const content::NotificationDetails& details) OVERRIDE; |
47 | 48 |
48 // Updates the text on the menu button. | 49 // Updates the text on the menu button. |
49 void UpdateText(); | 50 void UpdateText(); |
50 | 51 |
51 protected: | 52 protected: |
(...skipping 18 matching lines...) Expand all Loading... |
70 | 71 |
71 // Number of renderer kills we have observed. | 72 // Number of renderer kills we have observed. |
72 int renderer_kills_; | 73 int renderer_kills_; |
73 | 74 |
74 scoped_ptr<views::MenuRunner> menu_runner_; | 75 scoped_ptr<views::MenuRunner> menu_runner_; |
75 | 76 |
76 DISALLOW_COPY_AND_ASSIGN(MemoryMenuButton); | 77 DISALLOW_COPY_AND_ASSIGN(MemoryMenuButton); |
77 }; | 78 }; |
78 | 79 |
79 #endif // CHROME_BROWSER_CHROMEOS_STATUS_MEMORY_MENU_BUTTON_H_ | 80 #endif // CHROME_BROWSER_CHROMEOS_STATUS_MEMORY_MENU_BUTTON_H_ |
OLD | NEW |