Home | History | Annotate | Download | only in importer
      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 #ifndef CHROME_BROWSER_IMPORTER_IMPORT_PROGRESS_DIALOG_H_
      6 #define CHROME_BROWSER_IMPORTER_IMPORT_PROGRESS_DIALOG_H_
      7 #pragma once
      8 
      9 #import <Cocoa/Cocoa.h>
     10 
     11 #include "base/basictypes.h"
     12 #include "base/compiler_specific.h"
     13 #include "base/memory/scoped_ptr.h"
     14 #include "chrome/browser/importer/importer_data_types.h"
     15 #include "chrome/browser/importer/importer_progress_observer.h"
     16 
     17 class ImporterHost;
     18 class ImporterObserver;
     19 class ImporterObserverBridge;
     20 
     21 // Class that acts as a controller for the dialog that shows progress for an
     22 // import operation.
     23 // Lifetime: This object is responsible for deleting itself.
     24 @interface ImportProgressDialogController : NSWindowController {
     25   scoped_ptr<ImporterObserverBridge> import_host_observer_bridge_;
     26   ImporterHost* importer_host_;  // (weak)
     27   ImporterObserver* observer_;   // (weak)
     28 
     29   // Strings bound to static labels in the UI dialog.
     30   NSString* explanatory_text_;
     31   NSString* favorites_status_text_;
     32   NSString* search_status_text_;
     33   NSString* saved_password_status_text_;
     34   NSString* history_status_text_;
     35 
     36   // Bound to the color of the status text (this is the easiest way to disable
     37   // progress items that aren't supported by the current browser we're importing
     38   // from).
     39   NSColor* favorites_import_enabled_;
     40   NSColor* search_import_enabled_;
     41   NSColor* password_import_enabled_;
     42   NSColor* history_import_enabled_;
     43 
     44   // Placeholders for "Importing..." and "Done" text.
     45   NSString* progress_text_;
     46   NSString* done_text_;
     47 }
     48 
     49 @property(nonatomic, retain) NSString* explanatoryText;
     50 @property(nonatomic, retain) NSString* favoritesStatusText;
     51 @property(nonatomic, retain) NSString* searchStatusText;
     52 @property(nonatomic, retain) NSString* savedPasswordStatusText;
     53 @property(nonatomic, retain) NSString* historyStatusText;
     54 
     55 @property(nonatomic, retain) NSColor* favoritesImportEnabled;
     56 @property(nonatomic, retain) NSColor* searchImportEnabled;
     57 @property(nonatomic, retain) NSColor* passwordImportEnabled;
     58 @property(nonatomic, retain) NSColor* historyImportEnabled;
     59 
     60 // Cancel button calls this.
     61 - (IBAction)cancel:(id)sender;
     62 
     63 // Closes the dialog.
     64 - (void)closeDialog;
     65 
     66 // Methods called by importer_host via ImporterObserverBridge.
     67 - (void)ImportItemStarted:(importer::ImportItem)item;
     68 - (void)ImportItemEnded:(importer::ImportItem)item;
     69 - (void)ImportEnded;
     70 
     71 @end
     72 
     73 // C++ -> objc bridge for import status notifications.
     74 class ImporterObserverBridge : public importer::ImporterProgressObserver {
     75  public:
     76   ImporterObserverBridge(ImportProgressDialogController* owner);
     77   virtual ~ImporterObserverBridge();
     78 
     79  private:
     80   // importer::ImporterProgressObserver:
     81   virtual void ImportStarted() OVERRIDE;
     82   virtual void ImportItemStarted(importer::ImportItem item) OVERRIDE;
     83   virtual void ImportItemEnded(importer::ImportItem item) OVERRIDE;
     84   virtual void ImportEnded() OVERRIDE;
     85 
     86   ImportProgressDialogController* owner_;
     87 
     88   DISALLOW_COPY_AND_ASSIGN(ImporterObserverBridge);
     89 };
     90 
     91 #endif  // CHROME_BROWSER_IMPORTER_IMPORT_PROGRESS_DIALOG_H_
     92