OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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_view.h" | 5 #include "chrome/browser/ui/views/frame/browser_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1169 return browser_->SupportsWindowFeature(Browser::FEATURE_TOOLBAR) || | 1169 return browser_->SupportsWindowFeature(Browser::FEATURE_TOOLBAR) || |
1170 browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR); | 1170 browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR); |
1171 } | 1171 } |
1172 | 1172 |
1173 gfx::Rect BrowserView::GetRootWindowResizerRect() const { | 1173 gfx::Rect BrowserView::GetRootWindowResizerRect() const { |
1174 // Views does not support resizer rects because they caused page cycler | 1174 // Views does not support resizer rects because they caused page cycler |
1175 // performance regressions when they were added. See crrev.com/9654 | 1175 // performance regressions when they were added. See crrev.com/9654 |
1176 return gfx::Rect(); | 1176 return gfx::Rect(); |
1177 } | 1177 } |
1178 | 1178 |
1179 void BrowserView::DisableInactiveFrame() { | |
1180 #if defined(OS_WIN) && !defined(USE_AURA) | |
1181 frame_->DisableInactiveRendering(); | |
1182 #endif // No tricks are needed to get the right behavior on Linux. | |
1183 } | |
1184 | |
1185 void BrowserView::ConfirmAddSearchProvider(TemplateURL* template_url, | 1179 void BrowserView::ConfirmAddSearchProvider(TemplateURL* template_url, |
1186 Profile* profile) { | 1180 Profile* profile) { |
1187 chrome::EditSearchEngine(GetWidget()->GetNativeWindow(), template_url, NULL, | 1181 chrome::EditSearchEngine(GetWidget()->GetNativeWindow(), template_url, NULL, |
1188 profile); | 1182 profile); |
1189 } | 1183 } |
1190 | 1184 |
1191 void BrowserView::ShowUpdateChromeDialog() { | 1185 void BrowserView::ShowUpdateChromeDialog() { |
1192 UpdateRecommendedMessageBox::Show(GetWidget()->GetNativeWindow()); | 1186 UpdateRecommendedMessageBox::Show(GetWidget()->GetNativeWindow()); |
1193 } | 1187 } |
1194 | 1188 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1320 | 1314 |
1321 bool BrowserView::PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, | 1315 bool BrowserView::PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, |
1322 bool* is_keyboard_shortcut) { | 1316 bool* is_keyboard_shortcut) { |
1323 *is_keyboard_shortcut = false; | 1317 *is_keyboard_shortcut = false; |
1324 | 1318 |
1325 if ((event.type != blink::WebInputEvent::RawKeyDown) && | 1319 if ((event.type != blink::WebInputEvent::RawKeyDown) && |
1326 (event.type != blink::WebInputEvent::KeyUp)) { | 1320 (event.type != blink::WebInputEvent::KeyUp)) { |
1327 return false; | 1321 return false; |
1328 } | 1322 } |
1329 | 1323 |
1330 #if defined(OS_WIN) && !defined(USE_AURA) | |
1331 // As Alt+F4 is the close-app keyboard shortcut, it needs processing | |
1332 // immediately. | |
1333 if (event.windowsKeyCode == ui::VKEY_F4 && | |
1334 event.type == blink::WebInputEvent::RawKeyDown && | |
1335 event.modifiers == NativeWebKeyboardEvent::AltKey) { | |
1336 DefWindowProc(event.os_event.hwnd, event.os_event.message, | |
1337 event.os_event.wParam, event.os_event.lParam); | |
1338 return true; | |
1339 } | |
1340 #endif | |
1341 | |
1342 views::FocusManager* focus_manager = GetFocusManager(); | 1324 views::FocusManager* focus_manager = GetFocusManager(); |
1343 DCHECK(focus_manager); | 1325 DCHECK(focus_manager); |
1344 | 1326 |
1345 if (focus_manager->shortcut_handling_suspended()) | 1327 if (focus_manager->shortcut_handling_suspended()) |
1346 return false; | 1328 return false; |
1347 | 1329 |
1348 ui::Accelerator accelerator( | 1330 ui::Accelerator accelerator( |
1349 static_cast<ui::KeyboardCode>(event.windowsKeyCode), | 1331 static_cast<ui::KeyboardCode>(event.windowsKeyCode), |
1350 content::GetModifiersFromNativeWebKeyboardEvent(event)); | 1332 content::GetModifiersFromNativeWebKeyboardEvent(event)); |
1351 if (event.type == blink::WebInputEvent::KeyUp) | 1333 if (event.type == blink::WebInputEvent::KeyUp) |
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2271 return is_browser_fullscreen; | 2253 return is_browser_fullscreen; |
2272 } else { | 2254 } else { |
2273 return is_browser_fullscreen && IsBrowserTypeNormal(); | 2255 return is_browser_fullscreen && IsBrowserTypeNormal(); |
2274 } | 2256 } |
2275 #else | 2257 #else |
2276 return false; | 2258 return false; |
2277 #endif | 2259 #endif |
2278 } | 2260 } |
2279 | 2261 |
2280 void BrowserView::LoadAccelerators() { | 2262 void BrowserView::LoadAccelerators() { |
2281 #if defined(OS_WIN) && !defined(USE_AURA) | |
2282 HACCEL accelerator_table = AtlLoadAccelerators(IDR_MAINFRAME); | |
2283 DCHECK(accelerator_table); | |
2284 | |
2285 // We have to copy the table to access its contents. | |
2286 int count = CopyAcceleratorTable(accelerator_table, 0, 0); | |
2287 if (count == 0) { | |
2288 // Nothing to do in that case. | |
2289 return; | |
2290 } | |
2291 | |
2292 ACCEL* accelerators = static_cast<ACCEL*>(malloc(sizeof(ACCEL) * count)); | |
2293 CopyAcceleratorTable(accelerator_table, accelerators, count); | |
2294 | |
2295 views::FocusManager* focus_manager = GetFocusManager(); | |
2296 DCHECK(focus_manager); | |
2297 | |
2298 // Let's fill our own accelerator table. | |
2299 for (int i = 0; i < count; ++i) { | |
2300 ui::Accelerator accelerator( | |
2301 static_cast<ui::KeyboardCode>(accelerators[i].key), | |
2302 ui::GetModifiersFromACCEL(accelerators[i])); | |
2303 accelerator_table_[accelerator] = accelerators[i].cmd; | |
2304 | |
2305 // Also register with the focus manager. | |
2306 focus_manager->RegisterAccelerator( | |
2307 accelerator, ui::AcceleratorManager::kNormalPriority, this); | |
2308 } | |
2309 | |
2310 // We don't need the Windows accelerator table anymore. | |
2311 free(accelerators); | |
2312 #else | |
2313 views::FocusManager* focus_manager = GetFocusManager(); | 2263 views::FocusManager* focus_manager = GetFocusManager(); |
2314 DCHECK(focus_manager); | 2264 DCHECK(focus_manager); |
2315 | 2265 |
2316 // Let's fill our own accelerator table. | 2266 // Let's fill our own accelerator table. |
2317 const bool is_app_mode = chrome::IsRunningInForcedAppMode(); | 2267 const bool is_app_mode = chrome::IsRunningInForcedAppMode(); |
2318 const std::vector<chrome::AcceleratorMapping> accelerator_list( | 2268 const std::vector<chrome::AcceleratorMapping> accelerator_list( |
2319 chrome::GetAcceleratorList()); | 2269 chrome::GetAcceleratorList()); |
2320 for (std::vector<chrome::AcceleratorMapping>::const_iterator it = | 2270 for (std::vector<chrome::AcceleratorMapping>::const_iterator it = |
2321 accelerator_list.begin(); it != accelerator_list.end(); ++it) { | 2271 accelerator_list.begin(); it != accelerator_list.end(); ++it) { |
2322 // In app mode, only allow accelerators of white listed commands to pass | 2272 // In app mode, only allow accelerators of white listed commands to pass |
2323 // through. | 2273 // through. |
2324 if (is_app_mode && !chrome::IsCommandAllowedInAppMode(it->command_id)) | 2274 if (is_app_mode && !chrome::IsCommandAllowedInAppMode(it->command_id)) |
2325 continue; | 2275 continue; |
2326 | 2276 |
2327 ui::Accelerator accelerator(it->keycode, it->modifiers); | 2277 ui::Accelerator accelerator(it->keycode, it->modifiers); |
2328 accelerator_table_[accelerator] = it->command_id; | 2278 accelerator_table_[accelerator] = it->command_id; |
2329 | 2279 |
2330 // Also register with the focus manager. | 2280 // Also register with the focus manager. |
2331 focus_manager->RegisterAccelerator( | 2281 focus_manager->RegisterAccelerator( |
2332 accelerator, ui::AcceleratorManager::kNormalPriority, this); | 2282 accelerator, ui::AcceleratorManager::kNormalPriority, this); |
2333 } | 2283 } |
2334 #endif | |
2335 } | 2284 } |
2336 | 2285 |
2337 int BrowserView::GetCommandIDForAppCommandID(int app_command_id) const { | 2286 int BrowserView::GetCommandIDForAppCommandID(int app_command_id) const { |
2338 #if defined(OS_WIN) | 2287 #if defined(OS_WIN) |
2339 switch (app_command_id) { | 2288 switch (app_command_id) { |
2340 // NOTE: The order here matches the APPCOMMAND declaration order in the | 2289 // NOTE: The order here matches the APPCOMMAND declaration order in the |
2341 // Windows headers. | 2290 // Windows headers. |
2342 case APPCOMMAND_BROWSER_BACKWARD: return IDC_BACK; | 2291 case APPCOMMAND_BROWSER_BACKWARD: return IDC_BACK; |
2343 case APPCOMMAND_BROWSER_FORWARD: return IDC_FORWARD; | 2292 case APPCOMMAND_BROWSER_FORWARD: return IDC_FORWARD; |
2344 case APPCOMMAND_BROWSER_REFRESH: return IDC_RELOAD; | 2293 case APPCOMMAND_BROWSER_REFRESH: return IDC_RELOAD; |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2616 !GetLocationBar()->GetOmniboxView()->model()->popup_model()->IsOpen()) { | 2565 !GetLocationBar()->GetOmniboxView()->model()->popup_model()->IsOpen()) { |
2617 gfx::Point icon_bottom( | 2566 gfx::Point icon_bottom( |
2618 toolbar_->location_bar()->GetLocationBarAnchorPoint()); | 2567 toolbar_->location_bar()->GetLocationBarAnchorPoint()); |
2619 ConvertPointToTarget(toolbar_->location_bar(), this, &icon_bottom); | 2568 ConvertPointToTarget(toolbar_->location_bar(), this, &icon_bottom); |
2620 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(NULL)); | 2569 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(NULL)); |
2621 ConvertPointToTarget(infobar_container_, this, &infobar_top); | 2570 ConvertPointToTarget(infobar_container_, this, &infobar_top); |
2622 top_arrow_height = infobar_top.y() - icon_bottom.y(); | 2571 top_arrow_height = infobar_top.y() - icon_bottom.y(); |
2623 } | 2572 } |
2624 return top_arrow_height; | 2573 return top_arrow_height; |
2625 } | 2574 } |
OLD | NEW |