| 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_OPTIONS_NETWORK_CONFIG_VIEW_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_OPTIONS_NETWORK_CONFIG_VIEW_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_OPTIONS_NETWORK_CONFIG_VIEW_H_ | 6 #define CHROME_BROWSER_CHROMEOS_OPTIONS_NETWORK_CONFIG_VIEW_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
| 12 #include "chrome/browser/chromeos/cros/network_library.h" | |
| 13 #include "ui/gfx/native_widget_types.h" // gfx::NativeWindow | 12 #include "ui/gfx/native_widget_types.h" // gfx::NativeWindow |
| 14 #include "ui/views/controls/button/button.h" // views::ButtonListener | 13 #include "ui/views/controls/button/button.h" // views::ButtonListener |
| 15 #include "ui/views/window/dialog_delegate.h" | 14 #include "ui/views/window/dialog_delegate.h" |
| 16 | 15 |
| 17 namespace gfx { | 16 namespace gfx { |
| 18 class ImageSkia; | 17 class ImageSkia; |
| 19 } | 18 } |
| 20 | 19 |
| 21 namespace views { | 20 namespace views { |
| 22 class ImageView; | 21 class ImageView; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 38 virtual void OnDialogAccepted() = 0; | 37 virtual void OnDialogAccepted() = 0; |
| 39 | 38 |
| 40 // Called when dialog "Cancel" button is pressed. | 39 // Called when dialog "Cancel" button is pressed. |
| 41 virtual void OnDialogCancelled() = 0; | 40 virtual void OnDialogCancelled() = 0; |
| 42 | 41 |
| 43 protected: | 42 protected: |
| 44 virtual ~Delegate() {} | 43 virtual ~Delegate() {} |
| 45 }; | 44 }; |
| 46 | 45 |
| 47 // Shows a network connection dialog if none is currently visible. | 46 // Shows a network connection dialog if none is currently visible. |
| 48 static void Show(Network* network, gfx::NativeWindow parent); | 47 static void Show(const std::string& service_path, gfx::NativeWindow parent); |
| 49 static void ShowForType(ConnectionType type, gfx::NativeWindow parent); | 48 static void ShowForType(const std::string& type, gfx::NativeWindow parent); |
| 50 | 49 |
| 51 // Returns corresponding native window. | 50 // Returns corresponding native window. |
| 52 gfx::NativeWindow GetNativeWindow() const; | 51 gfx::NativeWindow GetNativeWindow() const; |
| 53 | 52 |
| 54 // views::DialogDelegate methods. | 53 // views::DialogDelegate methods. |
| 55 virtual string16 GetDialogButtonLabel(ui::DialogButton button) const OVERRIDE; | 54 virtual string16 GetDialogButtonLabel(ui::DialogButton button) const OVERRIDE; |
| 56 virtual bool IsDialogButtonEnabled(ui::DialogButton button) const OVERRIDE; | 55 virtual bool IsDialogButtonEnabled(ui::DialogButton button) const OVERRIDE; |
| 57 virtual bool Cancel() OVERRIDE; | 56 virtual bool Cancel() OVERRIDE; |
| 58 virtual bool Accept() OVERRIDE; | 57 virtual bool Accept() OVERRIDE; |
| 59 virtual views::View* CreateExtraView() OVERRIDE; | 58 virtual views::View* CreateExtraView() OVERRIDE; |
| 60 virtual views::View* GetInitiallyFocusedView() OVERRIDE; | 59 virtual views::View* GetInitiallyFocusedView() OVERRIDE; |
| 61 | 60 |
| 62 // views::WidgetDelegate methods. | 61 // views::WidgetDelegate methods. |
| 63 virtual string16 GetWindowTitle() const OVERRIDE; | 62 virtual string16 GetWindowTitle() const OVERRIDE; |
| 64 virtual ui::ModalType GetModalType() const OVERRIDE; | 63 virtual ui::ModalType GetModalType() const OVERRIDE; |
| 65 | 64 |
| 66 // views::View overrides. | 65 // views::View overrides. |
| 67 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; | 66 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; |
| 68 | 67 |
| 69 // views::ButtonListener overrides. | 68 // views::ButtonListener overrides. |
| 70 virtual void ButtonPressed( | 69 virtual void ButtonPressed( |
| 71 views::Button* sender, const ui::Event& event) OVERRIDE; | 70 views::Button* sender, const ui::Event& event) OVERRIDE; |
| 72 | 71 |
| 73 void set_delegate(Delegate* delegate) { | 72 void set_delegate(Delegate* delegate) { |
| 74 delegate_ = delegate; | 73 delegate_ = delegate; |
| 75 } | 74 } |
| 76 | 75 |
| 77 static const base::DictionaryValue* FindPolicyForActiveUser( | |
| 78 const Network* network, | |
| 79 onc::ONCSource* onc_source); | |
| 80 | |
| 81 protected: | 76 protected: |
| 82 // views::View overrides: | 77 // views::View overrides: |
| 83 virtual void Layout() OVERRIDE; | 78 virtual void Layout() OVERRIDE; |
| 84 virtual gfx::Size GetPreferredSize() OVERRIDE; | 79 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 85 virtual void ViewHierarchyChanged( | 80 virtual void ViewHierarchyChanged( |
| 86 const ViewHierarchyChangedDetails& details) OVERRIDE; | 81 const ViewHierarchyChangedDetails& details) OVERRIDE; |
| 87 | 82 |
| 88 private: | 83 private: |
| 84 NetworkConfigView(); |
| 85 virtual ~NetworkConfigView(); |
| 86 |
| 89 // Login dialog for known networks. | 87 // Login dialog for known networks. |
| 90 explicit NetworkConfigView(Network* network); | 88 void InitWithPath(const std::string& service_path); |
| 91 // Login dialog for new/hidden networks. | 89 // Login dialog for new/hidden networks. |
| 92 explicit NetworkConfigView(ConnectionType type); | 90 void InitWithType(const std::string& type); |
| 93 virtual ~NetworkConfigView(); | |
| 94 | 91 |
| 95 // Creates and shows a dialog containing this view. | 92 // Creates and shows a dialog containing this view. |
| 96 void ShowDialog(gfx::NativeWindow parent); | 93 void ShowDialog(gfx::NativeWindow parent); |
| 97 | 94 |
| 98 // Resets the underlying view to show advanced options. | 95 // Resets the underlying view to show advanced options. |
| 99 void ShowAdvancedView(); | 96 void ShowAdvancedView(); |
| 100 | 97 |
| 101 // There's always only one child view, which will get deleted when | 98 // There's always only one child view, which will get deleted when |
| 102 // NetworkConfigView gets cleaned up. | 99 // NetworkConfigView gets cleaned up. |
| 103 ChildNetworkConfigView* child_config_view_; | 100 ChildNetworkConfigView* child_config_view_; |
| 104 | 101 |
| 105 Delegate* delegate_; | 102 Delegate* delegate_; |
| 106 | 103 |
| 107 // Button in lower-left corner, may be null or hidden. | 104 // Button in lower-left corner, may be null or hidden. |
| 108 views::LabelButton* advanced_button_; | 105 views::LabelButton* advanced_button_; |
| 109 | 106 |
| 110 DISALLOW_COPY_AND_ASSIGN(NetworkConfigView); | 107 DISALLOW_COPY_AND_ASSIGN(NetworkConfigView); |
| 111 }; | 108 }; |
| 112 | 109 |
| 113 // Children of NetworkConfigView must subclass this and implement the virtual | 110 // Children of NetworkConfigView must subclass this and implement the virtual |
| 114 // methods, which are called by NetworkConfigView. | 111 // methods, which are called by NetworkConfigView. |
| 115 class ChildNetworkConfigView : public views::View { | 112 class ChildNetworkConfigView : public views::View { |
| 116 public: | 113 public: |
| 117 ChildNetworkConfigView(NetworkConfigView* parent, Network* network) | 114 ChildNetworkConfigView(NetworkConfigView* parent, |
| 118 : service_path_(network->service_path()), | 115 const std::string& service_path); |
| 119 parent_(parent) {} | 116 virtual ~ChildNetworkConfigView(); |
| 120 explicit ChildNetworkConfigView(NetworkConfigView* parent) | |
| 121 : parent_(parent) {} | |
| 122 virtual ~ChildNetworkConfigView() {} | |
| 123 | 117 |
| 124 // Get the title to show for the dialog. | 118 // Get the title to show for the dialog. |
| 125 virtual string16 GetTitle() const = 0; | 119 virtual string16 GetTitle() const = 0; |
| 126 | 120 |
| 127 // Returns view that should be focused on dialog activation. | 121 // Returns view that should be focused on dialog activation. |
| 128 virtual views::View* GetInitiallyFocusedView() = 0; | 122 virtual views::View* GetInitiallyFocusedView() = 0; |
| 129 | 123 |
| 130 // Called to determine if "Connect" button should be enabled. | 124 // Called to determine if "Connect" button should be enabled. |
| 131 virtual bool CanLogin() = 0; | 125 virtual bool CanLogin() = 0; |
| 132 | 126 |
| 133 // Called when "Connect" button is clicked. | 127 // Called when "Connect" button is clicked. |
| 134 // Should return false if dialog should remain open. | 128 // Should return false if dialog should remain open. |
| 135 virtual bool Login() = 0; | 129 virtual bool Login() = 0; |
| 136 | 130 |
| 137 // Called when "Cancel" button is clicked. | 131 // Called when "Cancel" button is clicked. |
| 138 virtual void Cancel() = 0; | 132 virtual void Cancel() = 0; |
| 139 | 133 |
| 140 // Called to set focus when view is recreated with the same dialog | 134 // Called to set focus when view is recreated with the same dialog |
| 141 // being active. For example, clicking on "Advanced" button. | 135 // being active. For example, clicking on "Advanced" button. |
| 142 virtual void InitFocus() = 0; | 136 virtual void InitFocus() = 0; |
| 143 | 137 |
| 144 // Minimum with of input fields / combo boxes. | 138 // Minimum with of input fields / combo boxes. |
| 145 static const int kInputFieldMinWidth; | 139 static const int kInputFieldMinWidth; |
| 146 | 140 |
| 147 protected: | 141 protected: |
| 142 NetworkConfigView* parent_; |
| 148 std::string service_path_; | 143 std::string service_path_; |
| 149 NetworkConfigView* parent_; | |
| 150 | 144 |
| 151 private: | 145 private: |
| 152 DISALLOW_COPY_AND_ASSIGN(ChildNetworkConfigView); | 146 DISALLOW_COPY_AND_ASSIGN(ChildNetworkConfigView); |
| 153 }; | 147 }; |
| 154 | 148 |
| 155 // Shows an icon with tooltip indicating whether a setting is under policy | 149 // Shows an icon with tooltip indicating whether a setting is under policy |
| 156 // control. | 150 // control. |
| 157 class ControlledSettingIndicatorView : public views::View { | 151 class ControlledSettingIndicatorView : public views::View { |
| 158 public: | 152 public: |
| 159 ControlledSettingIndicatorView(); | 153 ControlledSettingIndicatorView(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 178 views::ImageView* image_view_; | 172 views::ImageView* image_view_; |
| 179 const gfx::ImageSkia* gray_image_; | 173 const gfx::ImageSkia* gray_image_; |
| 180 const gfx::ImageSkia* color_image_; | 174 const gfx::ImageSkia* color_image_; |
| 181 | 175 |
| 182 DISALLOW_COPY_AND_ASSIGN(ControlledSettingIndicatorView); | 176 DISALLOW_COPY_AND_ASSIGN(ControlledSettingIndicatorView); |
| 183 }; | 177 }; |
| 184 | 178 |
| 185 } // namespace chromeos | 179 } // namespace chromeos |
| 186 | 180 |
| 187 #endif // CHROME_BROWSER_CHROMEOS_OPTIONS_NETWORK_CONFIG_VIEW_H_ | 181 #endif // CHROME_BROWSER_CHROMEOS_OPTIONS_NETWORK_CONFIG_VIEW_H_ |
| OLD | NEW |