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

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: rebase, remove dead code in app_list_menu_views, add ui assets Created 7 years, 3 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/callback.h" 7 #include "base/callback.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "ui/app_list/app_list_constants.h" 10 #include "ui/app_list/app_list_constants.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 //////////////////////////////////////////////////////////////////////////////// 48 ////////////////////////////////////////////////////////////////////////////////
49 // AppListView: 49 // AppListView:
50 50
51 AppListView::AppListView(AppListViewDelegate* delegate) 51 AppListView::AppListView(AppListViewDelegate* delegate)
52 : model_(new AppListModel), 52 : model_(new AppListModel),
53 delegate_(delegate), 53 delegate_(delegate),
54 app_list_main_view_(NULL), 54 app_list_main_view_(NULL),
55 signin_view_(NULL) { 55 signin_view_(NULL) {
56 if (delegate_) 56 if (delegate_)
57 delegate_->SetModel(model_.get()); 57 delegate_->InitModel(model_.get());
58 model_->AddObserver(this); 58 model_->AddObserver(this);
59 } 59 }
60 60
61 AppListView::~AppListView() { 61 AppListView::~AppListView() {
62 model_->RemoveObserver(this); 62 model_->RemoveObserver(this);
63 // Models are going away, ensure their references are cleared. 63 // Models are going away, ensure their references are cleared.
64 RemoveAllChildViews(true); 64 RemoveAllChildViews(true);
65 } 65 }
66 66
67 void AppListView::InitAsBubble(gfx::NativeView parent, 67 void AppListView::InitAsBubble(gfx::NativeView parent,
68 PaginationModel* pagination_model, 68 PaginationModel* pagination_model,
69 views::View* anchor, 69 views::View* anchor,
70 const gfx::Point& anchor_point, 70 const gfx::Point& anchor_point,
71 views::BubbleBorder::Arrow arrow, 71 views::BubbleBorder::Arrow arrow,
72 bool border_accepts_events) { 72 bool border_accepts_events) {
73 app_list_main_view_ = new AppListMainView(delegate_.get(), 73 app_list_main_view_ = new AppListMainView(delegate_.get(),
74 model_.get(), 74 model_.get(),
75 pagination_model, 75 pagination_model,
76 parent); 76 parent);
77 AddChildView(app_list_main_view_); 77 AddChildView(app_list_main_view_);
78 #if defined(USE_AURA) 78 #if defined(USE_AURA)
79 app_list_main_view_->SetPaintToLayer(true); 79 app_list_main_view_->SetPaintToLayer(true);
80 app_list_main_view_->SetFillsBoundsOpaquely(false); 80 app_list_main_view_->SetFillsBoundsOpaquely(false);
81 app_list_main_view_->layer()->SetMasksToBounds(true); 81 app_list_main_view_->layer()->SetMasksToBounds(true);
82 #endif 82 #endif
83 83
84 signin_view_ = new SigninView( 84 signin_view_ = new SigninView(
85 GetSigninDelegate(), 85 delegate_ ? delegate_->GetSigninDelegate()
86 : NULL,
86 app_list_main_view_->GetPreferredSize().width()); 87 app_list_main_view_->GetPreferredSize().width());
87 AddChildView(signin_view_); 88 AddChildView(signin_view_);
88 89
89 OnSigninStatusChanged(); 90 OnSigninStatusChanged();
90 91
91 set_anchor_view(anchor); 92 set_anchor_view(anchor);
92 set_anchor_rect(gfx::Rect(anchor_point, gfx::Size())); 93 set_anchor_rect(gfx::Rect(anchor_point, gfx::Size()));
93 set_color(kContentsBackgroundColor); 94 set_color(kContentsBackgroundColor);
94 set_margins(gfx::Insets()); 95 set_margins(gfx::Insets());
95 set_move_with_anchor(true); 96 set_move_with_anchor(true);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 void AppListView::Prerender() { 182 void AppListView::Prerender() {
182 app_list_main_view_->Prerender(); 183 app_list_main_view_->Prerender();
183 } 184 }
184 185
185 void AppListView::OnSigninStatusChanged() { 186 void AppListView::OnSigninStatusChanged() {
186 signin_view_->SetVisible(!model_->signed_in()); 187 signin_view_->SetVisible(!model_->signed_in());
187 app_list_main_view_->SetVisible(model_->signed_in()); 188 app_list_main_view_->SetVisible(model_->signed_in());
188 app_list_main_view_->search_box_view()->InvalidateMenu(); 189 app_list_main_view_->search_box_view()->InvalidateMenu();
189 } 190 }
190 191
192 void AppListView::SetProfileByPath(const base::FilePath& profile_path) {
193 delegate_->SetProfileByPath(profile_path);
194 }
195
191 void AppListView::AddObserver(Observer* observer) { 196 void AppListView::AddObserver(Observer* observer) {
192 observers_.AddObserver(observer); 197 observers_.AddObserver(observer);
193 } 198 }
194 199
195 void AppListView::RemoveObserver(Observer* observer) { 200 void AppListView::RemoveObserver(Observer* observer) {
196 observers_.RemoveObserver(observer); 201 observers_.RemoveObserver(observer);
197 } 202 }
198 203
199 // static 204 // static
200 void AppListView::SetNextPaintCallback(const base::Closure& callback) { 205 void AppListView::SetNextPaintCallback(const base::Closure& callback) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 // We clear the search when hiding so the next time the app list appears it is 285 // We clear the search when hiding so the next time the app list appears it is
281 // not showing search results. 286 // not showing search results.
282 if (!visible) 287 if (!visible)
283 app_list_main_view_->search_box_view()->ClearSearch(); 288 app_list_main_view_->search_box_view()->ClearSearch();
284 289
285 // Whether we need to signin or not may have changed since last time we were 290 // Whether we need to signin or not may have changed since last time we were
286 // shown. 291 // shown.
287 Layout(); 292 Layout();
288 } 293 }
289 294
290 SigninDelegate* AppListView::GetSigninDelegate() {
291 return delegate_ ? delegate_->GetSigninDelegate() : NULL;
292 }
293
294 void AppListView::OnAppListModelSigninStatusChanged() { 295 void AppListView::OnAppListModelSigninStatusChanged() {
295 OnSigninStatusChanged(); 296 OnSigninStatusChanged();
296 } 297 }
297 298
298 void AppListView::OnAppListModelCurrentUserChanged() { 299 void AppListView::OnAppListModelUsersChanged() {
299 OnSigninStatusChanged(); 300 OnSigninStatusChanged();
300 } 301 }
301 302
302 } // namespace app_list 303 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698