| 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 AddChildView(contents_switcher_view_); | 118 AddChildView(contents_switcher_view_); |
| 119 | 119 |
| 120 search_box_view_->set_contents_view(contents_view_); | 120 search_box_view_->set_contents_view(contents_view_); |
| 121 UpdateSearchBoxVisibility(); | 121 UpdateSearchBoxVisibility(); |
| 122 | 122 |
| 123 contents_view_->SetPaintToLayer(true); | 123 contents_view_->SetPaintToLayer(true); |
| 124 contents_view_->SetFillsBoundsOpaquely(false); | 124 contents_view_->SetFillsBoundsOpaquely(false); |
| 125 contents_view_->layer()->SetMasksToBounds(true); | 125 contents_view_->layer()->SetMasksToBounds(true); |
| 126 | 126 |
| 127 delegate_->StartSearch(); | 127 delegate_->StartSearch(); |
| 128 |
| 129 FOR_EACH_OBSERVER( |
| 130 AppListMainViewObserver, observers_, OnContentsViewCreated()); |
| 128 } | 131 } |
| 129 | 132 |
| 130 void AppListMainView::ShowAppListWhenReady() { | 133 void AppListMainView::ShowAppListWhenReady() { |
| 131 if (pending_icon_loaders_.empty()) { | 134 if (pending_icon_loaders_.empty()) { |
| 132 icon_loading_wait_timer_.Stop(); | 135 icon_loading_wait_timer_.Stop(); |
| 133 GetWidget()->Show(); | 136 GetWidget()->Show(); |
| 134 return; | 137 return; |
| 135 } | 138 } |
| 136 | 139 |
| 137 if (icon_loading_wait_timer_.IsRunning()) | 140 if (icon_loading_wait_timer_.IsRunning()) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 160 } | 163 } |
| 161 | 164 |
| 162 void AppListMainView::Prerender() { | 165 void AppListMainView::Prerender() { |
| 163 contents_view_->Prerender(); | 166 contents_view_->Prerender(); |
| 164 } | 167 } |
| 165 | 168 |
| 166 void AppListMainView::ModelChanged() { | 169 void AppListMainView::ModelChanged() { |
| 167 pending_icon_loaders_.clear(); | 170 pending_icon_loaders_.clear(); |
| 168 model_ = delegate_->GetModel(); | 171 model_ = delegate_->GetModel(); |
| 169 search_box_view_->ModelChanged(); | 172 search_box_view_->ModelChanged(); |
| 173 |
| 174 FOR_EACH_OBSERVER( |
| 175 AppListMainViewObserver, observers_, OnContentsViewDestroying()); |
| 176 |
| 170 delete contents_view_; | 177 delete contents_view_; |
| 171 contents_view_ = NULL; | 178 contents_view_ = NULL; |
| 172 if (contents_switcher_view_) { | 179 if (contents_switcher_view_) { |
| 173 delete contents_switcher_view_; | 180 delete contents_switcher_view_; |
| 174 contents_switcher_view_ = NULL; | 181 contents_switcher_view_ = NULL; |
| 175 } | 182 } |
| 176 AddContentsViews(); | 183 AddContentsViews(); |
| 177 Layout(); | 184 Layout(); |
| 178 } | 185 } |
| 179 | 186 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 } | 261 } |
| 255 | 262 |
| 256 void AppListMainView::NotifySearchBoxVisibilityChanged() { | 263 void AppListMainView::NotifySearchBoxVisibilityChanged() { |
| 257 // Repaint the AppListView's background which will repaint the background for | 264 // Repaint the AppListView's background which will repaint the background for |
| 258 // the search box. This is needed because this view paints to a layer and | 265 // the search box. This is needed because this view paints to a layer and |
| 259 // won't propagate paints upward. | 266 // won't propagate paints upward. |
| 260 if (parent()) | 267 if (parent()) |
| 261 parent()->SchedulePaint(); | 268 parent()->SchedulePaint(); |
| 262 } | 269 } |
| 263 | 270 |
| 271 void AppListMainView::AddObserver(AppListMainViewObserver* observer) { |
| 272 observers_.AddObserver(observer); |
| 273 } |
| 274 |
| 275 void AppListMainView::RemoveObserver(AppListMainViewObserver* observer) { |
| 276 observers_.RemoveObserver(observer); |
| 277 } |
| 278 |
| 264 void AppListMainView::ActivateApp(AppListItem* item, int event_flags) { | 279 void AppListMainView::ActivateApp(AppListItem* item, int event_flags) { |
| 265 // TODO(jennyz): Activate the folder via AppListModel notification. | 280 // TODO(jennyz): Activate the folder via AppListModel notification. |
| 266 if (item->GetItemType() == AppListFolderItem::kItemType) | 281 if (item->GetItemType() == AppListFolderItem::kItemType) |
| 267 contents_view_->ShowFolderContent(static_cast<AppListFolderItem*>(item)); | 282 contents_view_->ShowFolderContent(static_cast<AppListFolderItem*>(item)); |
| 268 else | 283 else |
| 269 item->Activate(event_flags); | 284 item->Activate(event_flags); |
| 270 } | 285 } |
| 271 | 286 |
| 272 void AppListMainView::GetShortcutPathForApp( | 287 void AppListMainView::GetShortcutPathForApp( |
| 273 const std::string& app_id, | 288 const std::string& app_id, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 302 // Resubmit the query via a posted task so that all observers for the | 317 // Resubmit the query via a posted task so that all observers for the |
| 303 // uninstall notification are notified. | 318 // uninstall notification are notified. |
| 304 base::MessageLoop::current()->PostTask( | 319 base::MessageLoop::current()->PostTask( |
| 305 FROM_HERE, | 320 FROM_HERE, |
| 306 base::Bind(&AppListMainView::QueryChanged, | 321 base::Bind(&AppListMainView::QueryChanged, |
| 307 weak_ptr_factory_.GetWeakPtr(), | 322 weak_ptr_factory_.GetWeakPtr(), |
| 308 search_box_view_)); | 323 search_box_view_)); |
| 309 } | 324 } |
| 310 | 325 |
| 311 } // namespace app_list | 326 } // namespace app_list |
| OLD | NEW |