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

Unified Diff: chrome/browser/chromeos/status/network_menu.h

Issue 7016042: Convert NetworkMenu from Menu2 to MenuItemView. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tweak menu vertical spacing. Created 9 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/status/network_menu.h
diff --git a/chrome/browser/chromeos/status/network_menu.h b/chrome/browser/chromeos/status/network_menu.h
index aca19be39f00299f491f1f8c382780b4c63da109..2995c5231962c148787c4d6f672afe28dc9eef9e 100644
--- a/chrome/browser/chromeos/status/network_menu.h
+++ b/chrome/browser/chromeos/status/network_menu.h
@@ -15,150 +15,26 @@
#include "ui/gfx/native_widget_types.h"
#include "views/controls/menu/view_menu_delegate.h"
+namespace {
+
+const int kMainCommandIndexOffset = 1000;
+const int kVPNCommandIndexOffset = 2000;
+const int kMoreCommandIndexOffset = 3000;
+
+} // namespace
+
namespace gfx {
class Canvas;
}
namespace views {
-class Menu2;
+class MenuItemView;
+class MenuButton;
}
namespace chromeos {
-class NetworkMenu;
-
-class NetworkMenuModel : public ui::MenuModel {
- public:
- struct NetworkInfo {
- NetworkInfo();
- ~NetworkInfo();
-
- // "ethernet" | "wifi" | "cellular" | "other".
- std::string network_type;
- // "connected" | "connecting" | "disconnected" | "error".
- std::string status;
- // status message or error message, empty if unknown status.
- std::string message;
- // IP address (if network is active, empty otherwise)
- std::string ip_address;
- // Remembered passphrase.
- std::string passphrase;
- // true if the network requires a passphrase.
- bool need_passphrase;
- // true if the network is currently remembered.
- bool remembered;
- // true if the network is auto connect (meaningful for Wifi only).
- bool auto_connect;
- };
-
- explicit NetworkMenuModel(NetworkMenu* owner);
- virtual ~NetworkMenuModel();
-
- // Connect or reconnect to the network at |index|.
- // If remember >= 0, set the favorite state of the network.
- // Returns true if a connect occurred (e.g. menu should be closed).
- bool ConnectToNetworkAt(int index,
- const std::string& passphrase,
- const std::string& ssid,
- int remember) const;
-
- // Called by NetworkMenu::RunMenu to initialize list of menu items.
- virtual void InitMenuItems(bool is_browser_mode,
- bool should_open_button_options) = 0;
-
- // ui::MenuModel implementation.
- virtual bool HasIcons() const;
- virtual int GetItemCount() const;
- virtual ui::MenuModel::ItemType GetTypeAt(int index) const;
- virtual int GetCommandIdAt(int index) const;
- virtual string16 GetLabelAt(int index) const;
- virtual bool IsItemDynamicAt(int index) const;
- virtual const gfx::Font* GetLabelFontAt(int index) const;
- virtual bool GetAcceleratorAt(int index, ui::Accelerator* accelerator) const;
- virtual bool IsItemCheckedAt(int index) const;
- virtual int GetGroupIdAt(int index) const;
- virtual bool GetIconAt(int index, SkBitmap* icon);
- virtual ui::ButtonMenuItemModel* GetButtonMenuItemAt(int index) const;
- virtual bool IsEnabledAt(int index) const;
- virtual ui::MenuModel* GetSubmenuModelAt(int index) const;
- virtual void HighlightChangedTo(int index);
- virtual void ActivatedAt(int index);
- virtual void MenuWillShow();
- virtual void SetMenuModelDelegate(ui::MenuModelDelegate* delegate);
-
- protected:
- enum MenuItemFlags {
- FLAG_NONE = 0,
- FLAG_DISABLED = 1 << 0,
- FLAG_TOGGLE_ETHERNET = 1 << 1,
- FLAG_TOGGLE_WIFI = 1 << 2,
- FLAG_TOGGLE_CELLULAR = 1 << 3,
- FLAG_TOGGLE_OFFLINE = 1 << 4,
- FLAG_ASSOCIATED = 1 << 5,
- FLAG_ETHERNET = 1 << 6,
- FLAG_WIFI = 1 << 7,
- FLAG_CELLULAR = 1 << 8,
- FLAG_OPTIONS = 1 << 9,
- FLAG_ADD_WIFI = 1 << 10,
- FLAG_ADD_CELLULAR = 1 << 11,
- FLAG_VPN = 1 << 12,
- FLAG_ADD_VPN = 1 << 13,
- FLAG_DISCONNECT_VPN = 1 << 14,
- FLAG_VIEW_ACCOUNT = 1 << 15,
- };
-
- struct MenuItem {
- MenuItem()
- : type(ui::MenuModel::TYPE_SEPARATOR),
- sub_menu_model(NULL),
- flags(0) {}
- MenuItem(ui::MenuModel::ItemType type, string16 label, SkBitmap icon,
- const std::string& service_path, int flags)
- : type(type),
- label(label),
- icon(icon),
- service_path(service_path),
- sub_menu_model(NULL),
- flags(flags) {}
- MenuItem(ui::MenuModel::ItemType type, string16 label, SkBitmap icon,
- NetworkMenuModel* sub_menu_model, int flags)
- : type(type),
- label(label),
- icon(icon),
- sub_menu_model(sub_menu_model),
- flags(flags) {}
-
- ui::MenuModel::ItemType type;
- string16 label;
- SkBitmap icon;
- std::string service_path;
- NetworkMenuModel* sub_menu_model; // Weak.
- int flags;
- };
- typedef std::vector<MenuItem> MenuItemVector;
-
- // Our menu items.
- MenuItemVector menu_items_;
-
- NetworkMenu* owner_; // Weak pointer to NetworkMenu that owns this MenuModel.
-
- // Top up URL of the current carrier on empty string if there's none.
- std::string top_up_url_;
-
- // Carrier ID which top up URL is initialized for.
- // Used to update top up URL only when cellular carrier has changed.
- std::string carrier_id_;
-
- private:
- // Show a NetworkConfigView modal dialog instance.
- void ShowNetworkConfigView(NetworkConfigView* view) const;
-
- void ActivateCellular(const CellularNetwork* cellular) const;
- void ShowOther(ConnectionType type) const;
- void ShowOtherCellular() const;
-
- DISALLOW_COPY_AND_ASSIGN(NetworkMenuModel);
-};
+class NetworkMenuModel;
// Menu for network menu button in the status area/welcome screen.
// This class will populating the menu with the list of networks.
@@ -256,6 +132,7 @@ class NetworkMenu : public views::ViewMenuDelegate {
const SkBitmap* bottom_left_badge);
protected:
+ virtual views::MenuButton* GetMenuButton() = 0;
virtual gfx::NativeWindow GetNativeWindow() const = 0;
virtual void OpenButtonOptions() = 0;
virtual bool ShouldOpenButtonOptions() const = 0;
@@ -296,11 +173,11 @@ class NetworkMenu : public views::ViewMenuDelegate {
static SkBitmap kAnimatingImagesBlack[];
// The network menu.
- scoped_ptr<views::Menu2> network_menu_;
+ scoped_ptr<views::MenuItemView> network_menu_;
scoped_ptr<NetworkMenuModel> main_menu_model_;
- // Holds minimum width or -1 if it wasn't set up.
+ // Holds minimum width of the menu.
int min_width_;
// If true, call into the settings UI for network configuration dialogs.

Powered by Google App Engine
This is Rietveld 408576698