OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_main_view.h" | 5 #include "ui/app_list/views/app_list_main_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 namespace app_list { | 35 namespace app_list { |
36 | 36 |
37 namespace { | 37 namespace { |
38 | 38 |
39 // Border padding space around the bubble contents. | 39 // Border padding space around the bubble contents. |
40 const int kPadding = 1; | 40 const int kPadding = 1; |
41 | 41 |
42 // The maximum allowed time to wait for icon loading in milliseconds. | 42 // The maximum allowed time to wait for icon loading in milliseconds. |
43 const int kMaxIconLoadingWaitTimeInMs = 50; | 43 const int kMaxIconLoadingWaitTimeInMs = 50; |
44 | 44 |
45 // The padding around the search box in the experimental app list. | |
46 const int kSearchBoxViewPadding = 23; | |
47 | |
48 // A view that holds another view and takes its preferred size. This is used for | 45 // A view that holds another view and takes its preferred size. This is used for |
49 // wrapping the search box view so it still gets laid out while hidden. This is | 46 // wrapping the search box view so it still gets laid out while hidden. This is |
50 // a separate class so it can notify the main view on search box visibility | 47 // a separate class so it can notify the main view on search box visibility |
51 // change. | 48 // change. |
52 class SearchBoxContainerView : public views::View { | 49 class SearchBoxContainerView : public views::View { |
53 public: | 50 public: |
54 SearchBoxContainerView(AppListMainView* host, SearchBoxView* search_box) | 51 SearchBoxContainerView(AppListMainView* host, SearchBoxView* search_box) |
55 : host_(host), search_box_(search_box) { | 52 : host_(host), search_box_(search_box) { |
56 SetLayoutManager(new views::FillLayout()); | 53 SetLayoutManager(new views::FillLayout()); |
57 AddChildView(search_box); | 54 AddChildView(search_box); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 contents_view_(NULL), | 115 contents_view_(NULL), |
119 contents_switcher_view_(NULL), | 116 contents_switcher_view_(NULL), |
120 weak_ptr_factory_(this) { | 117 weak_ptr_factory_(this) { |
121 SetLayoutManager( | 118 SetLayoutManager( |
122 new views::BoxLayout(views::BoxLayout::kVertical, kPadding, kPadding, 0)); | 119 new views::BoxLayout(views::BoxLayout::kVertical, kPadding, kPadding, 0)); |
123 | 120 |
124 search_box_view_ = new SearchBoxView(this, delegate); | 121 search_box_view_ = new SearchBoxView(this, delegate); |
125 views::View* container = new SearchBoxContainerView(this, search_box_view_); | 122 views::View* container = new SearchBoxContainerView(this, search_box_view_); |
126 if (switches::IsExperimentalAppListEnabled()) { | 123 if (switches::IsExperimentalAppListEnabled()) { |
127 container->SetBorder( | 124 container->SetBorder( |
128 views::Border::CreateEmptyBorder(kSearchBoxViewPadding, | 125 views::Border::CreateEmptyBorder(kExperimentalWindowPadding, |
129 kSearchBoxViewPadding, | 126 kExperimentalWindowPadding, |
130 0, | 127 0, |
131 kSearchBoxViewPadding)); | 128 kExperimentalWindowPadding)); |
132 } | 129 } |
133 AddChildView(container); | 130 AddChildView(container); |
134 AddContentsViews(); | 131 AddContentsViews(); |
135 | 132 |
136 // Switch the apps grid view to the specified page. | 133 // Switch the apps grid view to the specified page. |
137 app_list::PaginationModel* pagination_model = GetAppsPaginationModel(); | 134 app_list::PaginationModel* pagination_model = GetAppsPaginationModel(); |
138 if (pagination_model->is_valid_page(initial_apps_page)) | 135 if (pagination_model->is_valid_page(initial_apps_page)) |
139 pagination_model->SelectPage(initial_apps_page, false); | 136 pagination_model->SelectPage(initial_apps_page, false); |
140 | 137 |
141 // Starts icon loading early. | 138 // Starts icon loading early. |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 // Resubmit the query via a posted task so that all observers for the | 339 // Resubmit the query via a posted task so that all observers for the |
343 // uninstall notification are notified. | 340 // uninstall notification are notified. |
344 base::MessageLoop::current()->PostTask( | 341 base::MessageLoop::current()->PostTask( |
345 FROM_HERE, | 342 FROM_HERE, |
346 base::Bind(&AppListMainView::QueryChanged, | 343 base::Bind(&AppListMainView::QueryChanged, |
347 weak_ptr_factory_.GetWeakPtr(), | 344 weak_ptr_factory_.GetWeakPtr(), |
348 search_box_view_)); | 345 search_box_view_)); |
349 } | 346 } |
350 | 347 |
351 } // namespace app_list | 348 } // namespace app_list |
OLD | NEW |