• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright (c) 2011 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#import <Cocoa/Cocoa.h>
6
7#include <string>
8
9#include "base/sys_string_conversions.h"
10#include "base/utf_string_conversions.h"
11#include "chrome/browser/extensions/extension_uninstall_dialog.h"
12#include "chrome/browser/profiles/profile.h"
13#include "chrome/common/extensions/extension.h"
14#include "grit/chromium_strings.h"
15#include "grit/generated_resources.h"
16#include "skia/ext/skia_utils_mac.h"
17#include "ui/base/l10n/l10n_util_mac.h"
18#include "ui/base/resource/resource_bundle.h"
19
20// static
21void ExtensionUninstallDialog::Show(
22    Profile* profile,
23    ExtensionUninstallDialog::Delegate* delegate,
24    const Extension* extension,
25    SkBitmap* icon) {
26  NSAlert* alert = [[[NSAlert alloc] init] autorelease];
27
28  NSButton* continueButton = [alert addButtonWithTitle:l10n_util::GetNSString(
29      IDS_EXTENSION_PROMPT_UNINSTALL_BUTTON)];
30  // Clear the key equivalent (currently 'Return') because cancel is the default
31  // button.
32  [continueButton setKeyEquivalent:@""];
33
34  NSButton* cancelButton = [alert addButtonWithTitle:l10n_util::GetNSString(
35      IDS_CANCEL)];
36  [cancelButton setKeyEquivalent:@"\r"];
37
38  [alert setMessageText:l10n_util::GetNSStringF(
39       IDS_EXTENSION_UNINSTALL_PROMPT_HEADING,
40       UTF8ToUTF16(extension->name()))];
41  [alert setAlertStyle:NSWarningAlertStyle];
42  [alert setIcon:gfx::SkBitmapToNSImage(*icon)];
43
44  if ([alert runModal] == NSAlertFirstButtonReturn)
45    delegate->ExtensionDialogAccepted();
46  else
47    delegate->ExtensionDialogCanceled();
48}
49