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

Side by Side Diff: chrome/browser/ui/ash/system_tray_client.cc

Issue 2452283003: chromeos: Make network enrollment and SIM unlock dialogs work with mash (Closed)
Patch Set: rebase 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
« no previous file with comments | « chrome/browser/ui/ash/system_tray_client.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/ui/ash/system_tray_client.h" 5 #include "chrome/browser/ui/ash/system_tray_client.h"
6 6
7 #include "ash/common/login_status.h" 7 #include "ash/common/login_status.h"
8 #include "ash/common/session/session_state_delegate.h" 8 #include "ash/common/session/session_state_delegate.h"
9 #include "ash/common/wm_shell.h" 9 #include "ash/common/wm_shell.h"
10 #include "ash/public/cpp/shell_window_ids.h" 10 #include "ash/public/cpp/shell_window_ids.h"
11 #include "ash/shell.h"
11 #include "base/bind.h" 12 #include "base/bind.h"
12 #include "base/bind_helpers.h" 13 #include "base/bind_helpers.h"
13 #include "base/logging.h" 14 #include "base/logging.h"
14 #include "chrome/browser/browser_process.h" 15 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/browser_process_platform_part.h" 16 #include "chrome/browser/browser_process_platform_part.h"
16 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" 17 #include "chrome/browser/chromeos/accessibility/accessibility_util.h"
17 #include "chrome/browser/chromeos/login/ui/login_display_host.h" 18 #include "chrome/browser/chromeos/login/ui/login_display_host.h"
18 #include "chrome/browser/chromeos/options/network_config_view.h" 19 #include "chrome/browser/chromeos/options/network_config_view.h"
19 #include "chrome/browser/chromeos/set_time_dialog.h" 20 #include "chrome/browser/chromeos/set_time_dialog.h"
20 #include "chrome/browser/chromeos/system/system_clock.h" 21 #include "chrome/browser/chromeos/system/system_clock.h"
21 #include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h" 22 #include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h"
22 #include "chrome/browser/profiles/profile_manager.h" 23 #include "chrome/browser/profiles/profile_manager.h"
23 #include "chrome/browser/ui/ash/ash_util.h" 24 #include "chrome/browser/ui/ash/ash_util.h"
24 #include "chrome/browser/ui/chrome_pages.h" 25 #include "chrome/browser/ui/chrome_pages.h"
25 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" 26 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
26 #include "chrome/browser/ui/singleton_tabs.h" 27 #include "chrome/browser/ui/singleton_tabs.h"
27 #include "chrome/common/url_constants.h" 28 #include "chrome/common/url_constants.h"
28 #include "chromeos/dbus/dbus_thread_manager.h" 29 #include "chromeos/dbus/dbus_thread_manager.h"
29 #include "chromeos/dbus/session_manager_client.h" 30 #include "chromeos/dbus/session_manager_client.h"
30 #include "chromeos/login/login_state.h" 31 #include "chromeos/login/login_state.h"
31 #include "content/public/browser/user_metrics.h" 32 #include "content/public/browser/user_metrics.h"
32 #include "content/public/common/service_manager_connection.h" 33 #include "content/public/common/service_manager_connection.h"
33 #include "net/base/escape.h" 34 #include "net/base/escape.h"
34 #include "services/service_manager/public/cpp/connector.h" 35 #include "services/service_manager/public/cpp/connector.h"
36 #include "services/ui/public/cpp/property_type_converters.h"
37 #include "services/ui/public/interfaces/window_manager.mojom.h"
35 #include "third_party/cros_system_api/dbus/shill/dbus-constants.h" 38 #include "third_party/cros_system_api/dbus/shill/dbus-constants.h"
39 #include "ui/views/widget/widget.h"
40 #include "ui/views/window/dialog_delegate.h"
36 41
37 using chromeos::DBusThreadManager; 42 using chromeos::DBusThreadManager;
38 using chromeos::LoginState; 43 using chromeos::LoginState;
44 using views::Widget;
39 45
40 namespace { 46 namespace {
41 47
42 const char kDisplaySettingsSubPageName[] = "display"; 48 const char kDisplaySettingsSubPageName[] = "display";
43 const char kPaletteSettingsSubPageName[] = "stylus-overlay"; 49 const char kPaletteSettingsSubPageName[] = "stylus-overlay";
44 50
45 SystemTrayClient* g_instance = nullptr; 51 SystemTrayClient* g_instance = nullptr;
46 52
47 void ShowSettingsSubPageForActiveUser(const std::string& sub_page) { 53 void ShowSettingsSubPageForActiveUser(const std::string& sub_page) {
48 chrome::ShowSettingsSubPageForProfile(ProfileManager::GetActiveUserProfile(), 54 chrome::ShowSettingsSubPageForProfile(ProfileManager::GetActiveUserProfile(),
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 wm_shell->GetSessionStateDelegate()->IsActiveUserSessionStarted(); 128 wm_shell->GetSessionStateDelegate()->IsActiveUserSessionStarted();
123 const bool is_in_secondary_login_screen = 129 const bool is_in_secondary_login_screen =
124 wm_shell->GetSessionStateDelegate()->IsInSecondaryLoginScreen(); 130 wm_shell->GetSessionStateDelegate()->IsInSecondaryLoginScreen();
125 131
126 if (!session_started || is_in_secondary_login_screen) 132 if (!session_started || is_in_secondary_login_screen)
127 return ash::kShellWindowId_LockSystemModalContainer; 133 return ash::kShellWindowId_LockSystemModalContainer;
128 134
129 return ash::kShellWindowId_SystemModalContainer; 135 return ash::kShellWindowId_SystemModalContainer;
130 } 136 }
131 137
138 // static
139 Widget* SystemTrayClient::CreateUnownedDialogWidget(
140 views::WidgetDelegate* widget_delegate) {
141 DCHECK(widget_delegate);
142 Widget::InitParams params = views::DialogDelegate::GetDialogWidgetInitParams(
143 widget_delegate, nullptr, nullptr, gfx::Rect());
144 // Place the dialog in the appropriate modal dialog container, either above
145 // or below the lock screen, based on the login state.
146 int container_id = GetDialogParentContainerId();
147 if (chrome::IsRunningInMash()) {
148 using ui::mojom::WindowManager;
149 params.mus_properties[WindowManager::kInitialContainerId_Property] =
150 mojo::ConvertTo<std::vector<uint8_t>>(container_id);
151 } else {
152 params.parent = ash::Shell::GetContainer(ash::Shell::GetPrimaryRootWindow(),
153 container_id);
154 }
155 Widget* widget = new Widget; // Owned by native widget.
156 widget->Init(params);
157 return widget;
158 }
159
132 //////////////////////////////////////////////////////////////////////////////// 160 ////////////////////////////////////////////////////////////////////////////////
133 // ash::mojom::SystemTrayClient: 161 // ash::mojom::SystemTrayClient:
134 162
135 void SystemTrayClient::ShowSettings() { 163 void SystemTrayClient::ShowSettings() {
136 ShowSettingsSubPageForActiveUser(std::string()); 164 ShowSettingsSubPageForActiveUser(std::string());
137 } 165 }
138 166
139 void SystemTrayClient::ShowDateSettings() { 167 void SystemTrayClient::ShowDateSettings() {
140 content::RecordAction(base::UserMetricsAction("ShowDateOptions")); 168 content::RecordAction(base::UserMetricsAction("ShowDateOptions"));
141 // Everybody can change the time zone (even though it is a device setting). 169 // Everybody can change the time zone (even though it is a device setting).
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 connector->ConnectToInterface("service:content_browser", &system_tray_); 300 connector->ConnectToInterface("service:content_browser", &system_tray_);
273 301
274 // Tolerate ash crashing and coming back up. 302 // Tolerate ash crashing and coming back up.
275 system_tray_.set_connection_error_handler(base::Bind( 303 system_tray_.set_connection_error_handler(base::Bind(
276 &SystemTrayClient::OnClientConnectionError, base::Unretained(this))); 304 &SystemTrayClient::OnClientConnectionError, base::Unretained(this)));
277 } 305 }
278 306
279 void SystemTrayClient::OnClientConnectionError() { 307 void SystemTrayClient::OnClientConnectionError() {
280 system_tray_.reset(); 308 system_tray_.reset();
281 } 309 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/system_tray_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698