| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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_UI_STARTUP_DEFAULT_BROWSER_INFOBAR_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_UI_STARTUP_DEFAULT_BROWSER_INFOBAR_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_UI_STARTUP_DEFAULT_BROWSER_INFOBAR_DELEGATE_H_ | 6 #define CHROME_BROWSER_UI_STARTUP_DEFAULT_BROWSER_INFOBAR_DELEGATE_H_ |
| 7 | 7 |
| 8 #include "base/feature_list.h" | |
| 9 #include "chrome/browser/infobars/infobar_service.h" | 8 #include "chrome/browser/infobars/infobar_service.h" |
| 10 #include "chrome/browser/shell_integration.h" | 9 #include "chrome/browser/shell_integration.h" |
| 11 #include "components/infobars/core/confirm_infobar_delegate.h" | 10 #include "components/infobars/core/confirm_infobar_delegate.h" |
| 12 | 11 |
| 13 class Profile; | 12 class Profile; |
| 14 | 13 |
| 15 namespace chrome { | 14 namespace chrome { |
| 16 | 15 |
| 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. | 16 // 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 | 17 // Ownership of the delegate is given to the infobar itself, the lifetime of |
| 28 // which is bound to the containing WebContents. | 18 // which is bound to the containing WebContents. |
| 29 class DefaultBrowserInfoBarDelegate : public ConfirmInfoBarDelegate { | 19 class DefaultBrowserInfoBarDelegate : public ConfirmInfoBarDelegate { |
| 30 public: | 20 public: |
| 31 // Creates a default browser infobar and delegate and adds the infobar to | 21 // Creates a default browser infobar and delegate and adds the infobar to |
| 32 // |infobar_service|. | 22 // |infobar_service|. |
| 33 static void Create(InfoBarService* infobar_service, Profile* profile); | 23 static void Create(InfoBarService* infobar_service, Profile* profile); |
| 34 | 24 |
| 35 protected: | 25 protected: |
| (...skipping 22 matching lines...) Expand all Loading... |
| 58 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; | 48 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; |
| 59 const gfx::VectorIcon& GetVectorIcon() const override; | 49 const gfx::VectorIcon& GetVectorIcon() const override; |
| 60 bool ShouldExpire(const NavigationDetails& details) const override; | 50 bool ShouldExpire(const NavigationDetails& details) const override; |
| 61 void InfoBarDismissed() override; | 51 void InfoBarDismissed() override; |
| 62 base::string16 GetMessageText() const override; | 52 base::string16 GetMessageText() const override; |
| 63 int GetButtons() const override; | 53 int GetButtons() const override; |
| 64 base::string16 GetButtonLabel(InfoBarButton button) const override; | 54 base::string16 GetButtonLabel(InfoBarButton button) const override; |
| 65 bool OKButtonTriggersUACPrompt() const override; | 55 bool OKButtonTriggersUACPrompt() const override; |
| 66 bool Accept() override; | 56 bool Accept() override; |
| 67 | 57 |
| 68 // Declared virtual so tests can override. | |
| 69 virtual scoped_refptr<shell_integration::DefaultBrowserWorker> | |
| 70 CreateDefaultBrowserWorker( | |
| 71 const shell_integration::DefaultWebClientWorkerCallback& callback); | |
| 72 | |
| 73 // Removes the infobar when the worker is finished setting the default | |
| 74 // browser. Only used if the StickyDefaultBrowserPrompt experiment is | |
| 75 // enabled. | |
| 76 void OnSetAsDefaultFinished(shell_integration::DefaultWebClientState state); | |
| 77 | |
| 78 // The WebContents's corresponding profile. | 58 // The WebContents's corresponding profile. |
| 79 Profile* profile_; | 59 Profile* profile_; |
| 80 | 60 |
| 81 scoped_refptr<base::SingleThreadTaskRunner> thread_task_runner_; | |
| 82 | |
| 83 // Whether the info bar should be dismissed on the next navigation. | 61 // Whether the info bar should be dismissed on the next navigation. |
| 84 bool should_expire_; | 62 bool should_expire_; |
| 85 | 63 |
| 86 // Indicates if the user interacted with the infobar. | 64 // Indicates if the user interacted with the infobar. |
| 87 bool action_taken_; | 65 bool action_taken_; |
| 88 | 66 |
| 89 // Used to delay the expiration of the info-bar. | 67 // Used to delay the expiration of the info-bar. |
| 90 base::WeakPtrFactory<DefaultBrowserInfoBarDelegate> weak_factory_; | 68 base::WeakPtrFactory<DefaultBrowserInfoBarDelegate> weak_factory_; |
| 91 | 69 |
| 92 DISALLOW_COPY_AND_ASSIGN(DefaultBrowserInfoBarDelegate); | 70 DISALLOW_COPY_AND_ASSIGN(DefaultBrowserInfoBarDelegate); |
| 93 }; | 71 }; |
| 94 | 72 |
| 95 } // namespace chrome | 73 } // namespace chrome |
| 96 | 74 |
| 97 #endif // CHROME_BROWSER_UI_STARTUP_DEFAULT_BROWSER_INFOBAR_DELEGATE_H_ | 75 #endif // CHROME_BROWSER_UI_STARTUP_DEFAULT_BROWSER_INFOBAR_DELEGATE_H_ |
| OLD | NEW |