Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / app_list / app_list_shower_views.cc
index 33dfa30..809ee6c 100644 (file)
@@ -6,10 +6,10 @@
 
 #include "base/bind.h"
 #include "base/message_loop/message_loop.h"
+#include "chrome/browser/apps/scoped_keep_alive.h"
 #include "chrome/browser/profiles/profile.h"
 #include "chrome/browser/ui/app_list/app_list_shower_delegate.h"
 #include "chrome/browser/ui/app_list/app_list_view_delegate.h"
-#include "chrome/browser/ui/app_list/scoped_keep_alive.h"
 #include "ui/app_list/views/app_list_view.h"
 #include "ui/gfx/geometry/point.h"
 #include "ui/gfx/screen.h"
@@ -24,24 +24,15 @@ AppListShower::AppListShower(AppListShowerDelegate* delegate)
 AppListShower::~AppListShower() {
 }
 
-void AppListShower::ShowForProfile(Profile* requested_profile) {
+void AppListShower::ShowForCurrentProfile() {
+  DCHECK(HasView());
+  keep_alive_.reset(new ScopedKeepAlive);
+
   // If the app list is already displaying |profile| just activate it (in case
   // we have lost focus).
-  if (IsAppListVisible() && (requested_profile == profile_)) {
-    Show();
-    return;
-  }
-
-  if (!HasView()) {
-    CreateViewForProfile(requested_profile);
-  } else if (requested_profile != profile_) {
-    profile_ = requested_profile;
-    UpdateViewForNewProfile();
-  }
-
-  keep_alive_.reset(new ScopedKeepAlive);
   if (!IsAppListVisible())
     delegate_->MoveNearCursor(app_list_);
+
   Show();
 }
 
@@ -52,7 +43,15 @@ gfx::NativeWindow AppListShower::GetWindow() {
 }
 
 void AppListShower::CreateViewForProfile(Profile* requested_profile) {
-  profile_ = requested_profile;
+  DCHECK(requested_profile);
+  if (HasView() && requested_profile->IsSameProfile(profile_))
+    return;
+
+  profile_ = requested_profile->GetOriginalProfile();
+  if (HasView()) {
+    UpdateViewForNewProfile();
+    return;
+  }
   app_list_ = MakeViewForCurrentProfile();
   delegate_->OnViewCreated();
 }
@@ -99,11 +98,9 @@ bool AppListShower::HasView() const {
 }
 
 app_list::AppListView* AppListShower::MakeViewForCurrentProfile() {
-  // The view delegate will be owned by the app list view. The app list view
-  // manages its own lifetime.
-  AppListViewDelegate* view_delegate = new AppListViewDelegate(
-      profile_, delegate_->GetControllerDelegateForCreate());
-  app_list::AppListView* view = new app_list::AppListView(view_delegate);
+  // The app list view manages its own lifetime.
+  app_list::AppListView* view =
+      new app_list::AppListView(delegate_->GetViewDelegateForCreate());
   gfx::Point cursor = gfx::Screen::GetNativeScreen()->GetCursorScreenPoint();
   view->InitAsBubbleAtFixedLocation(NULL,
                                     0,