| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #include "chrome/browser/ui/startup/autolaunch_prompt.h" | 5 #include "chrome/browser/ui/startup/autolaunch_prompt.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 static void Create(InfoBarService* infobar_service, Profile* profile); | 41 static void Create(InfoBarService* infobar_service, Profile* profile); |
| 42 | 42 |
| 43 private: | 43 private: |
| 44 explicit AutolaunchInfoBarDelegate(Profile* profile); | 44 explicit AutolaunchInfoBarDelegate(Profile* profile); |
| 45 virtual ~AutolaunchInfoBarDelegate(); | 45 virtual ~AutolaunchInfoBarDelegate(); |
| 46 | 46 |
| 47 void set_should_expire() { should_expire_ = true; } | 47 void set_should_expire() { should_expire_ = true; } |
| 48 | 48 |
| 49 // ConfirmInfoBarDelegate: | 49 // ConfirmInfoBarDelegate: |
| 50 virtual int GetIconID() const override; | 50 virtual int GetIconID() const override; |
| 51 virtual bool ShouldExpireInternal( |
| 52 const NavigationDetails& details) const override; |
| 51 virtual base::string16 GetMessageText() const override; | 53 virtual base::string16 GetMessageText() const override; |
| 52 virtual base::string16 GetButtonLabel(InfoBarButton button) const override; | 54 virtual base::string16 GetButtonLabel(InfoBarButton button) const override; |
| 53 virtual bool Accept() override; | 55 virtual bool Accept() override; |
| 54 virtual bool Cancel() override; | 56 virtual bool Cancel() override; |
| 55 virtual bool ShouldExpireInternal( | |
| 56 const NavigationDetails& details) const override; | |
| 57 | 57 |
| 58 // Weak pointer to the profile, not owned by us. | 58 // Weak pointer to the profile, not owned by us. |
| 59 Profile* profile_; | 59 Profile* profile_; |
| 60 | 60 |
| 61 // Whether the info-bar should be dismissed on the next navigation. | 61 // Whether the info-bar should be dismissed on the next navigation. |
| 62 bool should_expire_; | 62 bool should_expire_; |
| 63 | 63 |
| 64 // Used to delay the expiration of the info-bar. | 64 // Used to delay the expiration of the info-bar. |
| 65 base::WeakPtrFactory<AutolaunchInfoBarDelegate> weak_factory_; | 65 base::WeakPtrFactory<AutolaunchInfoBarDelegate> weak_factory_; |
| 66 | 66 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 94 base::TimeDelta::FromSeconds(8)); | 94 base::TimeDelta::FromSeconds(8)); |
| 95 } | 95 } |
| 96 | 96 |
| 97 AutolaunchInfoBarDelegate::~AutolaunchInfoBarDelegate() { | 97 AutolaunchInfoBarDelegate::~AutolaunchInfoBarDelegate() { |
| 98 } | 98 } |
| 99 | 99 |
| 100 int AutolaunchInfoBarDelegate::GetIconID() const { | 100 int AutolaunchInfoBarDelegate::GetIconID() const { |
| 101 return IDR_PRODUCT_LOGO_32; | 101 return IDR_PRODUCT_LOGO_32; |
| 102 } | 102 } |
| 103 | 103 |
| 104 bool AutolaunchInfoBarDelegate::ShouldExpireInternal( |
| 105 const NavigationDetails& details) const { |
| 106 return should_expire_; |
| 107 } |
| 108 |
| 104 base::string16 AutolaunchInfoBarDelegate::GetMessageText() const { | 109 base::string16 AutolaunchInfoBarDelegate::GetMessageText() const { |
| 105 return l10n_util::GetStringUTF16(IDS_AUTO_LAUNCH_INFOBAR_TEXT); | 110 return l10n_util::GetStringUTF16(IDS_AUTO_LAUNCH_INFOBAR_TEXT); |
| 106 } | 111 } |
| 107 | 112 |
| 108 base::string16 AutolaunchInfoBarDelegate::GetButtonLabel( | 113 base::string16 AutolaunchInfoBarDelegate::GetButtonLabel( |
| 109 InfoBarButton button) const { | 114 InfoBarButton button) const { |
| 110 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? | 115 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? |
| 111 IDS_AUTO_LAUNCH_OK : IDS_AUTO_LAUNCH_REVERT); | 116 IDS_AUTO_LAUNCH_OK : IDS_AUTO_LAUNCH_REVERT); |
| 112 } | 117 } |
| 113 | 118 |
| 114 bool AutolaunchInfoBarDelegate::Accept() { | 119 bool AutolaunchInfoBarDelegate::Accept() { |
| 115 return true; | 120 return true; |
| 116 } | 121 } |
| 117 | 122 |
| 118 bool AutolaunchInfoBarDelegate::Cancel() { | 123 bool AutolaunchInfoBarDelegate::Cancel() { |
| 119 content::BrowserThread::PostTask( | 124 content::BrowserThread::PostTask( |
| 120 content::BrowserThread::FILE, FROM_HERE, | 125 content::BrowserThread::FILE, FROM_HERE, |
| 121 base::Bind(&auto_launch_util::DisableForegroundStartAtLogin, | 126 base::Bind(&auto_launch_util::DisableForegroundStartAtLogin, |
| 122 profile_->GetPath().BaseName().value())); | 127 profile_->GetPath().BaseName().value())); |
| 123 return true; | 128 return true; |
| 124 } | 129 } |
| 125 | 130 |
| 126 bool AutolaunchInfoBarDelegate::ShouldExpireInternal( | |
| 127 const NavigationDetails& details) const { | |
| 128 return should_expire_; | |
| 129 } | |
| 130 | |
| 131 } // namespace | 131 } // namespace |
| 132 | 132 |
| 133 | 133 |
| 134 // Functions ------------------------------------------------------------------ | 134 // Functions ------------------------------------------------------------------ |
| 135 | 135 |
| 136 namespace chrome { | 136 namespace chrome { |
| 137 | 137 |
| 138 bool ShowAutolaunchPrompt(Browser* browser) { | 138 bool ShowAutolaunchPrompt(Browser* browser) { |
| 139 if (!auto_launch_trial::IsInAutoLaunchGroup()) | 139 if (!auto_launch_trial::IsInAutoLaunchGroup()) |
| 140 return false; | 140 return false; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 167 return true; | 167 return true; |
| 168 } | 168 } |
| 169 | 169 |
| 170 void RegisterAutolaunchUserPrefs(user_prefs::PrefRegistrySyncable* registry) { | 170 void RegisterAutolaunchUserPrefs(user_prefs::PrefRegistrySyncable* registry) { |
| 171 registry->RegisterIntegerPref( | 171 registry->RegisterIntegerPref( |
| 172 prefs::kShownAutoLaunchInfobar, 0, | 172 prefs::kShownAutoLaunchInfobar, 0, |
| 173 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 173 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 174 } | 174 } |
| 175 | 175 |
| 176 } // namespace chrome | 176 } // namespace chrome |
| OLD | NEW |