| 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/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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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_->SetModel(model_.get()); |
| 54 if (GetSigninDelegate()) | 54 model_->AddObserver(this); |
| 55 GetSigninDelegate()->AddObserver(this); | |
| 56 } | 55 } |
| 57 | 56 |
| 58 AppListView::~AppListView() { | 57 AppListView::~AppListView() { |
| 59 if (GetSigninDelegate()) | 58 model_->RemoveObserver(this); |
| 60 GetSigninDelegate()->RemoveObserver(this); | |
| 61 | |
| 62 // Models are going away, ensure their references are cleared. | 59 // Models are going away, ensure their references are cleared. |
| 63 RemoveAllChildViews(true); | 60 RemoveAllChildViews(true); |
| 64 } | 61 } |
| 65 | 62 |
| 66 void AppListView::InitAsBubble(gfx::NativeView parent, | 63 void AppListView::InitAsBubble(gfx::NativeView parent, |
| 67 PaginationModel* pagination_model, | 64 PaginationModel* pagination_model, |
| 68 views::View* anchor, | 65 views::View* anchor, |
| 69 const gfx::Point& anchor_point, | 66 const gfx::Point& anchor_point, |
| 70 views::BubbleBorder::Arrow arrow, | 67 views::BubbleBorder::Arrow arrow, |
| 71 bool border_accepts_events) { | 68 bool border_accepts_events) { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 | 164 |
| 168 bool AppListView::ShouldHandleSystemCommands() const { | 165 bool AppListView::ShouldHandleSystemCommands() const { |
| 169 return true; | 166 return true; |
| 170 } | 167 } |
| 171 | 168 |
| 172 void AppListView::Prerender() { | 169 void AppListView::Prerender() { |
| 173 app_list_main_view_->Prerender(); | 170 app_list_main_view_->Prerender(); |
| 174 } | 171 } |
| 175 | 172 |
| 176 void AppListView::OnSigninStatusChanged() { | 173 void AppListView::OnSigninStatusChanged() { |
| 177 const bool needs_signin = | 174 signin_view_->SetVisible(!model_->signed_in()); |
| 178 GetSigninDelegate() && GetSigninDelegate()->NeedSignin(); | 175 app_list_main_view_->SetVisible(model_->signed_in()); |
| 179 | |
| 180 signin_view_->SetVisible(needs_signin); | |
| 181 app_list_main_view_->SetVisible(!needs_signin); | |
| 182 app_list_main_view_->search_box_view()->InvalidateMenu(); | 176 app_list_main_view_->search_box_view()->InvalidateMenu(); |
| 183 } | 177 } |
| 184 | 178 |
| 185 views::View* AppListView::GetInitiallyFocusedView() { | 179 views::View* AppListView::GetInitiallyFocusedView() { |
| 186 return app_list_main_view_->search_box_view()->search_box(); | 180 return app_list_main_view_->search_box_view()->search_box(); |
| 187 } | 181 } |
| 188 | 182 |
| 189 gfx::ImageSkia AppListView::GetWindowIcon() { | 183 gfx::ImageSkia AppListView::GetWindowIcon() { |
| 190 if (delegate_) | 184 if (delegate_) |
| 191 return delegate_->GetWindowIcon(); | 185 return delegate_->GetWindowIcon(); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 // We clear the search when hiding so the next time the app list appears it is | 242 // We clear the search when hiding so the next time the app list appears it is |
| 249 // not showing search results. | 243 // not showing search results. |
| 250 if (!visible) | 244 if (!visible) |
| 251 app_list_main_view_->search_box_view()->ClearSearch(); | 245 app_list_main_view_->search_box_view()->ClearSearch(); |
| 252 | 246 |
| 253 // Whether we need to signin or not may have changed since last time we were | 247 // Whether we need to signin or not may have changed since last time we were |
| 254 // shown. | 248 // shown. |
| 255 Layout(); | 249 Layout(); |
| 256 } | 250 } |
| 257 | 251 |
| 258 void AppListView::OnSigninSuccess() { | |
| 259 OnSigninStatusChanged(); | |
| 260 } | |
| 261 | |
| 262 SigninDelegate* AppListView::GetSigninDelegate() { | 252 SigninDelegate* AppListView::GetSigninDelegate() { |
| 263 return delegate_ ? delegate_->GetSigninDelegate() : NULL; | 253 return delegate_ ? delegate_->GetSigninDelegate() : NULL; |
| 264 } | 254 } |
| 265 | 255 |
| 256 void AppListView::OnAppListModelSigninStatusChanged() { |
| 257 OnSigninStatusChanged(); |
| 258 } |
| 259 |
| 260 void AppListView::OnAppListModelCurrentUserChanged() { |
| 261 OnSigninStatusChanged(); |
| 262 } |
| 263 |
| 266 } // namespace app_list | 264 } // namespace app_list |
| OLD | NEW |