Revert "Create a platform-independent ToolbarActionsBar"
[chromium-blink-merge.git] / chrome / browser / first_run / try_chrome_dialog_view.h
blobeebe9ce442131655fc393dc8835bb1708c8ac30a
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_FIRST_RUN_TRY_CHROME_DIALOG_VIEW_H_
6 #define CHROME_BROWSER_FIRST_RUN_TRY_CHROME_DIALOG_VIEW_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "ui/gfx/native_widget_types.h"
11 #include "ui/views/controls/button/button.h"
12 #include "ui/views/controls/link_listener.h"
14 class ProcessSingleton;
16 namespace gfx {
17 class Rect;
20 namespace views {
21 class RadioButton;
22 class Checkbox;
23 class Widget;
26 // This class displays a modal dialog using the views system. The dialog asks
27 // the user to give chrome another try. This class only handles the UI so the
28 // resulting actions are up to the caller. One flavor looks like this:
30 // +-----------------------------------------------+
31 // | |icon| There is a new, safer version [x] |
32 // | |icon| of Google Chrome available |
33 // | [o] Try it out (already installed) |
34 // | [ ] Uninstall Google Chrome |
35 // | [ OK ] [Don't bug me] |
36 // | _why_am_I_seeing this?_ |
37 // +-----------------------------------------------+
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 // +-----------------------------------------------+
48 // And the 2013 version looks like:
49 // +-----------------------------------------------+
50 // | |icon| There is a new version of [x] |
51 // | |icon| Google Chrome available |
52 // | [o] Try it out (already installed) |
53 // | [ ] Don't bug me |
54 // | --------------------------------------------- |
55 // | [x] Make it the default browser [ OK ] |
56 // +-----------------------------------------------+
58 class TryChromeDialogView : public views::ButtonListener,
59 public views::LinkListener {
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;
66 enum Result {
67 TRY_CHROME, // Launch chrome right now.
68 TRY_CHROME_AS_DEFAULT, // Launch chrome and make it the default.
69 NOT_NOW, // Don't launch chrome. Exit now.
70 UNINSTALL_CHROME, // Initiate chrome uninstall and exit.
71 DIALOG_ERROR, // An error occurred creating the dialog.
72 COUNT
75 // Shows a modal dialog asking the user to give chrome another try. See
76 // above for the possible outcomes of the function. This is an experimental,
77 // non-localized dialog.
78 // |flavor| can be 0, 1, 2 or 3 and selects what strings to present.
79 // |listener| will be notified when the dialog becomes active and when it is
80 // dismissed.
81 // Note that the dialog has no parent and it will position itself in a lower
82 // corner of the screen. The dialog does not steal focus and does not have an
83 // entry in the taskbar.
84 static Result Show(size_t flavor, const ActiveModalDialogListener& listener);
86 private:
87 explicit TryChromeDialogView(size_t flavor);
88 virtual ~TryChromeDialogView();
90 Result ShowModal(const ActiveModalDialogListener& listener);
92 // Returns a screen rectangle that is fit to show the window. In particular
93 // it has the following properties: a) is visible and b) is attached to the
94 // bottom of the working area. For LTR machines it returns a left side
95 // rectangle and for RTL it returns a right side rectangle so that the dialog
96 // does not compete with the standar place of the start menu.
97 gfx::Rect ComputeWindowPosition(int width, int height, bool is_RTL);
99 // Create a windows region that looks like a toast of width |w| and height
100 // |h|. This is best effort, so we don't care much if the operation fails.
101 void SetToastRegion(HWND window, int w, int h);
103 // views::ButtonListener:
104 // We have two buttons and according to what the user clicked we set |result_|
105 // and we should always close and end the modal loop.
106 virtual void ButtonPressed(views::Button* sender,
107 const ui::Event& event) override;
109 // views::LinkListener:
110 // If the user selects the link we need to fire off the default browser that
111 // by some convoluted logic should not be chrome.
112 virtual void LinkClicked(views::Link* source, int event_flags) override;
114 // Controls which flavor of the heading text to use.
115 size_t flavor_;
117 // We don't own any of these pointers. The |popup_| owns itself and owns the
118 // other views.
119 views::Widget* popup_;
120 views::RadioButton* try_chrome_;
121 views::RadioButton* kill_chrome_;
122 views::RadioButton* dont_try_chrome_;
123 views::Checkbox* make_default_;
124 Result result_;
126 DISALLOW_COPY_AND_ASSIGN(TryChromeDialogView);
129 #endif // CHROME_BROWSER_FIRST_RUN_TRY_CHROME_DIALOG_VIEW_H_