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 "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "base/chromeos/chromeos_version.h" | 8 #include "base/chromeos/chromeos_version.h" |
9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
10 #include "chrome/browser/app_mode/app_mode_utils.h" | 10 #include "chrome/browser/app_mode/app_mode_utils.h" |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 // remote desktop will be activated. However, NativeWidgetWin::Activate() | 166 // remote desktop will be activated. However, NativeWidgetWin::Activate() |
167 // will still bring this browser window to the foreground. We explicitly | 167 // will still bring this browser window to the foreground. We explicitly |
168 // set ourselves as the last active browser window to ensure that we get | 168 // set ourselves as the last active browser window to ensure that we get |
169 // treated as such by the rest of Chrome. | 169 // treated as such by the rest of Chrome. |
170 BrowserList::SetLastActive(browser_view_->browser()); | 170 BrowserList::SetLastActive(browser_view_->browser()); |
171 } | 171 } |
172 Widget::OnNativeWidgetActivationChanged(active); | 172 Widget::OnNativeWidgetActivationChanged(active); |
173 } | 173 } |
174 | 174 |
175 void BrowserFrame::ShowContextMenuForView(views::View* source, | 175 void BrowserFrame::ShowContextMenuForView(views::View* source, |
176 const gfx::Point& p) { | 176 const gfx::Point& p, |
| 177 ui::MenuSourceType source_type) { |
177 if (chrome::IsRunningInForcedAppMode()) | 178 if (chrome::IsRunningInForcedAppMode()) |
178 return; | 179 return; |
179 | 180 |
180 // Only show context menu if point is in unobscured parts of browser, i.e. | 181 // Only show context menu if point is in unobscured parts of browser, i.e. |
181 // if NonClientHitTest returns : | 182 // if NonClientHitTest returns : |
182 // - HTCAPTION: in title bar or unobscured part of tabstrip | 183 // - HTCAPTION: in title bar or unobscured part of tabstrip |
183 // - HTNOWHERE: as the name implies. | 184 // - HTNOWHERE: as the name implies. |
184 gfx::Point point_in_view_coords(p); | 185 gfx::Point point_in_view_coords(p); |
185 views::View::ConvertPointFromScreen(non_client_view(), &point_in_view_coords); | 186 views::View::ConvertPointFromScreen(non_client_view(), &point_in_view_coords); |
186 int hit_test = non_client_view()->NonClientHitTest(point_in_view_coords); | 187 int hit_test = non_client_view()->NonClientHitTest(point_in_view_coords); |
187 if (hit_test == HTCAPTION || hit_test == HTNOWHERE) { | 188 if (hit_test == HTCAPTION || hit_test == HTNOWHERE) { |
188 menu_runner_.reset(new views::MenuRunner(GetSystemMenuModel())); | 189 menu_runner_.reset(new views::MenuRunner(GetSystemMenuModel())); |
189 if (menu_runner_->RunMenuAt(source->GetWidget(), NULL, | 190 if (menu_runner_->RunMenuAt(source->GetWidget(), NULL, |
190 gfx::Rect(p, gfx::Size(0,0)), views::MenuItemView::TOPLEFT, | 191 gfx::Rect(p, gfx::Size(0,0)), views::MenuItemView::TOPLEFT, |
| 192 source_type, |
191 views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU) == | 193 views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU) == |
192 views::MenuRunner::MENU_DELETED) | 194 views::MenuRunner::MENU_DELETED) |
193 return; | 195 return; |
194 } | 196 } |
195 } | 197 } |
196 | 198 |
197 ui::MenuModel* BrowserFrame::GetSystemMenuModel() { | 199 ui::MenuModel* BrowserFrame::GetSystemMenuModel() { |
198 if (!menu_model_builder_.get()) { | 200 if (!menu_model_builder_.get()) { |
199 menu_model_builder_.reset( | 201 menu_model_builder_.reset( |
200 new SystemMenuModelBuilder(browser_view_, browser_view_->browser())); | 202 new SystemMenuModelBuilder(browser_view_, browser_view_->browser())); |
201 menu_model_builder_->Init(); | 203 menu_model_builder_->Init(); |
202 } | 204 } |
203 return menu_model_builder_->menu_model(); | 205 return menu_model_builder_->menu_model(); |
204 } | 206 } |
205 | 207 |
206 AvatarMenuButton* BrowserFrame::GetAvatarMenuButton() { | 208 AvatarMenuButton* BrowserFrame::GetAvatarMenuButton() { |
207 return browser_frame_view_->avatar_button(); | 209 return browser_frame_view_->avatar_button(); |
208 } | 210 } |
209 | 211 |
210 #if !defined(OS_WIN) || defined(USE_AURA) | 212 #if !defined(OS_WIN) || defined(USE_AURA) |
211 bool BrowserFrame::ShouldLeaveOffsetNearTopBorder() { | 213 bool BrowserFrame::ShouldLeaveOffsetNearTopBorder() { |
212 return !IsMaximized(); | 214 return !IsMaximized(); |
213 } | 215 } |
214 #endif // OS_WIN | 216 #endif // OS_WIN |
OLD | NEW |