| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Loading... |
| 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 #if defined(OS_WIN) | 180 #if defined(OS_WIN) |
| 187 HWND AppListView::GetHWND() const { | 181 HWND AppListView::GetHWND() const { |
| 188 #if defined(USE_AURA) | 182 #if defined(USE_AURA) |
| 189 gfx::NativeWindow window = | 183 gfx::NativeWindow window = |
| 190 GetWidget()->GetTopLevelWidget()->GetNativeWindow(); | 184 GetWidget()->GetTopLevelWidget()->GetNativeWindow(); |
| 191 return window->GetRootWindow()->GetAcceleratedWidget(); | 185 return window->GetRootWindow()->GetAcceleratedWidget(); |
| 192 #else | 186 #else |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 // We clear the search when hiding so the next time the app list appears it is | 255 // We clear the search when hiding so the next time the app list appears it is |
| 262 // not showing search results. | 256 // not showing search results. |
| 263 if (!visible) | 257 if (!visible) |
| 264 app_list_main_view_->search_box_view()->ClearSearch(); | 258 app_list_main_view_->search_box_view()->ClearSearch(); |
| 265 | 259 |
| 266 // Whether we need to signin or not may have changed since last time we were | 260 // Whether we need to signin or not may have changed since last time we were |
| 267 // shown. | 261 // shown. |
| 268 Layout(); | 262 Layout(); |
| 269 } | 263 } |
| 270 | 264 |
| 271 void AppListView::OnSigninSuccess() { | |
| 272 OnSigninStatusChanged(); | |
| 273 } | |
| 274 | |
| 275 SigninDelegate* AppListView::GetSigninDelegate() { | 265 SigninDelegate* AppListView::GetSigninDelegate() { |
| 276 return delegate_ ? delegate_->GetSigninDelegate() : NULL; | 266 return delegate_ ? delegate_->GetSigninDelegate() : NULL; |
| 277 } | 267 } |
| 278 | 268 |
| 269 void AppListView::OnAppListModelSigninStatusChanged() { |
| 270 OnSigninStatusChanged(); |
| 271 } |
| 272 |
| 273 void AppListView::OnAppListModelCurrentUserChanged() { |
| 274 OnSigninStatusChanged(); |
| 275 } |
| 276 |
| 279 } // namespace app_list | 277 } // namespace app_list |
| OLD | NEW |