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

Side by Side Diff: ui/app_list/views/app_list_menu_views.cc

Issue 20656002: Add profile selector menu to app list. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 4 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "ui/app_list/views/app_list_menu_views.h" 5 #include "ui/app_list/views/app_list_menu_views.h"
6 6
7 #include "grit/ui_resources.h" 7 #include "grit/ui_resources.h"
8 #include "ui/app_list/app_list_view_delegate.h" 8 #include "ui/app_list/app_list_view_delegate.h"
9 #include "ui/base/resource/resource_bundle.h" 9 #include "ui/base/resource/resource_bundle.h"
10 #include "ui/views/controls/button/menu_button.h" 10 #include "ui/views/controls/button/menu_button.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 private: 69 private:
70 DISALLOW_COPY_AND_ASSIGN(CurrentUserView); 70 DISALLOW_COPY_AND_ASSIGN(CurrentUserView);
71 }; 71 };
72 72
73 class CurrentUserMenuItem : public MenuItemView { 73 class CurrentUserMenuItem : public MenuItemView {
74 public: 74 public:
75 CurrentUserMenuItem(MenuItemView* parent, 75 CurrentUserMenuItem(MenuItemView* parent,
76 int id, 76 int id,
77 const base::string16& user_name, 77 const base::string16& user_name,
78 const base::string16& user_email, 78 const base::string16& user_email,
79 const gfx::ImageSkia& icon) 79 const gfx::ImageSkia& icon,
80 : MenuItemView(parent, id, MenuItemView::NORMAL) { 80 MenuItemView::Type type)
81 : MenuItemView(parent, id, type) {
81 AddChildView(new CurrentUserView(user_name, user_email, icon)); 82 AddChildView(new CurrentUserView(user_name, user_email, icon));
82 } 83 }
83 84
84 private: 85 private:
85 DISALLOW_COPY_AND_ASSIGN(CurrentUserMenuItem); 86 DISALLOW_COPY_AND_ASSIGN(CurrentUserMenuItem);
86 }; 87 };
87 88
88 class AppListMenuModelAdapter : public views::MenuModelAdapter { 89 class AppListMenuModelAdapter : public views::MenuModelAdapter {
89 public: 90 public:
90 AppListMenuModelAdapter(ui::MenuModel* menu_model, 91 AppListMenuModelAdapter(ui::MenuModel* menu_model,
(...skipping 12 matching lines...) Expand all
103 int id = model->GetCommandIdAt(index); 104 int id = model->GetCommandIdAt(index);
104 if (id != AppListMenu::CURRENT_USER) 105 if (id != AppListMenu::CURRENT_USER)
105 return MenuModelAdapter::AppendMenuItem(menu, model, index); 106 return MenuModelAdapter::AppendMenuItem(menu, model, index);
106 107
107 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 108 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
108 MenuItemView* item = new CurrentUserMenuItem( 109 MenuItemView* item = new CurrentUserMenuItem(
109 menu, 110 menu,
110 id, 111 id,
111 delegate_->GetCurrentUserName(), 112 delegate_->GetCurrentUserName(),
112 delegate_->GetCurrentUserEmail(), 113 delegate_->GetCurrentUserEmail(),
113 *rb.GetImageSkiaNamed(IDR_APP_LIST_USER_INDICATOR)); 114 *rb.GetImageSkiaNamed(IDR_APP_LIST_USER_INDICATOR),
115 model->GetTypeAt(index) == ui::MenuModel::TYPE_SUBMENU
116 ? MenuItemView::SUBMENU : MenuItemView::NORMAL);
114 menu->CreateSubmenu(); 117 menu->CreateSubmenu();
115 menu->GetSubmenu()->AddChildViewAt(item, index); 118 menu->GetSubmenu()->AddChildViewAt(item, index);
116 return item; 119 return item;
117 } 120 }
118 121
119 private: 122 private:
120 AppListViewDelegate* delegate_; 123 AppListViewDelegate* delegate_;
121 124
122 DISALLOW_COPY_AND_ASSIGN(AppListMenuModelAdapter); 125 DISALLOW_COPY_AND_ASSIGN(AppListMenuModelAdapter);
123 }; 126 };
(...skipping 16 matching lines...) Expand all
140 gfx::Rect(point, gfx::Size()), 143 gfx::Rect(point, gfx::Size()),
141 MenuItemView::TOPRIGHT, 144 MenuItemView::TOPRIGHT,
142 ui::MENU_SOURCE_NONE, 0)); 145 ui::MENU_SOURCE_NONE, 0));
143 } 146 }
144 147
145 void AppListMenuViews::Cancel() { 148 void AppListMenuViews::Cancel() {
146 menu_runner_->Cancel(); 149 menu_runner_->Cancel();
147 } 150 }
148 151
149 } // namespace app_list 152 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698