| Index: ui/app_list/views/app_list_view.cc
|
| diff --git a/ui/app_list/views/app_list_view.cc b/ui/app_list/views/app_list_view.cc
|
| index c288689919b81144f7c54e485cc01546b37c9018..1ece80d5d34031575400f4e85ee078139129405c 100644
|
| --- a/ui/app_list/views/app_list_view.cc
|
| +++ b/ui/app_list/views/app_list_view.cc
|
| @@ -9,9 +9,11 @@
|
| #include "ui/app_list/app_list_model.h"
|
| #include "ui/app_list/app_list_view_delegate.h"
|
| #include "ui/app_list/pagination_model.h"
|
| +#include "ui/app_list/signin_delegate.h"
|
| #include "ui/app_list/views/app_list_background.h"
|
| #include "ui/app_list/views/app_list_main_view.h"
|
| #include "ui/app_list/views/search_box_view.h"
|
| +#include "ui/app_list/views/signin_view.h"
|
| #include "ui/gfx/insets.h"
|
| #include "ui/gfx/path.h"
|
| #include "ui/gfx/skia_util.h"
|
| @@ -35,12 +37,18 @@ const int kArrowOffset = 10;
|
| AppListView::AppListView(AppListViewDelegate* delegate)
|
| : model_(new AppListModel),
|
| delegate_(delegate),
|
| - app_list_main_view_(NULL) {
|
| + app_list_main_view_(NULL),
|
| + signin_view_(NULL) {
|
| if (delegate_)
|
| delegate_->SetModel(model_.get());
|
| + if (GetSigninDelegate())
|
| + GetSigninDelegate()->AddObserver(this);
|
| }
|
|
|
| AppListView::~AppListView() {
|
| + if (GetSigninDelegate())
|
| + GetSigninDelegate()->RemoveObserver(this);
|
| +
|
| // Models are going away, ensure their references are cleared.
|
| RemoveAllChildViews(true);
|
| }
|
| @@ -51,19 +59,20 @@ void AppListView::InitAsBubble(
|
| views::View* anchor,
|
| const gfx::Point& anchor_point,
|
| views::BubbleBorder::ArrowLocation arrow_location) {
|
| +
|
| app_list_main_view_ = new AppListMainView(delegate_.get(),
|
| model_.get(),
|
| pagination_model,
|
| anchor);
|
| - SetLayoutManager(new views::FillLayout());
|
| -
|
| + AddChildView(app_list_main_view_);
|
| #if defined(USE_AURA)
|
| app_list_main_view_->SetPaintToLayer(true);
|
| app_list_main_view_->SetFillsBoundsOpaquely(false);
|
| app_list_main_view_->layer()->SetMasksToBounds(true);
|
| #endif
|
|
|
| - AddChildView(app_list_main_view_);
|
| + signin_view_ = new SigninView(GetSigninDelegate());
|
| + AddChildView(signin_view_);
|
|
|
| set_anchor_view(anchor);
|
| set_anchor_point(anchor_point);
|
| @@ -121,6 +130,10 @@ void AppListView::UpdateBounds() {
|
| SizeToContents();
|
| }
|
|
|
| +gfx::Size AppListView::GetPreferredSize() {
|
| + return app_list_main_view_->GetPreferredSize();
|
| +}
|
| +
|
| views::View* AppListView::GetInitiallyFocusedView() {
|
| return app_list_main_view_->search_box_view()->search_box();
|
| }
|
| @@ -145,6 +158,22 @@ bool AppListView::AcceleratorPressed(const ui::Accelerator& accelerator) {
|
| return false;
|
| }
|
|
|
| +void AppListView::Layout() {
|
| + if (!signin_view_) {
|
| + app_list_main_view_->SetBounds(0, 0, width(), height());
|
| + return;
|
| + }
|
| +
|
| + if (GetSigninDelegate() && GetSigninDelegate()->NeedSignin()) {
|
| + signin_view_->SetBounds(0, 0, width(), height());
|
| + app_list_main_view_->SetBounds(width(), 0, width(), height());
|
| + return;
|
| + }
|
| +
|
| + signin_view_->SetBounds(-width(), 0, width(), height());
|
| + app_list_main_view_->SetBounds(0, 0, width(), height());
|
| +}
|
| +
|
| void AppListView::OnWidgetClosing(views::Widget* widget) {
|
| BubbleDelegateView::OnWidgetClosing(widget);
|
| if (delegate_.get() && widget == GetWidget())
|
| @@ -159,4 +188,24 @@ void AppListView::OnWidgetActivationChanged(views::Widget* widget,
|
| delegate_->ViewActivationChanged(active);
|
| }
|
|
|
| +void AppListView::OnWidgetVisibilityChanged(views::Widget* widget,
|
| + bool visible) {
|
| + BubbleDelegateView::OnWidgetVisibilityChanged(widget, visible);
|
| +
|
| + if (widget != GetWidget())
|
| + return;
|
| +
|
| + Layout();
|
| + if (visible && GetSigninDelegate() && GetSigninDelegate()->NeedSignin())
|
| + signin_view_->BeginSignin();
|
| +}
|
| +
|
| +void AppListView::OnSigninSuccess() {
|
| + Layout();
|
| +}
|
| +
|
| +SigninDelegate* AppListView::GetSigninDelegate() {
|
| + return delegate_ ? delegate_->GetSigninDelegate() : NULL;
|
| +}
|
| +
|
| } // namespace app_list
|
|
|