network_config_view.h revision c407dc5cd9bdc5668497f21b26b09d988ab439de
1// Copyright (c) 2006-2008 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. 4 5#ifndef CHROME_BROWSER_CHROMEOS_OPTIONS_NETWORK_CONFIG_VIEW_H_ 6#define CHROME_BROWSER_CHROMEOS_OPTIONS_NETWORK_CONFIG_VIEW_H_ 7 8#include <string> 9 10#include "base/string16.h" 11#include "chrome/browser/chromeos/cros/network_library.h" 12#include "views/controls/tabbed_pane/tabbed_pane.h" 13#include "views/window/dialog_delegate.h" 14 15namespace views { 16class TabbedPane; 17class View; 18class Window; 19} 20 21namespace chromeos { 22 23class IPConfigView; 24class CellularConfigView; 25class WifiConfigView; 26 27// A dialog box for showing a password textfield. 28class NetworkConfigView : public views::View, 29 public views::DialogDelegate, 30 views::TabbedPane::Listener { 31 public: 32 class Delegate { 33 public: 34 // Called when dialog "OK" button is pressed. 35 virtual void OnDialogAccepted() = 0; 36 37 // Called when dialog "Cancel" button is pressed. 38 virtual void OnDialogCancelled() = 0; 39 40 protected: 41 virtual ~Delegate() {} 42 }; 43 44 // Configure dialog for ethernet. 45 explicit NetworkConfigView(EthernetNetwork ethernet); 46 // Configure dialog for wifi. If |login_only|, then only show login tab. 47 explicit NetworkConfigView(WifiNetwork wifi, bool login_only); 48 // Configure dialog for cellular. 49 explicit NetworkConfigView(CellularNetwork cellular); 50 // Login dialog for hidden networks. 51 explicit NetworkConfigView(); 52 virtual ~NetworkConfigView() {} 53 54 // Returns corresponding native window. 55 gfx::NativeWindow GetNativeWindow() const; 56 57 // views::DialogDelegate methods. 58 virtual std::wstring GetDialogButtonLabel( 59 MessageBoxFlags::DialogButton button) const; 60 virtual bool IsDialogButtonEnabled( 61 MessageBoxFlags::DialogButton button) const; 62 virtual bool Cancel(); 63 virtual bool Accept(); 64 65 // views::WindowDelegate method. 66 virtual bool IsModal() const { return true; } 67 virtual views::View* GetContentsView() { return this; } 68 69 // views::View overrides. 70 virtual std::wstring GetWindowTitle() const; 71 72 // views::TabbedPane::Listener overrides. 73 virtual void TabSelectedAt(int index); 74 75 // Sets the focus on the login tab's first textfield. 76 void SetLoginTextfieldFocus(); 77 78 // Getter/setter for browser mode. 79 void set_browser_mode(bool value) { 80 browser_mode_ = value; 81 } 82 bool is_browser_mode() const { 83 return browser_mode_; 84 } 85 86 void set_delegate(Delegate* delegate) { 87 delegate_ = delegate; 88 } 89 90 protected: 91 // views::View overrides: 92 virtual void Layout(); 93 virtual gfx::Size GetPreferredSize(); 94 virtual void ViewHierarchyChanged(bool is_add, 95 views::View* parent, 96 views::View* child); 97 98 private: 99 enum NetworkConfigFlags { 100 FLAG_ETHERNET = 1 << 0, 101 FLAG_WIFI = 1 << 1, 102 FLAG_CELLULAR = 1 << 2, 103 FLAG_SHOW_IPCONFIG = 1 << 3, 104 FLAG_LOGIN_ONLY = 1 << 4, 105 FLAG_OTHER_NETWORK = 1 << 5, 106 }; 107 108 // Initializes UI. 109 void Init(); 110 111 // True when opening in browser, otherwise in OOBE/login mode. 112 bool browser_mode_; 113 114 views::TabbedPane* tabs_; 115 116 // NetworkConfigFlags to specify which UIs to show. 117 int flags_; 118 119 EthernetNetwork ethernet_; 120 WifiNetwork wifi_; 121 CellularNetwork cellular_; 122 123 CellularConfigView* cellularconfig_view_; 124 WifiConfigView* wificonfig_view_; 125 IPConfigView* ipconfig_view_; 126 127 Delegate* delegate_; 128 129 DISALLOW_COPY_AND_ASSIGN(NetworkConfigView); 130}; 131 132} // namespace chromeos 133 134#endif // CHROME_BROWSER_CHROMEOS_OPTIONS_NETWORK_CONFIG_VIEW_H_ 135