| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 | 43 |
| 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_->InitModel(model_.get()); |
| 54 model_->AddObserver(this); | 54 model_->AddObserver(this); |
| 55 } | 55 } |
| 56 | 56 |
| 57 AppListView::~AppListView() { | 57 AppListView::~AppListView() { |
| 58 model_->RemoveObserver(this); | 58 model_->RemoveObserver(this); |
| 59 // Models are going away, ensure their references are cleared. | 59 // Models are going away, ensure their references are cleared. |
| 60 RemoveAllChildViews(true); | 60 RemoveAllChildViews(true); |
| 61 } | 61 } |
| 62 | 62 |
| 63 void AppListView::InitAsBubble(gfx::NativeView parent, | 63 void AppListView::InitAsBubble(gfx::NativeView parent, |
| 64 PaginationModel* pagination_model, | 64 PaginationModel* pagination_model, |
| 65 views::View* anchor, | 65 views::View* anchor, |
| 66 const gfx::Point& anchor_point, | 66 const gfx::Point& anchor_point, |
| 67 views::BubbleBorder::Arrow arrow, | 67 views::BubbleBorder::Arrow arrow, |
| 68 bool border_accepts_events) { | 68 bool border_accepts_events) { |
| 69 app_list_main_view_ = new AppListMainView(delegate_.get(), | 69 app_list_main_view_ = new AppListMainView(delegate_.get(), |
| 70 model_.get(), | 70 model_.get(), |
| 71 pagination_model, | 71 pagination_model, |
| 72 anchor); | 72 anchor); |
| 73 AddChildView(app_list_main_view_); | 73 AddChildView(app_list_main_view_); |
| 74 #if defined(USE_AURA) | 74 #if defined(USE_AURA) |
| 75 app_list_main_view_->SetPaintToLayer(true); | 75 app_list_main_view_->SetPaintToLayer(true); |
| 76 app_list_main_view_->SetFillsBoundsOpaquely(false); | 76 app_list_main_view_->SetFillsBoundsOpaquely(false); |
| 77 app_list_main_view_->layer()->SetMasksToBounds(true); | 77 app_list_main_view_->layer()->SetMasksToBounds(true); |
| 78 #endif | 78 #endif |
| 79 | 79 |
| 80 signin_view_ = new SigninView( | 80 signin_view_ = new SigninView( |
| 81 GetSigninDelegate(), | 81 delegate_ ? delegate_->GetSigninDelegate() |
| 82 : NULL, |
| 82 app_list_main_view_->GetPreferredSize().width()); | 83 app_list_main_view_->GetPreferredSize().width()); |
| 83 AddChildView(signin_view_); | 84 AddChildView(signin_view_); |
| 84 | 85 |
| 85 OnSigninStatusChanged(); | 86 OnSigninStatusChanged(); |
| 86 | 87 |
| 87 set_anchor_view(anchor); | 88 set_anchor_view(anchor); |
| 88 set_anchor_rect(gfx::Rect(anchor_point, gfx::Size())); | 89 set_anchor_rect(gfx::Rect(anchor_point, gfx::Size())); |
| 89 set_color(kContentsBackgroundColor); | 90 set_color(kContentsBackgroundColor); |
| 90 set_margins(gfx::Insets()); | 91 set_margins(gfx::Insets()); |
| 91 set_move_with_anchor(true); | 92 set_move_with_anchor(true); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 // We clear the search when hiding so the next time the app list appears it is | 243 // We clear the search when hiding so the next time the app list appears it is |
| 243 // not showing search results. | 244 // not showing search results. |
| 244 if (!visible) | 245 if (!visible) |
| 245 app_list_main_view_->search_box_view()->ClearSearch(); | 246 app_list_main_view_->search_box_view()->ClearSearch(); |
| 246 | 247 |
| 247 // Whether we need to signin or not may have changed since last time we were | 248 // Whether we need to signin or not may have changed since last time we were |
| 248 // shown. | 249 // shown. |
| 249 Layout(); | 250 Layout(); |
| 250 } | 251 } |
| 251 | 252 |
| 252 SigninDelegate* AppListView::GetSigninDelegate() { | |
| 253 return delegate_ ? delegate_->GetSigninDelegate() : NULL; | |
| 254 } | |
| 255 | |
| 256 void AppListView::OnAppListModelSigninStatusChanged() { | 253 void AppListView::OnAppListModelSigninStatusChanged() { |
| 257 OnSigninStatusChanged(); | 254 OnSigninStatusChanged(); |
| 258 } | 255 } |
| 259 | 256 |
| 260 void AppListView::OnAppListModelCurrentUserChanged() { | 257 void AppListView::OnAppListModelCurrentUserChanged() { |
| 261 OnSigninStatusChanged(); | 258 OnSigninStatusChanged(); |
| 262 } | 259 } |
| 263 | 260 |
| 261 void AppListView::OnAppListModelProfileMenuItemsChanged() { |
| 262 OnSigninStatusChanged(); |
| 263 } |
| 264 |
| 264 } // namespace app_list | 265 } // namespace app_list |
| OLD | NEW |