| 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.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "chrome/browser/auto_launch_trial.h" | 11 #include "chrome/browser/auto_launch_trial.h" |
| 12 #include "chrome/browser/first_run/first_run.h" | 12 #include "chrome/browser/first_run/first_run.h" |
| 13 #include "chrome/browser/infobars/confirm_infobar_delegate.h" | 13 #include "chrome/browser/infobars/confirm_infobar_delegate.h" |
| 14 #include "chrome/browser/infobars/infobar_service.h" | 14 #include "chrome/browser/infobars/infobar_service.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 18 #include "chrome/common/chrome_constants.h" | 18 #include "chrome/common/chrome_constants.h" |
| 19 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
| 20 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
| 21 #include "chrome/installer/util/auto_launch_util.h" | 21 #include "chrome/installer/util/auto_launch_util.h" |
| 22 #include "components/user_prefs/pref_registry_syncable.h" | 22 #include "components/user_prefs/pref_registry_syncable.h" |
| 23 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
| 24 #include "content/public/browser/navigation_details.h" | 24 #include "content/public/browser/navigation_details.h" |
| 25 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
| 26 #include "grit/chromium_strings.h" | 26 #include "grit/chromium_strings.h" |
| 27 #include "grit/generated_resources.h" | 27 #include "grit/generated_resources.h" |
| 28 #include "grit/theme_resources.h" | 28 #include "grit/theme_resources.h" |
| 29 #include "ui/base/l10n/l10n_util.h" | 29 #include "ui/base/l10n/l10n_util.h" |
| 30 #include "ui/base/resource/resource_bundle.h" | |
| 31 | 30 |
| 32 using content::BrowserThread; | 31 using content::BrowserThread; |
| 33 | 32 |
| 34 | 33 |
| 35 // AutolaunchInfoBarDelegate -------------------------------------------------- | 34 // AutolaunchInfoBarDelegate -------------------------------------------------- |
| 36 | 35 |
| 37 namespace { | 36 namespace { |
| 38 | 37 |
| 39 // The delegate for the infobar shown when Chrome was auto-launched. | 38 // The delegate for the infobar shown when Chrome was auto-launched. |
| 40 class AutolaunchInfoBarDelegate : public ConfirmInfoBarDelegate { | 39 class AutolaunchInfoBarDelegate : public ConfirmInfoBarDelegate { |
| 41 public: | 40 public: |
| 42 // Creates an autolaunch delegate and adds it to |infobar_service|. | 41 // Creates an autolaunch delegate and adds it to |infobar_service|. |
| 43 static void Create(InfoBarService* infobar_service, | 42 static void Create(InfoBarService* infobar_service, |
| 44 PrefService* prefs, | 43 PrefService* prefs, |
| 45 Profile* profile); | 44 Profile* profile); |
| 46 | 45 |
| 47 private: | 46 private: |
| 48 AutolaunchInfoBarDelegate(InfoBarService* infobar_service, | 47 AutolaunchInfoBarDelegate(InfoBarService* infobar_service, |
| 49 PrefService* prefs, | 48 PrefService* prefs, |
| 50 Profile* profile); | 49 Profile* profile); |
| 51 virtual ~AutolaunchInfoBarDelegate(); | 50 virtual ~AutolaunchInfoBarDelegate(); |
| 52 | 51 |
| 53 void AllowExpiry() { should_expire_ = true; } | 52 void AllowExpiry() { should_expire_ = true; } |
| 54 | 53 |
| 55 // ConfirmInfoBarDelegate: | 54 // ConfirmInfoBarDelegate: |
| 56 virtual gfx::Image* GetIcon() const OVERRIDE; | 55 virtual int GetIconID() const OVERRIDE; |
| 57 virtual string16 GetMessageText() const OVERRIDE; | 56 virtual string16 GetMessageText() const OVERRIDE; |
| 58 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; | 57 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; |
| 59 virtual bool Accept() OVERRIDE; | 58 virtual bool Accept() OVERRIDE; |
| 60 virtual bool Cancel() OVERRIDE; | 59 virtual bool Cancel() OVERRIDE; |
| 61 virtual bool ShouldExpireInternal( | 60 virtual bool ShouldExpireInternal( |
| 62 const content::LoadCommittedDetails& details) const OVERRIDE; | 61 const content::LoadCommittedDetails& details) const OVERRIDE; |
| 63 | 62 |
| 64 // The prefs to use. | 63 // The prefs to use. |
| 65 PrefService* prefs_; | 64 PrefService* prefs_; |
| 66 | 65 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 base::MessageLoop::current()->PostDelayedTask( | 100 base::MessageLoop::current()->PostDelayedTask( |
| 102 FROM_HERE, | 101 FROM_HERE, |
| 103 base::Bind(&AutolaunchInfoBarDelegate::AllowExpiry, | 102 base::Bind(&AutolaunchInfoBarDelegate::AllowExpiry, |
| 104 weak_factory_.GetWeakPtr()), | 103 weak_factory_.GetWeakPtr()), |
| 105 base::TimeDelta::FromSeconds(8)); | 104 base::TimeDelta::FromSeconds(8)); |
| 106 } | 105 } |
| 107 | 106 |
| 108 AutolaunchInfoBarDelegate::~AutolaunchInfoBarDelegate() { | 107 AutolaunchInfoBarDelegate::~AutolaunchInfoBarDelegate() { |
| 109 } | 108 } |
| 110 | 109 |
| 111 gfx::Image* AutolaunchInfoBarDelegate::GetIcon() const { | 110 int AutolaunchInfoBarDelegate::GetIconID() const { |
| 112 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed( | 111 return IDR_PRODUCT_LOGO_32; |
| 113 IDR_PRODUCT_LOGO_32); | |
| 114 } | 112 } |
| 115 | 113 |
| 116 string16 AutolaunchInfoBarDelegate::GetMessageText() const { | 114 string16 AutolaunchInfoBarDelegate::GetMessageText() const { |
| 117 return l10n_util::GetStringUTF16(IDS_AUTO_LAUNCH_INFOBAR_TEXT); | 115 return l10n_util::GetStringUTF16(IDS_AUTO_LAUNCH_INFOBAR_TEXT); |
| 118 } | 116 } |
| 119 | 117 |
| 120 string16 AutolaunchInfoBarDelegate::GetButtonLabel( | 118 string16 AutolaunchInfoBarDelegate::GetButtonLabel( |
| 121 InfoBarButton button) const { | 119 InfoBarButton button) const { |
| 122 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? | 120 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? |
| 123 IDS_AUTO_LAUNCH_OK : IDS_AUTO_LAUNCH_REVERT); | 121 IDS_AUTO_LAUNCH_OK : IDS_AUTO_LAUNCH_REVERT); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 } | 181 } |
| 184 | 182 |
| 185 void RegisterAutolaunchUserPrefs(user_prefs::PrefRegistrySyncable* registry) { | 183 void RegisterAutolaunchUserPrefs(user_prefs::PrefRegistrySyncable* registry) { |
| 186 registry->RegisterIntegerPref( | 184 registry->RegisterIntegerPref( |
| 187 prefs::kShownAutoLaunchInfobar, | 185 prefs::kShownAutoLaunchInfobar, |
| 188 0, | 186 0, |
| 189 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 187 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 190 } | 188 } |
| 191 | 189 |
| 192 } // namespace chrome | 190 } // namespace chrome |
| OLD | NEW |