Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(639)

Side by Side Diff: chrome/browser/ui/startup/default_browser_infobar_delegate.h

Issue 1974153002: Add an experiment for the default browser infobar on Windows 10 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Compile the test only on desktop platforms Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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.
4
5 #ifndef CHROME_BROWSER_UI_STARTUP_DEFAULT_BROWSER_INFOBAR_DELEGATE_H_
6 #define CHROME_BROWSER_UI_STARTUP_DEFAULT_BROWSER_INFOBAR_DELEGATE_H_
7
8 #include "base/feature_list.h"
9 #include "chrome/browser/infobars/infobar_service.h"
10 #include "chrome/browser/shell_integration.h"
11 #include "components/infobars/core/confirm_infobar_delegate.h"
12
13 class Profile;
14
15 namespace chrome {
16
17 // The StickyDefaultBrowserPrompt experiment delays the dismissal of the
18 // DefaultBrowserPrompt to after a change in the default browser setting has
19 // been detected.
20 constexpr base::Feature kStickyDefaultBrowserPrompt{
21 "StickyDefaultBrowserPrompt", base::FEATURE_DISABLED_BY_DEFAULT};
22
23 // Returns true if the StickyDefaultBrowserPrompt experiment is enabled.
24 bool IsStickyDefaultBrowserPromptEnabled();
25
26 // The delegate for the infobar shown when Chrome is not the default browser.
27 // Ownership of the delegate is given to the infobar itself, the lifetime of
28 // which is bound to the containing WebContents.
29 class DefaultBrowserInfoBarDelegate : public ConfirmInfoBarDelegate {
30 public:
31 // Creates a default browser infobar and delegate and adds the infobar to
32 // |infobar_service|.
33 static void Create(InfoBarService* infobar_service, Profile* profile);
34
35 protected:
36 explicit DefaultBrowserInfoBarDelegate(Profile* profile);
37 ~DefaultBrowserInfoBarDelegate() override;
38
39 private:
40 // Possible user interactions with the default browser info bar.
41 // Do not modify the ordering as it is important for UMA.
42 enum InfoBarUserInteraction {
43 // The user clicked the "OK" (i.e., "Set as default") button.
44 ACCEPT_INFO_BAR = 0,
45 // The user clicked the "Cancel" (i.e., "Don't ask again") button.
46 CANCEL_INFO_BAR = 1,
47 // The user did not interact with the info bar.
48 IGNORE_INFO_BAR = 2,
49 NUM_INFO_BAR_USER_INTERACTION_TYPES
50 };
51
52 void AllowExpiry();
53
54 // ConfirmInfoBarDelegate:
55 Type GetInfoBarType() const override;
56 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override;
57 int GetIconId() const override;
58 gfx::VectorIconId GetVectorIconId() const override;
59 bool ShouldExpire(const NavigationDetails& details) const override;
60 void InfoBarDismissed() override;
61 base::string16 GetMessageText() const override;
62 base::string16 GetButtonLabel(InfoBarButton button) const override;
63 bool OKButtonTriggersUACPrompt() const override;
64 bool Accept() override;
65 bool Cancel() override;
66
67 // Declared virtual so tests can override.
68 virtual scoped_refptr<shell_integration::DefaultBrowserWorker>
69 CreateDefaultBrowserWorker(
70 const shell_integration::DefaultWebClientWorkerCallback& callback);
71
72 // Removes the infobar when the worker is finished setting the default
73 // browser. Only used if the StickyDefaultBrowserPrompt experiment is
74 // enabled.
75 void OnSetAsDefaultFinished(shell_integration::DefaultWebClientState state);
76
77 // The WebContents's corresponding profile.
78 Profile* profile_;
79
80 scoped_refptr<base::SingleThreadTaskRunner> thread_task_runner_;
81
82 // Whether the info bar should be dismissed on the next navigation.
83 bool should_expire_;
84
85 // Used to delay the expiration of the info-bar.
86 base::WeakPtrFactory<DefaultBrowserInfoBarDelegate> weak_factory_;
87
88 DISALLOW_COPY_AND_ASSIGN(DefaultBrowserInfoBarDelegate);
89 };
90
91 } // namespace chrome
92
93 #endif // CHROME_BROWSER_UI_STARTUP_DEFAULT_BROWSER_INFOBAR_DELEGATE_H_
OLDNEW
« no previous file with comments | « chrome/browser/shell_integration.h ('k') | chrome/browser/ui/startup/default_browser_infobar_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698