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

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

Issue 22268009: Move signin status and current user information into AppListModel. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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
« no previous file with comments | « ui/app_list/views/app_list_view.h ('k') | ui/app_list/views/search_box_view.h » ('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 "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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 //////////////////////////////////////////////////////////////////////////////// 45 ////////////////////////////////////////////////////////////////////////////////
46 // AppListView: 46 // AppListView:
47 47
48 AppListView::AppListView(AppListViewDelegate* delegate) 48 AppListView::AppListView(AppListViewDelegate* delegate)
49 : model_(new AppListModel), 49 : model_(new AppListModel),
50 delegate_(delegate), 50 delegate_(delegate),
51 app_list_main_view_(NULL), 51 app_list_main_view_(NULL),
52 signin_view_(NULL) { 52 signin_view_(NULL) {
53 if (delegate_) 53 if (delegate_)
54 delegate_->SetModel(model_.get()); 54 delegate_->SetModel(model_.get());
55 if (GetSigninDelegate()) 55 model_->AddObserver(this);
56 GetSigninDelegate()->AddObserver(this);
57 } 56 }
58 57
59 AppListView::~AppListView() { 58 AppListView::~AppListView() {
60 if (GetSigninDelegate()) 59 model_->RemoveObserver(this);
61 GetSigninDelegate()->RemoveObserver(this);
62
63 // Models are going away, ensure their references are cleared. 60 // Models are going away, ensure their references are cleared.
64 RemoveAllChildViews(true); 61 RemoveAllChildViews(true);
65 } 62 }
66 63
67 void AppListView::InitAsBubble(gfx::NativeView parent, 64 void AppListView::InitAsBubble(gfx::NativeView parent,
68 PaginationModel* pagination_model, 65 PaginationModel* pagination_model,
69 views::View* anchor, 66 views::View* anchor,
70 const gfx::Point& anchor_point, 67 const gfx::Point& anchor_point,
71 views::BubbleBorder::Arrow arrow, 68 views::BubbleBorder::Arrow arrow,
72 bool border_accepts_events) { 69 bool border_accepts_events) {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 165
169 bool AppListView::ShouldHandleSystemCommands() const { 166 bool AppListView::ShouldHandleSystemCommands() const {
170 return true; 167 return true;
171 } 168 }
172 169
173 void AppListView::Prerender() { 170 void AppListView::Prerender() {
174 app_list_main_view_->Prerender(); 171 app_list_main_view_->Prerender();
175 } 172 }
176 173
177 void AppListView::OnSigninStatusChanged() { 174 void AppListView::OnSigninStatusChanged() {
178 const bool needs_signin = 175 signin_view_->SetVisible(!model_->signed_in());
179 GetSigninDelegate() && GetSigninDelegate()->NeedSignin(); 176 app_list_main_view_->SetVisible(model_->signed_in());
180
181 signin_view_->SetVisible(needs_signin);
182 app_list_main_view_->SetVisible(!needs_signin);
183 app_list_main_view_->search_box_view()->InvalidateMenu(); 177 app_list_main_view_->search_box_view()->InvalidateMenu();
184 } 178 }
185 179
186 void AppListView::AddObserver(Observer* observer) { 180 void AppListView::AddObserver(Observer* observer) {
187 observers_.AddObserver(observer); 181 observers_.AddObserver(observer);
188 } 182 }
189 183
190 void AppListView::RemoveObserver(Observer* observer) { 184 void AppListView::RemoveObserver(Observer* observer) {
191 observers_.RemoveObserver(observer); 185 observers_.RemoveObserver(observer);
192 } 186 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 // We clear the search when hiding so the next time the app list appears it is 264 // We clear the search when hiding so the next time the app list appears it is
271 // not showing search results. 265 // not showing search results.
272 if (!visible) 266 if (!visible)
273 app_list_main_view_->search_box_view()->ClearSearch(); 267 app_list_main_view_->search_box_view()->ClearSearch();
274 268
275 // Whether we need to signin or not may have changed since last time we were 269 // Whether we need to signin or not may have changed since last time we were
276 // shown. 270 // shown.
277 Layout(); 271 Layout();
278 } 272 }
279 273
280 void AppListView::OnSigninSuccess() {
281 OnSigninStatusChanged();
282 }
283
284 SigninDelegate* AppListView::GetSigninDelegate() { 274 SigninDelegate* AppListView::GetSigninDelegate() {
285 return delegate_ ? delegate_->GetSigninDelegate() : NULL; 275 return delegate_ ? delegate_->GetSigninDelegate() : NULL;
286 } 276 }
287 277
278 void AppListView::OnAppListModelSigninStatusChanged() {
279 OnSigninStatusChanged();
280 }
281
282 void AppListView::OnAppListModelCurrentUserChanged() {
283 OnSigninStatusChanged();
284 }
285
288 } // namespace app_list 286 } // namespace app_list
OLDNEW
« no previous file with comments | « ui/app_list/views/app_list_view.h ('k') | ui/app_list/views/search_box_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698