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/enrollment_dialog_view.h" | 5 #include "chrome/browser/chromeos/enrollment_dialog_view.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 10 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 | 46 |
47 static void ShowDialog(gfx::NativeWindow owning_window, | 47 static void ShowDialog(gfx::NativeWindow owning_window, |
48 const std::string& network_name, | 48 const std::string& network_name, |
49 Profile* profile, | 49 Profile* profile, |
50 const GURL& target_uri, | 50 const GURL& target_uri, |
51 const base::Closure& connect); | 51 const base::Closure& connect); |
52 | 52 |
53 // views::DialogDelegateView overrides | 53 // views::DialogDelegateView overrides |
54 int GetDialogButtons() const override; | 54 int GetDialogButtons() const override; |
55 bool Accept() override; | 55 bool Accept() override; |
| 56 void OnClosed() override; |
56 base::string16 GetDialogButtonLabel(ui::DialogButton button) const override; | 57 base::string16 GetDialogButtonLabel(ui::DialogButton button) const override; |
57 | 58 |
58 // views::WidgetDelegate overrides | 59 // views::WidgetDelegate overrides |
59 ui::ModalType GetModalType() const override; | 60 ui::ModalType GetModalType() const override; |
60 base::string16 GetWindowTitle() const override; | 61 base::string16 GetWindowTitle() const override; |
61 void WindowClosing() override; | |
62 | 62 |
63 // views::View overrides | 63 // views::View overrides |
64 gfx::Size GetPreferredSize() const override; | 64 gfx::Size GetPreferredSize() const override; |
65 | 65 |
66 private: | 66 private: |
67 EnrollmentDialogView(const std::string& network_name, | 67 EnrollmentDialogView(const std::string& network_name, |
68 Profile* profile, | 68 Profile* profile, |
69 const GURL& target_uri, | 69 const GURL& target_uri, |
70 const base::Closure& connect); | 70 const base::Closure& connect); |
71 void InitDialog(); | 71 void InitDialog(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 | 113 |
114 int EnrollmentDialogView::GetDialogButtons() const { | 114 int EnrollmentDialogView::GetDialogButtons() const { |
115 return ui::DIALOG_BUTTON_CANCEL | ui::DIALOG_BUTTON_OK; | 115 return ui::DIALOG_BUTTON_CANCEL | ui::DIALOG_BUTTON_OK; |
116 } | 116 } |
117 | 117 |
118 bool EnrollmentDialogView::Accept() { | 118 bool EnrollmentDialogView::Accept() { |
119 accepted_ = true; | 119 accepted_ = true; |
120 return true; | 120 return true; |
121 } | 121 } |
122 | 122 |
| 123 void EnrollmentDialogView::OnClosed() { |
| 124 if (!accepted_) |
| 125 return; |
| 126 chrome::NavigateParams params(profile_, |
| 127 GURL(target_uri_), |
| 128 ui::PAGE_TRANSITION_LINK); |
| 129 params.disposition = NEW_FOREGROUND_TAB; |
| 130 params.window_action = chrome::NavigateParams::SHOW_WINDOW; |
| 131 chrome::Navigate(¶ms); |
| 132 } |
| 133 |
123 base::string16 EnrollmentDialogView::GetDialogButtonLabel( | 134 base::string16 EnrollmentDialogView::GetDialogButtonLabel( |
124 ui::DialogButton button) const { | 135 ui::DialogButton button) const { |
125 if (button == ui::DIALOG_BUTTON_OK) | 136 if (button == ui::DIALOG_BUTTON_OK) |
126 return l10n_util::GetStringUTF16(IDS_NETWORK_ENROLLMENT_HANDLER_BUTTON); | 137 return l10n_util::GetStringUTF16(IDS_NETWORK_ENROLLMENT_HANDLER_BUTTON); |
127 return views::DialogDelegateView::GetDialogButtonLabel(button); | 138 return views::DialogDelegateView::GetDialogButtonLabel(button); |
128 } | 139 } |
129 | 140 |
130 ui::ModalType EnrollmentDialogView::GetModalType() const { | 141 ui::ModalType EnrollmentDialogView::GetModalType() const { |
131 return ui::MODAL_TYPE_SYSTEM; | 142 return ui::MODAL_TYPE_SYSTEM; |
132 } | 143 } |
133 | 144 |
134 base::string16 EnrollmentDialogView::GetWindowTitle() const { | 145 base::string16 EnrollmentDialogView::GetWindowTitle() const { |
135 return l10n_util::GetStringUTF16(IDS_NETWORK_ENROLLMENT_HANDLER_TITLE); | 146 return l10n_util::GetStringUTF16(IDS_NETWORK_ENROLLMENT_HANDLER_TITLE); |
136 } | 147 } |
137 | 148 |
138 void EnrollmentDialogView::WindowClosing() { | |
139 if (!accepted_) | |
140 return; | |
141 chrome::NavigateParams params(profile_, GURL(target_uri_), | |
142 ui::PAGE_TRANSITION_LINK); | |
143 params.disposition = NEW_FOREGROUND_TAB; | |
144 params.window_action = chrome::NavigateParams::SHOW_WINDOW; | |
145 chrome::Navigate(¶ms); | |
146 } | |
147 | |
148 gfx::Size EnrollmentDialogView::GetPreferredSize() const { | 149 gfx::Size EnrollmentDialogView::GetPreferredSize() const { |
149 return gfx::Size(kDefaultWidth, kDefaultHeight); | 150 return gfx::Size(kDefaultWidth, kDefaultHeight); |
150 } | 151 } |
151 | 152 |
152 void EnrollmentDialogView::InitDialog() { | 153 void EnrollmentDialogView::InitDialog() { |
153 added_cert_ = false; | 154 added_cert_ = false; |
154 // Create the views and layout manager and set them up. | 155 // Create the views and layout manager and set them up. |
155 views::Label* label = new views::Label( | 156 views::Label* label = new views::Label( |
156 l10n_util::GetStringFUTF16(IDS_NETWORK_ENROLLMENT_HANDLER_INSTRUCTIONS, | 157 l10n_util::GetStringFUTF16(IDS_NETWORK_ENROLLMENT_HANDLER_INSTRUCTIONS, |
157 base::UTF8ToUTF16(network_name_))); | 158 base::UTF8ToUTF16(network_name_))); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 | 301 |
301 DialogEnrollmentDelegate* enrollment = | 302 DialogEnrollmentDelegate* enrollment = |
302 new DialogEnrollmentDelegate(owning_window, network->name(), profile); | 303 new DialogEnrollmentDelegate(owning_window, network->name(), profile); |
303 return enrollment->Enroll(cert_config.pattern.enrollment_uri_list(), | 304 return enrollment->Enroll(cert_config.pattern.enrollment_uri_list(), |
304 base::Bind(&EnrollmentComplete, service_path)); | 305 base::Bind(&EnrollmentComplete, service_path)); |
305 } | 306 } |
306 | 307 |
307 } // namespace enrollment | 308 } // namespace enrollment |
308 | 309 |
309 } // namespace chromeos | 310 } // namespace chromeos |
OLD | NEW |