[Metrics] Make MetricsStateManager take a callback param to check if UMA is enabled.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / importer / import_lock_dialog_cocoa.mm
blob59ed4821c18d99d5fe50bde386b3e6ef0bd117bf
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.
5 #import <Cocoa/Cocoa.h>
7 #include "base/bind.h"
8 #include "base/callback.h"
9 #include "base/mac/scoped_nsobject.h"
10 #include "base/message_loop/message_loop.h"
11 #include "chrome/browser/importer/importer_lock_dialog.h"
12 #include "content/public/browser/user_metrics.h"
13 #include "grit/chromium_strings.h"
14 #include "grit/generated_resources.h"
15 #include "ui/base/l10n/l10n_util_mac.h"
17 using base::UserMetricsAction;
19 namespace importer {
21 void ShowImportLockDialog(gfx::NativeWindow parent,
22                           const base::Callback<void(bool)>& callback) {
23   base::scoped_nsobject<NSAlert> lock_alert([[NSAlert alloc] init]);
24   [lock_alert addButtonWithTitle:l10n_util::GetNSStringWithFixup(
25       IDS_IMPORTER_LOCK_OK)];
26   [lock_alert addButtonWithTitle:l10n_util::GetNSStringWithFixup(
27       IDS_IMPORTER_LOCK_CANCEL)];
28   [lock_alert setInformativeText:l10n_util::GetNSStringWithFixup(
29       IDS_IMPORTER_LOCK_TEXT)];
30   [lock_alert setMessageText:l10n_util::GetNSStringWithFixup(
31       IDS_IMPORTER_LOCK_TITLE)];
33   base::MessageLoop::current()->PostTask(
34       FROM_HERE,
35       base::Bind(callback, [lock_alert runModal] == NSAlertFirstButtonReturn));
36   content::RecordAction(UserMetricsAction("ImportLockDialogCocoa_Shown"));
39 }  // namespace importer