Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(320)

Side by Side Diff: chrome/browser/chromeos/enrollment_dialog_view.cc

Issue 2452283003: chromeos: Make network enrollment and SIM unlock dialogs work with mash (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "ash/shell.h"
7 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback.h"
8 #include "base/macros.h" 10 #include "base/macros.h"
9 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/chromeos/profiles/profile_helper.h" 12 #include "chrome/browser/chromeos/profiles/profile_helper.h"
11 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/profiles/profile_manager.h" 14 #include "chrome/browser/profiles/profile_manager.h"
15 #include "chrome/browser/ui/ash/ash_util.h"
16 #include "chrome/browser/ui/ash/system_tray_client.h"
13 #include "chrome/browser/ui/browser_finder.h" 17 #include "chrome/browser/ui/browser_finder.h"
14 #include "chrome/browser/ui/browser_navigator.h" 18 #include "chrome/browser/ui/browser_navigator.h"
15 #include "chrome/browser/ui/browser_navigator_params.h" 19 #include "chrome/browser/ui/browser_navigator_params.h"
16 #include "chrome/grit/generated_resources.h" 20 #include "chrome/grit/generated_resources.h"
17 #include "chromeos/network/client_cert_util.h" 21 #include "chromeos/network/client_cert_util.h"
18 #include "chromeos/network/managed_network_configuration_handler.h" 22 #include "chromeos/network/managed_network_configuration_handler.h"
19 #include "chromeos/network/network_event_log.h" 23 #include "chromeos/network/network_event_log.h"
20 #include "chromeos/network/network_state.h" 24 #include "chromeos/network/network_state.h"
21 #include "chromeos/network/network_state_handler.h" 25 #include "chromeos/network/network_state_handler.h"
22 #include "extensions/browser/extension_host.h" 26 #include "extensions/browser/extension_host.h"
23 #include "extensions/common/constants.h" 27 #include "extensions/common/constants.h"
28 #include "services/ui/public/cpp/property_type_converters.h"
29 #include "services/ui/public/interfaces/window_manager.mojom.h"
24 #include "ui/base/l10n/l10n_util.h" 30 #include "ui/base/l10n/l10n_util.h"
25 #include "ui/base/page_transition_types.h" 31 #include "ui/base/page_transition_types.h"
26 #include "ui/views/controls/label.h" 32 #include "ui/views/controls/label.h"
27 #include "ui/views/layout/grid_layout.h" 33 #include "ui/views/layout/grid_layout.h"
28 #include "ui/views/layout/layout_constants.h" 34 #include "ui/views/layout/layout_constants.h"
29 #include "ui/views/widget/widget.h" 35 #include "ui/views/widget/widget.h"
30 #include "ui/views/window/dialog_delegate.h" 36 #include "ui/views/window/dialog_delegate.h"
31 37
38 using views::Widget;
39
32 namespace chromeos { 40 namespace chromeos {
33 41
34 namespace { 42 namespace {
35 43
36 // Default width/height of the dialog. 44 // Default width/height of the dialog.
37 const int kDefaultWidth = 350; 45 const int kDefaultWidth = 350;
38 const int kDefaultHeight = 100; 46 const int kDefaultHeight = 100;
39 47
40 //////////////////////////////////////////////////////////////////////////////// 48 ////////////////////////////////////////////////////////////////////////////////
41 // Dialog for certificate enrollment. This displays the content from the 49 // Dialog for certificate enrollment. This displays the content from the
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 } 104 }
97 105
98 // static 106 // static
99 void EnrollmentDialogView::ShowDialog(gfx::NativeWindow owning_window, 107 void EnrollmentDialogView::ShowDialog(gfx::NativeWindow owning_window,
100 const std::string& network_name, 108 const std::string& network_name,
101 Profile* profile, 109 Profile* profile,
102 const GURL& target_uri, 110 const GURL& target_uri,
103 const base::Closure& connect) { 111 const base::Closure& connect) {
104 EnrollmentDialogView* dialog_view = 112 EnrollmentDialogView* dialog_view =
105 new EnrollmentDialogView(network_name, profile, target_uri, connect); 113 new EnrollmentDialogView(network_name, profile, target_uri, connect);
106 views::DialogDelegate::CreateDialogWidget(dialog_view, NULL, owning_window); 114 if (owning_window) {
115 views::DialogDelegate::CreateDialogWidget(dialog_view, nullptr,
116 owning_window);
117 } else {
118 // Place the dialog in the appropriate modal dialog container, either above
119 // or below the lock screen, based on the login state.
120 Widget::InitParams params = DialogDelegate::GetDialogWidgetInitParams(
121 dialog_view, nullptr, nullptr, gfx::Rect());
122 int container_id = SystemTrayClient::GetDialogParentContainerId();
James Cook 2016/10/27 18:20:37 As I noted in the last CL: I would like to move Ge
stevenjb 2016/10/27 18:45:13 The added dependencies are somewhat unfortunate.
James Cook 2016/10/27 22:28:27 Done. In a follow-up CL I'll migrate NetworkConfig
123 if (chrome::IsRunningInMash()) {
124 using ui::mojom::WindowManager;
125 params.mus_properties[WindowManager::kInitialContainerId_Property] =
126 mojo::ConvertTo<std::vector<uint8_t>>(container_id);
127 } else {
128 params.parent = ash::Shell::GetContainer(
129 ash::Shell::GetPrimaryRootWindow(), container_id);
130 }
131 Widget* widget = new Widget;
132 widget->Init(params);
133 }
107 dialog_view->InitDialog(); 134 dialog_view->InitDialog();
108 views::Widget* widget = dialog_view->GetWidget(); 135 dialog_view->GetWidget()->Show();
109 DCHECK(widget);
110 widget->Show();
111 } 136 }
112 137
113 bool EnrollmentDialogView::Accept() { 138 bool EnrollmentDialogView::Accept() {
114 accepted_ = true; 139 accepted_ = true;
115 return true; 140 return true;
116 } 141 }
117 142
118 base::string16 EnrollmentDialogView::GetDialogButtonLabel( 143 base::string16 EnrollmentDialogView::GetDialogButtonLabel(
119 ui::DialogButton button) const { 144 ui::DialogButton button) const {
120 if (button == ui::DIALOG_BUTTON_OK) 145 if (button == ui::DIALOG_BUTTON_OK)
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 320
296 DialogEnrollmentDelegate* enrollment = 321 DialogEnrollmentDelegate* enrollment =
297 new DialogEnrollmentDelegate(owning_window, network->name(), profile); 322 new DialogEnrollmentDelegate(owning_window, network->name(), profile);
298 return enrollment->Enroll(cert_config.pattern.enrollment_uri_list(), 323 return enrollment->Enroll(cert_config.pattern.enrollment_uri_list(),
299 base::Bind(&EnrollmentComplete, service_path)); 324 base::Bind(&EnrollmentComplete, service_path));
300 } 325 }
301 326
302 } // namespace enrollment 327 } // namespace enrollment
303 328
304 } // namespace chromeos 329 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698