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

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: {background,border}_color fixup and HoverBorderColor 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
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 const SkColor background = background_color(view, state);
198 const SkColor border = border_color(view, state);
197 switch (TypeAdjustedForRTL()) { 199 switch (TypeAdjustedForRTL()) {
198 case LEFT_BUTTON: 200 case LEFT_BUTTON:
199 canvas->FillRect(gfx::Rect(1, 1, w, h - 2), background_color(state)); 201 canvas->FillRect(gfx::Rect(1, 1, w, h - 2), background);
200 canvas->FillRect(gfx::Rect(2, 0, w, 1), border_color(state)); 202 canvas->FillRect(gfx::Rect(2, 0, w, 1), border);
201 canvas->FillRect(gfx::Rect(1, 1, 1, 1), border_color(state)); 203 canvas->FillRect(gfx::Rect(1, 1, 1, 1), border);
202 canvas->FillRect(gfx::Rect(0, 2, 1, h - 4), border_color(state)); 204 canvas->FillRect(gfx::Rect(0, 2, 1, h - 4), border);
203 canvas->FillRect(gfx::Rect(1, h - 2, 1, 1), border_color(state)); 205 canvas->FillRect(gfx::Rect(1, h - 2, 1, 1), border);
204 canvas->FillRect(gfx::Rect(2, h - 1, w, 1), border_color(state)); 206 canvas->FillRect(gfx::Rect(2, h - 1, w, 1), border);
205 break; 207 break;
206 208
207 case CENTER_BUTTON: { 209 case CENTER_BUTTON: {
208 canvas->FillRect(gfx::Rect(1, 1, w - 2, h - 2), 210 canvas->FillRect(gfx::Rect(1, 1, w - 2, h - 2), background);
209 background_color(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 : border_color(view, left_button_->state());
212 canvas->FillRect(gfx::Rect(0, 0, 1, h), left_color); 213 canvas->FillRect(gfx::Rect(0, 0, 1, h), left_color);
213 canvas->FillRect(gfx::Rect(1, 0, w - 2, 1), border_color(state)); 214 canvas->FillRect(gfx::Rect(1, 0, w - 2, 1), border);
214 canvas->FillRect(gfx::Rect(1, h - 1, w - 2, 1), border_color(state)); 215 canvas->FillRect(gfx::Rect(1, h - 1, w - 2, 1),
216 border);
215 SkColor right_color = state != CustomButton::STATE_NORMAL ? 217 SkColor right_color = state != CustomButton::STATE_NORMAL ?
216 border_color(state) : border_color(right_button_->state()); 218 border : border_color(view, right_button_->state());
217 canvas->FillRect(gfx::Rect(w - 1, 0, 1, h), right_color); 219 canvas->FillRect(gfx::Rect(w - 1, 0, 1, h), right_color);
218 break; 220 break;
219 } 221 }
220 222
221 case RIGHT_BUTTON: 223 case RIGHT_BUTTON:
222 canvas->FillRect(gfx::Rect(0, 1, w - 1, h - 2), 224 canvas->FillRect(gfx::Rect(0, 1, w - 1, h - 2), background);
223 background_color(state)); 225 canvas->FillRect(gfx::Rect(0, 0, w - 2, 1), border);
224 canvas->FillRect(gfx::Rect(0, 0, w - 2, 1), border_color(state)); 226 canvas->FillRect(gfx::Rect(w - 2, 1, 1, 1), border);
225 canvas->FillRect(gfx::Rect(w - 2, 1, 1, 1), border_color(state)); 227 canvas->FillRect(gfx::Rect(w - 1, 2, 1, h - 4), border);
226 canvas->FillRect(gfx::Rect(w - 1, 2, 1, h - 4), border_color(state)); 228 canvas->FillRect(gfx::Rect(w - 2, h - 2, 1, 1), border);
227 canvas->FillRect(gfx::Rect(w - 2, h - 2, 1, 1), border_color(state)); 229 canvas->FillRect(gfx::Rect(0, h - 1, w - 2, 1), border);
228 canvas->FillRect(gfx::Rect(0, h - 1, w - 2, 1), border_color(state));
229 break; 230 break;
230 231
231 case SINGLE_BUTTON: 232 case SINGLE_BUTTON:
232 canvas->FillRect(gfx::Rect(1, 1, w - 2, h - 2), 233 canvas->FillRect(gfx::Rect(1, 1, w - 2, h - 2), background);
233 background_color(state)); 234 canvas->FillRect(gfx::Rect(2, 0, w - 4, 1), border);
234 canvas->FillRect(gfx::Rect(2, 0, w - 4, 1), border_color(state)); 235 canvas->FillRect(gfx::Rect(1, 1, 1, 1), border);
235 canvas->FillRect(gfx::Rect(1, 1, 1, 1), border_color(state)); 236 canvas->FillRect(gfx::Rect(0, 2, 1, h - 4), border);
236 canvas->FillRect(gfx::Rect(0, 2, 1, h - 4), border_color(state)); 237 canvas->FillRect(gfx::Rect(1, h - 2, 1, 1), border);
237 canvas->FillRect(gfx::Rect(1, h - 2, 1, 1), border_color(state)); 238 canvas->FillRect(gfx::Rect(2, h - 1, w - 4, 1), border);
238 canvas->FillRect(gfx::Rect(2, h - 1, w - 4, 1), border_color(state)); 239 canvas->FillRect(gfx::Rect(w - 2, 1, 1, 1), border);
239 canvas->FillRect(gfx::Rect(w - 2, 1, 1, 1), border_color(state)); 240 canvas->FillRect(gfx::Rect(w - 1, 2, 1, h - 4), border);
240 canvas->FillRect(gfx::Rect(w - 1, 2, 1, h - 4), border_color(state)); 241 canvas->FillRect(gfx::Rect(w - 2, h - 2, 1, 1), border);
241 canvas->FillRect(gfx::Rect(w - 2, h - 2, 1, 1), border_color(state));
242 break; 242 break;
243 243
244 default: 244 default:
245 NOTREACHED(); 245 NOTREACHED();
246 break; 246 break;
247 } 247 }
248 } 248 }
249 249
250 private: 250 private:
251 static SkColor border_color(CustomButton::ButtonState state) { 251 #if defined(USE_AURA)
Elliot Glaysher 2013/03/18 21:38:21 It's a start, but this #ifdef block still exists.
Bobby Powers 2013/03/19 13:27:01 Done.
252 static SkColor border_color(View* view, CustomButton::ButtonState state) {
253 ui::NativeTheme *theme = view->GetNativeTheme();
254 switch (state) {
255 case CustomButton::STATE_HOVERED:
256 return theme->GetSystemColor(
257 ui::NativeTheme::kColorId_HoverBorderColor);
258 case CustomButton::STATE_PRESSED:
259 return theme->GetSystemColor(
260 ui::NativeTheme::kColorId_FocusedBorderColor);
261 default:
262 return theme->GetSystemColor(
263 ui::NativeTheme::kColorId_MenuBorderColor);
264 }
265 }
266
267 static SkColor background_color(View* view, CustomButton::ButtonState state) {
268 ui::NativeTheme *theme = view->GetNativeTheme();
269 switch (state) {
270 case CustomButton::STATE_HOVERED:
271 return theme->GetSystemColor(
272 ui::NativeTheme::kColorId_HoverMenuItemBackgroundColor);
273 case CustomButton::STATE_PRESSED:
274 return theme->GetSystemColor(
275 ui::NativeTheme::kColorId_FocusedMenuItemBackgroundColor);
276 default:
277 return theme->GetSystemColor(
278 ui::NativeTheme::kColorId_MenuBackgroundColor);
279 }
280 }
281 #else
282 static SkColor border_color(View *view, CustomButton::ButtonState state) {
252 switch (state) { 283 switch (state) {
253 case CustomButton::STATE_HOVERED: return kHotBorderColor; 284 case CustomButton::STATE_HOVERED: return kHotBorderColor;
254 case CustomButton::STATE_PRESSED: return kPushedBorderColor; 285 case CustomButton::STATE_PRESSED: return kPushedBorderColor;
255 default: return kBorderColor; 286 default: return kBorderColor;
256 } 287 }
257 } 288 }
258 289
259 static SkColor background_color(CustomButton::ButtonState state) { 290 static SkColor background_color(View *view, CustomButton::ButtonState state) {
260 switch (state) { 291 switch (state) {
261 case CustomButton::STATE_HOVERED: return kHotBackgroundColor; 292 case CustomButton::STATE_HOVERED: return kHotBackgroundColor;
262 case CustomButton::STATE_PRESSED: return kPushedBackgroundColor; 293 case CustomButton::STATE_PRESSED: return kPushedBackgroundColor;
263 default: return kBackgroundColor; 294 default: return kBackgroundColor;
264 } 295 }
265 } 296 }
297 #endif
266 298
267 static SkColor touch_background_color(CustomButton::ButtonState state) { 299 static SkColor touch_background_color(CustomButton::ButtonState state) {
268 switch (state) { 300 switch (state) {
269 case CustomButton::STATE_HOVERED: return kHotTouchBackgroundColor; 301 case CustomButton::STATE_HOVERED: return kHotTouchBackgroundColor;
270 case CustomButton::STATE_PRESSED: return kPushedTouchBackgroundColor; 302 case CustomButton::STATE_PRESSED: return kPushedTouchBackgroundColor;
271 default: return kTouchBackgroundColor; 303 default: return kTouchBackgroundColor;
272 } 304 }
273 } 305 }
274 306
275 ButtonType TypeAdjustedForRTL() const { 307 ButtonType TypeAdjustedForRTL() const {
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 435
404 } // namespace 436 } // namespace
405 437
406 // CutCopyPasteView ------------------------------------------------------------ 438 // CutCopyPasteView ------------------------------------------------------------
407 439
408 // CutCopyPasteView is the view containing the cut/copy/paste buttons. 440 // CutCopyPasteView is the view containing the cut/copy/paste buttons.
409 class WrenchMenu::CutCopyPasteView : public WrenchMenuView { 441 class WrenchMenu::CutCopyPasteView : public WrenchMenuView {
410 public: 442 public:
411 CutCopyPasteView(WrenchMenu* menu, 443 CutCopyPasteView(WrenchMenu* menu,
412 MenuModel* menu_model, 444 MenuModel* menu_model,
445 View* menu_view,
413 int cut_index, 446 int cut_index,
414 int copy_index, 447 int copy_index,
415 int paste_index) 448 int paste_index)
416 : WrenchMenuView(menu, menu_model) { 449 : WrenchMenuView(menu, menu_model) {
417 LabelButton* cut = CreateAndConfigureButton( 450 LabelButton* cut = CreateAndConfigureButton(
418 IDS_CUT, MenuButtonBackground::LEFT_BUTTON, cut_index, NULL); 451 IDS_CUT, MenuButtonBackground::LEFT_BUTTON, cut_index, NULL);
419 452
420 MenuButtonBackground* copy_background = NULL; 453 MenuButtonBackground* copy_background = NULL;
421 LabelButton* copy = CreateAndConfigureButton( 454 LabelButton* copy = CreateAndConfigureButton(
422 IDS_COPY, MenuButtonBackground::CENTER_BUTTON, copy_index, 455 IDS_COPY, MenuButtonBackground::CENTER_BUTTON, copy_index,
423 &copy_background); 456 &copy_background);
424 457
425 LabelButton* paste = CreateAndConfigureButton( 458 LabelButton* paste = CreateAndConfigureButton(
426 IDS_PASTE, 459 IDS_PASTE,
427 menu_->use_new_menu() && menu_->supports_new_separators_ ? 460 menu_->use_new_menu() && menu_->supports_new_separators_ ?
428 MenuButtonBackground::CENTER_BUTTON : 461 MenuButtonBackground::CENTER_BUTTON :
429 MenuButtonBackground::RIGHT_BUTTON, 462 MenuButtonBackground::RIGHT_BUTTON,
430 paste_index, 463 paste_index,
431 NULL); 464 NULL);
432 if (menu_->use_new_menu()) { 465 if (menu_->use_new_menu()) {
433 cut->SetTextColor(views::Button::STATE_NORMAL, kTouchButtonText); 466 cut->SetTextColor(views::Button::STATE_NORMAL, kTouchButtonText);
434 copy->SetTextColor(views::Button::STATE_NORMAL, kTouchButtonText); 467 copy->SetTextColor(views::Button::STATE_NORMAL, kTouchButtonText);
435 paste->SetTextColor(views::Button::STATE_NORMAL, kTouchButtonText); 468 paste->SetTextColor(views::Button::STATE_NORMAL, kTouchButtonText);
436 } else { 469 } else {
437 SkColor text_color = GetNativeTheme()->GetSystemColor( 470 SkColor text_color = menu_view->GetNativeTheme()->GetSystemColor(
438 ui::NativeTheme::kColorId_EnabledMenuItemForegroundColor); 471 ui::NativeTheme::kColorId_EnabledMenuItemForegroundColor);
439 cut->SetTextColor(views::Button::STATE_NORMAL, text_color); 472 cut->SetTextColor(views::Button::STATE_NORMAL, text_color);
440 copy->SetTextColor(views::Button::STATE_NORMAL, text_color); 473 copy->SetTextColor(views::Button::STATE_NORMAL, text_color);
441 paste->SetTextColor(views::Button::STATE_NORMAL, text_color); 474 paste->SetTextColor(views::Button::STATE_NORMAL, text_color);
442 } 475 }
443 copy_background->SetOtherButtons(cut, paste); 476 copy_background->SetOtherButtons(cut, paste);
444 } 477 }
445 478
446 // Overridden from View. 479 // Overridden from View.
447 virtual gfx::Size GetPreferredSize() OVERRIDE { 480 virtual gfx::Size GetPreferredSize() OVERRIDE {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 static const int kZoomPadding = 6; 514 static const int kZoomPadding = 6;
482 static const int kTouchZoomPadding = 14; 515 static const int kTouchZoomPadding = 14;
483 516
484 // ZoomView contains the various zoom controls: two buttons to increase/decrease 517 // 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 518 // the zoom, a label showing the current zoom percent, and a button to go
486 // full-screen. 519 // full-screen.
487 class WrenchMenu::ZoomView : public WrenchMenuView { 520 class WrenchMenu::ZoomView : public WrenchMenuView {
488 public: 521 public:
489 ZoomView(WrenchMenu* menu, 522 ZoomView(WrenchMenu* menu,
490 MenuModel* menu_model, 523 MenuModel* menu_model,
524 View* menu_view,
491 int decrement_index, 525 int decrement_index,
492 int increment_index, 526 int increment_index,
493 int fullscreen_index) 527 int fullscreen_index)
494 : WrenchMenuView(menu, menu_model), 528 : WrenchMenuView(menu, menu_model),
495 fullscreen_index_(fullscreen_index), 529 fullscreen_index_(fullscreen_index),
496 zoom_callback_(base::Bind(&WrenchMenu::ZoomView::OnZoomLevelChanged, 530 zoom_callback_(base::Bind(&WrenchMenu::ZoomView::OnZoomLevelChanged,
497 base::Unretained(this))), 531 base::Unretained(this))),
498 increment_button_(NULL), 532 increment_button_(NULL),
499 zoom_label_(NULL), 533 zoom_label_(NULL),
500 decrement_button_(NULL), 534 decrement_button_(NULL),
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 572 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
539 IDR_FULLSCREEN_MENU_BUTTON); 573 IDR_FULLSCREEN_MENU_BUTTON);
540 fullscreen_button_->SetImage(ImageButton::STATE_NORMAL, full_screen_image); 574 fullscreen_button_->SetImage(ImageButton::STATE_NORMAL, full_screen_image);
541 if (menu_->use_new_menu()) { 575 if (menu_->use_new_menu()) {
542 zoom_label_->SetEnabledColor(kTouchButtonText); 576 zoom_label_->SetEnabledColor(kTouchButtonText);
543 decrement_button_->SetTextColor(views::Button::STATE_NORMAL, 577 decrement_button_->SetTextColor(views::Button::STATE_NORMAL,
544 kTouchButtonText); 578 kTouchButtonText);
545 increment_button_->SetTextColor(views::Button::STATE_NORMAL, 579 increment_button_->SetTextColor(views::Button::STATE_NORMAL,
546 kTouchButtonText); 580 kTouchButtonText);
547 } else { 581 } else {
548 SkColor enabled_text_color = GetNativeTheme()->GetSystemColor( 582 SkColor enabled_text_color = menu_view->GetNativeTheme()->GetSystemColor(
549 ui::NativeTheme::kColorId_EnabledMenuItemForegroundColor); 583 ui::NativeTheme::kColorId_EnabledMenuItemForegroundColor);
550 zoom_label_->SetEnabledColor(enabled_text_color); 584 zoom_label_->SetEnabledColor(enabled_text_color);
551 decrement_button_->SetTextColor(views::Button::STATE_NORMAL, 585 decrement_button_->SetTextColor(views::Button::STATE_NORMAL,
552 enabled_text_color); 586 enabled_text_color);
553 increment_button_->SetTextColor(views::Button::STATE_NORMAL, 587 increment_button_->SetTextColor(views::Button::STATE_NORMAL,
554 enabled_text_color); 588 enabled_text_color);
555 SkColor disabled_text_color = GetNativeTheme()->GetSystemColor( 589 SkColor disabled_text_color = menu_view->GetNativeTheme()->GetSystemColor(
556 ui::NativeTheme::kColorId_DisabledMenuItemForegroundColor); 590 ui::NativeTheme::kColorId_DisabledMenuItemForegroundColor);
557 decrement_button_->SetTextColor(views::Button::STATE_DISABLED, 591 decrement_button_->SetTextColor(views::Button::STATE_DISABLED,
558 disabled_text_color); 592 disabled_text_color);
559 increment_button_->SetTextColor(views::Button::STATE_DISABLED, 593 increment_button_->SetTextColor(views::Button::STATE_DISABLED,
560 disabled_text_color); 594 disabled_text_color);
561 } 595 }
562 596
563 fullscreen_button_->set_focusable(true); 597 fullscreen_button_->set_focusable(true);
564 fullscreen_button_->set_request_focus_on_press(false); 598 fullscreen_button_->set_request_focus_on_press(false);
565 fullscreen_button_->set_tag(fullscreen_index); 599 fullscreen_button_->set_tag(fullscreen_index);
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 813
780 WrenchMenu::~WrenchMenu() { 814 WrenchMenu::~WrenchMenu() {
781 if (bookmark_menu_delegate_.get()) { 815 if (bookmark_menu_delegate_.get()) {
782 BookmarkModel* model = BookmarkModelFactory::GetForProfile( 816 BookmarkModel* model = BookmarkModelFactory::GetForProfile(
783 browser_->profile()); 817 browser_->profile());
784 if (model) 818 if (model)
785 model->RemoveObserver(this); 819 model->RemoveObserver(this);
786 } 820 }
787 } 821 }
788 822
789 void WrenchMenu::Init(ui::MenuModel* model) { 823 void WrenchMenu::Init(View* view, ui::MenuModel* model) {
790 DCHECK(!root_); 824 DCHECK(!root_);
791 root_ = new MenuItemView(this); 825 root_ = new MenuItemView(this);
792 root_->set_has_icons(true); // We have checks, radios and icons, set this 826 root_->set_has_icons(true); // We have checks, radios and icons, set this
793 // so we get the taller menu style. 827 // so we get the taller menu style.
794 int next_id = 1; 828 int next_id = 1;
795 PopulateMenu(root_, model, &next_id); 829 PopulateMenu(root_, model, view, &next_id);
796 first_bookmark_command_id_ = next_id + 1; 830 first_bookmark_command_id_ = next_id + 1;
797 menu_runner_.reset(new views::MenuRunner(root_)); 831 menu_runner_.reset(new views::MenuRunner(root_));
798 } 832 }
799 833
800 void WrenchMenu::RunMenu(views::MenuButton* host) { 834 void WrenchMenu::RunMenu(views::MenuButton* host) {
801 gfx::Point screen_loc; 835 gfx::Point screen_loc;
802 views::View::ConvertPointToScreen(host, &screen_loc); 836 views::View::ConvertPointToScreen(host, &screen_loc);
803 gfx::Rect bounds(screen_loc, host->size()); 837 gfx::Rect bounds(screen_loc, host->size());
804 content::RecordAction(UserMetricsAction("ShowAppMenu")); 838 content::RecordAction(UserMetricsAction("ShowAppMenu"));
805 if (menu_runner_->RunMenuAt(host->GetWidget(), host, bounds, 839 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. 1059 // menu. Close the menu to avoid have a stale menu on-screen.
1026 root_->Cancel(); 1060 root_->Cancel();
1027 break; 1061 break;
1028 default: 1062 default:
1029 NOTREACHED(); 1063 NOTREACHED();
1030 } 1064 }
1031 } 1065 }
1032 1066
1033 void WrenchMenu::PopulateMenu(MenuItemView* parent, 1067 void WrenchMenu::PopulateMenu(MenuItemView* parent,
1034 MenuModel* model, 1068 MenuModel* model,
1069 View* view,
1035 int* next_id) { 1070 int* next_id) {
1036 for (int i = 0, max = model->GetItemCount(); i < max; ++i) { 1071 for (int i = 0, max = model->GetItemCount(); i < max; ++i) {
1037 // The button container menu items have a special height which we have to 1072 // The button container menu items have a special height which we have to
1038 // use instead of the normal height. 1073 // use instead of the normal height.
1039 int height = 0; 1074 int height = 0;
1040 if (use_new_menu_ && 1075 if (use_new_menu_ &&
1041 (model->GetCommandIdAt(i) == IDC_CUT || 1076 (model->GetCommandIdAt(i) == IDC_CUT ||
1042 model->GetCommandIdAt(i) == IDC_ZOOM_MINUS)) 1077 model->GetCommandIdAt(i) == IDC_ZOOM_MINUS))
1043 height = kMenuItemContainingButtonsHeight; 1078 height = kMenuItemContainingButtonsHeight;
1044 1079
1045 MenuItemView* item = AppendMenuItem( 1080 MenuItemView* item = AppendMenuItem(
1046 parent, model, i, model->GetTypeAt(i), next_id, height); 1081 parent, model, i, model->GetTypeAt(i), next_id, height);
1047 1082
1048 if (model->GetTypeAt(i) == MenuModel::TYPE_SUBMENU) 1083 if (model->GetTypeAt(i) == MenuModel::TYPE_SUBMENU)
1049 PopulateMenu(item, model->GetSubmenuModelAt(i), next_id); 1084 PopulateMenu(item, model->GetSubmenuModelAt(i), view, next_id);
1050 1085
1051 switch (model->GetCommandIdAt(i)) { 1086 switch (model->GetCommandIdAt(i)) {
1052 case IDC_CUT: 1087 case IDC_CUT:
1053 DCHECK_EQ(MenuModel::TYPE_COMMAND, model->GetTypeAt(i)); 1088 DCHECK_EQ(MenuModel::TYPE_COMMAND, model->GetTypeAt(i));
1054 DCHECK_LT(i + 2, max); 1089 DCHECK_LT(i + 2, max);
1055 DCHECK_EQ(IDC_COPY, model->GetCommandIdAt(i + 1)); 1090 DCHECK_EQ(IDC_COPY, model->GetCommandIdAt(i + 1));
1056 DCHECK_EQ(IDC_PASTE, model->GetCommandIdAt(i + 2)); 1091 DCHECK_EQ(IDC_PASTE, model->GetCommandIdAt(i + 2));
1057 item->SetTitle(l10n_util::GetStringUTF16(IDS_EDIT2)); 1092 item->SetTitle(l10n_util::GetStringUTF16(IDS_EDIT2));
1058 item->AddChildView(new CutCopyPasteView(this, model, i, i + 1, i + 2)); 1093 item->AddChildView(new CutCopyPasteView(this, model, view,
1094 i, i + 1, i + 2));
1059 i += 2; 1095 i += 2;
1060 break; 1096 break;
1061 1097
1062 case IDC_ZOOM_MINUS: 1098 case IDC_ZOOM_MINUS:
1063 DCHECK_EQ(MenuModel::TYPE_COMMAND, model->GetTypeAt(i)); 1099 DCHECK_EQ(MenuModel::TYPE_COMMAND, model->GetTypeAt(i));
1064 DCHECK_EQ(IDC_ZOOM_PLUS, model->GetCommandIdAt(i + 1)); 1100 DCHECK_EQ(IDC_ZOOM_PLUS, model->GetCommandIdAt(i + 1));
1065 DCHECK_EQ(IDC_FULLSCREEN, model->GetCommandIdAt(i + 2)); 1101 DCHECK_EQ(IDC_FULLSCREEN, model->GetCommandIdAt(i + 2));
1066 item->SetTitle(l10n_util::GetStringUTF16(IDS_ZOOM_MENU2)); 1102 item->SetTitle(l10n_util::GetStringUTF16(IDS_ZOOM_MENU2));
1067 item->AddChildView(new ZoomView(this, model, i, i + 1, i + 2)); 1103 item->AddChildView(new ZoomView(this, model, view,
1104 i, i + 1, i + 2));
1068 i += 2; 1105 i += 2;
1069 break; 1106 break;
1070 1107
1071 case IDC_BOOKMARKS_MENU: 1108 case IDC_BOOKMARKS_MENU:
1072 DCHECK(!bookmark_menu_); 1109 DCHECK(!bookmark_menu_);
1073 bookmark_menu_ = item; 1110 bookmark_menu_ = item;
1074 break; 1111 break;
1075 1112
1076 case IDC_FEEDBACK: 1113 case IDC_FEEDBACK:
1077 DCHECK(!feedback_menu_item_); 1114 DCHECK(!feedback_menu_item_);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1151 bookmark_menu_delegate_.reset( 1188 bookmark_menu_delegate_.reset(
1152 new BookmarkMenuDelegate(browser_, 1189 new BookmarkMenuDelegate(browser_,
1153 browser_, 1190 browser_,
1154 parent, 1191 parent,
1155 first_bookmark_command_id_)); 1192 first_bookmark_command_id_));
1156 bookmark_menu_delegate_->Init( 1193 bookmark_menu_delegate_->Init(
1157 this, bookmark_menu_, model->bookmark_bar_node(), 0, 1194 this, bookmark_menu_, model->bookmark_bar_node(), 0,
1158 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, 1195 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS,
1159 bookmark_utils::LAUNCH_WRENCH_MENU); 1196 bookmark_utils::LAUNCH_WRENCH_MENU);
1160 } 1197 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698