| 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 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "grit/ui_resources.h" | 10 #include "grit/ui_resources.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 : search_results_view_(NULL), | 39 : search_results_view_(NULL), |
| 40 start_page_view_(NULL), | 40 start_page_view_(NULL), |
| 41 app_list_main_view_(app_list_main_view), | 41 app_list_main_view_(app_list_main_view), |
| 42 contents_switcher_view_(NULL), | 42 contents_switcher_view_(NULL), |
| 43 view_model_(new views::ViewModel) { | 43 view_model_(new views::ViewModel) { |
| 44 pagination_model_.AddObserver(this); | 44 pagination_model_.AddObserver(this); |
| 45 } | 45 } |
| 46 | 46 |
| 47 ContentsView::~ContentsView() { | 47 ContentsView::~ContentsView() { |
| 48 pagination_model_.RemoveObserver(this); | 48 pagination_model_.RemoveObserver(this); |
| 49 if (contents_switcher_view_) |
| 50 pagination_model_.RemoveObserver(contents_switcher_view_); |
| 49 } | 51 } |
| 50 | 52 |
| 51 void ContentsView::InitNamedPages(AppListModel* model, | 53 void ContentsView::InitNamedPages(AppListModel* model, |
| 52 AppListViewDelegate* view_delegate) { | 54 AppListViewDelegate* view_delegate) { |
| 53 DCHECK(model); | 55 DCHECK(model); |
| 54 | 56 |
| 55 if (app_list::switches::IsExperimentalAppListEnabled()) { | 57 if (app_list::switches::IsExperimentalAppListEnabled()) { |
| 56 views::View* custom_page_view = | 58 views::View* custom_page_view = |
| 57 view_delegate->CreateCustomPageWebView(GetLocalBounds().size()); | 59 view_delegate->CreateCustomPageWebView(GetLocalBounds().size()); |
| 58 if (custom_page_view) | 60 if (custom_page_view) |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 apps_container_view_->app_list_folder_view()->items_grid_view()->EndDrag( | 92 apps_container_view_->app_list_folder_view()->items_grid_view()->EndDrag( |
| 91 true); | 93 true); |
| 92 } | 94 } |
| 93 } | 95 } |
| 94 | 96 |
| 95 void ContentsView::SetDragAndDropHostOfCurrentAppList( | 97 void ContentsView::SetDragAndDropHostOfCurrentAppList( |
| 96 ApplicationDragAndDropHost* drag_and_drop_host) { | 98 ApplicationDragAndDropHost* drag_and_drop_host) { |
| 97 apps_container_view_->SetDragAndDropHostOfCurrentAppList(drag_and_drop_host); | 99 apps_container_view_->SetDragAndDropHostOfCurrentAppList(drag_and_drop_host); |
| 98 } | 100 } |
| 99 | 101 |
| 102 void ContentsView::set_contents_switcher_view( |
| 103 ContentsSwitcherView* contents_switcher_view) { |
| 104 contents_switcher_view_ = contents_switcher_view; |
| 105 if (contents_switcher_view_) |
| 106 pagination_model_.AddObserver(contents_switcher_view_); |
| 107 } |
| 108 |
| 100 void ContentsView::SetActivePage(int page_index) { | 109 void ContentsView::SetActivePage(int page_index) { |
| 101 if (GetActivePageIndex() == page_index) | 110 if (GetActivePageIndex() == page_index) |
| 102 return; | 111 return; |
| 103 | 112 |
| 104 SetActivePageInternal(page_index, false); | 113 SetActivePageInternal(page_index, false); |
| 105 } | 114 } |
| 106 | 115 |
| 107 int ContentsView::GetActivePageIndex() const { | 116 int ContentsView::GetActivePageIndex() const { |
| 108 // The active page is changed at the beginning of an animation, not the end. | 117 // The active page is changed at the beginning of an animation, not the end. |
| 109 return pagination_model_.SelectedTargetPage(); | 118 return pagination_model_.SelectedTargetPage(); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 } | 246 } |
| 238 | 247 |
| 239 void ContentsView::AddBlankPageForTesting() { | 248 void ContentsView::AddBlankPageForTesting() { |
| 240 AddLauncherPage(new views::View, 0); | 249 AddLauncherPage(new views::View, 0); |
| 241 } | 250 } |
| 242 | 251 |
| 243 int ContentsView::AddLauncherPage(views::View* view, int resource_id) { | 252 int ContentsView::AddLauncherPage(views::View* view, int resource_id) { |
| 244 int page_index = view_model_->view_size(); | 253 int page_index = view_model_->view_size(); |
| 245 AddChildView(view); | 254 AddChildView(view); |
| 246 view_model_->Add(view, page_index); | 255 view_model_->Add(view, page_index); |
| 247 pagination_model_.SetTotalPages(view_model_->view_size()); | |
| 248 if (contents_switcher_view_) | 256 if (contents_switcher_view_) |
| 249 contents_switcher_view_->AddSwitcherButton(resource_id, page_index); | 257 contents_switcher_view_->AddSwitcherButton(resource_id, page_index); |
| 258 pagination_model_.SetTotalPages(view_model_->view_size()); |
| 250 return page_index; | 259 return page_index; |
| 251 } | 260 } |
| 252 | 261 |
| 253 int ContentsView::AddLauncherPage(views::View* view, | 262 int ContentsView::AddLauncherPage(views::View* view, |
| 254 int resource_id, | 263 int resource_id, |
| 255 NamedPage named_page) { | 264 NamedPage named_page) { |
| 256 int page_index = AddLauncherPage(view, resource_id); | 265 int page_index = AddLauncherPage(view, resource_id); |
| 257 named_page_to_view_.insert(std::pair<NamedPage, int>(named_page, page_index)); | 266 named_page_to_view_.insert(std::pair<NamedPage, int>(named_page, page_index)); |
| 258 return page_index; | 267 return page_index; |
| 259 } | 268 } |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 if (std::abs(offset) > kMinScrollToSwitchPage) { | 387 if (std::abs(offset) > kMinScrollToSwitchPage) { |
| 379 if (!GetAppsPaginationModel()->has_transition()) { | 388 if (!GetAppsPaginationModel()->has_transition()) { |
| 380 GetAppsPaginationModel()->SelectPageRelative(offset > 0 ? -1 : 1, true); | 389 GetAppsPaginationModel()->SelectPageRelative(offset > 0 ? -1 : 1, true); |
| 381 } | 390 } |
| 382 event->SetHandled(); | 391 event->SetHandled(); |
| 383 event->StopPropagation(); | 392 event->StopPropagation(); |
| 384 } | 393 } |
| 385 } | 394 } |
| 386 | 395 |
| 387 } // namespace app_list | 396 } // namespace app_list |
| OLD | NEW |