| 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/ui/views/frame/browser_frame.h" | 5 #include "chrome/browser/ui/views/frame/browser_frame.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/leak_annotations.h" | 10 #include "base/debug/leak_annotations.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "chrome/browser/ui/views/frame/top_container_view.h" | 26 #include "chrome/browser/ui/views/frame/top_container_view.h" |
| 27 #include "chrome/common/chrome_switches.h" | 27 #include "chrome/common/chrome_switches.h" |
| 28 #include "ui/base/hit_test.h" | 28 #include "ui/base/hit_test.h" |
| 29 #include "ui/events/event_handler.h" | 29 #include "ui/events/event_handler.h" |
| 30 #include "ui/gfx/font_list.h" | 30 #include "ui/gfx/font_list.h" |
| 31 #include "ui/native_theme/native_theme_dark_aura.h" | 31 #include "ui/native_theme/native_theme_dark_aura.h" |
| 32 #include "ui/views/controls/menu/menu_runner.h" | 32 #include "ui/views/controls/menu/menu_runner.h" |
| 33 #include "ui/views/widget/native_widget.h" | 33 #include "ui/views/widget/native_widget.h" |
| 34 | 34 |
| 35 #if defined(OS_CHROMEOS) | 35 #if defined(OS_CHROMEOS) |
| 36 #include "ash/common/session/session_state_delegate.h" // nogncheck | 36 #include "components/user_manager/user_manager.h" |
| 37 #include "ash/common/wm_shell.h" // nogncheck | |
| 38 #endif | 37 #endif |
| 39 | 38 |
| 40 #if defined(OS_LINUX) | 39 #if defined(OS_LINUX) |
| 41 #include "chrome/browser/ui/views/frame/browser_command_handler_linux.h" | 40 #include "chrome/browser/ui/views/frame/browser_command_handler_linux.h" |
| 42 #endif | 41 #endif |
| 43 | 42 |
| 44 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 43 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 45 #include "ui/views/widget/desktop_aura/x11_desktop_handler.h" | 44 #include "ui/views/widget/desktop_aura/x11_desktop_handler.h" |
| 46 #endif | 45 #endif |
| 47 | 46 |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 views::MenuRunner::ASYNC, | 249 views::MenuRunner::ASYNC, |
| 251 base::Bind(&BrowserFrame::OnMenuClosed, base::Unretained(this)))); | 250 base::Bind(&BrowserFrame::OnMenuClosed, base::Unretained(this)))); |
| 252 menu_runner_->RunMenuAt(source->GetWidget(), nullptr, | 251 menu_runner_->RunMenuAt(source->GetWidget(), nullptr, |
| 253 gfx::Rect(p, gfx::Size(0, 0)), | 252 gfx::Rect(p, gfx::Size(0, 0)), |
| 254 views::MENU_ANCHOR_TOPLEFT, source_type); | 253 views::MENU_ANCHOR_TOPLEFT, source_type); |
| 255 } | 254 } |
| 256 } | 255 } |
| 257 | 256 |
| 258 ui::MenuModel* BrowserFrame::GetSystemMenuModel() { | 257 ui::MenuModel* BrowserFrame::GetSystemMenuModel() { |
| 259 #if defined(OS_CHROMEOS) | 258 #if defined(OS_CHROMEOS) |
| 260 ash::SessionStateDelegate* delegate = | 259 if (user_manager::UserManager::IsInitialized() && |
| 261 ash::WmShell::Get()->GetSessionStateDelegate(); | 260 user_manager::UserManager::Get()->GetLoggedInUsers().size() > 1) { |
| 262 if (delegate && delegate->NumberOfLoggedInUsers() > 1) { | |
| 263 // In Multi user mode, the number of users as well as the order of users | 261 // In Multi user mode, the number of users as well as the order of users |
| 264 // can change. Coming here we have more than one user and since the menu | 262 // can change. Coming here we have more than one user and since the menu |
| 265 // model contains the user information, it must get updated to show any | 263 // model contains the user information, it must get updated to show any |
| 266 // changes happened since the last invocation. | 264 // changes happened since the last invocation. |
| 267 menu_model_builder_.reset(); | 265 menu_model_builder_.reset(); |
| 268 } | 266 } |
| 269 #endif | 267 #endif |
| 270 if (!menu_model_builder_.get()) { | 268 if (!menu_model_builder_.get()) { |
| 271 menu_model_builder_.reset( | 269 menu_model_builder_.reset( |
| 272 new SystemMenuModelBuilder(browser_view_, browser_view_->browser())); | 270 new SystemMenuModelBuilder(browser_view_, browser_view_->browser())); |
| 273 menu_model_builder_->Init(); | 271 menu_model_builder_->Init(); |
| 274 } | 272 } |
| 275 return menu_model_builder_->menu_model(); | 273 return menu_model_builder_->menu_model(); |
| 276 } | 274 } |
| 277 | 275 |
| 278 views::View* BrowserFrame::GetNewAvatarMenuButton() { | 276 views::View* BrowserFrame::GetNewAvatarMenuButton() { |
| 279 return browser_frame_view_->GetProfileSwitcherView(); | 277 return browser_frame_view_->GetProfileSwitcherView(); |
| 280 } | 278 } |
| 281 | 279 |
| 282 void BrowserFrame::OnMenuClosed() { | 280 void BrowserFrame::OnMenuClosed() { |
| 283 menu_runner_.reset(); | 281 menu_runner_.reset(); |
| 284 } | 282 } |
| OLD | NEW |