Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / cocoa / apps / quit_with_apps_controller_mac.cc
index 5560387..3a65f0d 100644 (file)
@@ -4,15 +4,13 @@
 
 #include "chrome/browser/ui/cocoa/apps/quit_with_apps_controller_mac.h"
 
-#include "apps/app_window.h"
-#include "apps/app_window_registry.h"
-#include "apps/ui/native_app_window.h"
 #include "base/command_line.h"
 #include "base/i18n/number_formatting.h"
 #include "base/prefs/pref_registry_simple.h"
 #include "base/prefs/pref_service.h"
 #include "base/strings/sys_string_conversions.h"
 #include "base/strings/utf_string_conversions.h"
+#include "chrome/browser/apps/app_window_registry_util.h"
 #include "chrome/browser/browser_process.h"
 #include "chrome/browser/notifications/notification.h"
 #include "chrome/browser/notifications/notification_ui_manager.h"
 #include "chrome/browser/ui/browser_iterator.h"
 #include "chrome/common/chrome_switches.h"
 #include "chrome/common/pref_names.h"
+#include "chrome/grit/chromium_strings.h"
+#include "chrome/grit/generated_resources.h"
+#include "chrome/grit/google_chrome_strings.h"
+#include "extensions/browser/app_window/app_window.h"
+#include "extensions/browser/app_window/native_app_window.h"
 #include "extensions/common/extension.h"
 #include "grit/chrome_unscaled_resources.h"
-#include "grit/chromium_strings.h"
-#include "grit/generated_resources.h"
-#include "grit/google_chrome_strings.h"
 #include "ui/base/l10n/l10n_util.h"
 #include "ui/base/l10n/l10n_util_mac.h"
 #include "ui/base/resource/resource_bundle.h"
@@ -37,7 +37,7 @@ const char QuitWithAppsController::kQuitWithAppsNotificationID[] =
     "quit-with-apps";
 
 QuitWithAppsController::QuitWithAppsController()
-    : suppress_for_session_(false) {
+    : notification_profile_(NULL), suppress_for_session_(false) {
   DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
 
   // There is only ever one notification to replace, so use the same replace_id
@@ -72,31 +72,27 @@ QuitWithAppsController::~QuitWithAppsController() {}
 
 void QuitWithAppsController::Display() {}
 
-void QuitWithAppsController::Error() {}
-
 void QuitWithAppsController::Close(bool by_user) {
   if (by_user)
     suppress_for_session_ = true;
 }
 
 void QuitWithAppsController::Click() {
-  g_browser_process->notification_ui_manager()->CancelById(id());
+  g_browser_process->notification_ui_manager()->CancelById(
+      id(), NotificationUIManager::GetProfileID(notification_profile_));
 }
 
 void QuitWithAppsController::ButtonClick(int button_index) {
-  g_browser_process->notification_ui_manager()->CancelById(id());
+  g_browser_process->notification_ui_manager()->CancelById(
+      id(), NotificationUIManager::GetProfileID(notification_profile_));
   if (button_index == kQuitAllAppsButtonIndex) {
-    apps::AppWindowRegistry::CloseAllAppWindows();
+    AppWindowRegistryUtil::CloseAllAppWindows();
   } else if (button_index == kDontShowAgainButtonIndex) {
     g_browser_process->local_state()->SetBoolean(
         prefs::kNotifyWhenAppsKeepChromeAlive, false);
   }
 }
 
-content::WebContents* QuitWithAppsController::GetWebContents() const {
-  return NULL;
-}
-
 std::string QuitWithAppsController::id() const {
   return kQuitWithAppsNotificationID;
 }
@@ -113,7 +109,7 @@ bool QuitWithAppsController::ShouldQuit() {
 
   // Quit immediately if there are no windows or the confirmation has been
   // suppressed.
-  if (!apps::AppWindowRegistry::IsAppWindowRegisteredInAnyProfile(0))
+  if (!AppWindowRegistryUtil::IsAppWindowRegisteredInAnyProfile(0))
     return true;
 
   // If there are browser windows, and this notification has been suppressed for
@@ -132,10 +128,16 @@ bool QuitWithAppsController::ShouldQuit() {
   std::vector<Profile*> profiles(profile_manager->GetLoadedProfiles());
   DCHECK(profiles.size());
 
-  // Delete any existing notification to ensure this one is shown.
-  g_browser_process->notification_ui_manager()->CancelById(id());
+  // Delete any existing notification to ensure this one is shown. If
+  // notification_profile_ is NULL then it must be that no notification has been
+  // added by this class yet.
+  if (notification_profile_) {
+    g_browser_process->notification_ui_manager()->CancelById(
+        id(), NotificationUIManager::GetProfileID(notification_profile_));
+  }
+  notification_profile_ = profiles[0];
   g_browser_process->notification_ui_manager()->Add(*notification_,
-                                                    profiles[0]);
+                                                    notification_profile_);
 
   // Always return false, the notification UI can be used to quit all apps which
   // will cause Chrome to quit.