summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/import_settings_dialog.h
blob: 0cac63f8b5eb68b0f8ad90597b8a6fe847f8b842 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_COCOA_IMPORT_SETTINGS_DIALOG_H_
#define CHROME_BROWSER_COCOA_IMPORT_SETTINGS_DIALOG_H_
#pragma once

#import <Cocoa/Cocoa.h>

#include "base/ref_counted.h"
#include "base/scoped_nsobject.h"
#include "chrome/browser/importer/importer.h"

class Profile;

// Controller for the Import Bookmarks and Settings dialog.  This controller
// automatically autoreleases itself when its associated dialog is dismissed.
@interface ImportSettingsDialogController : NSWindowController {
 @private
  NSWindow* parentWindow_;  // weak
  Profile* profile_;  // weak
  scoped_ptr<ImporterList> importerList_;
  scoped_nsobject<NSArray> sourceBrowsersList_;
  NSUInteger sourceBrowserIndex_;
  // The following are all bound via the properties below.
  BOOL importHistory_;
  BOOL importFavorites_;
  BOOL importPasswords_;
  BOOL importSearchEngines_;
  BOOL historyAvailable_;
  BOOL favoritesAvailable_;
  BOOL passwordsAvailable_;
  BOOL searchEnginesAvailable_;
}

// Show the import settings window.  Window is displayed as an app modal dialog.
// If the dialog is already being displayed, this method whill return with
// no error.
+ (void)showImportSettingsDialogForProfile:(Profile*)profile;

// Called when the "Import" button is pressed.
- (IBAction)ok:(id)sender;

// Cancel button calls this.
- (IBAction)cancel:(id)sender;

// An array of ImportSettingsProfiles, provide the list of browser profiles
// available for importing. Bound to the Browser List array controller.
- (NSArray*)sourceBrowsersList;

// Properties for bindings.
@property(assign, nonatomic) NSUInteger sourceBrowserIndex;
@property(assign, readonly, nonatomic) BOOL importSomething;
// Bindings for the value of the import checkboxes.
@property(assign, nonatomic) BOOL importHistory;
@property(assign, nonatomic) BOOL importFavorites;
@property(assign, nonatomic) BOOL importPasswords;
@property(assign, nonatomic) BOOL importSearchEngines;
// Bindings for enabling/disabling the checkboxes.
@property(assign, readonly, nonatomic) BOOL historyAvailable;
@property(assign, readonly, nonatomic) BOOL favoritesAvailable;
@property(assign, readonly, nonatomic) BOOL passwordsAvailable;
@property(assign, readonly, nonatomic) BOOL searchEnginesAvailable;

@end

@interface ImportSettingsDialogController (TestingAPI)

// Initialize by providing an array of profile dictionaries. Exposed for
// unit testing but also called by -[initWithProfile:].
- (id)initWithProfiles:(NSArray*)profiles;

// Return selected services to import as mapped by the ImportItem enum.
- (uint16)servicesToImport;

@end

// Utility class used as array elements for sourceBrowsersList, above.
@interface ImportSettingsProfile : NSObject {
 @private
  NSString* browserName_;
  uint16 services_;  // Services as defined by enum ImportItem.
}

// Convenience creator. |services| is a bitfield of enum ImportItems.
+ (id)importSettingsProfileWithBrowserName:(NSString*)browserName
                                  services:(uint16)services;

// Designated initializer. |services| is a bitfield of enum ImportItems.
- (id)initWithBrowserName:(NSString*)browserName
                 services:(uint16)services;  // Bitfield of enum ImportItems.

@property(copy, nonatomic) NSString* browserName;
@property(assign, nonatomic) uint16 services;  // Bitfield of enum ImportItems.

@end

#endif  // CHROME_BROWSER_COCOA_IMPORT_SETTINGS_DIALOG_H_