Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/system_menu_model_builder.h" | 5 #include "chrome/browser/ui/views/frame/system_menu_model_builder.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
| 10 #include "chrome/browser/ui/browser_commands.h" | 10 #include "chrome/browser/ui/browser_commands.h" |
| 11 #include "chrome/browser/ui/host_desktop.h" | 11 #include "chrome/browser/ui/host_desktop.h" |
| 12 #include "chrome/browser/ui/tabs/tab_strip_model.h" | |
| 12 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" | 13 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" |
| 13 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
| 15 #include "chrome/common/url_constants.h" | |
| 14 #include "chrome/grit/generated_resources.h" | 16 #include "chrome/grit/generated_resources.h" |
| 15 #include "ui/base/accelerators/accelerator.h" | 17 #include "ui/base/accelerators/accelerator.h" |
| 16 #include "ui/base/models/simple_menu_model.h" | 18 #include "ui/base/models/simple_menu_model.h" |
| 17 | 19 |
| 18 #if defined(OS_CHROMEOS) | 20 #if defined(OS_CHROMEOS) |
| 19 #include "ash/session/session_state_delegate.h" | 21 #include "ash/session/session_state_delegate.h" |
| 20 #include "ash/shell.h" | 22 #include "ash/shell.h" |
| 21 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" | 23 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" |
| 22 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" | 24 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" |
| 23 #include "chrome/browser/ui/browser_window.h" | 25 #include "chrome/browser/ui/browser_window.h" |
| 24 #include "components/user_manager/user_info.h" | 26 #include "components/user_manager/user_info.h" |
| 25 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
| 26 #endif | 28 #endif |
| 27 | 29 |
| 30 namespace { | |
| 31 | |
| 32 // Check if the current window is chrome settings app or popup window. | |
|
Peter Kasting
2015/05/15 08:05:49
Nit: How about:
Given a |browser| that's an app o
xdai1
2015/05/15 18:12:48
Done.
| |
| 33 bool IsChromeSettingsAppOrPopupWindow(Browser* browser) { | |
| 34 if (browser) { | |
|
Peter Kasting
2015/05/15 08:05:49
Nit: Simpler:
if (!browser)
return false;
xdai1
2015/05/15 18:12:48
Done.
| |
| 35 TabStripModel* tab_strip = browser->tab_strip_model(); | |
| 36 DCHECK_EQ(1, tab_strip->count()); | |
| 37 const GURL gurl = tab_strip->GetWebContentsAt(0)->GetURL(); | |
|
Peter Kasting
2015/05/15 08:05:49
Nit: Use constructor-style init for class objects
xdai1
2015/05/15 18:12:48
Done.
| |
| 38 if (gurl.SchemeIs(content::kChromeUIScheme) && gurl.has_host() && | |
|
Peter Kasting
2015/05/15 08:05:49
Nit: No need to check has_host(); if there were no
xdai1
2015/05/15 18:12:48
Done.
| |
| 39 gurl.host().find(chrome::kChromeUISettingsHost) != std::string::npos) { | |
| 40 return true; | |
| 41 } | |
| 42 } | |
| 43 return false; | |
| 44 } | |
| 45 | |
| 46 } // namespace | |
| 47 | |
| 28 SystemMenuModelBuilder::SystemMenuModelBuilder( | 48 SystemMenuModelBuilder::SystemMenuModelBuilder( |
| 29 ui::AcceleratorProvider* provider, | 49 ui::AcceleratorProvider* provider, |
| 30 Browser* browser) | 50 Browser* browser) |
| 31 : menu_delegate_(provider, browser) { | 51 : menu_delegate_(provider, browser) { |
| 32 } | 52 } |
| 33 | 53 |
| 34 SystemMenuModelBuilder::~SystemMenuModelBuilder() { | 54 SystemMenuModelBuilder::~SystemMenuModelBuilder() { |
| 35 } | 55 } |
| 36 | 56 |
| 37 void SystemMenuModelBuilder::Init() { | 57 void SystemMenuModelBuilder::Init() { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 encoding_menu_contents_.get()); | 121 encoding_menu_contents_.get()); |
| 102 if (browser()->is_app() && chrome::CanOpenTaskManager()) { | 122 if (browser()->is_app() && chrome::CanOpenTaskManager()) { |
| 103 model->AddSeparator(ui::NORMAL_SEPARATOR); | 123 model->AddSeparator(ui::NORMAL_SEPARATOR); |
| 104 model->AddItemWithStringId(IDC_TASK_MANAGER, IDS_TASK_MANAGER); | 124 model->AddItemWithStringId(IDC_TASK_MANAGER, IDS_TASK_MANAGER); |
| 105 } | 125 } |
| 106 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 126 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 107 model->AddSeparator(ui::NORMAL_SEPARATOR); | 127 model->AddSeparator(ui::NORMAL_SEPARATOR); |
| 108 model->AddItemWithStringId(IDC_CLOSE_WINDOW, IDS_CLOSE); | 128 model->AddItemWithStringId(IDC_CLOSE_WINDOW, IDS_CLOSE); |
| 109 #endif | 129 #endif |
| 110 | 130 |
| 111 AppendTeleportMenu(model); | 131 // We don't append teleport menu for Chrome Settings window. The Settings |
| 132 // window on Chrome OS is currently unique. It's a browser window with an | |
| 133 // app-like frame and don't have a user icon badged when teleporting. To avoid | |
| 134 // confusion and edge cases, we disable teleporting for Settings window. | |
|
Peter Kasting
2015/05/15 08:05:49
Nit: How about:
Avoid appending the teleport menu
xdai1
2015/05/15 18:12:48
Done.
| |
| 135 if (!IsChromeSettingsAppOrPopupWindow(browser())) | |
| 136 AppendTeleportMenu(model); | |
| 112 } | 137 } |
| 113 | 138 |
| 114 void SystemMenuModelBuilder::AddFrameToggleItems(ui::SimpleMenuModel* model) { | 139 void SystemMenuModelBuilder::AddFrameToggleItems(ui::SimpleMenuModel* model) { |
| 115 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 140 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 116 switches::kDebugEnableFrameToggle)) { | 141 switches::kDebugEnableFrameToggle)) { |
| 117 model->AddSeparator(ui::NORMAL_SEPARATOR); | 142 model->AddSeparator(ui::NORMAL_SEPARATOR); |
| 118 model->AddItem(IDC_DEBUG_FRAME_TOGGLE, | 143 model->AddItem(IDC_DEBUG_FRAME_TOGGLE, |
| 119 base::ASCIIToUTF16("Toggle Frame Type")); | 144 base::ASCIIToUTF16("Toggle Frame Type")); |
| 120 } | 145 } |
| 121 } | 146 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 const user_manager::UserInfo* user_info = delegate->GetUserInfo(user_index); | 180 const user_manager::UserInfo* user_info = delegate->GetUserInfo(user_index); |
| 156 model->AddItem( | 181 model->AddItem( |
| 157 user_index == 1 ? IDC_VISIT_DESKTOP_OF_LRU_USER_2 | 182 user_index == 1 ? IDC_VISIT_DESKTOP_OF_LRU_USER_2 |
| 158 : IDC_VISIT_DESKTOP_OF_LRU_USER_3, | 183 : IDC_VISIT_DESKTOP_OF_LRU_USER_3, |
| 159 l10n_util::GetStringFUTF16(IDS_VISIT_DESKTOP_OF_LRU_USER, | 184 l10n_util::GetStringFUTF16(IDS_VISIT_DESKTOP_OF_LRU_USER, |
| 160 user_info->GetDisplayName(), | 185 user_info->GetDisplayName(), |
| 161 base::ASCIIToUTF16(user_info->GetEmail()))); | 186 base::ASCIIToUTF16(user_info->GetEmail()))); |
| 162 } | 187 } |
| 163 #endif | 188 #endif |
| 164 } | 189 } |
| OLD | NEW |