Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(725)

Unified Diff: ui/app_list/views/app_list_main_view.cc

Issue 334293005: Fix use-after-free when switching profiles in the experimental app list. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix misnomer Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/app_list/views/app_list_main_view.h ('k') | ui/app_list/views/app_list_view_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/app_list/views/app_list_main_view.cc
diff --git a/ui/app_list/views/app_list_main_view.cc b/ui/app_list/views/app_list_main_view.cc
index 8874bbeccc6d7db126e3298b2dd4f527848d391b..9837ae2a2d7c275e971506d4e99cedd675662aca 100644
--- a/ui/app_list/views/app_list_main_view.cc
+++ b/ui/app_list/views/app_list_main_view.cc
@@ -39,8 +39,6 @@ const int kInnerPadding = 1;
// The maximum allowed time to wait for icon loading in milliseconds.
const int kMaxIconLoadingWaitTimeInMs = 50;
-const int kContentsViewIndex = 1;
-
} // namespace
////////////////////////////////////////////////////////////////////////////////
@@ -90,6 +88,7 @@ AppListMainView::AppListMainView(AppListViewDelegate* delegate,
model_(delegate->GetModel()),
search_box_view_(NULL),
contents_view_(NULL),
+ contents_switcher_view_(NULL),
weak_ptr_factory_(this) {
SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical,
kInnerPadding,
@@ -98,9 +97,7 @@ AppListMainView::AppListMainView(AppListViewDelegate* delegate,
search_box_view_ = new SearchBoxView(this, delegate);
AddChildView(search_box_view_);
- AddContentsView();
- if (app_list::switches::IsExperimentalAppListEnabled())
- AddChildView(new ContentsSwitcherView(contents_view_));
+ AddContentsViews();
// Switch the apps grid view to the specified page.
app_list::PaginationModel* pagination_model = GetAppsPaginationModel();
@@ -111,9 +108,13 @@ AppListMainView::AppListMainView(AppListViewDelegate* delegate,
PreloadIcons(parent);
}
-void AppListMainView::AddContentsView() {
+void AppListMainView::AddContentsViews() {
contents_view_ = new ContentsView(this, model_, delegate_);
- AddChildViewAt(contents_view_, kContentsViewIndex);
+ AddChildView(contents_view_);
+ if (app_list::switches::IsExperimentalAppListEnabled()) {
+ contents_switcher_view_ = new ContentsSwitcherView(contents_view_);
+ AddChildView(contents_switcher_view_);
+ }
search_box_view_->set_contents_view(contents_view_);
@@ -164,7 +165,11 @@ void AppListMainView::ModelChanged() {
search_box_view_->ModelChanged();
delete contents_view_;
contents_view_ = NULL;
- AddContentsView();
+ if (contents_switcher_view_) {
+ delete contents_switcher_view_;
+ contents_switcher_view_ = NULL;
+ }
+ AddContentsViews();
Layout();
}
« no previous file with comments | « ui/app_list/views/app_list_main_view.h ('k') | ui/app_list/views/app_list_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698