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_UI_VIEWS_TRY_CHROME_DIALOG_VIEW_H_ |
6 #define CHROME_BROWSER_FIRST_RUN_TRY_CHROME_DIALOG_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_TRY_CHROME_DIALOG_VIEW_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "ui/gfx/geometry/rect.h" | 12 #include "ui/gfx/geometry/rect.h" |
13 #include "ui/gfx/geometry/size.h" | 13 #include "ui/gfx/geometry/size.h" |
14 #include "ui/gfx/native_widget_types.h" | 14 #include "ui/gfx/native_widget_types.h" |
15 #include "ui/views/controls/button/button.h" | 15 #include "ui/views/controls/button/button.h" |
16 #include "ui/views/controls/link_listener.h" | 16 #include "ui/views/controls/link_listener.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 | 72 |
73 // Shows a modal dialog asking the user to give chrome another try. See | 73 // Shows a modal dialog asking the user to give chrome another try. See |
74 // above for the possible outcomes of the function. This is an experimental, | 74 // above for the possible outcomes of the function. This is an experimental, |
75 // non-localized dialog. | 75 // non-localized dialog. |
76 // |flavor| can be 0, 1, 2 or 3 and selects what strings to present. | 76 // |flavor| can be 0, 1, 2 or 3 and selects what strings to present. |
77 // |listener| will be notified when the dialog becomes active and when it is | 77 // |listener| will be notified when the dialog becomes active and when it is |
78 // dismissed. | 78 // dismissed. |
79 // Note that the dialog has no parent and it will position itself in a lower | 79 // Note that the dialog has no parent and it will position itself in a lower |
80 // corner of the screen. The dialog does not steal focus and does not have an | 80 // corner of the screen. The dialog does not steal focus and does not have an |
81 // entry in the taskbar. | 81 // entry in the taskbar. |
82 static Result Show(size_t flavor, const ActiveModalDialogListener& listener); | 82 static Result Show(size_t flavor, |
| 83 const ActiveModalDialogListener& listener); |
| 84 private: |
| 85 // Indicates whether the dialog is modal |
| 86 enum class kDialogType { |
| 87 MODAL, // Modal dialog. |
| 88 MODELESS, // Modeless dialog. |
| 89 }; |
83 | 90 |
84 private: | 91 // Indicates the usage type. Chrome or tests. |
| 92 enum class kUsageType { |
| 93 FOR_CHROME, |
| 94 FOR_TESTING, |
| 95 }; |
| 96 |
| 97 friend class TryChromeDialogTest; |
| 98 |
85 explicit TryChromeDialogView(size_t flavor); | 99 explicit TryChromeDialogView(size_t flavor); |
86 ~TryChromeDialogView() override; | 100 ~TryChromeDialogView() override; |
87 | 101 |
88 Result ShowModal(const ActiveModalDialogListener& listener); | 102 // Helper function to show the dialog. |
| 103 // The |dialog_type| parameter indicates whether the dialog is modal. |
| 104 // The |usage_type| parameter indicates whether this is being invoked by |
| 105 // chrome or a test. |
| 106 Result ShowDialog(const ActiveModalDialogListener& listener, |
| 107 kDialogType dialog_type, |
| 108 kUsageType usage_type); |
89 | 109 |
90 // Returns a screen rectangle that is fit to show the window. In particular | 110 // Returns a screen rectangle that is fit to show the window. In particular |
91 // it has the following properties: a) is visible and b) is attached to the | 111 // it has the following properties: a) is visible and b) is attached to the |
92 // bottom of the working area. For LTR machines it returns a left side | 112 // bottom of the working area. For LTR machines it returns a left side |
93 // rectangle and for RTL it returns a right side rectangle so that the dialog | 113 // rectangle and for RTL it returns a right side rectangle so that the dialog |
94 // does not compete with the standard place of the start menu. | 114 // does not compete with the standard place of the start menu. |
95 gfx::Rect ComputeWindowPosition(gfx::Size size, bool is_RTL); | 115 gfx::Rect ComputeWindowPosition(const gfx::Size& size, bool is_RTL); |
96 | 116 |
97 // Create a windows region that looks like a toast of width |w| and height | 117 // Create a windows region that looks like a toast of width |w| and height |
98 // |h|. This is best effort, so we don't care much if the operation fails. | 118 // |h|. This is best effort, so we don't care much if the operation fails. |
99 void SetToastRegion(HWND window, int w, int h); | 119 void SetToastRegion(HWND window, int w, int h); |
100 | 120 |
101 // views::ButtonListener: | 121 // views::ButtonListener: |
102 // We have two buttons and according to what the user clicked we set |result_| | 122 // We have two buttons and according to what the user clicked we set |result_| |
103 // and we should always close and end the modal loop. | 123 // and we should always close and end the modal loop. |
104 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | 124 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
105 | 125 |
(...skipping 10 matching lines...) Expand all Loading... |
116 views::Widget* popup_; | 136 views::Widget* popup_; |
117 views::RadioButton* try_chrome_; | 137 views::RadioButton* try_chrome_; |
118 views::RadioButton* kill_chrome_; | 138 views::RadioButton* kill_chrome_; |
119 views::RadioButton* dont_try_chrome_; | 139 views::RadioButton* dont_try_chrome_; |
120 views::Checkbox* make_default_; | 140 views::Checkbox* make_default_; |
121 Result result_; | 141 Result result_; |
122 | 142 |
123 DISALLOW_COPY_AND_ASSIGN(TryChromeDialogView); | 143 DISALLOW_COPY_AND_ASSIGN(TryChromeDialogView); |
124 }; | 144 }; |
125 | 145 |
126 #endif // CHROME_BROWSER_FIRST_RUN_TRY_CHROME_DIALOG_VIEW_H_ | 146 #endif // CHROME_BROWSER_UI_VIEWS_TRY_CHROME_DIALOG_VIEW_H_ |
OLD | NEW |