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

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

Issue 20656002: Add profile selector menu to app list. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: small fixups 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 (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 "ui/app_list/views/app_list_view.h" 5 #include "ui/app_list/views/app_list_view.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "ui/app_list/app_list_constants.h" 9 #include "ui/app_list/app_list_constants.h"
10 #include "ui/app_list/app_list_model.h" 10 #include "ui/app_list/app_list_model.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 //////////////////////////////////////////////////////////////////////////////// 44 ////////////////////////////////////////////////////////////////////////////////
45 // AppListView: 45 // AppListView:
46 46
47 AppListView::AppListView(AppListViewDelegate* delegate) 47 AppListView::AppListView(AppListViewDelegate* delegate)
48 : model_(new AppListModel), 48 : model_(new AppListModel),
49 delegate_(delegate), 49 delegate_(delegate),
50 app_list_main_view_(NULL), 50 app_list_main_view_(NULL),
51 signin_view_(NULL) { 51 signin_view_(NULL) {
52 if (delegate_) 52 if (delegate_)
53 delegate_->SetModel(model_.get()); 53 delegate_->InitModel(model_.get());
54 if (GetSigninDelegate()) 54 if (GetSigninDelegate())
55 GetSigninDelegate()->AddObserver(this); 55 GetSigninDelegate()->AddObserver(this);
56 model_->AddObserver(this);
56 } 57 }
57 58
58 AppListView::~AppListView() { 59 AppListView::~AppListView() {
59 if (GetSigninDelegate()) 60 if (GetSigninDelegate())
60 GetSigninDelegate()->RemoveObserver(this); 61 GetSigninDelegate()->RemoveObserver(this);
61 62 model_->RemoveObserver(this);
62 // Models are going away, ensure their references are cleared. 63 // Models are going away, ensure their references are cleared.
63 RemoveAllChildViews(true); 64 RemoveAllChildViews(true);
64 } 65 }
65 66
66 void AppListView::InitAsBubble(gfx::NativeView parent, 67 void AppListView::InitAsBubble(gfx::NativeView parent,
67 PaginationModel* pagination_model, 68 PaginationModel* pagination_model,
68 views::View* anchor, 69 views::View* anchor,
69 const gfx::Point& anchor_point, 70 const gfx::Point& anchor_point,
70 views::BubbleBorder::Arrow arrow, 71 views::BubbleBorder::Arrow arrow,
71 bool border_accepts_events) { 72 bool border_accepts_events) {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 168
168 bool AppListView::ShouldHandleSystemCommands() const { 169 bool AppListView::ShouldHandleSystemCommands() const {
169 return true; 170 return true;
170 } 171 }
171 172
172 void AppListView::Prerender() { 173 void AppListView::Prerender() {
173 app_list_main_view_->Prerender(); 174 app_list_main_view_->Prerender();
174 } 175 }
175 176
176 void AppListView::OnSigninStatusChanged() { 177 void AppListView::OnSigninStatusChanged() {
178 delegate_->UpdateModelWithCurrentProfiles();
koz (OOO until 15th September) 2013/08/02 01:51:16 This would be better if the delegate listened to t
calamity 2013/08/02 09:59:54 Done.
177 const bool needs_signin = 179 const bool needs_signin =
178 GetSigninDelegate() && GetSigninDelegate()->NeedSignin(); 180 GetSigninDelegate() && GetSigninDelegate()->NeedSignin();
179 181
180 signin_view_->SetVisible(needs_signin); 182 signin_view_->SetVisible(needs_signin);
181 app_list_main_view_->SetVisible(!needs_signin); 183 app_list_main_view_->SetVisible(!needs_signin);
182 app_list_main_view_->search_box_view()->InvalidateMenu(); 184 app_list_main_view_->search_box_view()->InvalidateMenu();
183 } 185 }
184 186
185 views::View* AppListView::GetInitiallyFocusedView() { 187 views::View* AppListView::GetInitiallyFocusedView() {
186 return app_list_main_view_->search_box_view()->search_box(); 188 return app_list_main_view_->search_box_view()->search_box();
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 254
253 // Whether we need to signin or not may have changed since last time we were 255 // Whether we need to signin or not may have changed since last time we were
254 // shown. 256 // shown.
255 Layout(); 257 Layout();
256 } 258 }
257 259
258 void AppListView::OnSigninSuccess() { 260 void AppListView::OnSigninSuccess() {
259 OnSigninStatusChanged(); 261 OnSigninStatusChanged();
260 } 262 }
261 263
264 void AppListView::OnAppListModelProfilesChanged() {
265 const bool needs_signin =
266 GetSigninDelegate() && GetSigninDelegate()->NeedSignin();
267
268 signin_view_->SetVisible(needs_signin);
269 app_list_main_view_->SetVisible(!needs_signin);
270 app_list_main_view_->search_box_view()->InvalidateMenu();
271 }
272
262 SigninDelegate* AppListView::GetSigninDelegate() { 273 SigninDelegate* AppListView::GetSigninDelegate() {
263 return delegate_ ? delegate_->GetSigninDelegate() : NULL; 274 return delegate_ ? delegate_->GetSigninDelegate() : NULL;
264 } 275 }
265 276
266 } // namespace app_list 277 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698