OLD | NEW |
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 Loading... |
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::InitAsBubbleAttachedToAnchor( | 67 void AppListView::InitAsBubbleAttachedToAnchor( |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 void AppListView::Prerender() { | 139 void AppListView::Prerender() { |
140 app_list_main_view_->Prerender(); | 140 app_list_main_view_->Prerender(); |
141 } | 141 } |
142 | 142 |
143 void AppListView::OnSigninStatusChanged() { | 143 void AppListView::OnSigninStatusChanged() { |
144 signin_view_->SetVisible(!model_->signed_in()); | 144 signin_view_->SetVisible(!model_->signed_in()); |
145 app_list_main_view_->SetVisible(model_->signed_in()); | 145 app_list_main_view_->SetVisible(model_->signed_in()); |
146 app_list_main_view_->search_box_view()->InvalidateMenu(); | 146 app_list_main_view_->search_box_view()->InvalidateMenu(); |
147 } | 147 } |
148 | 148 |
| 149 void AppListView::SetProfileByPath(const base::FilePath& profile_path) { |
| 150 delegate_->SetProfileByPath(profile_path); |
| 151 } |
| 152 |
149 void AppListView::AddObserver(Observer* observer) { | 153 void AppListView::AddObserver(Observer* observer) { |
150 observers_.AddObserver(observer); | 154 observers_.AddObserver(observer); |
151 } | 155 } |
152 | 156 |
153 void AppListView::RemoveObserver(Observer* observer) { | 157 void AppListView::RemoveObserver(Observer* observer) { |
154 observers_.RemoveObserver(observer); | 158 observers_.RemoveObserver(observer); |
155 } | 159 } |
156 | 160 |
157 // static | 161 // static |
158 void AppListView::SetNextPaintCallback(const base::Closure& callback) { | 162 void AppListView::SetNextPaintCallback(const base::Closure& callback) { |
(...skipping 22 matching lines...) Expand all Loading... |
181 pagination_model, | 185 pagination_model, |
182 parent); | 186 parent); |
183 AddChildView(app_list_main_view_); | 187 AddChildView(app_list_main_view_); |
184 #if defined(USE_AURA) | 188 #if defined(USE_AURA) |
185 app_list_main_view_->SetPaintToLayer(true); | 189 app_list_main_view_->SetPaintToLayer(true); |
186 app_list_main_view_->SetFillsBoundsOpaquely(false); | 190 app_list_main_view_->SetFillsBoundsOpaquely(false); |
187 app_list_main_view_->layer()->SetMasksToBounds(true); | 191 app_list_main_view_->layer()->SetMasksToBounds(true); |
188 #endif | 192 #endif |
189 | 193 |
190 signin_view_ = new SigninView( | 194 signin_view_ = new SigninView( |
191 GetSigninDelegate(), | 195 delegate_ ? delegate_->GetSigninDelegate() |
| 196 : NULL, |
192 app_list_main_view_->GetPreferredSize().width()); | 197 app_list_main_view_->GetPreferredSize().width()); |
193 AddChildView(signin_view_); | 198 AddChildView(signin_view_); |
194 | 199 |
195 OnSigninStatusChanged(); | 200 OnSigninStatusChanged(); |
196 set_color(kContentsBackgroundColor); | 201 set_color(kContentsBackgroundColor); |
197 set_margins(gfx::Insets()); | 202 set_margins(gfx::Insets()); |
198 set_move_with_anchor(true); | 203 set_move_with_anchor(true); |
199 set_parent_window(parent); | 204 set_parent_window(parent); |
200 set_close_on_deactivate(false); | 205 set_close_on_deactivate(false); |
201 set_close_on_esc(false); | 206 set_close_on_esc(false); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 // We clear the search when hiding so the next time the app list appears it is | 307 // We clear the search when hiding so the next time the app list appears it is |
303 // not showing search results. | 308 // not showing search results. |
304 if (!visible) | 309 if (!visible) |
305 app_list_main_view_->search_box_view()->ClearSearch(); | 310 app_list_main_view_->search_box_view()->ClearSearch(); |
306 | 311 |
307 // Whether we need to signin or not may have changed since last time we were | 312 // Whether we need to signin or not may have changed since last time we were |
308 // shown. | 313 // shown. |
309 Layout(); | 314 Layout(); |
310 } | 315 } |
311 | 316 |
312 SigninDelegate* AppListView::GetSigninDelegate() { | |
313 return delegate_ ? delegate_->GetSigninDelegate() : NULL; | |
314 } | |
315 | |
316 void AppListView::OnAppListModelSigninStatusChanged() { | 317 void AppListView::OnAppListModelSigninStatusChanged() { |
317 OnSigninStatusChanged(); | 318 OnSigninStatusChanged(); |
318 } | 319 } |
319 | 320 |
320 void AppListView::OnAppListModelCurrentUserChanged() { | 321 void AppListView::OnAppListModelUsersChanged() { |
321 OnSigninStatusChanged(); | 322 OnSigninStatusChanged(); |
322 } | 323 } |
323 | 324 |
324 } // namespace app_list | 325 } // namespace app_list |
OLD | NEW |