| 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/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 11 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/profiles/profile_manager.h" | 13 #include "chrome/browser/profiles/profile_manager.h" |
| 14 #include "chrome/browser/ui/ash/system_tray_client.h" | 14 #include "chrome/browser/ui/ash/system_tray_client.h" |
| 15 #include "chrome/browser/ui/browser_dialogs.h" | 15 #include "chrome/browser/ui/browser_dialogs.h" |
| 16 #include "chrome/browser/ui/browser_finder.h" | 16 #include "chrome/browser/ui/browser_finder.h" |
| 17 #include "chrome/browser/ui/browser_navigator.h" | 17 #include "chrome/browser/ui/browser_navigator.h" |
| 18 #include "chrome/browser/ui/browser_navigator_params.h" | 18 #include "chrome/browser/ui/browser_navigator_params.h" |
| 19 #include "chrome/browser/ui/views/harmony/chrome_layout_provider.h" |
| 19 #include "chrome/grit/generated_resources.h" | 20 #include "chrome/grit/generated_resources.h" |
| 20 #include "chromeos/login/login_state.h" | 21 #include "chromeos/login/login_state.h" |
| 21 #include "chromeos/network/client_cert_util.h" | 22 #include "chromeos/network/client_cert_util.h" |
| 22 #include "chromeos/network/managed_network_configuration_handler.h" | 23 #include "chromeos/network/managed_network_configuration_handler.h" |
| 23 #include "chromeos/network/network_event_log.h" | 24 #include "chromeos/network/network_event_log.h" |
| 24 #include "chromeos/network/network_state.h" | 25 #include "chromeos/network/network_state.h" |
| 25 #include "chromeos/network/network_state_handler.h" | 26 #include "chromeos/network/network_state_handler.h" |
| 26 #include "extensions/browser/extension_host.h" | 27 #include "extensions/browser/extension_host.h" |
| 27 #include "extensions/common/constants.h" | 28 #include "extensions/common/constants.h" |
| 28 #include "ui/base/l10n/l10n_util.h" | 29 #include "ui/base/l10n/l10n_util.h" |
| 29 #include "ui/base/page_transition_types.h" | 30 #include "ui/base/page_transition_types.h" |
| 30 #include "ui/views/controls/label.h" | 31 #include "ui/views/controls/label.h" |
| 31 #include "ui/views/layout/grid_layout.h" | 32 #include "ui/views/layout/grid_layout.h" |
| 32 #include "ui/views/layout/layout_constants.h" | |
| 33 #include "ui/views/widget/widget.h" | 33 #include "ui/views/widget/widget.h" |
| 34 #include "ui/views/window/dialog_delegate.h" | 34 #include "ui/views/window/dialog_delegate.h" |
| 35 | 35 |
| 36 namespace chromeos { | 36 namespace chromeos { |
| 37 | 37 |
| 38 namespace { | 38 namespace { |
| 39 | 39 |
| 40 // Default width/height of the dialog. | 40 // Default width/height of the dialog. |
| 41 const int kDefaultWidth = 350; | 41 const int kDefaultWidth = 350; |
| 42 const int kDefaultHeight = 100; | 42 const int kDefaultHeight = 100; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 views::GridLayout* grid_layout = views::GridLayout::CreatePanel(this); | 167 views::GridLayout* grid_layout = views::GridLayout::CreatePanel(this); |
| 168 | 168 |
| 169 views::ColumnSet* columns = grid_layout->AddColumnSet(0); | 169 views::ColumnSet* columns = grid_layout->AddColumnSet(0); |
| 170 columns->AddColumn(views::GridLayout::FILL, // Horizontal resize. | 170 columns->AddColumn(views::GridLayout::FILL, // Horizontal resize. |
| 171 views::GridLayout::FILL, // Vertical resize. | 171 views::GridLayout::FILL, // Vertical resize. |
| 172 1, // Resize weight. | 172 1, // Resize weight. |
| 173 views::GridLayout::USE_PREF, // Size type. | 173 views::GridLayout::USE_PREF, // Size type. |
| 174 0, // Ignored for USE_PREF. | 174 0, // Ignored for USE_PREF. |
| 175 0); // Minimum size. | 175 0); // Minimum size. |
| 176 columns = grid_layout->AddColumnSet(1); | 176 columns = grid_layout->AddColumnSet(1); |
| 177 |
| 178 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get(); |
| 179 |
| 177 columns->AddPaddingColumn( | 180 columns->AddPaddingColumn( |
| 178 0, views::kUnrelatedControlHorizontalSpacing); | 181 0, provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_HORIZONTAL)); |
| 179 columns->AddColumn(views::GridLayout::LEADING, // Horizontal leading. | 182 columns->AddColumn(views::GridLayout::LEADING, // Horizontal leading. |
| 180 views::GridLayout::FILL, // Vertical resize. | 183 views::GridLayout::FILL, // Vertical resize. |
| 181 1, // Resize weight. | 184 1, // Resize weight. |
| 182 views::GridLayout::USE_PREF, // Size type. | 185 views::GridLayout::USE_PREF, // Size type. |
| 183 0, // Ignored for USE_PREF. | 186 0, // Ignored for USE_PREF. |
| 184 0); // Minimum size. | 187 0); // Minimum size. |
| 185 | 188 |
| 186 grid_layout->StartRow(0, 0); | 189 grid_layout->StartRow(0, 0); |
| 187 grid_layout->AddView(label); | 190 grid_layout->AddView(label); |
| 188 grid_layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); | 191 grid_layout->AddPaddingRow( |
| 192 0, provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_VERTICAL)); |
| 189 grid_layout->Layout(this); | 193 grid_layout->Layout(this); |
| 190 } | 194 } |
| 191 | 195 |
| 192 //////////////////////////////////////////////////////////////////////////////// | 196 //////////////////////////////////////////////////////////////////////////////// |
| 193 // Handler for certificate enrollment. | 197 // Handler for certificate enrollment. |
| 194 | 198 |
| 195 class DialogEnrollmentDelegate { | 199 class DialogEnrollmentDelegate { |
| 196 public: | 200 public: |
| 197 // |owning_window| is the window that will own the dialog. | 201 // |owning_window| is the window that will own the dialog. |
| 198 DialogEnrollmentDelegate(gfx::NativeWindow owning_window, | 202 DialogEnrollmentDelegate(gfx::NativeWindow owning_window, |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 | 339 |
| 336 DialogEnrollmentDelegate* enrollment = | 340 DialogEnrollmentDelegate* enrollment = |
| 337 new DialogEnrollmentDelegate(owning_window, network->name(), profile); | 341 new DialogEnrollmentDelegate(owning_window, network->name(), profile); |
| 338 return enrollment->Enroll(cert_config.pattern.enrollment_uri_list(), | 342 return enrollment->Enroll(cert_config.pattern.enrollment_uri_list(), |
| 339 base::Bind(&EnrollmentComplete, network_id)); | 343 base::Bind(&EnrollmentComplete, network_id)); |
| 340 } | 344 } |
| 341 | 345 |
| 342 } // namespace enrollment | 346 } // namespace enrollment |
| 343 | 347 |
| 344 } // namespace chromeos | 348 } // namespace chromeos |
| OLD | NEW |