| 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 // active on the users desktop, then none of the windows contained in the | 149 // active on the users desktop, then none of the windows contained in the |
| 150 // remote desktop will be activated. However, NativeWidgetWin::Activate() | 150 // remote desktop will be activated. However, NativeWidgetWin::Activate() |
| 151 // will still bring this browser window to the foreground. We explicitly | 151 // will still bring this browser window to the foreground. We explicitly |
| 152 // set ourselves as the last active browser window to ensure that we get | 152 // set ourselves as the last active browser window to ensure that we get |
| 153 // treated as such by the rest of Chrome. | 153 // treated as such by the rest of Chrome. |
| 154 BrowserList::SetLastActive(browser_view_->browser()); | 154 BrowserList::SetLastActive(browser_view_->browser()); |
| 155 } | 155 } |
| 156 Widget::OnNativeWidgetActivationChanged(active); | 156 Widget::OnNativeWidgetActivationChanged(active); |
| 157 } | 157 } |
| 158 | 158 |
| 159 void BrowserFrame::ShowContextMenuForView(views::View* source, | 159 void BrowserFrame::ShowContextMenuForView( |
| 160 const gfx::Point& p) { | 160 views::View* source, |
| 161 const gfx::Point& p, |
| 162 ui::ContextMenuSourceType source_type) { |
| 161 if (chrome::IsRunningInForcedAppMode()) | 163 if (chrome::IsRunningInForcedAppMode()) |
| 162 return; | 164 return; |
| 163 | 165 |
| 164 // Only show context menu if point is in unobscured parts of browser, i.e. | 166 // Only show context menu if point is in unobscured parts of browser, i.e. |
| 165 // if NonClientHitTest returns : | 167 // if NonClientHitTest returns : |
| 166 // - HTCAPTION: in title bar or unobscured part of tabstrip | 168 // - HTCAPTION: in title bar or unobscured part of tabstrip |
| 167 // - HTNOWHERE: as the name implies. | 169 // - HTNOWHERE: as the name implies. |
| 168 gfx::Point point_in_view_coords(p); | 170 gfx::Point point_in_view_coords(p); |
| 169 views::View::ConvertPointFromScreen(non_client_view(), &point_in_view_coords); | 171 views::View::ConvertPointFromScreen(non_client_view(), &point_in_view_coords); |
| 170 int hit_test = non_client_view()->NonClientHitTest(point_in_view_coords); | 172 int hit_test = non_client_view()->NonClientHitTest(point_in_view_coords); |
| 171 if (hit_test == HTCAPTION || hit_test == HTNOWHERE) { | 173 if (hit_test == HTCAPTION || hit_test == HTNOWHERE) { |
| 172 menu_runner_.reset(new views::MenuRunner(GetSystemMenuModel())); | 174 menu_runner_.reset(new views::MenuRunner(GetSystemMenuModel())); |
| 173 if (menu_runner_->RunMenuAt(source->GetWidget(), NULL, | 175 if (menu_runner_->RunContextMenuAt(source->GetWidget(), NULL, |
| 174 gfx::Rect(p, gfx::Size(0,0)), views::MenuItemView::TOPLEFT, | 176 gfx::Rect(p, gfx::Size(0,0)), source_type, |
| 175 views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU) == | 177 views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU) == |
| 176 views::MenuRunner::MENU_DELETED) | 178 views::MenuRunner::MENU_DELETED) |
| 177 return; | 179 return; |
| 178 } | 180 } |
| 179 } | 181 } |
| 180 | 182 |
| 181 ui::MenuModel* BrowserFrame::GetSystemMenuModel() { | 183 ui::MenuModel* BrowserFrame::GetSystemMenuModel() { |
| 182 if (!menu_model_builder_.get()) { | 184 if (!menu_model_builder_.get()) { |
| 183 menu_model_builder_.reset( | 185 menu_model_builder_.reset( |
| 184 new SystemMenuModelBuilder(browser_view_, browser_view_->browser())); | 186 new SystemMenuModelBuilder(browser_view_, browser_view_->browser())); |
| 185 menu_model_builder_->Init(); | 187 menu_model_builder_->Init(); |
| 186 } | 188 } |
| 187 return menu_model_builder_->menu_model(); | 189 return menu_model_builder_->menu_model(); |
| 188 } | 190 } |
| 189 | 191 |
| 190 AvatarMenuButton* BrowserFrame::GetAvatarMenuButton() { | 192 AvatarMenuButton* BrowserFrame::GetAvatarMenuButton() { |
| 191 return browser_frame_view_->avatar_button(); | 193 return browser_frame_view_->avatar_button(); |
| 192 } | 194 } |
| 193 | 195 |
| 194 #if !defined(OS_WIN) || defined(USE_AURA) | 196 #if !defined(OS_WIN) || defined(USE_AURA) |
| 195 bool BrowserFrame::ShouldLeaveOffsetNearTopBorder() { | 197 bool BrowserFrame::ShouldLeaveOffsetNearTopBorder() { |
| 196 return !IsMaximized(); | 198 return !IsMaximized(); |
| 197 } | 199 } |
| 198 #endif // OS_WIN | 200 #endif // OS_WIN |
| OLD | NEW |