summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/cocoa
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-16 20:50:58 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-16 20:50:58 +0000
commit4f0012c1ea5181d8aa6aec67f0648e77aa068fc7 (patch)
treeb358cabcb1145ec55eec14ce4c4a1cdbb0d8ae3a /chrome/browser/ui/cocoa
parentd9a749a5a13a338b799aee241905a4ab557ec80c (diff)
downloadchromium_src-4f0012c1ea5181d8aa6aec67f0648e77aa068fc7.zip
chromium_src-4f0012c1ea5181d8aa6aec67f0648e77aa068fc7.tar.gz
chromium_src-4f0012c1ea5181d8aa6aec67f0648e77aa068fc7.tar.bz2
Remove importer views that aren't used any more.
BUG=none TEST=trybots Review URL: http://codereview.chromium.org/6674019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78428 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/cocoa')
-rw-r--r--chrome/browser/ui/cocoa/browser_window_cocoa.mm1
-rw-r--r--chrome/browser/ui/cocoa/importer/import_dialog_cocoa.h104
-rw-r--r--chrome/browser/ui/cocoa/importer/import_dialog_cocoa.mm306
-rw-r--r--chrome/browser/ui/cocoa/importer/import_dialog_cocoa_unittest.mm129
4 files changed, 0 insertions, 540 deletions
diff --git a/chrome/browser/ui/cocoa/browser_window_cocoa.mm b/chrome/browser/ui/cocoa/browser_window_cocoa.mm
index b3b4c003..37049d6 100644
--- a/chrome/browser/ui/cocoa/browser_window_cocoa.mm
+++ b/chrome/browser/ui/cocoa/browser_window_cocoa.mm
@@ -25,7 +25,6 @@
#import "chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.h"
#import "chrome/browser/ui/cocoa/download/download_shelf_controller.h"
#import "chrome/browser/ui/cocoa/html_dialog_window_controller.h"
-#import "chrome/browser/ui/cocoa/importer/import_dialog_cocoa.h"
#import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
#import "chrome/browser/ui/cocoa/nsmenuitem_additions.h"
#include "chrome/browser/ui/cocoa/repost_form_warning_mac.h"
diff --git a/chrome/browser/ui/cocoa/importer/import_dialog_cocoa.h b/chrome/browser/ui/cocoa/importer/import_dialog_cocoa.h
deleted file mode 100644
index 2d20602c..0000000
--- a/chrome/browser/ui/cocoa/importer/import_dialog_cocoa.h
+++ /dev/null
@@ -1,104 +0,0 @@
-// Copyright (c) 2011 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_UI_COCOA_IMPORTER_IMPORT_DIALOG_COCOA_H_
-#define CHROME_BROWSER_UI_COCOA_IMPORTER_IMPORT_DIALOG_COCOA_H_
-#pragma once
-
-#import <Cocoa/Cocoa.h>
-
-#include "base/scoped_nsobject.h"
-#include "chrome/browser/importer/importer_host.h"
-
-class Profile;
-class ImporterListObserverBridge;
-
-// Controller for the Import Bookmarks and Settings dialog. This controller
-// automatically autoreleases itself when its associated dialog is dismissed.
-@interface ImportDialogController : NSWindowController {
- @private
- NSWindow* parentWindow_; // weak
- Profile* profile_; // weak
- scoped_refptr<ImporterList> importerList_;
- scoped_ptr<ImporterListObserverBridge> importerListObserver_;
- 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_;
- IBOutlet NSPopUpButton* sourceProfilePopUpButton_;
-}
-
-// 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;
-
-// Called when source profiles have been loaded.
-- (void)sourceProfilesLoaded;
-
-// 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 ImportDialogController (TestingAPI)
-
-// Initialize by providing an array of source profile dictionaries. Exposed for
-// unit testing but also called by -[initWithProfile:].
-- (id)initWithSourceProfiles:(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_UI_COCOA_IMPORTER_IMPORT_DIALOG_COCOA_H_
diff --git a/chrome/browser/ui/cocoa/importer/import_dialog_cocoa.mm b/chrome/browser/ui/cocoa/importer/import_dialog_cocoa.mm
deleted file mode 100644
index df12a15..0000000
--- a/chrome/browser/ui/cocoa/importer/import_dialog_cocoa.mm
+++ /dev/null
@@ -1,306 +0,0 @@
-// Copyright (c) 2011 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.
-
-#import "chrome/browser/ui/cocoa/importer/import_dialog_cocoa.h"
-
-#include "base/compiler_specific.h"
-#include "base/mac/mac_util.h"
-#include "base/sys_string_conversions.h"
-#include "chrome/browser/importer/external_process_importer_host.h"
-#include "chrome/browser/importer/importer_data_types.h"
-#include "chrome/browser/importer/importer_list.h"
-#include "chrome/browser/importer/importer_progress_dialog.h"
-#include "chrome/browser/profiles/profile.h"
-#include "grit/generated_resources.h"
-#include "ui/base/l10n/l10n_util_mac.h"
-
-// Bridge to receive observer messages from an ImporterList and relay
-// them to the ImportDialogController.
-class ImporterListObserverBridge : public ImporterList::Observer {
- public:
- explicit ImporterListObserverBridge(
- ImportDialogController *controller);
-
- private:
- // ImporterList::Observer:
- virtual void SourceProfilesLoaded() OVERRIDE;
-
- ImportDialogController* window_controller_; // weak, owns us.
-};
-
-ImporterListObserverBridge::ImporterListObserverBridge(
- ImportDialogController *controller)
- : window_controller_(controller) {
-}
-
-void ImporterListObserverBridge::SourceProfilesLoaded() {
- [window_controller_ sourceProfilesLoaded];
-}
-
-namespace {
-
-bool importSettingsDialogVisible = false;
-
-} // namespace
-
-@interface ImportDialogController ()
-
-@property(assign, readwrite, nonatomic) BOOL historyAvailable;
-@property(assign, readwrite, nonatomic) BOOL favoritesAvailable;
-@property(assign, readwrite, nonatomic) BOOL passwordsAvailable;
-@property(assign, readwrite, nonatomic) BOOL searchEnginesAvailable;
-
-@end
-
-@implementation ImportSettingsProfile
-
-@synthesize browserName = browserName_;
-@synthesize services = services_;
-
-+ (id)importSettingsProfileWithBrowserName:(NSString*)browserName
- services:(uint16)services {
- id settingsProfile = [[[ImportSettingsProfile alloc]
- initWithBrowserName:browserName
- services:services] autorelease];
- return settingsProfile;
-}
-
-- (id)initWithBrowserName:(NSString*)browserName
- services:(uint16)services {
- DCHECK(browserName);
- if ((self = [super init])) {
- if (browserName) {
- browserName_ = [browserName retain];
- services_ = services;
- } else {
- [self release];
- self = nil;
- }
- }
- return self;
-}
-
-- (id)init {
- NOTREACHED(); // Should never be called.
- return [self initWithBrowserName:NULL services:0];
-}
-
-- (void)dealloc {
- [browserName_ release];
- [super dealloc];
-}
-
-@end
-
-@interface ImportDialogController (Private)
-
-// Initialize the dialog controller with either the default profile or
-// the profile for the current browser.
-- (id)initWithProfile:(Profile*)profile;
-
-// Present the app modal dialog.
-- (void)runModalDialog;
-
-// Close the modal dialog.
-- (void)closeDialog;
-
-@end
-
-@implementation ImportDialogController
-
-@synthesize sourceBrowserIndex = sourceBrowserIndex_;
-@synthesize importHistory = importHistory_;
-@synthesize importFavorites = importFavorites_;
-@synthesize importPasswords = importPasswords_;
-@synthesize importSearchEngines = importSearchEngines_;
-@synthesize historyAvailable = historyAvailable_;
-@synthesize favoritesAvailable = favoritesAvailable_;
-@synthesize passwordsAvailable = passwordsAvailable_;
-@synthesize searchEnginesAvailable = searchEnginesAvailable_;
-
-// Set bindings dependencies for importSomething property.
-+ (NSSet*)keyPathsForValuesAffectingImportSomething {
- return [NSSet setWithObjects:@"importHistory", @"importFavorites",
- @"importPasswords", @"importSearchEngines", nil];
-}
-
-+ (void)showImportSettingsDialogForProfile:(Profile*)profile {
- // Don't display if already visible.
- if (importSettingsDialogVisible)
- return;
- ImportDialogController* controller =
- [[ImportDialogController alloc] initWithProfile:profile];
- [controller runModalDialog];
-}
-
-- (id)initWithProfile:(Profile*)profile {
- // Collect profile information (profile name and the services which can
- // be imported from each) into an array of ImportSettingsProfile which
- // are bound to the Browser List array controller and the popup name
- // presentation. The services element is used to indirectly control
- // checkbox enabling.
- importerList_ = new ImporterList;
- ImporterList& importerList(*(importerList_.get()));
- importerListObserver_.reset(new ImporterListObserverBridge(self));
- importerList.DetectSourceProfiles(importerListObserver_.get());
-
- if ((self = [self initWithSourceProfiles:nil])) {
- profile_ = profile;
- }
- return self;
-}
-
-- (id)initWithSourceProfiles:(NSArray*)profiles {
- NSString* nibpath =
- [base::mac::MainAppBundle() pathForResource:@"ImportSettingsDialog"
- ofType:@"nib"];
- if ((self = [super initWithWindowNibPath:nibpath owner:self]) && profiles)
- sourceBrowsersList_.reset([profiles retain]);
-
- return self;
-}
-
-- (id)init {
- return [self initWithProfile:nil];
-}
-
-- (void)dealloc {
- if (importerList_)
- importerList_->SetObserver(NULL);
- [super dealloc];
-}
-
-- (void)awakeFromNib {
- // Force an update of the checkbox enabled states.
- [self setSourceBrowserIndex:0];
-}
-
-// Run application modal.
-- (void)runModalDialog {
- importSettingsDialogVisible = true;
- [NSApp runModalForWindow:[self window]];
-}
-
-- (IBAction)ok:(id)sender {
- [self closeDialog];
- const importer::ProfileInfo& sourceProfile =
- importerList_.get()->GetSourceProfileInfoAt([self sourceBrowserIndex]);
- uint16 items = sourceProfile.services_supported;
- uint16 servicesToImport = items & [self servicesToImport];
- if (servicesToImport) {
- if (profile_) {
- ImporterHost* importerHost = new ExternalProcessImporterHost;
- // Note that a side effect of the following call is to cause the
- // importerHost to be disposed once the import has completed.
- importer::ShowImportProgressDialog(
- nil, servicesToImport, importerHost, nil, sourceProfile, profile_,
- false);
- }
- } else {
- LOG(WARNING) << "There were no settings to import from '"
- << sourceProfile.description << "'.";
- }
-}
-
-- (IBAction)cancel:(id)sender {
- [self closeDialog];
-}
-
-- (void)closeDialog {
- importSettingsDialogVisible = false;
- [[self window] orderOut:self];
- [NSApp stopModal];
- [self autorelease];
-}
-
-- (void)sourceProfilesLoaded {
- NSMutableArray* browserProfiles;
- ImporterList& importerList(*(importerList_.get()));
- int profilesCount = importerList.GetAvailableProfileCount();
- if (profilesCount) {
- browserProfiles =
- [[NSMutableArray alloc] initWithCapacity:profilesCount];
- for (int i = 0; i < profilesCount; ++i) {
- const importer::ProfileInfo& sourceProfile =
- importerList.GetSourceProfileInfoAt(i);
- NSString* browserName =
- base::SysWideToNSString(sourceProfile.description);
- uint16 browserServices = sourceProfile.services_supported;
- ImportSettingsProfile* settingsProfile =
- [ImportSettingsProfile
- importSettingsProfileWithBrowserName:browserName
- services:browserServices];
- [browserProfiles addObject:settingsProfile];
- }
- } else {
- browserProfiles =
- [[NSMutableArray alloc] initWithCapacity:1];
- NSString* dummyName = l10n_util::GetNSString(IDS_IMPORT_NO_PROFILE_FOUND);
- ImportSettingsProfile* dummySourceProfile =
- [ImportSettingsProfile importSettingsProfileWithBrowserName:dummyName
- services:0];
- [browserProfiles addObject:dummySourceProfile];
- }
-
- [self willChangeValueForKey:@"sourceBrowsersList"];
- sourceBrowsersList_.reset(browserProfiles);
- [self didChangeValueForKey:@"sourceBrowsersList"];
-
- // Force an update of the checkbox enabled states.
- [self setSourceBrowserIndex:0];
-
- // Resize and show the popup button.
- [sourceProfilePopUpButton_ sizeToFit];
- [sourceProfilePopUpButton_ setHidden:NO];
-}
-
-#pragma mark Accessors
-
-- (NSArray*)sourceBrowsersList {
- return sourceBrowsersList_.get();
-}
-
-// Accessor which cascades selected-browser changes into a re-evaluation of the
-// available services and the associated checkbox enable and checked states.
-- (void)setSourceBrowserIndex:(NSUInteger)browserIndex {
- uint16 items = 0;
- if ([sourceBrowsersList_.get() count]) {
- [self willChangeValueForKey:@"sourceBrowserIndex"];
- sourceBrowserIndex_ = browserIndex;
- [self didChangeValueForKey:@"sourceBrowserIndex"];
-
- ImportSettingsProfile* profile =
- [sourceBrowsersList_.get() objectAtIndex:browserIndex];
- items = [profile services];
- }
- [self setHistoryAvailable:(items & importer::HISTORY) ? YES : NO];
- [self setImportHistory:[self historyAvailable]];
- [self setFavoritesAvailable:(items & importer::FAVORITES) ? YES : NO];
- [self setImportFavorites:[self favoritesAvailable]];
- [self setPasswordsAvailable:(items & importer::PASSWORDS) ? YES : NO];
- [self setImportPasswords:[self passwordsAvailable]];
- [self setSearchEnginesAvailable:(items & importer::SEARCH_ENGINES) ?
- YES : NO];
- [self setImportSearchEngines:[self searchEnginesAvailable]];
-}
-
-- (uint16)servicesToImport {
- uint16 servicesToImport = 0;
- if ([self importHistory]) servicesToImport |= importer::HISTORY;
- if ([self importFavorites]) servicesToImport |= importer::FAVORITES;
- if ([self importPasswords]) servicesToImport |= importer::PASSWORDS;
- if ([self importSearchEngines]) servicesToImport |=
- importer::SEARCH_ENGINES;
- return servicesToImport;
-}
-
-// KVO accessor which returns YES if at least one of the services
-// provided by the selected profile has been marked for importing
-// and bound to the OK button's enable property.
-- (BOOL)importSomething {
- return [self importHistory] || [self importFavorites] ||
- [self importPasswords] || [self importSearchEngines];
-}
-
-@end
diff --git a/chrome/browser/ui/cocoa/importer/import_dialog_cocoa_unittest.mm b/chrome/browser/ui/cocoa/importer/import_dialog_cocoa_unittest.mm
deleted file mode 100644
index e9cf7aa..0000000
--- a/chrome/browser/ui/cocoa/importer/import_dialog_cocoa_unittest.mm
+++ /dev/null
@@ -1,129 +0,0 @@
-// Copyright (c) 2011 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.
-
-#import <Cocoa/Cocoa.h>
-
-#include "base/scoped_nsobject.h"
-#include "chrome/browser/importer/importer_host.h"
-#import "chrome/browser/ui/cocoa/browser_test_helper.h"
-#import "chrome/browser/ui/cocoa/cocoa_test_helper.h"
-#import "chrome/browser/ui/cocoa/importer/import_dialog_cocoa.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "testing/platform_test.h"
-
-class ImportSettingsDialogTest : public CocoaTest {
- public:
- ImportDialogController* controller_;
-
- virtual void SetUp() {
- CocoaTest::SetUp();
- uint16 safariServices = importer::HISTORY | importer::FAVORITES |
- importer::COOKIES | importer::PASSWORDS |
- importer::SEARCH_ENGINES;
- ImportSettingsProfile* mockSafari =
- [ImportSettingsProfile
- importSettingsProfileWithBrowserName:@"MockSafari"
- services:safariServices];
- uint16 firefoxServices = importer::HISTORY | importer::FAVORITES |
- importer::COOKIES | importer::PASSWORDS;
- ImportSettingsProfile* mockFirefox =
- [ImportSettingsProfile
- importSettingsProfileWithBrowserName:@"MockFirefox"
- services:firefoxServices];
- uint16 caminoServices = importer::HISTORY | importer::COOKIES |
- importer::SEARCH_ENGINES;
- ImportSettingsProfile* mockCamino =
- [ImportSettingsProfile
- importSettingsProfileWithBrowserName:@"MockCamino"
- services:caminoServices];
- NSArray* browsers = [NSArray arrayWithObjects:
- mockSafari, mockFirefox, mockCamino, nil];
- controller_ = [[ImportDialogController alloc]
- initWithSourceProfiles:browsers];
- }
-
- virtual void TearDown() {
- controller_ = NULL;
- CocoaTest::TearDown();
- }
-};
-
-TEST_F(ImportSettingsDialogTest, CancelDialog) {
- [controller_ cancel:nil];
-}
-
-TEST_F(ImportSettingsDialogTest, ChooseVariousBrowsers) {
- // Initial choice should already be MockSafari with all items enabled.
- [controller_ setSourceBrowserIndex:0];
- EXPECT_TRUE([controller_ importHistory]);
- EXPECT_TRUE([controller_ historyAvailable]);
- EXPECT_TRUE([controller_ importFavorites]);
- EXPECT_TRUE([controller_ favoritesAvailable]);
- EXPECT_TRUE([controller_ importPasswords]);
- EXPECT_TRUE([controller_ passwordsAvailable]);
- EXPECT_TRUE([controller_ importSearchEngines]);
- EXPECT_TRUE([controller_ searchEnginesAvailable]);
- EXPECT_EQ(importer::HISTORY | importer::FAVORITES | importer::PASSWORDS |
- importer::SEARCH_ENGINES,
- [controller_ servicesToImport]);
-
- // Next choice we test is MockCamino.
- [controller_ setSourceBrowserIndex:2];
- EXPECT_TRUE([controller_ importHistory]);
- EXPECT_TRUE([controller_ historyAvailable]);
- EXPECT_FALSE([controller_ importFavorites]);
- EXPECT_FALSE([controller_ favoritesAvailable]);
- EXPECT_FALSE([controller_ importPasswords]);
- EXPECT_FALSE([controller_ passwordsAvailable]);
- EXPECT_TRUE([controller_ importSearchEngines]);
- EXPECT_TRUE([controller_ searchEnginesAvailable]);
- EXPECT_EQ(importer::HISTORY | importer::SEARCH_ENGINES,
- [controller_ servicesToImport]);
-
- // Next choice we test is MockFirefox.
- [controller_ setSourceBrowserIndex:1];
- EXPECT_TRUE([controller_ importHistory]);
- EXPECT_TRUE([controller_ historyAvailable]);
- EXPECT_TRUE([controller_ importFavorites]);
- EXPECT_TRUE([controller_ favoritesAvailable]);
- EXPECT_TRUE([controller_ importPasswords]);
- EXPECT_TRUE([controller_ passwordsAvailable]);
- EXPECT_FALSE([controller_ importSearchEngines]);
- EXPECT_FALSE([controller_ searchEnginesAvailable]);
- EXPECT_EQ(importer::HISTORY | importer::FAVORITES | importer::PASSWORDS,
- [controller_ servicesToImport]);
-
- [controller_ cancel:nil];
-}
-
-TEST_F(ImportSettingsDialogTest, SetVariousSettings) {
- // Leave the choice MockSafari, but toggle the settings.
- [controller_ setImportHistory:NO];
- [controller_ setImportFavorites:NO];
- [controller_ setImportPasswords:NO];
- [controller_ setImportSearchEngines:NO];
- EXPECT_EQ(importer::NONE, [controller_ servicesToImport]);
- EXPECT_FALSE([controller_ importSomething]);
-
- [controller_ setImportHistory:YES];
- EXPECT_EQ(importer::HISTORY, [controller_ servicesToImport]);
- EXPECT_TRUE([controller_ importSomething]);
-
- [controller_ setImportHistory:NO];
- [controller_ setImportFavorites:YES];
- EXPECT_EQ(importer::FAVORITES, [controller_ servicesToImport]);
- EXPECT_TRUE([controller_ importSomething]);
- [controller_ setImportFavorites:NO];
-
- [controller_ setImportPasswords:YES];
- EXPECT_EQ(importer::PASSWORDS, [controller_ servicesToImport]);
- EXPECT_TRUE([controller_ importSomething]);
-
- [controller_ setImportPasswords:NO];
- [controller_ setImportSearchEngines:YES];
- EXPECT_EQ(importer::SEARCH_ENGINES, [controller_ servicesToImport]);
- EXPECT_TRUE([controller_ importSomething]);
-
- [controller_ cancel:nil];
-}