summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/ui')
-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
-rw-r--r--chrome/browser/ui/gtk/browser_window_gtk.cc1
-rw-r--r--chrome/browser/ui/gtk/importer/import_dialog_gtk.cc216
-rw-r--r--chrome/browser/ui/gtk/importer/import_dialog_gtk.h99
-rw-r--r--chrome/browser/ui/views/importer/import_dialog_view.cc299
-rw-r--r--chrome/browser/ui/views/importer/import_dialog_view.h125
9 files changed, 0 insertions, 1280 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];
-}
diff --git a/chrome/browser/ui/gtk/browser_window_gtk.cc b/chrome/browser/ui/gtk/browser_window_gtk.cc
index 8704e7c..4ab240e 100644
--- a/chrome/browser/ui/gtk/browser_window_gtk.cc
+++ b/chrome/browser/ui/gtk/browser_window_gtk.cc
@@ -53,7 +53,6 @@
#include "chrome/browser/ui/gtk/gtk_floating_container.h"
#include "chrome/browser/ui/gtk/gtk_theme_provider.h"
#include "chrome/browser/ui/gtk/gtk_util.h"
-#include "chrome/browser/ui/gtk/importer/import_dialog_gtk.h"
#include "chrome/browser/ui/gtk/info_bubble_gtk.h"
#include "chrome/browser/ui/gtk/infobars/infobar_container_gtk.h"
#include "chrome/browser/ui/gtk/infobars/infobar_gtk.h"
diff --git a/chrome/browser/ui/gtk/importer/import_dialog_gtk.cc b/chrome/browser/ui/gtk/importer/import_dialog_gtk.cc
deleted file mode 100644
index afd46ba..0000000
--- a/chrome/browser/ui/gtk/importer/import_dialog_gtk.cc
+++ /dev/null
@@ -1,216 +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.
-
-#include "chrome/browser/ui/gtk/importer/import_dialog_gtk.h"
-
-#include <string>
-
-#include "base/utf_string_conversions.h"
-#include "chrome/browser/importer/importer_data_types.h"
-#include "chrome/browser/importer/importer_host.h"
-#include "chrome/browser/importer/importer_progress_dialog.h"
-#include "chrome/browser/ui/gtk/gtk_util.h"
-#include "grit/generated_resources.h"
-#include "grit/locale_settings.h"
-#include "ui/base/l10n/l10n_util.h"
-
-namespace {
-
-// Returns true if the checkbox is checked.
-gboolean IsChecked(GtkWidget* widget) {
- return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
-}
-
-} // namespace
-
-// static
-void ImportDialogGtk::Show(GtkWindow* parent, Profile* profile,
- uint16 initial_state) {
- new ImportDialogGtk(parent, profile, initial_state);
-}
-
-ImportDialogGtk::ImportDialogGtk(GtkWindow* parent, Profile* profile,
- uint16 initial_state)
- : parent_(parent),
- profile_(profile),
- importer_host_(new ImporterHost),
- ALLOW_THIS_IN_INITIALIZER_LIST(importer_list_(new ImporterList)),
- initial_state_(initial_state) {
- // Load the available source profiles.
- importer_list_->DetectSourceProfiles(this);
-
- // Build the dialog.
- std::string dialog_name = l10n_util::GetStringUTF8(
- IDS_IMPORT_SETTINGS_TITLE);
- dialog_ = gtk_dialog_new_with_buttons(
- dialog_name.c_str(),
- parent,
- (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR),
- GTK_STOCK_CANCEL,
- GTK_RESPONSE_REJECT,
- NULL);
-
- importer_host_->set_parent_window(GTK_WINDOW(dialog_));
-
- // Add import button separately as we might need to disable it, if
- // no supported browsers found.
- import_button_ = gtk_util::AddButtonToDialog(dialog_,
- l10n_util::GetStringUTF8(IDS_IMPORT_COMMIT).c_str(),
- GTK_STOCK_APPLY, GTK_RESPONSE_ACCEPT);
- GTK_WIDGET_SET_FLAGS(import_button_, GTK_CAN_DEFAULT);
- gtk_dialog_set_default_response(GTK_DIALOG(dialog_), GTK_RESPONSE_ACCEPT);
-
- GtkWidget* content_area = GTK_DIALOG(dialog_)->vbox;
- gtk_box_set_spacing(GTK_BOX(content_area), gtk_util::kContentAreaSpacing);
-
- GtkWidget* combo_hbox = gtk_hbox_new(FALSE, gtk_util::kLabelSpacing);
- GtkWidget* from = gtk_label_new(
- l10n_util::GetStringUTF8(IDS_IMPORT_FROM_LABEL).c_str());
- gtk_box_pack_start(GTK_BOX(combo_hbox), from, FALSE, FALSE, 0);
-
- combo_ = gtk_combo_box_new_text();
- gtk_box_pack_start(GTK_BOX(combo_hbox), combo_, TRUE, TRUE, 0);
-
- gtk_box_pack_start(GTK_BOX(content_area), combo_hbox, FALSE, FALSE, 0);
-
- GtkWidget* vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing);
-
- GtkWidget* description = gtk_label_new(
- l10n_util::GetStringUTF8(IDS_IMPORT_ITEMS_LABEL).c_str());
- gtk_misc_set_alignment(GTK_MISC(description), 0, 0);
- gtk_box_pack_start(GTK_BOX(vbox), description, FALSE, FALSE, 0);
-
- bookmarks_ = gtk_check_button_new_with_label(
- l10n_util::GetStringUTF8(IDS_IMPORT_FAVORITES_CHKBOX).c_str());
- gtk_box_pack_start(GTK_BOX(vbox), bookmarks_, FALSE, FALSE, 0);
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(bookmarks_),
- (initial_state_ & importer::FAVORITES) != 0);
- g_signal_connect(bookmarks_, "toggled",
- G_CALLBACK(OnDialogWidgetClickedThunk), this);
-
- search_engines_ = gtk_check_button_new_with_label(
- l10n_util::GetStringUTF8(IDS_IMPORT_SEARCH_ENGINES_CHKBOX).c_str());
- gtk_box_pack_start(GTK_BOX(vbox), search_engines_, FALSE, FALSE, 0);
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(search_engines_),
- (initial_state_ & importer::SEARCH_ENGINES) != 0);
- g_signal_connect(search_engines_, "toggled",
- G_CALLBACK(OnDialogWidgetClickedThunk), this);
-
- passwords_ = gtk_check_button_new_with_label(
- l10n_util::GetStringUTF8(IDS_IMPORT_PASSWORDS_CHKBOX).c_str());
- gtk_box_pack_start(GTK_BOX(vbox), passwords_, FALSE, FALSE, 0);
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(passwords_),
- (initial_state_ & importer::PASSWORDS) != 0);
- g_signal_connect(passwords_, "toggled",
- G_CALLBACK(OnDialogWidgetClickedThunk), this);
-
- history_ = gtk_check_button_new_with_label(
- l10n_util::GetStringUTF8(IDS_IMPORT_HISTORY_CHKBOX).c_str());
- gtk_box_pack_start(GTK_BOX(vbox), history_, FALSE, FALSE, 0);
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(history_),
- (initial_state_ & importer::HISTORY) !=0);
- g_signal_connect(history_, "toggled",
- G_CALLBACK(OnDialogWidgetClickedThunk), this);
-
- gtk_box_pack_start(GTK_BOX(content_area), vbox, FALSE, FALSE, 0);
-
- // Let the user know profiles are being loaded.
- gtk_combo_box_append_text(GTK_COMBO_BOX(combo_),
- l10n_util::GetStringUTF8(IDS_IMPORT_LOADING_PROFILES).c_str());
- gtk_combo_box_set_active(GTK_COMBO_BOX(combo_), 0);
-
- // Disable controls until source profiles are loaded.
- SetDialogControlsSensitive(false);
-
- g_signal_connect(dialog_, "response", G_CALLBACK(OnResponseThunk), this);
-
- UpdateDialogButtons();
-
- gtk_util::ShowDialogWithLocalizedSize(dialog_,
- IDS_IMPORT_DIALOG_WIDTH_CHARS,
- -1, // height
- false); // resizable
-}
-
-ImportDialogGtk::~ImportDialogGtk() {
- if (importer_list_)
- importer_list_->SetObserver(NULL);
-}
-
-void ImportDialogGtk::OnResponse(GtkWidget* dialog, int response_id) {
- gtk_widget_hide_all(dialog_);
- if (response_id == GTK_RESPONSE_ACCEPT) {
- uint16 items = GetCheckedItems();
- if (items == 0) {
- ImportCompleted();
- } else {
- const importer::ProfileInfo& source_profile =
- importer_list_->GetSourceProfileInfoAt(
- gtk_combo_box_get_active(GTK_COMBO_BOX(combo_)));
- importer::ShowImportProgressDialog(parent_, items, importer_host_, this,
- source_profile, profile_, false);
- }
- } else {
- ImportCanceled();
- }
-}
-
-void ImportDialogGtk::OnDialogWidgetClicked(GtkWidget* widget) {
- UpdateDialogButtons();
-}
-
-void ImportDialogGtk::UpdateDialogButtons() {
- gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog_), GTK_RESPONSE_ACCEPT,
- GetCheckedItems() != 0);
-}
-
-void ImportDialogGtk::SetDialogControlsSensitive(bool sensitive) {
- gtk_widget_set_sensitive(bookmarks_, sensitive);
- gtk_widget_set_sensitive(search_engines_, sensitive);
- gtk_widget_set_sensitive(passwords_, sensitive);
- gtk_widget_set_sensitive(history_, sensitive);
- gtk_widget_set_sensitive(import_button_, sensitive);
-}
-
-uint16 ImportDialogGtk::GetCheckedItems() {
- uint16 items = importer::NONE;
- if (IsChecked(bookmarks_))
- items |= importer::FAVORITES;
- if (IsChecked(search_engines_))
- items |= importer::SEARCH_ENGINES;
- if (IsChecked(passwords_))
- items |= importer::PASSWORDS;
- if (IsChecked(history_))
- items |= importer::HISTORY;
- return items;
-}
-
-void ImportDialogGtk::SourceProfilesLoaded() {
- // Detect any supported browsers that we can import from and fill
- // up the combo box. If none found, disable all controls except cancel.
- int profiles_count = importer_list_->GetAvailableProfileCount();
- SetDialogControlsSensitive(profiles_count != 0);
- gtk_combo_box_remove_text(GTK_COMBO_BOX(combo_), 0);
- if (profiles_count > 0) {
- for (int i = 0; i < profiles_count; i++) {
- std::wstring profile = importer_list_->GetSourceProfileNameAt(i);
- gtk_combo_box_append_text(GTK_COMBO_BOX(combo_),
- WideToUTF8(profile).c_str());
- }
- gtk_widget_grab_focus(import_button_);
- } else {
- gtk_combo_box_append_text(GTK_COMBO_BOX(combo_),
- l10n_util::GetStringUTF8(IDS_IMPORT_NO_PROFILE_FOUND).c_str());
- }
- gtk_combo_box_set_active(GTK_COMBO_BOX(combo_), 0);
-}
-
-void ImportDialogGtk::ImportCompleted() {
- gtk_widget_destroy(dialog_);
- delete this;
-}
-
-void ImportDialogGtk::ImportCanceled() {
- ImportCompleted();
-}
diff --git a/chrome/browser/ui/gtk/importer/import_dialog_gtk.h b/chrome/browser/ui/gtk/importer/import_dialog_gtk.h
deleted file mode 100644
index 136b74e..0000000
--- a/chrome/browser/ui/gtk/importer/import_dialog_gtk.h
+++ /dev/null
@@ -1,99 +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_GTK_IMPORTER_IMPORT_DIALOG_GTK_H_
-#define CHROME_BROWSER_UI_GTK_IMPORTER_IMPORT_DIALOG_GTK_H_
-#pragma once
-
-#include "base/basictypes.h"
-#include "base/compiler_specific.h"
-#include "base/ref_counted.h"
-#include "chrome/browser/importer/importer_list.h"
-#include "chrome/browser/importer/importer_observer.h"
-#include "ui/base/gtk/gtk_signal.h"
-
-class ImporterHost;
-class Profile;
-
-typedef struct _GtkWidget GtkWidget;
-typedef struct _GtkWindow GtkWindow;
-
-// ImportDialogGtk presents the dialog that allows the user to select what to
-// import from other browsers.
-class ImportDialogGtk : public ImporterList::Observer,
- public ImporterObserver {
- public:
- // Displays the import box to import data from another browser into |profile|.
- // |initial_state| is a bitmask of importer::ImportItem.
- // Each checkbox for the bits in |initial_state| is checked.
- static void Show(GtkWindow* parent, Profile* profile, uint16 initial_state);
-
- private:
- ImportDialogGtk(GtkWindow* parent, Profile* profile, uint16 initial_state);
- virtual ~ImportDialogGtk();
-
- // Handler to respond to OK or Cancel responses from the dialog.
- CHROMEGTK_CALLBACK_1(ImportDialogGtk, void, OnResponse, int);
-
- // Handler to respond to widget clicked actions from the dialog.
- CHROMEGTK_CALLBACK_0(ImportDialogGtk, void, OnDialogWidgetClicked);
-
- // Enable or disable the dialog buttons depending on the state of the
- // checkboxes.
- void UpdateDialogButtons();
-
- // Sets the sensitivity of all controls on the dialog except the cancel
- // button.
- void SetDialogControlsSensitive(bool sensitive);
-
- // Create a bitmask from the checkboxes of the dialog.
- uint16 GetCheckedItems();
-
- // ImporterList::Observer:
- virtual void SourceProfilesLoaded() OVERRIDE;
-
- // ImporterObserver:
- virtual void ImportCompleted() OVERRIDE;
- virtual void ImportCanceled() OVERRIDE;
-
- // Parent window
- GtkWindow* parent_;
-
- // Import Dialog
- GtkWidget* dialog_;
-
- // Combo box that displays list of profiles from which we can import.
- GtkWidget* combo_;
-
- // Bookmarks/Favorites checkbox
- GtkWidget* bookmarks_;
-
- // Search Engines checkbox
- GtkWidget* search_engines_;
-
- // Passwords checkbox
- GtkWidget* passwords_;
-
- // History checkbox
- GtkWidget* history_;
-
- // Import button.
- GtkWidget* import_button_;
-
- // Our current profile
- Profile* profile_;
-
- // Utility class that does the actual import.
- scoped_refptr<ImporterHost> importer_host_;
-
- // Enumerates the source profiles.
- scoped_refptr<ImporterList> importer_list_;
-
- // Initial state of the |checkbox_items_|.
- uint16 initial_state_;
-
- DISALLOW_COPY_AND_ASSIGN(ImportDialogGtk);
-};
-
-#endif // CHROME_BROWSER_UI_GTK_IMPORTER_IMPORT_DIALOG_GTK_H_
diff --git a/chrome/browser/ui/views/importer/import_dialog_view.cc b/chrome/browser/ui/views/importer/import_dialog_view.cc
deleted file mode 100644
index ef7b49c..0000000
--- a/chrome/browser/ui/views/importer/import_dialog_view.cc
+++ /dev/null
@@ -1,299 +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.
-
-#include "chrome/browser/ui/views/importer/import_dialog_view.h"
-
-#include "base/compiler_specific.h"
-#include "base/utf_string_conversions.h"
-#include "chrome/browser/browser_list.h"
-#include "chrome/browser/browser_window.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 "grit/generated_resources.h"
-#include "grit/locale_settings.h"
-#include "ui/base/l10n/l10n_util.h"
-#include "views/controls/button/checkbox.h"
-#include "views/controls/label.h"
-#include "views/layout/grid_layout.h"
-#include "views/layout/layout_constants.h"
-#include "views/widget/widget.h"
-#include "views/window/window.h"
-
-using views::ColumnSet;
-using views::GridLayout;
-
-ImportDialogView::ImportDialogView(Profile* profile, uint16 initial_state)
- : import_from_label_(NULL),
- profile_combobox_(NULL),
- import_items_label_(NULL),
- history_checkbox_(NULL),
- favorites_checkbox_(NULL),
- passwords_checkbox_(NULL),
- search_engines_checkbox_(NULL),
- profile_(profile),
- importer_host_(new ImporterHost),
- importer_list_(new ImporterList),
- initial_state_(initial_state) {
- DCHECK(profile);
- importer_list_->DetectSourceProfiles(this);
- SetupControl();
-}
-
-ImportDialogView::~ImportDialogView() {
- if (importer_list_)
- importer_list_->SetObserver(NULL);
-}
-
-gfx::Size ImportDialogView::GetPreferredSize() {
- return gfx::Size(views::Window::GetLocalizedContentsSize(
- IDS_IMPORT_DIALOG_WIDTH_CHARS,
- IDS_IMPORT_DIALOG_HEIGHT_LINES));
-}
-
-void ImportDialogView::Layout() {
- GetLayoutManager()->Layout(this);
-}
-
-std::wstring ImportDialogView::GetDialogButtonLabel(
- MessageBoxFlags::DialogButton button) const {
- if (button == MessageBoxFlags::DIALOGBUTTON_OK) {
- return UTF16ToWide(l10n_util::GetStringUTF16(IDS_IMPORT_COMMIT));
- } else {
- return std::wstring();
- }
-}
-
-bool ImportDialogView::IsDialogButtonEnabled(
- MessageBoxFlags::DialogButton button) const {
- if (button == MessageBoxFlags::DIALOGBUTTON_OK) {
- return history_checkbox_->checked() ||
- favorites_checkbox_->checked() ||
- passwords_checkbox_->checked() ||
- search_engines_checkbox_->checked();
- }
-
- return true;
-}
-
-bool ImportDialogView::IsModal() const {
- return true;
-}
-
-std::wstring ImportDialogView::GetWindowTitle() const {
- return UTF16ToWide(l10n_util::GetStringUTF16(IDS_IMPORT_SETTINGS_TITLE));
-}
-
-bool ImportDialogView::Accept() {
- if (!IsDialogButtonEnabled(MessageBoxFlags::DIALOGBUTTON_OK))
- return false;
-
- int selected_index = profile_combobox_->selected_item();
- importer::ShowImportProgressDialog(
- GetWidget()->GetNativeView(),
- GetCheckedItems(),
- importer_host_.get(),
- this,
- importer_list_->GetSourceProfileInfoAt(selected_index),
- profile_,
- false);
-
- // We return false here to prevent the window from being closed. We will be
- // notified back by our implementation of ImporterObserver when the import is
- // complete so that we can close ourselves.
- return false;
-}
-
-views::View* ImportDialogView::GetContentsView() {
- return this;
-}
-
-void ImportDialogView::ButtonPressed(
- views::Button* sender, const views::Event& event) {
- // When no checkbox is checked we should disable the "Import" button.
- // This forces the button to evaluate what state they should be in.
- GetDialogClientView()->UpdateDialogButtons();
-}
-
-int ImportDialogView::GetItemCount() {
- DCHECK(importer_host_.get());
- return checkbox_items_.size();
-}
-
-string16 ImportDialogView::GetItemAt(int index) {
- DCHECK(importer_host_.get());
-
- if (!importer_list_->source_profiles_loaded())
- return l10n_util::GetStringUTF16(IDS_IMPORT_LOADING_PROFILES);
- else
- return WideToUTF16Hack(importer_list_->GetSourceProfileNameAt(index));
-}
-
-void ImportDialogView::ItemChanged(views::Combobox* combobox,
- int prev_index, int new_index) {
- DCHECK(combobox);
- DCHECK(checkbox_items_.size() >=
- static_cast<size_t>(importer_list_->GetAvailableProfileCount()));
-
- if (prev_index == new_index)
- return;
-
- if (!importer_list_->source_profiles_loaded()) {
- SetCheckedItemsState(0);
- return;
- }
-
- // Save the current state
- uint16 prev_items = GetCheckedItems();
- checkbox_items_[prev_index] = prev_items;
-
- // Enable/Disable the checkboxes for this Item
- uint16 new_enabled_items = importer_list_->GetSourceProfileInfoAt(
- new_index).services_supported;
- SetCheckedItemsState(new_enabled_items);
-
- // Set the checked items for this Item
- uint16 new_items = checkbox_items_[new_index];
- SetCheckedItems(new_items);
-}
-
-void ImportDialogView::SetupControl() {
- // Adds all controls.
- import_from_label_ = new views::Label(UTF16ToWide(
- l10n_util::GetStringUTF16(IDS_IMPORT_FROM_LABEL)));
-
- profile_combobox_ = new views::Combobox(this);
- profile_combobox_->set_listener(this);
- profile_combobox_->SetAccessibleName(
- WideToUTF16Hack(import_from_label_->GetText()));
-
- import_items_label_ = new views::Label(UTF16ToWide(
- l10n_util::GetStringUTF16(IDS_IMPORT_ITEMS_LABEL)));
-
- history_checkbox_ = InitCheckbox(
- UTF16ToWide(l10n_util::GetStringUTF16(IDS_IMPORT_HISTORY_CHKBOX)),
- (initial_state_ & importer::HISTORY) != 0);
- favorites_checkbox_ = InitCheckbox(
- UTF16ToWide(l10n_util::GetStringUTF16(IDS_IMPORT_FAVORITES_CHKBOX)),
- (initial_state_ & importer::FAVORITES) != 0);
- passwords_checkbox_ = InitCheckbox(
- UTF16ToWide(l10n_util::GetStringUTF16(IDS_IMPORT_PASSWORDS_CHKBOX)),
- (initial_state_ & importer::PASSWORDS) != 0);
- search_engines_checkbox_ = InitCheckbox(
- UTF16ToWide(l10n_util::GetStringUTF16(IDS_IMPORT_SEARCH_ENGINES_CHKBOX)),
- (initial_state_ & importer::SEARCH_ENGINES) != 0);
-
- // Arranges controls by using GridLayout.
- const int column_set_id = 0;
- GridLayout* layout = GridLayout::CreatePanel(this);
- SetLayoutManager(layout);
- ColumnSet* column_set = layout->AddColumnSet(column_set_id);
- column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
- GridLayout::USE_PREF, 0, 0);
- column_set->AddPaddingColumn(0, views::kRelatedControlHorizontalSpacing);
- column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 0,
- GridLayout::FIXED, 200, 0);
-
- layout->StartRow(0, column_set_id);
- layout->AddView(import_from_label_);
- layout->AddView(profile_combobox_);
-
- layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing);
- layout->StartRow(0, column_set_id);
- layout->AddView(import_items_label_, 3, 1);
- layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
- layout->StartRow(0, column_set_id);
- layout->AddView(favorites_checkbox_, 3, 1);
- layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
- layout->StartRow(0, column_set_id);
- layout->AddView(search_engines_checkbox_, 3, 1);
- layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
- layout->StartRow(0, column_set_id);
- layout->AddView(passwords_checkbox_, 3, 1);
- layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
- layout->StartRow(0, column_set_id);
- layout->AddView(history_checkbox_, 3, 1);
- layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
-}
-
-views::Checkbox* ImportDialogView::InitCheckbox(const std::wstring& text,
- bool checked) {
- views::Checkbox* checkbox = new views::Checkbox(text);
- checkbox->SetChecked(checked);
- checkbox->set_listener(this);
- return checkbox;
-}
-
-uint16 ImportDialogView::GetCheckedItems() {
- uint16 items = importer::NONE;
- if (history_checkbox_->IsEnabled() && history_checkbox_->checked())
- items |= importer::HISTORY;
- if (favorites_checkbox_->IsEnabled() && favorites_checkbox_->checked())
- items |= importer::FAVORITES;
- if (passwords_checkbox_->IsEnabled() && passwords_checkbox_->checked())
- items |= importer::PASSWORDS;
- if (search_engines_checkbox_->IsEnabled() &&
- search_engines_checkbox_->checked())
- items |= importer::SEARCH_ENGINES;
- return items;
-}
-
-void ImportDialogView::SetCheckedItemsState(uint16 items) {
- if (items & importer::HISTORY) {
- history_checkbox_->SetEnabled(true);
- } else {
- history_checkbox_->SetEnabled(false);
- history_checkbox_->SetChecked(false);
- }
- if (items & importer::FAVORITES) {
- favorites_checkbox_->SetEnabled(true);
- } else {
- favorites_checkbox_->SetEnabled(false);
- favorites_checkbox_->SetChecked(false);
- }
- if (items & importer::PASSWORDS) {
- passwords_checkbox_->SetEnabled(true);
- } else {
- passwords_checkbox_->SetEnabled(false);
- passwords_checkbox_->SetChecked(false);
- }
- if (items & importer::SEARCH_ENGINES) {
- search_engines_checkbox_->SetEnabled(true);
- } else {
- search_engines_checkbox_->SetEnabled(false);
- search_engines_checkbox_->SetChecked(false);
- }
-}
-
-void ImportDialogView::SetCheckedItems(uint16 items) {
- if (history_checkbox_->IsEnabled())
- history_checkbox_->SetChecked(!!(items & importer::HISTORY));
-
- if (favorites_checkbox_->IsEnabled())
- favorites_checkbox_->SetChecked(!!(items & importer::FAVORITES));
-
- if (passwords_checkbox_->IsEnabled())
- passwords_checkbox_->SetChecked(!!(items & importer::PASSWORDS));
-
- if (search_engines_checkbox_->IsEnabled())
- search_engines_checkbox_->SetChecked(!!(items & importer::SEARCH_ENGINES));
-}
-
-void ImportDialogView::SourceProfilesLoaded() {
- DCHECK(importer_list_->source_profiles_loaded());
- checkbox_items_.resize(
- importer_list_->GetAvailableProfileCount(), initial_state_);
-
- // Reload the profile combobox.
- profile_combobox_->ModelChanged();
-}
-
-void ImportDialogView::ImportCompleted() {
- // Now close this window since the import completed or was canceled.
- window()->CloseWindow();
-}
-
-void ImportDialogView::ImportCanceled() {
- ImportCompleted();
-}
diff --git a/chrome/browser/ui/views/importer/import_dialog_view.h b/chrome/browser/ui/views/importer/import_dialog_view.h
deleted file mode 100644
index 1a5ec93..0000000
--- a/chrome/browser/ui/views/importer/import_dialog_view.h
+++ /dev/null
@@ -1,125 +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_VIEWS_IMPORTER_IMPORT_DIALOG_VIEW_H_
-#define CHROME_BROWSER_UI_VIEWS_IMPORTER_IMPORT_DIALOG_VIEW_H_
-#pragma once
-
-#include <vector>
-
-#include "base/basictypes.h"
-#include "base/compiler_specific.h"
-#include "base/ref_counted.h"
-#include "base/string16.h"
-#include "chrome/browser/importer/importer_host.h"
-#include "chrome/browser/importer/importer_observer.h"
-#include "ui/base/models/combobox_model.h"
-#include "views/controls/button/native_button.h"
-#include "views/controls/combobox/combobox.h"
-#include "views/view.h"
-#include "views/window/dialog_delegate.h"
-
-namespace views {
-class Checkbox;
-class Label;
-class Window;
-}
-
-class ImporterList;
-class Profile;
-
-// ImportDialogView draws the dialog that allows the user to select what to
-// import from other browsers.
-class ImportDialogView : public views::View,
- public views::DialogDelegate,
- public views::ButtonListener,
- public ui::ComboboxModel,
- public views::Combobox::Listener,
- public ImporterList::Observer,
- public ImporterObserver {
- public:
- // |initial_state| is a bitmask of importer::ImportItem.
- // Each checkbox for the bits in |initial_state| is checked.
- ImportDialogView(Profile* profile, uint16 initial_state);
- virtual ~ImportDialogView();
-
- protected:
- // views::View:
- virtual gfx::Size GetPreferredSize() OVERRIDE;
- virtual void Layout() OVERRIDE;
-
- // views::DialogDelegate:
- virtual std::wstring GetDialogButtonLabel(
- MessageBoxFlags::DialogButton button) const OVERRIDE;
- virtual bool IsDialogButtonEnabled(
- MessageBoxFlags::DialogButton button) const OVERRIDE;
- virtual bool IsModal() const OVERRIDE;
- virtual std::wstring GetWindowTitle() const OVERRIDE;
- virtual bool Accept() OVERRIDE;
- virtual views::View* GetContentsView() OVERRIDE;
-
- // views::ButtonListener:
- virtual void ButtonPressed(views::Button* sender,
- const views::Event& event) OVERRIDE;
-
- // ui::ComboboxModel:
- virtual int GetItemCount();
- virtual string16 GetItemAt(int index) OVERRIDE;
-
- // views::Combobox::Listener
- virtual void ItemChanged(views::Combobox* combobox,
- int prev_index,
- int new_index) OVERRIDE;
-
- private:
- // Initializes the controls on the dialog.
- void SetupControl();
-
- // Creates and initializes a new check-box.
- views::Checkbox* InitCheckbox(const std::wstring& text, bool checked);
-
- // Create a bitmap from the checkboxes of the view.
- uint16 GetCheckedItems();
-
- // Enables/Disables all the checked items for the given state.
- void SetCheckedItemsState(uint16 items);
-
- // Sets all checked items in the given state.
- void SetCheckedItems(uint16 items);
-
- // ImporterList::Observer:
- virtual void SourceProfilesLoaded() OVERRIDE;
-
- // ImporterObserver:
- virtual void ImportCompleted() OVERRIDE;
- virtual void ImportCanceled() OVERRIDE;
-
- views::Label* import_from_label_;
- views::Combobox* profile_combobox_;
- views::Label* import_items_label_;
- views::Checkbox* history_checkbox_;
- views::Checkbox* favorites_checkbox_;
- views::Checkbox* passwords_checkbox_;
- views::Checkbox* search_engines_checkbox_;
-
- // Our current profile.
- Profile* profile_;
-
- // Utility class that does the actual import.
- scoped_refptr<ImporterHost> importer_host_;
-
- // Enumerates the source profiles.
- scoped_refptr<ImporterList> importer_list_;
-
- // Stores the state of the checked items associated with the position of the
- // selected item in the combo-box.
- std::vector<uint16> checkbox_items_;
-
- // Initial state of the |checkbox_items_|.
- uint16 initial_state_;
-
- DISALLOW_COPY_AND_ASSIGN(ImportDialogView);
-};
-
-#endif // CHROME_BROWSER_UI_VIEWS_IMPORTER_IMPORT_DIALOG_VIEW_H_