Index: chrome/browser/ui/views/try_chrome_dialog.h |
diff --git a/chrome/browser/ui/views/try_chrome_dialog_view.h b/chrome/browser/ui/views/try_chrome_dialog.h |
similarity index 37% |
rename from chrome/browser/ui/views/try_chrome_dialog_view.h |
rename to chrome/browser/ui/views/try_chrome_dialog.h |
index 004cbbc63c1cfd2c72494a5863e108934b29bf11..7c32a7f0aee4c64fb94b70d029186ec0c76b406d 100644 |
--- a/chrome/browser/ui/views/try_chrome_dialog_view.h |
+++ b/chrome/browser/ui/views/try_chrome_dialog.h |
@@ -2,59 +2,41 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#ifndef CHROME_BROWSER_UI_VIEWS_TRY_CHROME_DIALOG_VIEW_H_ |
-#define CHROME_BROWSER_UI_VIEWS_TRY_CHROME_DIALOG_VIEW_H_ |
+#ifndef CHROME_BROWSER_UI_VIEWS_TRY_CHROME_DIALOG_H_ |
+#define CHROME_BROWSER_UI_VIEWS_TRY_CHROME_DIALOG_H_ |
#include <stddef.h> |
#include "base/compiler_specific.h" |
#include "base/macros.h" |
+#include "base/run_loop.h" |
+#include "base/time/time.h" |
+#include "chrome/browser/ui/startup/startup_browser_creator.h" |
+#include "chrome/installer/util/experiment_storage.h" |
#include "ui/gfx/geometry/rect.h" |
#include "ui/gfx/geometry/size.h" |
#include "ui/gfx/native_widget_types.h" |
#include "ui/views/controls/button/button.h" |
-#include "ui/views/controls/link_listener.h" |
namespace views { |
-class RadioButton; |
-class Checkbox; |
class Widget; |
} |
// This class displays a modal dialog using the views system. The dialog asks |
-// the user to give chrome another try. This class only handles the UI so the |
-// resulting actions are up to the caller. One flavor looks like this: |
+// the user to give Chrome another try. This class only handles the UI so the |
+// resulting actions are up to the caller. |
// |
-// +-----------------------------------------------+ |
-// | |icon| There is a new, safer version [x] | |
-// | |icon| of Google Chrome available | |
-// | [o] Try it out (already installed) | |
-// | [ ] Uninstall Google Chrome | |
-// | [ OK ] [Don't bug me] | |
-// | _why_am_I_seeing this?_ | |
-// +-----------------------------------------------+ |
+// The layout is as follows: |
// |
-// Another flavor looks like: |
// +-----------------------------------------------+ |
-// | |icon| There is a new, safer version [x] | |
-// | |icon| of Google Chrome available | |
-// | [o] Try it out (already installed) | |
-// | [ ] Don't bug me | |
-// | [ OK ] | |
+// | |icon| Header text. [x] | |
+// | | |
+// | Body text. | |
+// | [ Open Chrome ] [No Thanks] | |
// +-----------------------------------------------+ |
// |
-// And the 2013 version looks like: |
-// +-----------------------------------------------+ |
-// | |icon| There is a new version of [x] | |
-// | |icon| Google Chrome available | |
-// | [o] Try it out (already installed) | |
-// | [ ] Don't bug me | |
-// | --------------------------------------------- | |
-// | [x] Make it the default browser [ OK ] | |
-// +-----------------------------------------------+ |
- |
-class TryChromeDialogView : public views::ButtonListener, |
- public views::LinkListener { |
+// Some variants do not have body text, or only have one button. |
+class TryChromeDialog : public views::ButtonListener { |
public: |
// Receives a handle to the active modal dialog, or NULL when the active |
// dialog is dismissed. |
@@ -62,85 +44,87 @@ class TryChromeDialogView : public views::ButtonListener, |
ActiveModalDialogListener; |
enum Result { |
- TRY_CHROME, // Launch chrome right now. |
- TRY_CHROME_AS_DEFAULT, // Launch chrome and make it the default. |
- NOT_NOW, // Don't launch chrome. Exit now. |
- UNINSTALL_CHROME, // Initiate chrome uninstall and exit. |
- DIALOG_ERROR, // An error occurred creating the dialog. |
- COUNT |
+ NOT_NOW, // Don't launch chrome. Exit now. |
+ OPEN_CHROME_DEFAULT, // Launch Chrome to the default page. |
+ OPEN_CHROME_WELCOME, // Launch Chrome to the standard Welcome page. |
+ OPEN_CHROME_WELCOME_WIN10, // Launch Chrome to the Win10 Welcome page. |
}; |
- // Shows a modal dialog asking the user to give chrome another try. See |
- // above for the possible outcomes of the function. This is an experimental, |
- // non-localized dialog. |
- // |flavor| can be 0, 1, 2 or 3 and selects what strings to present. |
+ // Shows a modal dialog asking the user to give Chrome another try. See |
+ // above for the possible outcomes of the function. |
+ // |group| selects what strings to present and what controls are shown. |
// |listener| will be notified when the dialog becomes active and when it is |
// dismissed. |
// Note that the dialog has no parent and it will position itself in a lower |
- // corner of the screen. The dialog does not steal focus and does not have an |
- // entry in the taskbar. |
- static Result Show(size_t flavor, |
- const ActiveModalDialogListener& listener); |
+ // corner of the screen or near the Chrome taskbar button. |
+ // The dialog does not steal focus and does not have an entry in the taskbar. |
+ static Result Show(size_t group, const ActiveModalDialogListener& listener); |
+ |
private: |
// Indicates whether the dialog is modal |
- enum class kDialogType { |
- MODAL, // Modal dialog. |
- MODELESS, // Modeless dialog. |
+ enum class DialogType { |
+ MODAL, // Modal dialog. |
+ MODELESS_FOR_TEST, // Modeless dialog. |
}; |
// Indicates the usage type. Chrome or tests. |
- enum class kUsageType { |
+ enum class UsageType { |
FOR_CHROME, |
FOR_TESTING, |
}; |
friend class TryChromeDialogTest; |
- explicit TryChromeDialogView(size_t flavor); |
- ~TryChromeDialogView() override; |
+ // Creates a Try Chrome toast dialog. |group| signifies an experiment group |
+ // which dictactes messaging text and presence of ui elements. |
+ explicit TryChromeDialog(size_t group); |
+ ~TryChromeDialog() override; |
// Helper function to show the dialog. |
// The |dialog_type| parameter indicates whether the dialog is modal. |
+ // Note that modeless invocation returns before the user has made a |
+ // selection, and is used in testing. |
grt (UTC plus 2)
2017/08/17 11:26:32
nit: is it relevant that the function unconditiona
skare_
2017/08/18 11:37:34
Done.
|
// The |usage_type| parameter indicates whether this is being invoked by |
- // chrome or a test. |
+ // Chrome or a test. |
Result ShowDialog(const ActiveModalDialogListener& listener, |
- kDialogType dialog_type, |
- kUsageType usage_type); |
+ DialogType dialog_type, |
+ UsageType usage_type); |
// Returns a screen rectangle that is fit to show the window. In particular |
// it has the following properties: a) is visible and b) is attached to the |
// bottom of the working area. For LTR machines it returns a left side |
// rectangle and for RTL it returns a right side rectangle so that the dialog |
// does not compete with the standard place of the start menu. |
- gfx::Rect ComputeWindowPosition(const gfx::Size& size, bool is_RTL); |
- |
- // Create a windows region that looks like a toast of width |w| and height |
- // |h|. This is best effort, so we don't care much if the operation fails. |
- void SetToastRegion(HWND window, int w, int h); |
+ gfx::Rect ComputePopupBounds(const gfx::Size& size, bool is_RTL); |
// views::ButtonListener: |
// We have two buttons and according to what the user clicked we set |result_| |
// and we should always close and end the modal loop. |
void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
- // views::LinkListener: |
- // If the user selects the link we need to fire off the default browser that |
- // by some convoluted logic should not be chrome. |
- void LinkClicked(views::Link* source, int event_flags) override; |
+ // Controls whether we're running in testing config. |
+ // Experiment metrics setting is disabled in tests. |
+ UsageType usage_type_; |
+ |
+ // Controls which experiment group to use for varying the layout and controls. |
+ const size_t group_; |
- // Controls which flavor of the heading text to use. |
- size_t flavor_; |
+ // Time when the toast was displayed. |
+ base::TimeTicks time_shown_; |
- // We don't own any of these pointers. The |popup_| owns itself and owns the |
- // other views. |
+ // Unowned; |popup_| owns itself. |
views::Widget* popup_; |
- views::RadioButton* try_chrome_; |
- views::RadioButton* kill_chrome_; |
- views::RadioButton* dont_try_chrome_; |
- views::Checkbox* make_default_; |
+ |
+ // RunLoop to run the dialog before the main message loop. |
+ base::RunLoop run_loop_; |
+ |
+ // Experiment feedback interface. |
+ installer::ExperimentStorage storage_; |
+ |
+ // Result of displaying the dialog: accepted, dismissed, etc. |
Result result_; |
- DISALLOW_COPY_AND_ASSIGN(TryChromeDialogView); |
+ DISALLOW_COPY_AND_ASSIGN(TryChromeDialog); |
}; |
-#endif // CHROME_BROWSER_UI_VIEWS_TRY_CHROME_DIALOG_VIEW_H_ |
+#endif // CHROME_BROWSER_UI_VIEWS_TRY_CHROME_DIALOG_H_ |