Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 extern const base::Feature kStickyDefaultBrowserPrompt; | |
|
Peter Kasting
2016/06/01 00:21:12
Is it possible to declare this as non-extern const
Patrick Monette
2016/06/01 18:43:48
Seems to work. Done.
| |
| 21 | |
| 22 // Returns true if the StickyDefaultBrowserPrompt experiment is enabled. | |
| 23 bool IsStickyDefaultBrowserPromptEnabled(); | |
| 24 | |
| 25 // The delegate for the infobar shown when Chrome is not the default browser. | |
| 26 // Ownership of the delegate is given to the infobar itself, the lifetime of | |
| 27 // which is bound to the containing WebContents. | |
| 28 class DefaultBrowserInfoBarDelegate : public ConfirmInfoBarDelegate { | |
| 29 public: | |
| 30 // Creates a default browser infobar and delegate and adds the infobar to | |
| 31 // |infobar_service|. | |
| 32 static void Create(InfoBarService* infobar_service, Profile* profile); | |
| 33 | |
| 34 protected: | |
| 35 explicit DefaultBrowserInfoBarDelegate(Profile* profile); | |
| 36 ~DefaultBrowserInfoBarDelegate() override; | |
| 37 | |
| 38 private: | |
| 39 // Possible user interactions with the default browser info bar. | |
| 40 // Do not modify the ordering as it is important for UMA. | |
| 41 enum InfoBarUserInteraction { | |
| 42 // The user clicked the "OK" (i.e., "Set as default") button. | |
| 43 ACCEPT_INFO_BAR = 0, | |
| 44 // The user clicked the "Cancel" (i.e., "Don't ask again") button. | |
| 45 CANCEL_INFO_BAR = 1, | |
| 46 // The user did not interact with the info bar. | |
| 47 IGNORE_INFO_BAR = 2, | |
| 48 NUM_INFO_BAR_USER_INTERACTION_TYPES | |
| 49 }; | |
| 50 | |
| 51 void AllowExpiry() { should_expire_ = true; } | |
|
Peter Kasting
2016/06/01 00:21:12
Nit: If you want to inline this, name it unix_hack
Patrick Monette
2016/06/01 18:43:48
Moved the definition to the .cc file.
Peter Kasting
2016/06/01 19:32:10
I don't see that...
Patrick Monette
2016/06/01 22:07:39
Now moved.
| |
| 52 | |
| 53 // InfoBarDelegate: | |
|
Peter Kasting
2016/06/01 00:21:12
Nit: This class doesn't directly subclass InfoBarD
Patrick Monette
2016/06/01 18:43:48
Done.
| |
| 54 Type GetInfoBarType() const override; | |
| 55 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; | |
| 56 int GetIconId() const override; | |
| 57 gfx::VectorIconId GetVectorIconId() const override; | |
| 58 bool ShouldExpire(const NavigationDetails& details) const override; | |
| 59 void InfoBarDismissed() override; | |
| 60 | |
| 61 // ConfirmInfoBarDelegate: | |
| 62 base::string16 GetMessageText() const override; | |
| 63 base::string16 GetButtonLabel(InfoBarButton button) const override; | |
| 64 bool OKButtonTriggersUACPrompt() const override; | |
| 65 bool Accept() override; | |
| 66 bool Cancel() override; | |
| 67 | |
| 68 virtual scoped_refptr<shell_integration::DefaultBrowserWorker> | |
|
Peter Kasting
2016/06/01 00:21:11
Nit: Perhaps note "Declared virtual so tests can o
Patrick Monette
2016/06/01 18:43:48
Done.
| |
| 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. | |
|
Peter Kasting
2016/06/01 00:21:12
Nit: No hyphen
Patrick Monette
2016/06/01 18:43:48
Done.
| |
| 83 bool should_expire_ = false; | |
|
Peter Kasting
2016/06/01 00:21:12
Nit: Since you initialize everything else in the i
Patrick Monette
2016/06/01 18:43:48
Done.
| |
| 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_ | |
| OLD | NEW |