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/contents_view.h" | 5 #include "ui/app_list/views/contents_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 pagination_model_.RemoveObserver(this); | 49 pagination_model_.RemoveObserver(this); |
50 if (contents_switcher_view_) | 50 if (contents_switcher_view_) |
51 pagination_model_.RemoveObserver(contents_switcher_view_); | 51 pagination_model_.RemoveObserver(contents_switcher_view_); |
52 } | 52 } |
53 | 53 |
54 void ContentsView::InitNamedPages(AppListModel* model, | 54 void ContentsView::InitNamedPages(AppListModel* model, |
55 AppListViewDelegate* view_delegate) { | 55 AppListViewDelegate* view_delegate) { |
56 DCHECK(model); | 56 DCHECK(model); |
57 | 57 |
58 if (app_list::switches::IsExperimentalAppListEnabled()) { | 58 if (app_list::switches::IsExperimentalAppListEnabled()) { |
59 std::vector<views::View*> custom_page_views = | |
60 view_delegate->CreateCustomPageWebViews(GetLocalBounds().size()); | |
61 for (std::vector<views::View*>::const_iterator it = | |
62 custom_page_views.begin(); | |
63 it != custom_page_views.end(); | |
64 ++it) { | |
65 AddLauncherPage(*it, IDR_APP_LIST_NOTIFICATIONS_ICON); | |
66 } | |
67 | |
68 start_page_view_ = new StartPageView(app_list_main_view_, view_delegate); | 59 start_page_view_ = new StartPageView(app_list_main_view_, view_delegate); |
69 AddLauncherPage( | 60 AddLauncherPage( |
70 start_page_view_, IDR_APP_LIST_SEARCH_ICON, NAMED_PAGE_START); | 61 start_page_view_, IDR_APP_LIST_SEARCH_ICON, NAMED_PAGE_START); |
71 } else { | 62 } else { |
72 search_results_view_ = | 63 search_results_view_ = |
73 new SearchResultListView(app_list_main_view_, view_delegate); | 64 new SearchResultListView(app_list_main_view_, view_delegate); |
74 AddLauncherPage(search_results_view_, 0, NAMED_PAGE_SEARCH_RESULTS); | 65 AddLauncherPage(search_results_view_, 0, NAMED_PAGE_SEARCH_RESULTS); |
75 search_results_view_->SetResults(model->results()); | 66 search_results_view_->SetResults(model->results()); |
76 } | 67 } |
77 | 68 |
78 apps_container_view_ = new AppsContainerView(app_list_main_view_, model); | 69 apps_container_view_ = new AppsContainerView(app_list_main_view_, model); |
79 | 70 |
80 int initial_page_index = AddLauncherPage( | 71 AddLauncherPage( |
81 apps_container_view_, IDR_APP_LIST_APPS_ICON, NAMED_PAGE_APPS); | 72 apps_container_view_, IDR_APP_LIST_APPS_ICON, NAMED_PAGE_APPS); |
82 if (app_list::switches::IsExperimentalAppListEnabled()) | 73 |
83 initial_page_index = GetPageIndexForNamedPage(NAMED_PAGE_START); | 74 if (app_list::switches::IsExperimentalAppListEnabled()) { |
| 75 std::vector<views::View*> custom_page_views = |
| 76 view_delegate->CreateCustomPageWebViews(GetLocalBounds().size()); |
| 77 for (std::vector<views::View*>::const_iterator it = |
| 78 custom_page_views.begin(); |
| 79 it != custom_page_views.end(); |
| 80 ++it) { |
| 81 AddLauncherPage(*it, IDR_APP_LIST_NOTIFICATIONS_ICON); |
| 82 } |
| 83 } |
| 84 |
| 85 int initial_page_index = app_list::switches::IsExperimentalAppListEnabled() |
| 86 ? GetPageIndexForNamedPage(NAMED_PAGE_START) |
| 87 : GetPageIndexForNamedPage(NAMED_PAGE_APPS); |
84 | 88 |
85 page_before_search_ = initial_page_index; | 89 page_before_search_ = initial_page_index; |
86 pagination_model_.SelectPage(initial_page_index, false); | 90 pagination_model_.SelectPage(initial_page_index, false); |
87 | 91 |
88 // Needed to update the main search box visibility. | 92 // Needed to update the main search box visibility. |
89 ActivePageChanged(false); | 93 ActivePageChanged(false); |
90 } | 94 } |
91 | 95 |
92 void ContentsView::CancelDrag() { | 96 void ContentsView::CancelDrag() { |
93 if (apps_container_view_->apps_grid_view()->has_dragged_view()) | 97 if (apps_container_view_->apps_grid_view()->has_dragged_view()) |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 if (std::abs(offset) > kMinScrollToSwitchPage) { | 391 if (std::abs(offset) > kMinScrollToSwitchPage) { |
388 if (!GetAppsPaginationModel()->has_transition()) { | 392 if (!GetAppsPaginationModel()->has_transition()) { |
389 GetAppsPaginationModel()->SelectPageRelative(offset > 0 ? -1 : 1, true); | 393 GetAppsPaginationModel()->SelectPageRelative(offset > 0 ? -1 : 1, true); |
390 } | 394 } |
391 event->SetHandled(); | 395 event->SetHandled(); |
392 event->StopPropagation(); | 396 event->StopPropagation(); |
393 } | 397 } |
394 } | 398 } |
395 | 399 |
396 } // namespace app_list | 400 } // namespace app_list |
OLD | NEW |