| 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" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 // | |icon| Google Chrome available | | 51 // | |icon| Google Chrome available | |
| 52 // | [o] Try it out (already installed) | | 52 // | [o] Try it out (already installed) | |
| 53 // | [ ] Don't bug me | | 53 // | [ ] Don't bug me | |
| 54 // | --------------------------------------------- | | 54 // | --------------------------------------------- | |
| 55 // | [x] Make it the default browser [ OK ] | | 55 // | [x] Make it the default browser [ OK ] | |
| 56 // +-----------------------------------------------+ | 56 // +-----------------------------------------------+ |
| 57 | 57 |
| 58 class TryChromeDialogView : public views::ButtonListener, | 58 class TryChromeDialogView : public views::ButtonListener, |
| 59 public views::LinkListener { | 59 public views::LinkListener { |
| 60 public: | 60 public: |
| 61 // Receives a handle to the active modal dialog, or NULL when the active |
| 62 // dialog is dismissed. |
| 63 typedef base::Callback<void(gfx::NativeWindow active_dialog)> |
| 64 ActiveModalDialogListener; |
| 65 |
| 61 enum Result { | 66 enum Result { |
| 62 TRY_CHROME, // Launch chrome right now. | 67 TRY_CHROME, // Launch chrome right now. |
| 63 TRY_CHROME_AS_DEFAULT, // Launch chrome and make it the default. | 68 TRY_CHROME_AS_DEFAULT, // Launch chrome and make it the default. |
| 64 NOT_NOW, // Don't launch chrome. Exit now. | 69 NOT_NOW, // Don't launch chrome. Exit now. |
| 65 UNINSTALL_CHROME, // Initiate chrome uninstall and exit. | 70 UNINSTALL_CHROME, // Initiate chrome uninstall and exit. |
| 66 DIALOG_ERROR, // An error occurred creating the dialog. | 71 DIALOG_ERROR, // An error occurred creating the dialog. |
| 67 COUNT | 72 COUNT |
| 68 }; | 73 }; |
| 69 | 74 |
| 70 // Shows a modal dialog asking the user to give chrome another try. See | 75 // Shows a modal dialog asking the user to give chrome another try. See |
| 71 // above for the possible outcomes of the function. This is an experimental, | 76 // above for the possible outcomes of the function. This is an experimental, |
| 72 // non-localized dialog. | 77 // non-localized dialog. |
| 73 // |flavor| can be 0, 1, 2 or 3 and selects what strings to present. | 78 // |flavor| can be 0, 1, 2 or 3 and selects what strings to present. |
| 74 // |process_singleton| needs to be valid and it will be locked while | 79 // |listener| will be notified when the dialog becomes active and when it is |
| 75 // the dialog is shown. | 80 // dismissed. |
| 76 // Note that the dialog has no parent and it will position itself in a lower | 81 // Note that the dialog has no parent and it will position itself in a lower |
| 77 // corner of the screen. The dialog does not steal focus and does not have an | 82 // corner of the screen. The dialog does not steal focus and does not have an |
| 78 // entry in the taskbar. | 83 // entry in the taskbar. |
| 79 static Result Show(size_t flavor, ProcessSingleton* process_singleton); | 84 static Result Show(size_t flavor, const ActiveModalDialogListener& listener); |
| 80 | 85 |
| 81 private: | 86 private: |
| 82 explicit TryChromeDialogView(size_t flavor); | 87 explicit TryChromeDialogView(size_t flavor); |
| 83 virtual ~TryChromeDialogView(); | 88 virtual ~TryChromeDialogView(); |
| 84 | 89 |
| 85 Result ShowModal(ProcessSingleton* process_singleton); | 90 Result ShowModal(const ActiveModalDialogListener& listener); |
| 86 | 91 |
| 87 // Returns a screen rectangle that is fit to show the window. In particular | 92 // Returns a screen rectangle that is fit to show the window. In particular |
| 88 // it has the following properties: a) is visible and b) is attached to the | 93 // it has the following properties: a) is visible and b) is attached to the |
| 89 // bottom of the working area. For LTR machines it returns a left side | 94 // bottom of the working area. For LTR machines it returns a left side |
| 90 // rectangle and for RTL it returns a right side rectangle so that the dialog | 95 // rectangle and for RTL it returns a right side rectangle so that the dialog |
| 91 // does not compete with the standar place of the start menu. | 96 // does not compete with the standar place of the start menu. |
| 92 gfx::Rect ComputeWindowPosition(int width, int height, bool is_RTL); | 97 gfx::Rect ComputeWindowPosition(int width, int height, bool is_RTL); |
| 93 | 98 |
| 94 // Create a windows region that looks like a toast of width |w| and height | 99 // Create a windows region that looks like a toast of width |w| and height |
| 95 // |h|. This is best effort, so we don't care much if the operation fails. | 100 // |h|. This is best effort, so we don't care much if the operation fails. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 115 views::RadioButton* try_chrome_; | 120 views::RadioButton* try_chrome_; |
| 116 views::RadioButton* kill_chrome_; | 121 views::RadioButton* kill_chrome_; |
| 117 views::RadioButton* dont_try_chrome_; | 122 views::RadioButton* dont_try_chrome_; |
| 118 views::Checkbox* make_default_; | 123 views::Checkbox* make_default_; |
| 119 Result result_; | 124 Result result_; |
| 120 | 125 |
| 121 DISALLOW_COPY_AND_ASSIGN(TryChromeDialogView); | 126 DISALLOW_COPY_AND_ASSIGN(TryChromeDialogView); |
| 122 }; | 127 }; |
| 123 | 128 |
| 124 #endif // CHROME_BROWSER_FIRST_RUN_TRY_CHROME_DIALOG_VIEW_H_ | 129 #endif // CHROME_BROWSER_FIRST_RUN_TRY_CHROME_DIALOG_VIEW_H_ |
| OLD | NEW |