| OLD | NEW |
| 1 // Copyright (c) 2010 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/views/wrench_menu.h" | 5 #include "chrome/browser/views/wrench_menu.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
| 11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/app/chrome_command_ids.h" | 13 #include "chrome/app/chrome_command_ids.h" |
| 14 #include "chrome/browser/metrics/user_metrics.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/tab_contents/tab_contents.h" | 16 #include "chrome/browser/tab_contents/tab_contents.h" |
| 16 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/common/notification_observer.h" | 18 #include "chrome/common/notification_observer.h" |
| 18 #include "chrome/common/notification_registrar.h" | 19 #include "chrome/common/notification_registrar.h" |
| 19 #include "chrome/common/notification_source.h" | 20 #include "chrome/common/notification_source.h" |
| 20 #include "chrome/common/notification_type.h" | 21 #include "chrome/common/notification_type.h" |
| 21 #include "gfx/canvas.h" | 22 #include "gfx/canvas.h" |
| 22 #include "gfx/canvas_skia.h" | 23 #include "gfx/canvas_skia.h" |
| 23 #include "gfx/skia_util.h" | 24 #include "gfx/skia_util.h" |
| (...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 | 583 |
| 583 void WrenchMenu::RunMenu(views::MenuButton* host) { | 584 void WrenchMenu::RunMenu(views::MenuButton* host) { |
| 584 // Up the ref count while the menu is displaying. This way if the window is | 585 // Up the ref count while the menu is displaying. This way if the window is |
| 585 // deleted while we're running we won't prematurely delete the menu. | 586 // deleted while we're running we won't prematurely delete the menu. |
| 586 // TODO(sky): fix this, the menu should really take ownership of the menu | 587 // TODO(sky): fix this, the menu should really take ownership of the menu |
| 587 // (57890). | 588 // (57890). |
| 588 scoped_refptr<WrenchMenu> dont_delete_while_running(this); | 589 scoped_refptr<WrenchMenu> dont_delete_while_running(this); |
| 589 gfx::Point screen_loc; | 590 gfx::Point screen_loc; |
| 590 views::View::ConvertPointToScreen(host, &screen_loc); | 591 views::View::ConvertPointToScreen(host, &screen_loc); |
| 591 gfx::Rect bounds(screen_loc, host->size()); | 592 gfx::Rect bounds(screen_loc, host->size()); |
| 593 UserMetrics::RecordAction(UserMetricsAction("ShowAppMenu")); |
| 592 root_->RunMenuAt(host->GetWindow()->GetNativeWindow(), host, bounds, | 594 root_->RunMenuAt(host->GetWindow()->GetNativeWindow(), host, bounds, |
| 593 base::i18n::IsRTL() ? MenuItemView::TOPLEFT : MenuItemView::TOPRIGHT, | 595 base::i18n::IsRTL() ? MenuItemView::TOPLEFT : MenuItemView::TOPRIGHT, |
| 594 true); | 596 true); |
| 595 if (selected_menu_model_) | 597 if (selected_menu_model_) |
| 596 selected_menu_model_->ActivatedAt(selected_index_); | 598 selected_menu_model_->ActivatedAt(selected_index_); |
| 597 } | 599 } |
| 598 | 600 |
| 599 bool WrenchMenu::IsItemChecked(int id) const { | 601 bool WrenchMenu::IsItemChecked(int id) const { |
| 600 const Entry& entry = id_to_entry_.find(id)->second; | 602 const Entry& entry = id_to_entry_.find(id)->second; |
| 601 return entry.first->IsItemCheckedAt(entry.second); | 603 return entry.first->IsItemCheckedAt(entry.second); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 } | 706 } |
| 705 | 707 |
| 706 return menu_item; | 708 return menu_item; |
| 707 } | 709 } |
| 708 | 710 |
| 709 void WrenchMenu::CancelAndEvaluate(MenuModel* model, int index) { | 711 void WrenchMenu::CancelAndEvaluate(MenuModel* model, int index) { |
| 710 selected_menu_model_ = model; | 712 selected_menu_model_ = model; |
| 711 selected_index_ = index; | 713 selected_index_ = index; |
| 712 root_->Cancel(); | 714 root_->Cancel(); |
| 713 } | 715 } |
| OLD | NEW |