| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2010 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_VIEWS_FIRST_RUN_VIEW_BASE_H_ | |
| 6 #define CHROME_BROWSER_VIEWS_FIRST_RUN_VIEW_BASE_H_ | |
| 7 | |
| 8 #include "chrome/browser/importer/importer.h" | |
| 9 #include "views/view.h" | |
| 10 #include "views/window/dialog_delegate.h" | |
| 11 | |
| 12 namespace views { | |
| 13 class Checkbox; | |
| 14 class Label; | |
| 15 class Window; | |
| 16 class ImageView; | |
| 17 class Separator; | |
| 18 class Throbber; | |
| 19 } | |
| 20 | |
| 21 class Profile; | |
| 22 class ImporterHost; | |
| 23 | |
| 24 // This class abstracts the code that creates the dialog look for the two | |
| 25 // first-run dialogs. This amounts to the bitmap, the two separators, the | |
| 26 // progress throbber and some common resize code. | |
| 27 class FirstRunViewBase : public views::View, | |
| 28 public views::ButtonListener, | |
| 29 public views::DialogDelegate { | |
| 30 public: | |
| 31 explicit FirstRunViewBase(Profile* profile, bool homepage_defined, | |
| 32 int import_items, int dont_import_items, | |
| 33 bool search_engine_experiment, | |
| 34 bool randomize_search_engine_experiment); | |
| 35 virtual ~FirstRunViewBase(); | |
| 36 | |
| 37 // Overridden from views::View. | |
| 38 virtual void Layout(); | |
| 39 | |
| 40 // Overridden from views::WindowDelegate. | |
| 41 virtual bool CanResize() const; | |
| 42 virtual bool CanMaximize() const; | |
| 43 virtual bool IsAlwaysOnTop() const; | |
| 44 virtual bool HasAlwaysOnTopMenu() const; | |
| 45 | |
| 46 // Overridden form views::ButtonListener. | |
| 47 virtual void ButtonPressed(views::Button* sender, const views::Event& event); | |
| 48 | |
| 49 // Overridden from views::DialogDelegate. | |
| 50 std::wstring GetDialogButtonLabel(MessageBoxFlags::DialogButton button) const; | |
| 51 | |
| 52 protected: | |
| 53 // Returns the items that the first run process should import | |
| 54 // from other browsers. If there are any items that should or should not | |
| 55 // be imported (read and passed through from master preferences), it will | |
| 56 // take those into account. | |
| 57 int GetImportItems() const; | |
| 58 | |
| 59 // Creates the desktop and quick launch shortcut. Existing shortcut is lost. | |
| 60 bool CreateDesktopShortcut(); | |
| 61 bool CreateQuickLaunchShortcut(); | |
| 62 | |
| 63 // Set us as default browser if the user checked the box. | |
| 64 bool SetDefaultBrowser(); | |
| 65 | |
| 66 // Modifies the chrome configuration so that the first-run dialogs are not | |
| 67 // shown again. | |
| 68 bool FirstRunComplete(); | |
| 69 | |
| 70 // Disables the standard buttons of the dialog. Useful when importing. | |
| 71 void DisableButtons(); | |
| 72 // Computes a tight dialog width given a contained UI element. | |
| 73 void AdjustDialogWidth(const views::View* sub_view); | |
| 74 | |
| 75 // Sets a minimum dialog size. | |
| 76 void SetMinimumDialogWidth(int width); | |
| 77 | |
| 78 // Returns the background image. It is useful for getting the metrics. | |
| 79 const views::ImageView* background_image() const { | |
| 80 return background_image_; | |
| 81 } | |
| 82 // Returns the computed preferred width of the dialog. This value can change | |
| 83 // when AdjustDialogWidth() is called during layout. | |
| 84 int preferred_width() const { | |
| 85 return preferred_width_; | |
| 86 } | |
| 87 | |
| 88 scoped_refptr<ImporterHost> importer_host_; | |
| 89 Profile* profile_; | |
| 90 views::Checkbox* default_browser_; | |
| 91 views::Label* non_default_browser_label_; | |
| 92 | |
| 93 protected: | |
| 94 bool homepage_defined_; | |
| 95 int import_items_; | |
| 96 int dont_import_items_; | |
| 97 bool search_engine_experiment_; | |
| 98 bool randomize_search_engine_experiment_; | |
| 99 | |
| 100 private: | |
| 101 // Initializes the controls on the dialog. | |
| 102 void SetupControls(); | |
| 103 views::ImageView* background_image_; | |
| 104 views::Separator* separator_1_; | |
| 105 views::Separator* separator_2_; | |
| 106 int preferred_width_; | |
| 107 | |
| 108 DISALLOW_COPY_AND_ASSIGN(FirstRunViewBase); | |
| 109 }; | |
| 110 | |
| 111 #endif // CHROME_BROWSER_VIEWS_FIRST_RUN_VIEW_BASE_H_ | |
| OLD | NEW |