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
3// found in the LICENSE file.
4
5#include "chrome/browser/ui/apps/apps_metro_handler_win.h"
6
7#include "chrome/app/chrome_command_ids.h"
8#include "chrome/browser/apps/app_window_registry_util.h"
9#include "chrome/browser/ui/simple_message_box.h"
10#include "chrome/grit/chromium_strings.h"
11#include "chrome/grit/generated_resources.h"
12#include "extensions/browser/app_window/app_window.h"
13#include "ui/base/l10n/l10n_util.h"
14
15bool VerifyASHSwitchForApps(gfx::NativeWindow parent_window,
16                            int win_restart_command_id) {
17  DCHECK(win_restart_command_id == IDC_WIN_DESKTOP_RESTART ||
18      win_restart_command_id == IDC_WIN8_METRO_RESTART ||
19      win_restart_command_id == IDC_WIN_CHROMEOS_RESTART);
20  if (!AppWindowRegistryUtil::IsAppWindowRegisteredInAnyProfile(
21           extensions::AppWindow::WINDOW_TYPE_DEFAULT)) {
22    return true;
23  }
24
25  int string_id = 0;
26  switch (win_restart_command_id) {
27    case IDC_WIN8_METRO_RESTART:
28      string_id = IDS_WIN8_PROMPT_TO_CLOSE_APPS_FOR_METRO;
29      break;
30    case IDC_WIN_CHROMEOS_RESTART:
31      string_id = IDS_WIN_PROMPT_TO_CLOSE_APPS_FOR_CHROMEOS;
32      break;
33    default:
34      string_id = IDS_WIN_PROMPT_TO_CLOSE_APPS_FOR_DESKTOP;
35      break;
36  }
37  chrome::MessageBoxResult result = chrome::ShowMessageBox(
38      parent_window,
39      l10n_util::GetStringUTF16(IDS_PRODUCT_NAME),
40      l10n_util::GetStringUTF16(string_id),
41      chrome::MESSAGE_BOX_TYPE_OK_CANCEL);
42
43  return result == chrome::MESSAGE_BOX_RESULT_YES;
44}
45