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 #include "chrome/browser/chromeos/status/network_menu.h" | 5 #include "chrome/browser/chromeos/status/network_menu.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/shell_delegate.h" | 10 #include "ash/shell_delegate.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 void ConnectToNetworkAt(int index); | 115 void ConnectToNetworkAt(int index); |
116 | 116 |
117 // Called by NetworkMenu::UpdateMenu to initialize menu items. | 117 // Called by NetworkMenu::UpdateMenu to initialize menu items. |
118 virtual void InitMenuItems(bool should_open_button_options) = 0; | 118 virtual void InitMenuItems(bool should_open_button_options) = 0; |
119 | 119 |
120 // Menu item field accessors. | 120 // Menu item field accessors. |
121 const MenuItemVector& menu_items() const { return menu_items_; } | 121 const MenuItemVector& menu_items() const { return menu_items_; } |
122 | 122 |
123 // ui::MenuModel implementation | 123 // ui::MenuModel implementation |
124 // GetCommandIdAt() must be implemented by subclasses. | 124 // GetCommandIdAt() must be implemented by subclasses. |
125 virtual bool HasIcons() const OVERRIDE; | 125 virtual bool HasIcons() const override; |
126 virtual int GetItemCount() const OVERRIDE; | 126 virtual int GetItemCount() const override; |
127 virtual ui::MenuModel::ItemType GetTypeAt(int index) const OVERRIDE; | 127 virtual ui::MenuModel::ItemType GetTypeAt(int index) const override; |
128 virtual ui::MenuSeparatorType GetSeparatorTypeAt(int index) const OVERRIDE; | 128 virtual ui::MenuSeparatorType GetSeparatorTypeAt(int index) const override; |
129 virtual base::string16 GetLabelAt(int index) const OVERRIDE; | 129 virtual base::string16 GetLabelAt(int index) const override; |
130 virtual bool IsItemDynamicAt(int index) const OVERRIDE; | 130 virtual bool IsItemDynamicAt(int index) const override; |
131 virtual const gfx::FontList* GetLabelFontListAt(int index) const OVERRIDE; | 131 virtual const gfx::FontList* GetLabelFontListAt(int index) const override; |
132 virtual bool GetAcceleratorAt(int index, | 132 virtual bool GetAcceleratorAt(int index, |
133 ui::Accelerator* accelerator) const OVERRIDE; | 133 ui::Accelerator* accelerator) const override; |
134 virtual bool IsItemCheckedAt(int index) const OVERRIDE; | 134 virtual bool IsItemCheckedAt(int index) const override; |
135 virtual int GetGroupIdAt(int index) const OVERRIDE; | 135 virtual int GetGroupIdAt(int index) const override; |
136 virtual bool GetIconAt(int index, gfx::Image* icon) OVERRIDE; | 136 virtual bool GetIconAt(int index, gfx::Image* icon) override; |
137 virtual ui::ButtonMenuItemModel* GetButtonMenuItemAt( | 137 virtual ui::ButtonMenuItemModel* GetButtonMenuItemAt( |
138 int index) const OVERRIDE; | 138 int index) const override; |
139 virtual bool IsEnabledAt(int index) const OVERRIDE; | 139 virtual bool IsEnabledAt(int index) const override; |
140 virtual bool IsVisibleAt(int index) const OVERRIDE; | 140 virtual bool IsVisibleAt(int index) const override; |
141 virtual ui::MenuModel* GetSubmenuModelAt(int index) const OVERRIDE; | 141 virtual ui::MenuModel* GetSubmenuModelAt(int index) const override; |
142 virtual void HighlightChangedTo(int index) OVERRIDE; | 142 virtual void HighlightChangedTo(int index) override; |
143 virtual void ActivatedAt(int index) OVERRIDE; | 143 virtual void ActivatedAt(int index) override; |
144 virtual void SetMenuModelDelegate(ui::MenuModelDelegate* delegate) OVERRIDE; | 144 virtual void SetMenuModelDelegate(ui::MenuModelDelegate* delegate) override; |
145 virtual ui::MenuModelDelegate* GetMenuModelDelegate() const OVERRIDE; | 145 virtual ui::MenuModelDelegate* GetMenuModelDelegate() const override; |
146 | 146 |
147 protected: | 147 protected: |
148 enum MenuItemFlags { | 148 enum MenuItemFlags { |
149 FLAG_NONE = 0, | 149 FLAG_NONE = 0, |
150 FLAG_DISABLED = 1 << 0, | 150 FLAG_DISABLED = 1 << 0, |
151 FLAG_TOGGLE_WIFI = 1 << 2, | 151 FLAG_TOGGLE_WIFI = 1 << 2, |
152 FLAG_TOGGLE_MOBILE = 1 << 3, | 152 FLAG_TOGGLE_MOBILE = 1 << 3, |
153 FLAG_ASSOCIATED = 1 << 5, | 153 FLAG_ASSOCIATED = 1 << 5, |
154 FLAG_ETHERNET = 1 << 6, | 154 FLAG_ETHERNET = 1 << 6, |
155 FLAG_WIFI = 1 << 7, | 155 FLAG_WIFI = 1 << 7, |
(...skipping 17 matching lines...) Expand all Loading... |
173 DISALLOW_COPY_AND_ASSIGN(NetworkMenuModel); | 173 DISALLOW_COPY_AND_ASSIGN(NetworkMenuModel); |
174 }; | 174 }; |
175 | 175 |
176 class MoreMenuModel : public NetworkMenuModel { | 176 class MoreMenuModel : public NetworkMenuModel { |
177 public: | 177 public: |
178 explicit MoreMenuModel(const base::WeakPtr<NetworkMenu> owner) | 178 explicit MoreMenuModel(const base::WeakPtr<NetworkMenu> owner) |
179 : NetworkMenuModel(owner) {} | 179 : NetworkMenuModel(owner) {} |
180 virtual ~MoreMenuModel() {} | 180 virtual ~MoreMenuModel() {} |
181 | 181 |
182 // NetworkMenuModel implementation. | 182 // NetworkMenuModel implementation. |
183 virtual void InitMenuItems(bool should_open_button_options) OVERRIDE; | 183 virtual void InitMenuItems(bool should_open_button_options) override; |
184 | 184 |
185 // ui::MenuModel implementation | 185 // ui::MenuModel implementation |
186 virtual int GetCommandIdAt(int index) const OVERRIDE; | 186 virtual int GetCommandIdAt(int index) const override; |
187 | 187 |
188 private: | 188 private: |
189 DISALLOW_COPY_AND_ASSIGN(MoreMenuModel); | 189 DISALLOW_COPY_AND_ASSIGN(MoreMenuModel); |
190 }; | 190 }; |
191 | 191 |
192 class MainMenuModel : public NetworkMenuModel { | 192 class MainMenuModel : public NetworkMenuModel { |
193 public: | 193 public: |
194 explicit MainMenuModel(const base::WeakPtr<NetworkMenu>& owner) | 194 explicit MainMenuModel(const base::WeakPtr<NetworkMenu>& owner) |
195 : NetworkMenuModel(owner), | 195 : NetworkMenuModel(owner), |
196 more_menu_model_(new MoreMenuModel(owner)) { | 196 more_menu_model_(new MoreMenuModel(owner)) { |
197 } | 197 } |
198 virtual ~MainMenuModel() {} | 198 virtual ~MainMenuModel() {} |
199 | 199 |
200 // NetworkMenuModel implementation. | 200 // NetworkMenuModel implementation. |
201 virtual void InitMenuItems(bool should_open_button_options) OVERRIDE; | 201 virtual void InitMenuItems(bool should_open_button_options) override; |
202 | 202 |
203 // ui::MenuModel implementation | 203 // ui::MenuModel implementation |
204 virtual int GetCommandIdAt(int index) const OVERRIDE; | 204 virtual int GetCommandIdAt(int index) const override; |
205 | 205 |
206 private: | 206 private: |
207 void AddWirelessNetworkMenuItem(const NetworkState* wifi_network, int flag); | 207 void AddWirelessNetworkMenuItem(const NetworkState* wifi_network, int flag); |
208 void AddMessageItem(const base::string16& msg); | 208 void AddMessageItem(const base::string16& msg); |
209 | 209 |
210 scoped_ptr<MoreMenuModel> more_menu_model_; | 210 scoped_ptr<MoreMenuModel> more_menu_model_; |
211 | 211 |
212 DISALLOW_COPY_AND_ASSIGN(MainMenuModel); | 212 DISALLOW_COPY_AND_ASSIGN(MainMenuModel); |
213 }; | 213 }; |
214 | 214 |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 return main_menu_model_.get(); | 673 return main_menu_model_.get(); |
674 } | 674 } |
675 | 675 |
676 void NetworkMenu::UpdateMenu() { | 676 void NetworkMenu::UpdateMenu() { |
677 refreshing_menu_ = true; | 677 refreshing_menu_ = true; |
678 main_menu_model_->InitMenuItems(delegate_->ShouldOpenButtonOptions()); | 678 main_menu_model_->InitMenuItems(delegate_->ShouldOpenButtonOptions()); |
679 refreshing_menu_ = false; | 679 refreshing_menu_ = false; |
680 } | 680 } |
681 | 681 |
682 } // namespace chromeos | 682 } // namespace chromeos |
OLD | NEW |