OLD | NEW |
1 // Copyright (c) 2011 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/infobars/after_translate_infobar.h" | 5 #include "chrome/browser/ui/views/infobars/after_translate_infobar.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/translate/translate_infobar_delegate.h" | 8 #include "chrome/browser/translate/translate_infobar_delegate.h" |
9 #include "grit/generated_resources.h" | 9 #include "grit/generated_resources.h" |
10 #include "ui/base/l10n/l10n_util.h" | 10 #include "ui/base/l10n/l10n_util.h" |
11 #include "ui/views/controls/button/menu_button.h" | 11 #include "ui/views/controls/button/menu_button.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 | 157 |
158 void AfterTranslateInfoBar::TargetLanguageChanged() { | 158 void AfterTranslateInfoBar::TargetLanguageChanged() { |
159 // Tests can call this function when the infobar has never been added to a | 159 // Tests can call this function when the infobar has never been added to a |
160 // view hierarchy and thus there is no button. | 160 // view hierarchy and thus there is no button. |
161 if (target_language_menu_button_) { | 161 if (target_language_menu_button_) { |
162 UpdateLanguageButtonText(target_language_menu_button_, | 162 UpdateLanguageButtonText(target_language_menu_button_, |
163 LanguagesMenuModel::TARGET); | 163 LanguagesMenuModel::TARGET); |
164 } | 164 } |
165 } | 165 } |
166 | 166 |
167 void AfterTranslateInfoBar::RunMenu(View* source, const gfx::Point& pt) { | 167 void AfterTranslateInfoBar::OnMenuButtonClicked(views::View* source, |
| 168 const gfx::Point& point) { |
168 if (!owned()) | 169 if (!owned()) |
169 return; // We're closing; don't call anything, it might access the owner. | 170 return; // We're closing; don't call anything, it might access the owner. |
170 ui::MenuModel* menu_model = NULL; | 171 ui::MenuModel* menu_model = NULL; |
171 views::MenuButton* button = NULL; | 172 views::MenuButton* button = NULL; |
172 views::MenuItemView::AnchorPosition anchor = views::MenuItemView::TOPLEFT; | 173 views::MenuItemView::AnchorPosition anchor = views::MenuItemView::TOPLEFT; |
173 if (source == original_language_menu_button_) { | 174 if (source == original_language_menu_button_) { |
174 menu_model = &original_language_menu_model_; | 175 menu_model = &original_language_menu_model_; |
175 button = original_language_menu_button_; | 176 button = original_language_menu_button_; |
176 } else if (source == target_language_menu_button_) { | 177 } else if (source == target_language_menu_button_) { |
177 menu_model = &target_language_menu_model_; | 178 menu_model = &target_language_menu_model_; |
178 button = target_language_menu_button_; | 179 button = target_language_menu_button_; |
179 } else { | 180 } else { |
180 DCHECK_EQ(options_menu_button_, source); | 181 DCHECK_EQ(options_menu_button_, source); |
181 menu_model = &options_menu_model_; | 182 menu_model = &options_menu_model_; |
182 button = options_menu_button_; | 183 button = options_menu_button_; |
183 anchor = views::MenuItemView::TOPRIGHT; | 184 anchor = views::MenuItemView::TOPRIGHT; |
184 } | 185 } |
185 RunMenuAt(menu_model, button, anchor); | 186 RunMenuAt(menu_model, button, anchor); |
186 } | 187 } |
OLD | NEW |