| 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; | |
| 57 base::string16 GetDialogButtonLabel(ui::DialogButton button) const override; | 56 base::string16 GetDialogButtonLabel(ui::DialogButton button) const override; |
| 58 | 57 |
| 59 // views::WidgetDelegate overrides | 58 // views::WidgetDelegate overrides |
| 60 ui::ModalType GetModalType() const override; | 59 ui::ModalType GetModalType() const override; |
| 61 base::string16 GetWindowTitle() const override; | 60 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 | |
| 134 base::string16 EnrollmentDialogView::GetDialogButtonLabel( | 123 base::string16 EnrollmentDialogView::GetDialogButtonLabel( |
| 135 ui::DialogButton button) const { | 124 ui::DialogButton button) const { |
| 136 if (button == ui::DIALOG_BUTTON_OK) | 125 if (button == ui::DIALOG_BUTTON_OK) |
| 137 return l10n_util::GetStringUTF16(IDS_NETWORK_ENROLLMENT_HANDLER_BUTTON); | 126 return l10n_util::GetStringUTF16(IDS_NETWORK_ENROLLMENT_HANDLER_BUTTON); |
| 138 return views::DialogDelegateView::GetDialogButtonLabel(button); | 127 return views::DialogDelegateView::GetDialogButtonLabel(button); |
| 139 } | 128 } |
| 140 | 129 |
| 141 ui::ModalType EnrollmentDialogView::GetModalType() const { | 130 ui::ModalType EnrollmentDialogView::GetModalType() const { |
| 142 return ui::MODAL_TYPE_SYSTEM; | 131 return ui::MODAL_TYPE_SYSTEM; |
| 143 } | 132 } |
| 144 | 133 |
| 145 base::string16 EnrollmentDialogView::GetWindowTitle() const { | 134 base::string16 EnrollmentDialogView::GetWindowTitle() const { |
| 146 return l10n_util::GetStringUTF16(IDS_NETWORK_ENROLLMENT_HANDLER_TITLE); | 135 return l10n_util::GetStringUTF16(IDS_NETWORK_ENROLLMENT_HANDLER_TITLE); |
| 147 } | 136 } |
| 148 | 137 |
| 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 |
| 149 gfx::Size EnrollmentDialogView::GetPreferredSize() const { | 148 gfx::Size EnrollmentDialogView::GetPreferredSize() const { |
| 150 return gfx::Size(kDefaultWidth, kDefaultHeight); | 149 return gfx::Size(kDefaultWidth, kDefaultHeight); |
| 151 } | 150 } |
| 152 | 151 |
| 153 void EnrollmentDialogView::InitDialog() { | 152 void EnrollmentDialogView::InitDialog() { |
| 154 added_cert_ = false; | 153 added_cert_ = false; |
| 155 // Create the views and layout manager and set them up. | 154 // Create the views and layout manager and set them up. |
| 156 views::Label* label = new views::Label( | 155 views::Label* label = new views::Label( |
| 157 l10n_util::GetStringFUTF16(IDS_NETWORK_ENROLLMENT_HANDLER_INSTRUCTIONS, | 156 l10n_util::GetStringFUTF16(IDS_NETWORK_ENROLLMENT_HANDLER_INSTRUCTIONS, |
| 158 base::UTF8ToUTF16(network_name_))); | 157 base::UTF8ToUTF16(network_name_))); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 | 300 |
| 302 DialogEnrollmentDelegate* enrollment = | 301 DialogEnrollmentDelegate* enrollment = |
| 303 new DialogEnrollmentDelegate(owning_window, network->name(), profile); | 302 new DialogEnrollmentDelegate(owning_window, network->name(), profile); |
| 304 return enrollment->Enroll(cert_config.pattern.enrollment_uri_list(), | 303 return enrollment->Enroll(cert_config.pattern.enrollment_uri_list(), |
| 305 base::Bind(&EnrollmentComplete, service_path)); | 304 base::Bind(&EnrollmentComplete, service_path)); |
| 306 } | 305 } |
| 307 | 306 |
| 308 } // namespace enrollment | 307 } // namespace enrollment |
| 309 | 308 |
| 310 } // namespace chromeos | 309 } // namespace chromeos |
| OLD | NEW |