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 "base/memory/scoped_nsobject.h" 8 #include "base/message_loop.h" 9 #include "chrome/browser/importer/importer_host.h" 10 #include "chrome/browser/importer/importer_lock_dialog.h" 11 #include "chrome/browser/metrics/user_metrics.h" 12 #include "grit/chromium_strings.h" 13 #include "grit/generated_resources.h" 14 #include "ui/base/l10n/l10n_util_mac.h" 15 16 namespace importer { 17 18 void ShowImportLockDialog(gfx::NativeWindow parent, 19 ImporterHost* importer_host) { 20 scoped_nsobject<NSAlert> lock_alert([[NSAlert alloc] init]); 21 [lock_alert addButtonWithTitle:l10n_util::GetNSStringWithFixup( 22 IDS_IMPORTER_LOCK_OK)]; 23 [lock_alert addButtonWithTitle:l10n_util::GetNSStringWithFixup( 24 IDS_IMPORTER_LOCK_CANCEL)]; 25 [lock_alert setInformativeText:l10n_util::GetNSStringWithFixup( 26 IDS_IMPORTER_LOCK_TEXT)]; 27 [lock_alert setMessageText:l10n_util::GetNSStringWithFixup( 28 IDS_IMPORTER_LOCK_TITLE)]; 29 30 if ([lock_alert runModal] == NSAlertFirstButtonReturn) { 31 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( 32 importer_host, &ImporterHost::OnImportLockDialogEnd, true)); 33 } else { 34 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( 35 importer_host, &ImporterHost::OnImportLockDialogEnd, false)); 36 } 37 UserMetrics::RecordAction(UserMetricsAction("ImportLockDialogCocoa_Shown")); 38 } 39 40 } // namespace importer 41