Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Side by Side Diff: chrome/browser/ui/views/wrench_menu.cc

Issue 12483006: wrench_menu: use NativeTheme colors under aura (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: always use View::GetNativeTheme() Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/views/wrench_menu.h ('k') | ui/native_theme/common_theme.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/wrench_menu.h" 5 #include "chrome/browser/ui/views/wrench_menu.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <set> 9 #include <set>
10 10
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 #if defined(USE_AURA) 180 #if defined(USE_AURA)
181 if (use_new_menu_ && 181 if (use_new_menu_ &&
182 view->GetNativeTheme() == ui::NativeThemeAura::instance()) { 182 view->GetNativeTheme() == ui::NativeThemeAura::instance()) {
183 // Normal buttons get a border drawn on the right side and the rest gets 183 // Normal buttons get a border drawn on the right side and the rest gets
184 // filled in. The left button however does not get a line to combine 184 // filled in. The left button however does not get a line to combine
185 // buttons. 185 // buttons.
186 int border = 0; 186 int border = 0;
187 if (type_ != RIGHT_BUTTON) { 187 if (type_ != RIGHT_BUTTON) {
188 border = 1; 188 border = 1;
189 canvas->FillRect(gfx::Rect(0, 0, border, h), 189 canvas->FillRect(gfx::Rect(0, 0, border, h),
190 border_color(CustomButton::STATE_NORMAL)); 190 border_color(view, CustomButton::STATE_NORMAL));
191 } 191 }
192 canvas->FillRect(gfx::Rect(border, 0, w - border, h), 192 canvas->FillRect(gfx::Rect(border, 0, w - border, h),
193 touch_background_color(state)); 193 touch_background_color(state));
194 return; 194 return;
195 } 195 }
196 #endif 196 #endif
197 switch (TypeAdjustedForRTL()) { 197 switch (TypeAdjustedForRTL()) {
198 case LEFT_BUTTON: 198 case LEFT_BUTTON:
199 canvas->FillRect(gfx::Rect(1, 1, w, h - 2), background_color(state)); 199 canvas->FillRect(gfx::Rect(1, 1, w, h - 2),
200 canvas->FillRect(gfx::Rect(2, 0, w, 1), border_color(state)); 200 background_color(view, state));
Elliot Glaysher 2013/03/18 21:03:39 Please call {background,border}_color(view, state)
Bobby Powers 2013/03/18 21:24:58 Done.
201 canvas->FillRect(gfx::Rect(1, 1, 1, 1), border_color(state)); 201 canvas->FillRect(gfx::Rect(2, 0, w, 1), border_color(view, state));
202 canvas->FillRect(gfx::Rect(0, 2, 1, h - 4), border_color(state)); 202 canvas->FillRect(gfx::Rect(1, 1, 1, 1), border_color(view, state));
203 canvas->FillRect(gfx::Rect(1, h - 2, 1, 1), border_color(state)); 203 canvas->FillRect(gfx::Rect(0, 2, 1, h - 4), border_color(view, state));
204 canvas->FillRect(gfx::Rect(2, h - 1, w, 1), border_color(state)); 204 canvas->FillRect(gfx::Rect(1, h - 2, 1, 1), border_color(view, state));
205 canvas->FillRect(gfx::Rect(2, h - 1, w, 1), border_color(view, state));
205 break; 206 break;
206 207
207 case CENTER_BUTTON: { 208 case CENTER_BUTTON: {
208 canvas->FillRect(gfx::Rect(1, 1, w - 2, h - 2), 209 canvas->FillRect(gfx::Rect(1, 1, w - 2, h - 2),
209 background_color(state)); 210 background_color(view, state));
210 SkColor left_color = state != CustomButton::STATE_NORMAL ? 211 SkColor left_color = state != CustomButton::STATE_NORMAL ?
211 border_color(state) : border_color(left_button_->state()); 212 border_color(view, state) :
213 border_color(view, left_button_->state());
212 canvas->FillRect(gfx::Rect(0, 0, 1, h), left_color); 214 canvas->FillRect(gfx::Rect(0, 0, 1, h), left_color);
213 canvas->FillRect(gfx::Rect(1, 0, w - 2, 1), border_color(state)); 215 canvas->FillRect(gfx::Rect(1, 0, w - 2, 1), border_color(view, state));
214 canvas->FillRect(gfx::Rect(1, h - 1, w - 2, 1), border_color(state)); 216 canvas->FillRect(gfx::Rect(1, h - 1, w - 2, 1),
217 border_color(view, state));
215 SkColor right_color = state != CustomButton::STATE_NORMAL ? 218 SkColor right_color = state != CustomButton::STATE_NORMAL ?
216 border_color(state) : border_color(right_button_->state()); 219 border_color(view, state) :
220 border_color(view, right_button_->state());
217 canvas->FillRect(gfx::Rect(w - 1, 0, 1, h), right_color); 221 canvas->FillRect(gfx::Rect(w - 1, 0, 1, h), right_color);
218 break; 222 break;
219 } 223 }
220 224
221 case RIGHT_BUTTON: 225 case RIGHT_BUTTON:
222 canvas->FillRect(gfx::Rect(0, 1, w - 1, h - 2), 226 canvas->FillRect(gfx::Rect(0, 1, w - 1, h - 2),
223 background_color(state)); 227 background_color(view, state));
224 canvas->FillRect(gfx::Rect(0, 0, w - 2, 1), border_color(state)); 228 canvas->FillRect(gfx::Rect(0, 0, w - 2, 1), border_color(view, state));
225 canvas->FillRect(gfx::Rect(w - 2, 1, 1, 1), border_color(state)); 229 canvas->FillRect(gfx::Rect(w - 2, 1, 1, 1), border_color(view, state));
226 canvas->FillRect(gfx::Rect(w - 1, 2, 1, h - 4), border_color(state)); 230 canvas->FillRect(gfx::Rect(w - 1, 2, 1, h - 4),
227 canvas->FillRect(gfx::Rect(w - 2, h - 2, 1, 1), border_color(state)); 231 border_color(view, state));
228 canvas->FillRect(gfx::Rect(0, h - 1, w - 2, 1), border_color(state)); 232 canvas->FillRect(gfx::Rect(w - 2, h - 2, 1, 1),
233 border_color(view, state));
234 canvas->FillRect(gfx::Rect(0, h - 1, w - 2, 1),
235 border_color(view, state));
229 break; 236 break;
230 237
231 case SINGLE_BUTTON: 238 case SINGLE_BUTTON:
232 canvas->FillRect(gfx::Rect(1, 1, w - 2, h - 2), 239 canvas->FillRect(gfx::Rect(1, 1, w - 2, h - 2),
233 background_color(state)); 240 background_color(view, state));
234 canvas->FillRect(gfx::Rect(2, 0, w - 4, 1), border_color(state)); 241 canvas->FillRect(gfx::Rect(2, 0, w - 4, 1), border_color(view, state));
235 canvas->FillRect(gfx::Rect(1, 1, 1, 1), border_color(state)); 242 canvas->FillRect(gfx::Rect(1, 1, 1, 1), border_color(view, state));
236 canvas->FillRect(gfx::Rect(0, 2, 1, h - 4), border_color(state)); 243 canvas->FillRect(gfx::Rect(0, 2, 1, h - 4), border_color(view, state));
237 canvas->FillRect(gfx::Rect(1, h - 2, 1, 1), border_color(state)); 244 canvas->FillRect(gfx::Rect(1, h - 2, 1, 1), border_color(view, state));
238 canvas->FillRect(gfx::Rect(2, h - 1, w - 4, 1), border_color(state)); 245 canvas->FillRect(gfx::Rect(2, h - 1, w - 4, 1),
239 canvas->FillRect(gfx::Rect(w - 2, 1, 1, 1), border_color(state)); 246 border_color(view, state));
240 canvas->FillRect(gfx::Rect(w - 1, 2, 1, h - 4), border_color(state)); 247 canvas->FillRect(gfx::Rect(w - 2, 1, 1, 1), border_color(view, state));
241 canvas->FillRect(gfx::Rect(w - 2, h - 2, 1, 1), border_color(state)); 248 canvas->FillRect(gfx::Rect(w - 1, 2, 1, h - 4),
249 border_color(view, state));
250 canvas->FillRect(gfx::Rect(w - 2, h - 2, 1, 1),
251 border_color(view, state));
242 break; 252 break;
243 253
244 default: 254 default:
245 NOTREACHED(); 255 NOTREACHED();
246 break; 256 break;
247 } 257 }
248 } 258 }
249 259
250 private: 260 private:
251 static SkColor border_color(CustomButton::ButtonState state) { 261 #if defined(USE_AURA)
262 static SkColor border_color(View* view, CustomButton::ButtonState state) {
Elliot Glaysher 2013/03/18 21:03:39 This block changes the behavior of border_color on
Bobby Powers 2013/03/18 21:24:58 Done.
263 ui::NativeTheme *theme = view->GetNativeTheme();
264 switch (state) {
265 case CustomButton::STATE_HOVERED:
266 return theme->GetSystemColor(
267 ui::NativeTheme::kColorId_UnfocusedBorderColor);
268 case CustomButton::STATE_PRESSED:
269 return theme->GetSystemColor(
270 ui::NativeTheme::kColorId_FocusedBorderColor);
271 default:
272 return theme->GetSystemColor(
273 ui::NativeTheme::kColorId_MenuBorderColor);
274 }
275 }
276
277 static SkColor background_color(View* view, CustomButton::ButtonState state) {
278 ui::NativeTheme *theme = view->GetNativeTheme();
279 switch (state) {
280 case CustomButton::STATE_HOVERED:
281 return theme->GetSystemColor(
282 ui::NativeTheme::kColorId_HoverMenuItemBackgroundColor);
283 case CustomButton::STATE_PRESSED:
284 return theme->GetSystemColor(
285 ui::NativeTheme::kColorId_FocusedMenuItemBackgroundColor);
286 default:
287 return theme->GetSystemColor(
288 ui::NativeTheme::kColorId_MenuBackgroundColor);
289 }
290 }
291 #else
292 static SkColor border_color(View *view, CustomButton::ButtonState state) {
252 switch (state) { 293 switch (state) {
253 case CustomButton::STATE_HOVERED: return kHotBorderColor; 294 case CustomButton::STATE_HOVERED: return kHotBorderColor;
254 case CustomButton::STATE_PRESSED: return kPushedBorderColor; 295 case CustomButton::STATE_PRESSED: return kPushedBorderColor;
255 default: return kBorderColor; 296 default: return kBorderColor;
256 } 297 }
257 } 298 }
258 299
259 static SkColor background_color(CustomButton::ButtonState state) { 300 static SkColor background_color(View *view, CustomButton::ButtonState state) {
260 switch (state) { 301 switch (state) {
261 case CustomButton::STATE_HOVERED: return kHotBackgroundColor; 302 case CustomButton::STATE_HOVERED: return kHotBackgroundColor;
262 case CustomButton::STATE_PRESSED: return kPushedBackgroundColor; 303 case CustomButton::STATE_PRESSED: return kPushedBackgroundColor;
263 default: return kBackgroundColor; 304 default: return kBackgroundColor;
264 } 305 }
265 } 306 }
307 #endif
266 308
267 static SkColor touch_background_color(CustomButton::ButtonState state) { 309 static SkColor touch_background_color(CustomButton::ButtonState state) {
268 switch (state) { 310 switch (state) {
269 case CustomButton::STATE_HOVERED: return kHotTouchBackgroundColor; 311 case CustomButton::STATE_HOVERED: return kHotTouchBackgroundColor;
270 case CustomButton::STATE_PRESSED: return kPushedTouchBackgroundColor; 312 case CustomButton::STATE_PRESSED: return kPushedTouchBackgroundColor;
271 default: return kTouchBackgroundColor; 313 default: return kTouchBackgroundColor;
272 } 314 }
273 } 315 }
274 316
275 ButtonType TypeAdjustedForRTL() const { 317 ButtonType TypeAdjustedForRTL() const {
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 445
404 } // namespace 446 } // namespace
405 447
406 // CutCopyPasteView ------------------------------------------------------------ 448 // CutCopyPasteView ------------------------------------------------------------
407 449
408 // CutCopyPasteView is the view containing the cut/copy/paste buttons. 450 // CutCopyPasteView is the view containing the cut/copy/paste buttons.
409 class WrenchMenu::CutCopyPasteView : public WrenchMenuView { 451 class WrenchMenu::CutCopyPasteView : public WrenchMenuView {
410 public: 452 public:
411 CutCopyPasteView(WrenchMenu* menu, 453 CutCopyPasteView(WrenchMenu* menu,
412 MenuModel* menu_model, 454 MenuModel* menu_model,
455 View* menu_view,
413 int cut_index, 456 int cut_index,
414 int copy_index, 457 int copy_index,
415 int paste_index) 458 int paste_index)
416 : WrenchMenuView(menu, menu_model) { 459 : WrenchMenuView(menu, menu_model) {
417 LabelButton* cut = CreateAndConfigureButton( 460 LabelButton* cut = CreateAndConfigureButton(
418 IDS_CUT, MenuButtonBackground::LEFT_BUTTON, cut_index, NULL); 461 IDS_CUT, MenuButtonBackground::LEFT_BUTTON, cut_index, NULL);
419 462
420 MenuButtonBackground* copy_background = NULL; 463 MenuButtonBackground* copy_background = NULL;
421 LabelButton* copy = CreateAndConfigureButton( 464 LabelButton* copy = CreateAndConfigureButton(
422 IDS_COPY, MenuButtonBackground::CENTER_BUTTON, copy_index, 465 IDS_COPY, MenuButtonBackground::CENTER_BUTTON, copy_index,
423 &copy_background); 466 &copy_background);
424 467
425 LabelButton* paste = CreateAndConfigureButton( 468 LabelButton* paste = CreateAndConfigureButton(
426 IDS_PASTE, 469 IDS_PASTE,
427 menu_->use_new_menu() && menu_->supports_new_separators_ ? 470 menu_->use_new_menu() && menu_->supports_new_separators_ ?
428 MenuButtonBackground::CENTER_BUTTON : 471 MenuButtonBackground::CENTER_BUTTON :
429 MenuButtonBackground::RIGHT_BUTTON, 472 MenuButtonBackground::RIGHT_BUTTON,
430 paste_index, 473 paste_index,
431 NULL); 474 NULL);
432 if (menu_->use_new_menu()) { 475 if (menu_->use_new_menu()) {
433 cut->SetTextColor(views::Button::STATE_NORMAL, kTouchButtonText); 476 cut->SetTextColor(views::Button::STATE_NORMAL, kTouchButtonText);
434 copy->SetTextColor(views::Button::STATE_NORMAL, kTouchButtonText); 477 copy->SetTextColor(views::Button::STATE_NORMAL, kTouchButtonText);
435 paste->SetTextColor(views::Button::STATE_NORMAL, kTouchButtonText); 478 paste->SetTextColor(views::Button::STATE_NORMAL, kTouchButtonText);
436 } else { 479 } else {
437 SkColor text_color = GetNativeTheme()->GetSystemColor( 480 SkColor text_color = menu_view->GetNativeTheme()->GetSystemColor(
438 ui::NativeTheme::kColorId_EnabledMenuItemForegroundColor); 481 ui::NativeTheme::kColorId_EnabledMenuItemForegroundColor);
439 cut->SetTextColor(views::Button::STATE_NORMAL, text_color); 482 cut->SetTextColor(views::Button::STATE_NORMAL, text_color);
440 copy->SetTextColor(views::Button::STATE_NORMAL, text_color); 483 copy->SetTextColor(views::Button::STATE_NORMAL, text_color);
441 paste->SetTextColor(views::Button::STATE_NORMAL, text_color); 484 paste->SetTextColor(views::Button::STATE_NORMAL, text_color);
442 } 485 }
443 copy_background->SetOtherButtons(cut, paste); 486 copy_background->SetOtherButtons(cut, paste);
444 } 487 }
445 488
446 // Overridden from View. 489 // Overridden from View.
447 virtual gfx::Size GetPreferredSize() OVERRIDE { 490 virtual gfx::Size GetPreferredSize() OVERRIDE {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 static const int kZoomPadding = 6; 524 static const int kZoomPadding = 6;
482 static const int kTouchZoomPadding = 14; 525 static const int kTouchZoomPadding = 14;
483 526
484 // ZoomView contains the various zoom controls: two buttons to increase/decrease 527 // ZoomView contains the various zoom controls: two buttons to increase/decrease
485 // the zoom, a label showing the current zoom percent, and a button to go 528 // the zoom, a label showing the current zoom percent, and a button to go
486 // full-screen. 529 // full-screen.
487 class WrenchMenu::ZoomView : public WrenchMenuView { 530 class WrenchMenu::ZoomView : public WrenchMenuView {
488 public: 531 public:
489 ZoomView(WrenchMenu* menu, 532 ZoomView(WrenchMenu* menu,
490 MenuModel* menu_model, 533 MenuModel* menu_model,
534 View* menu_view,
491 int decrement_index, 535 int decrement_index,
492 int increment_index, 536 int increment_index,
493 int fullscreen_index) 537 int fullscreen_index)
494 : WrenchMenuView(menu, menu_model), 538 : WrenchMenuView(menu, menu_model),
495 fullscreen_index_(fullscreen_index), 539 fullscreen_index_(fullscreen_index),
496 zoom_callback_(base::Bind(&WrenchMenu::ZoomView::OnZoomLevelChanged, 540 zoom_callback_(base::Bind(&WrenchMenu::ZoomView::OnZoomLevelChanged,
497 base::Unretained(this))), 541 base::Unretained(this))),
498 increment_button_(NULL), 542 increment_button_(NULL),
499 zoom_label_(NULL), 543 zoom_label_(NULL),
500 decrement_button_(NULL), 544 decrement_button_(NULL),
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 582 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
539 IDR_FULLSCREEN_MENU_BUTTON); 583 IDR_FULLSCREEN_MENU_BUTTON);
540 fullscreen_button_->SetImage(ImageButton::STATE_NORMAL, full_screen_image); 584 fullscreen_button_->SetImage(ImageButton::STATE_NORMAL, full_screen_image);
541 if (menu_->use_new_menu()) { 585 if (menu_->use_new_menu()) {
542 zoom_label_->SetEnabledColor(kTouchButtonText); 586 zoom_label_->SetEnabledColor(kTouchButtonText);
543 decrement_button_->SetTextColor(views::Button::STATE_NORMAL, 587 decrement_button_->SetTextColor(views::Button::STATE_NORMAL,
544 kTouchButtonText); 588 kTouchButtonText);
545 increment_button_->SetTextColor(views::Button::STATE_NORMAL, 589 increment_button_->SetTextColor(views::Button::STATE_NORMAL,
546 kTouchButtonText); 590 kTouchButtonText);
547 } else { 591 } else {
548 SkColor enabled_text_color = GetNativeTheme()->GetSystemColor( 592 SkColor enabled_text_color = menu_view->GetNativeTheme()->GetSystemColor(
549 ui::NativeTheme::kColorId_EnabledMenuItemForegroundColor); 593 ui::NativeTheme::kColorId_EnabledMenuItemForegroundColor);
550 zoom_label_->SetEnabledColor(enabled_text_color); 594 zoom_label_->SetEnabledColor(enabled_text_color);
551 decrement_button_->SetTextColor(views::Button::STATE_NORMAL, 595 decrement_button_->SetTextColor(views::Button::STATE_NORMAL,
552 enabled_text_color); 596 enabled_text_color);
553 increment_button_->SetTextColor(views::Button::STATE_NORMAL, 597 increment_button_->SetTextColor(views::Button::STATE_NORMAL,
554 enabled_text_color); 598 enabled_text_color);
555 SkColor disabled_text_color = GetNativeTheme()->GetSystemColor( 599 SkColor disabled_text_color = menu_view->GetNativeTheme()->GetSystemColor(
556 ui::NativeTheme::kColorId_DisabledMenuItemForegroundColor); 600 ui::NativeTheme::kColorId_DisabledMenuItemForegroundColor);
557 decrement_button_->SetTextColor(views::Button::STATE_DISABLED, 601 decrement_button_->SetTextColor(views::Button::STATE_DISABLED,
558 disabled_text_color); 602 disabled_text_color);
559 increment_button_->SetTextColor(views::Button::STATE_DISABLED, 603 increment_button_->SetTextColor(views::Button::STATE_DISABLED,
560 disabled_text_color); 604 disabled_text_color);
561 } 605 }
562 606
563 fullscreen_button_->set_focusable(true); 607 fullscreen_button_->set_focusable(true);
564 fullscreen_button_->set_request_focus_on_press(false); 608 fullscreen_button_->set_request_focus_on_press(false);
565 fullscreen_button_->set_tag(fullscreen_index); 609 fullscreen_button_->set_tag(fullscreen_index);
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 823
780 WrenchMenu::~WrenchMenu() { 824 WrenchMenu::~WrenchMenu() {
781 if (bookmark_menu_delegate_.get()) { 825 if (bookmark_menu_delegate_.get()) {
782 BookmarkModel* model = BookmarkModelFactory::GetForProfile( 826 BookmarkModel* model = BookmarkModelFactory::GetForProfile(
783 browser_->profile()); 827 browser_->profile());
784 if (model) 828 if (model)
785 model->RemoveObserver(this); 829 model->RemoveObserver(this);
786 } 830 }
787 } 831 }
788 832
789 void WrenchMenu::Init(ui::MenuModel* model) { 833 void WrenchMenu::Init(View* view, ui::MenuModel* model) {
790 DCHECK(!root_); 834 DCHECK(!root_);
791 root_ = new MenuItemView(this); 835 root_ = new MenuItemView(this);
792 root_->set_has_icons(true); // We have checks, radios and icons, set this 836 root_->set_has_icons(true); // We have checks, radios and icons, set this
793 // so we get the taller menu style. 837 // so we get the taller menu style.
794 int next_id = 1; 838 int next_id = 1;
795 PopulateMenu(root_, model, &next_id); 839 PopulateMenu(root_, model, view, &next_id);
796 first_bookmark_command_id_ = next_id + 1; 840 first_bookmark_command_id_ = next_id + 1;
797 menu_runner_.reset(new views::MenuRunner(root_)); 841 menu_runner_.reset(new views::MenuRunner(root_));
798 } 842 }
799 843
800 void WrenchMenu::RunMenu(views::MenuButton* host) { 844 void WrenchMenu::RunMenu(views::MenuButton* host) {
801 gfx::Point screen_loc; 845 gfx::Point screen_loc;
802 views::View::ConvertPointToScreen(host, &screen_loc); 846 views::View::ConvertPointToScreen(host, &screen_loc);
803 gfx::Rect bounds(screen_loc, host->size()); 847 gfx::Rect bounds(screen_loc, host->size());
804 content::RecordAction(UserMetricsAction("ShowAppMenu")); 848 content::RecordAction(UserMetricsAction("ShowAppMenu"));
805 if (menu_runner_->RunMenuAt(host->GetWidget(), host, bounds, 849 if (menu_runner_->RunMenuAt(host->GetWidget(), host, bounds,
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 // menu. Close the menu to avoid have a stale menu on-screen. 1069 // menu. Close the menu to avoid have a stale menu on-screen.
1026 root_->Cancel(); 1070 root_->Cancel();
1027 break; 1071 break;
1028 default: 1072 default:
1029 NOTREACHED(); 1073 NOTREACHED();
1030 } 1074 }
1031 } 1075 }
1032 1076
1033 void WrenchMenu::PopulateMenu(MenuItemView* parent, 1077 void WrenchMenu::PopulateMenu(MenuItemView* parent,
1034 MenuModel* model, 1078 MenuModel* model,
1079 View* view,
1035 int* next_id) { 1080 int* next_id) {
1036 for (int i = 0, max = model->GetItemCount(); i < max; ++i) { 1081 for (int i = 0, max = model->GetItemCount(); i < max; ++i) {
1037 // The button container menu items have a special height which we have to 1082 // The button container menu items have a special height which we have to
1038 // use instead of the normal height. 1083 // use instead of the normal height.
1039 int height = 0; 1084 int height = 0;
1040 if (use_new_menu_ && 1085 if (use_new_menu_ &&
1041 (model->GetCommandIdAt(i) == IDC_CUT || 1086 (model->GetCommandIdAt(i) == IDC_CUT ||
1042 model->GetCommandIdAt(i) == IDC_ZOOM_MINUS)) 1087 model->GetCommandIdAt(i) == IDC_ZOOM_MINUS))
1043 height = kMenuItemContainingButtonsHeight; 1088 height = kMenuItemContainingButtonsHeight;
1044 1089
1045 MenuItemView* item = AppendMenuItem( 1090 MenuItemView* item = AppendMenuItem(
1046 parent, model, i, model->GetTypeAt(i), next_id, height); 1091 parent, model, i, model->GetTypeAt(i), next_id, height);
1047 1092
1048 if (model->GetTypeAt(i) == MenuModel::TYPE_SUBMENU) 1093 if (model->GetTypeAt(i) == MenuModel::TYPE_SUBMENU)
1049 PopulateMenu(item, model->GetSubmenuModelAt(i), next_id); 1094 PopulateMenu(item, model->GetSubmenuModelAt(i), view, next_id);
1050 1095
1051 switch (model->GetCommandIdAt(i)) { 1096 switch (model->GetCommandIdAt(i)) {
1052 case IDC_CUT: 1097 case IDC_CUT:
1053 DCHECK_EQ(MenuModel::TYPE_COMMAND, model->GetTypeAt(i)); 1098 DCHECK_EQ(MenuModel::TYPE_COMMAND, model->GetTypeAt(i));
1054 DCHECK_LT(i + 2, max); 1099 DCHECK_LT(i + 2, max);
1055 DCHECK_EQ(IDC_COPY, model->GetCommandIdAt(i + 1)); 1100 DCHECK_EQ(IDC_COPY, model->GetCommandIdAt(i + 1));
1056 DCHECK_EQ(IDC_PASTE, model->GetCommandIdAt(i + 2)); 1101 DCHECK_EQ(IDC_PASTE, model->GetCommandIdAt(i + 2));
1057 item->SetTitle(l10n_util::GetStringUTF16(IDS_EDIT2)); 1102 item->SetTitle(l10n_util::GetStringUTF16(IDS_EDIT2));
1058 item->AddChildView(new CutCopyPasteView(this, model, i, i + 1, i + 2)); 1103 item->AddChildView(new CutCopyPasteView(this, model, view,
1104 i, i + 1, i + 2));
1059 i += 2; 1105 i += 2;
1060 break; 1106 break;
1061 1107
1062 case IDC_ZOOM_MINUS: 1108 case IDC_ZOOM_MINUS:
1063 DCHECK_EQ(MenuModel::TYPE_COMMAND, model->GetTypeAt(i)); 1109 DCHECK_EQ(MenuModel::TYPE_COMMAND, model->GetTypeAt(i));
1064 DCHECK_EQ(IDC_ZOOM_PLUS, model->GetCommandIdAt(i + 1)); 1110 DCHECK_EQ(IDC_ZOOM_PLUS, model->GetCommandIdAt(i + 1));
1065 DCHECK_EQ(IDC_FULLSCREEN, model->GetCommandIdAt(i + 2)); 1111 DCHECK_EQ(IDC_FULLSCREEN, model->GetCommandIdAt(i + 2));
1066 item->SetTitle(l10n_util::GetStringUTF16(IDS_ZOOM_MENU2)); 1112 item->SetTitle(l10n_util::GetStringUTF16(IDS_ZOOM_MENU2));
1067 item->AddChildView(new ZoomView(this, model, i, i + 1, i + 2)); 1113 item->AddChildView(new ZoomView(this, model, view,
1114 i, i + 1, i + 2));
1068 i += 2; 1115 i += 2;
1069 break; 1116 break;
1070 1117
1071 case IDC_BOOKMARKS_MENU: 1118 case IDC_BOOKMARKS_MENU:
1072 DCHECK(!bookmark_menu_); 1119 DCHECK(!bookmark_menu_);
1073 bookmark_menu_ = item; 1120 bookmark_menu_ = item;
1074 break; 1121 break;
1075 1122
1076 case IDC_FEEDBACK: 1123 case IDC_FEEDBACK:
1077 DCHECK(!feedback_menu_item_); 1124 DCHECK(!feedback_menu_item_);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1151 bookmark_menu_delegate_.reset( 1198 bookmark_menu_delegate_.reset(
1152 new BookmarkMenuDelegate(browser_, 1199 new BookmarkMenuDelegate(browser_,
1153 browser_, 1200 browser_,
1154 parent, 1201 parent,
1155 first_bookmark_command_id_)); 1202 first_bookmark_command_id_));
1156 bookmark_menu_delegate_->Init( 1203 bookmark_menu_delegate_->Init(
1157 this, bookmark_menu_, model->bookmark_bar_node(), 0, 1204 this, bookmark_menu_, model->bookmark_bar_node(), 0,
1158 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, 1205 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS,
1159 bookmark_utils::LAUNCH_WRENCH_MENU); 1206 bookmark_utils::LAUNCH_WRENCH_MENU);
1160 } 1207 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/wrench_menu.h ('k') | ui/native_theme/common_theme.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698