| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_FIRST_RUN_TRY_CHROME_DIALOG_VIEW_H_ | 5 #ifndef CHROME_BROWSER_FIRST_RUN_TRY_CHROME_DIALOG_VIEW_H_ |
| 6 #define CHROME_BROWSER_FIRST_RUN_TRY_CHROME_DIALOG_VIEW_H_ | 6 #define CHROME_BROWSER_FIRST_RUN_TRY_CHROME_DIALOG_VIEW_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "ui/gfx/native_widget_types.h" | 10 #include "ui/gfx/native_widget_types.h" |
| 11 #include "ui/views/controls/button/button.h" | 11 #include "ui/views/controls/button/button.h" |
| 12 #include "ui/views/controls/link_listener.h" | 12 #include "ui/views/controls/link_listener.h" |
| 13 | 13 |
| 14 class ProcessSingleton; | 14 class ProcessSingleton; |
| 15 | 15 |
| 16 namespace gfx { | 16 namespace gfx { |
| 17 class Rect; | 17 class Rect; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace views { | 20 namespace views { |
| 21 class RadioButton; | 21 class RadioButton; |
| 22 class Checkbox; |
| 22 class Widget; | 23 class Widget; |
| 23 } | 24 } |
| 24 | 25 |
| 25 // This class displays a modal dialog using the views system. The dialog asks | 26 // This class displays a modal dialog using the views system. The dialog asks |
| 26 // the user to give chrome another try. This class only handles the UI so the | 27 // the user to give chrome another try. This class only handles the UI so the |
| 27 // resulting actions are up to the caller. One flavor looks like this: | 28 // resulting actions are up to the caller. One flavor looks like this: |
| 28 // | 29 // |
| 29 // +-----------------------------------------------+ | 30 // +-----------------------------------------------+ |
| 30 // | |icon| You stopped using Google Chrome [x] | | 31 // | |icon| There is a new, safer version [x] | |
| 31 // | |icon| Would you like to: | | 32 // | |icon| of Google Chrome available | |
| 32 // | [o] Give the new version a try | | 33 // | [o] Try it out (already installed) | |
| 33 // | [ ] Uninstall Google Chrome | | 34 // | [ ] Uninstall Google Chrome | |
| 34 // | [ OK ] [Don't bug me] | | 35 // | [ OK ] [Don't bug me] | |
| 35 // | | | |
| 36 // | _why_am_I_seeing this?_ | | 36 // | _why_am_I_seeing this?_ | |
| 37 // +-----------------------------------------------+ | 37 // +-----------------------------------------------+ |
| 38 // | 38 // |
| 39 // Another flavor looks like: |
| 40 // +-----------------------------------------------+ |
| 41 // | |icon| There is a new, safer version [x] | |
| 42 // | |icon| of Google Chrome available | |
| 43 // | [o] Try it out (already installed) | |
| 44 // | [ ] Don't bug me | |
| 45 // | [ OK ] | |
| 46 // +-----------------------------------------------+ |
| 47 // |
| 39 class TryChromeDialogView : public views::ButtonListener, | 48 class TryChromeDialogView : public views::ButtonListener, |
| 40 public views::LinkListener { | 49 public views::LinkListener { |
| 41 public: | 50 public: |
| 42 enum Result { | 51 enum Result { |
| 43 TRY_CHROME, // Launch chrome right now. | 52 TRY_CHROME, // Launch chrome right now. |
| 44 NOT_NOW, // Don't launch chrome. Exit now. | 53 TRY_CHROME_AS_DEFAULT, // Launch chrome and make it the default. |
| 45 UNINSTALL_CHROME, // Initiate chrome uninstall and exit. | 54 NOT_NOW, // Don't launch chrome. Exit now. |
| 46 DIALOG_ERROR, // An error occurred creating the dialog. | 55 UNINSTALL_CHROME, // Initiate chrome uninstall and exit. |
| 56 DIALOG_ERROR, // An error occurred creating the dialog. |
| 47 COUNT | 57 COUNT |
| 48 }; | 58 }; |
| 49 | 59 |
| 50 // Shows a modal dialog asking the user to give chrome another try. See | 60 // Shows a modal dialog asking the user to give chrome another try. See |
| 51 // above for the possible outcomes of the function. This is an experimental, | 61 // above for the possible outcomes of the function. This is an experimental, |
| 52 // non-localized dialog. | 62 // non-localized dialog. |
| 53 // |flavor| can be 0, 1, 2 or 3 and selects what strings to present. | 63 // |flavor| can be 0, 1, 2 or 3 and selects what strings to present. |
| 54 // |process_singleton| needs to be valid and it will be locked while | 64 // |process_singleton| needs to be valid and it will be locked while |
| 55 // the dialog is shown. | 65 // the dialog is shown. |
| 56 // Note that the dialog has no parent and it will position itself in a lower | 66 // Note that the dialog has no parent and it will position itself in a lower |
| 57 // corner of the screen. The dialog does not steal focus and does not have an | 67 // corner of the screen. The dialog does not steal focus and does not have an |
| 58 // entry in the taskbar. | 68 // entry in the taskbar. |
| 59 static Result Show(size_t flavor, ProcessSingleton* process_singleton); | 69 static Result Show(size_t flavor, ProcessSingleton* process_singleton); |
| 60 | 70 |
| 61 private: | 71 private: |
| 62 enum ButtonTags { | |
| 63 BT_NONE, | |
| 64 BT_CLOSE_BUTTON, | |
| 65 BT_OK_BUTTON, | |
| 66 }; | |
| 67 | |
| 68 explicit TryChromeDialogView(size_t flavor); | 72 explicit TryChromeDialogView(size_t flavor); |
| 69 virtual ~TryChromeDialogView(); | 73 virtual ~TryChromeDialogView(); |
| 70 | 74 |
| 71 Result ShowModal(ProcessSingleton* process_singleton); | 75 Result ShowModal(ProcessSingleton* process_singleton); |
| 72 | 76 |
| 73 // Returns a screen rectangle that is fit to show the window. In particular | 77 // Returns a screen rectangle that is fit to show the window. In particular |
| 74 // it has the following properties: a) is visible and b) is attached to the | 78 // it has the following properties: a) is visible and b) is attached to the |
| 75 // bottom of the working area. For LTR machines it returns a left side | 79 // bottom of the working area. For LTR machines it returns a left side |
| 76 // rectangle and for RTL it returns a right side rectangle so that the dialog | 80 // rectangle and for RTL it returns a right side rectangle so that the dialog |
| 77 // does not compete with the standar place of the start menu. | 81 // does not compete with the standar place of the start menu. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 94 | 98 |
| 95 // Controls which flavor of the heading text to use. | 99 // Controls which flavor of the heading text to use. |
| 96 size_t flavor_; | 100 size_t flavor_; |
| 97 | 101 |
| 98 // We don't own any of these pointers. The |popup_| owns itself and owns the | 102 // We don't own any of these pointers. The |popup_| owns itself and owns the |
| 99 // other views. | 103 // other views. |
| 100 views::Widget* popup_; | 104 views::Widget* popup_; |
| 101 views::RadioButton* try_chrome_; | 105 views::RadioButton* try_chrome_; |
| 102 views::RadioButton* kill_chrome_; | 106 views::RadioButton* kill_chrome_; |
| 103 views::RadioButton* dont_try_chrome_; | 107 views::RadioButton* dont_try_chrome_; |
| 108 views::Checkbox* make_default_; |
| 104 Result result_; | 109 Result result_; |
| 105 | 110 |
| 106 DISALLOW_COPY_AND_ASSIGN(TryChromeDialogView); | 111 DISALLOW_COPY_AND_ASSIGN(TryChromeDialogView); |
| 107 }; | 112 }; |
| 108 | 113 |
| 109 #endif // CHROME_BROWSER_FIRST_RUN_TRY_CHROME_DIALOG_VIEW_H_ | 114 #endif // CHROME_BROWSER_FIRST_RUN_TRY_CHROME_DIALOG_VIEW_H_ |
| OLD | NEW |