| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #if defined(TOOLKIT_USES_GTK) | 7 #if defined(TOOLKIT_USES_GTK) |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 ProfileInfoCache& cache = | 450 ProfileInfoCache& cache = |
| 451 g_browser_process->profile_manager()->GetProfileInfoCache(); | 451 g_browser_process->profile_manager()->GetProfileInfoCache(); |
| 452 if (cache.GetIndexOfProfileWithPath(browser_->profile()->GetPath()) == | 452 if (cache.GetIndexOfProfileWithPath(browser_->profile()->GetPath()) == |
| 453 std::string::npos) { | 453 std::string::npos) { |
| 454 return false; | 454 return false; |
| 455 } | 455 } |
| 456 | 456 |
| 457 return AvatarMenuModel::ShouldShowAvatarMenu(); | 457 return AvatarMenuModel::ShouldShowAvatarMenu(); |
| 458 } | 458 } |
| 459 | 459 |
| 460 bool BrowserView::AcceleratorPressed(const views::Accelerator& accelerator) { | 460 bool BrowserView::AcceleratorPressed(const ui::Accelerator& accelerator) { |
| 461 #if defined(OS_CHROMEOS) | 461 #if defined(OS_CHROMEOS) |
| 462 // If accessibility is enabled, stop speech and return false so that key | 462 // If accessibility is enabled, stop speech and return false so that key |
| 463 // combinations involving Search can be used for extra accessibility | 463 // combinations involving Search can be used for extra accessibility |
| 464 // functionality. | 464 // functionality. |
| 465 if (accelerator.key_code() == ui::VKEY_LWIN && | 465 if (accelerator.key_code() == ui::VKEY_LWIN && |
| 466 g_browser_process->local_state()->GetBoolean( | 466 g_browser_process->local_state()->GetBoolean( |
| 467 prefs::kAccessibilityEnabled)) { | 467 prefs::kAccessibilityEnabled)) { |
| 468 ExtensionTtsController::GetInstance()->Stop(); | 468 ExtensionTtsController::GetInstance()->Stop(); |
| 469 return false; | 469 return false; |
| 470 } | 470 } |
| 471 #endif | 471 #endif |
| 472 | 472 |
| 473 std::map<views::Accelerator, int>::const_iterator iter = | 473 std::map<ui::Accelerator, int>::const_iterator iter = |
| 474 accelerator_table_.find(accelerator); | 474 accelerator_table_.find(accelerator); |
| 475 DCHECK(iter != accelerator_table_.end()); | 475 DCHECK(iter != accelerator_table_.end()); |
| 476 int command_id = iter->second; | 476 int command_id = iter->second; |
| 477 | 477 |
| 478 if (!browser_->block_command_execution()) | 478 if (!browser_->block_command_execution()) |
| 479 UpdateAcceleratorMetrics(accelerator, command_id); | 479 UpdateAcceleratorMetrics(accelerator, command_id); |
| 480 return browser_->ExecuteCommandIfEnabled(command_id); | 480 return browser_->ExecuteCommandIfEnabled(command_id); |
| 481 } | 481 } |
| 482 | 482 |
| 483 bool BrowserView::GetAccelerator(int cmd_id, ui::Accelerator* accelerator) { | 483 bool BrowserView::GetAccelerator(int cmd_id, ui::Accelerator* accelerator) { |
| 484 // The standard Ctrl-X, Ctrl-V and Ctrl-C are not defined as accelerators | 484 // The standard Ctrl-X, Ctrl-V and Ctrl-C are not defined as accelerators |
| 485 // anywhere so we need to check for them explicitly here. | 485 // anywhere so we need to check for them explicitly here. |
| 486 switch (cmd_id) { | 486 switch (cmd_id) { |
| 487 case IDC_CUT: | 487 case IDC_CUT: |
| 488 *accelerator = views::Accelerator(ui::VKEY_X, false, true, false); | 488 *accelerator = ui::Accelerator(ui::VKEY_X, false, true, false); |
| 489 return true; | 489 return true; |
| 490 case IDC_COPY: | 490 case IDC_COPY: |
| 491 *accelerator = views::Accelerator(ui::VKEY_C, false, true, false); | 491 *accelerator = ui::Accelerator(ui::VKEY_C, false, true, false); |
| 492 return true; | 492 return true; |
| 493 case IDC_PASTE: | 493 case IDC_PASTE: |
| 494 *accelerator = views::Accelerator(ui::VKEY_V, false, true, false); | 494 *accelerator = ui::Accelerator(ui::VKEY_V, false, true, false); |
| 495 return true; | 495 return true; |
| 496 } | 496 } |
| 497 // Else, we retrieve the accelerator information from the accelerator table. | 497 // Else, we retrieve the accelerator information from the accelerator table. |
| 498 std::map<views::Accelerator, int>::iterator it = | 498 std::map<ui::Accelerator, int>::iterator it = accelerator_table_.begin(); |
| 499 accelerator_table_.begin(); | |
| 500 for (; it != accelerator_table_.end(); ++it) { | 499 for (; it != accelerator_table_.end(); ++it) { |
| 501 if (it->second == cmd_id) { | 500 if (it->second == cmd_id) { |
| 502 *accelerator = it->first; | 501 *accelerator = it->first; |
| 503 return true; | 502 return true; |
| 504 } | 503 } |
| 505 } | 504 } |
| 506 return false; | 505 return false; |
| 507 } | 506 } |
| 508 | 507 |
| 509 bool BrowserView::ActivateAppModalDialog() const { | 508 bool BrowserView::ActivateAppModalDialog() const { |
| (...skipping 1943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2453 | 2452 |
| 2454 pref_service->SetInteger(prefs::kPluginMessageResponseTimeout, | 2453 pref_service->SetInteger(prefs::kPluginMessageResponseTimeout, |
| 2455 plugin_message_response_timeout); | 2454 plugin_message_response_timeout); |
| 2456 pref_service->SetInteger(prefs::kHungPluginDetectFrequency, | 2455 pref_service->SetInteger(prefs::kHungPluginDetectFrequency, |
| 2457 hung_plugin_detect_freq); | 2456 hung_plugin_detect_freq); |
| 2458 } | 2457 } |
| 2459 #endif | 2458 #endif |
| 2460 } | 2459 } |
| 2461 | 2460 |
| 2462 void BrowserView::UpdateAcceleratorMetrics( | 2461 void BrowserView::UpdateAcceleratorMetrics( |
| 2463 const views::Accelerator& accelerator, int command_id) { | 2462 const ui::Accelerator& accelerator, int command_id) { |
| 2464 const ui::KeyboardCode key_code = accelerator.key_code(); | 2463 const ui::KeyboardCode key_code = accelerator.key_code(); |
| 2465 if (command_id == IDC_HELP_PAGE && key_code == ui::VKEY_F1) | 2464 if (command_id == IDC_HELP_PAGE && key_code == ui::VKEY_F1) |
| 2466 UserMetrics::RecordAction(UserMetricsAction("ShowHelpTabViaF1")); | 2465 UserMetrics::RecordAction(UserMetricsAction("ShowHelpTabViaF1")); |
| 2467 | 2466 |
| 2468 #if defined(OS_CHROMEOS) | 2467 #if defined(OS_CHROMEOS) |
| 2469 // Collect information about the relative popularity of various accelerators | 2468 // Collect information about the relative popularity of various accelerators |
| 2470 // on Chrome OS. | 2469 // on Chrome OS. |
| 2471 switch (command_id) { | 2470 switch (command_id) { |
| 2472 case IDC_BACK: | 2471 case IDC_BACK: |
| 2473 if (key_code == ui::VKEY_BACK) | 2472 if (key_code == ui::VKEY_BACK) |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2610 Bubble::Show(this->GetWidget(), bounds, views::BubbleBorder::TOP_RIGHT, | 2609 Bubble::Show(this->GetWidget(), bounds, views::BubbleBorder::TOP_RIGHT, |
| 2611 views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE, | 2610 views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE, |
| 2612 bubble_view, bubble_view); | 2611 bubble_view, bubble_view); |
| 2613 } | 2612 } |
| 2614 | 2613 |
| 2615 void BrowserView::ShowAvatarBubbleFromAvatarButton() { | 2614 void BrowserView::ShowAvatarBubbleFromAvatarButton() { |
| 2616 AvatarMenuButton* button = frame_->GetAvatarMenuButton(); | 2615 AvatarMenuButton* button = frame_->GetAvatarMenuButton(); |
| 2617 if (button) | 2616 if (button) |
| 2618 button->ShowAvatarBubble(); | 2617 button->ShowAvatarBubble(); |
| 2619 } | 2618 } |
| OLD | NEW |