| 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/omnibox_search_hint.h" | 5 #include "chrome/browser/omnibox_search_hint.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 | 129 |
| 130 HintInfoBarDelegate::HintInfoBarDelegate(OmniboxSearchHint* omnibox_hint, | 130 HintInfoBarDelegate::HintInfoBarDelegate(OmniboxSearchHint* omnibox_hint, |
| 131 InfoBarService* infobar_service) | 131 InfoBarService* infobar_service) |
| 132 : ConfirmInfoBarDelegate(infobar_service), | 132 : ConfirmInfoBarDelegate(infobar_service), |
| 133 omnibox_hint_(omnibox_hint), | 133 omnibox_hint_(omnibox_hint), |
| 134 action_taken_(false), | 134 action_taken_(false), |
| 135 should_expire_(false), | 135 should_expire_(false), |
| 136 weak_factory_(this) { | 136 weak_factory_(this) { |
| 137 // We want the info-bar to stick-around for few seconds and then be hidden | 137 // We want the info-bar to stick-around for few seconds and then be hidden |
| 138 // on the next navigation after that. | 138 // on the next navigation after that. |
| 139 MessageLoop::current()->PostDelayedTask( | 139 base::MessageLoop::current()->PostDelayedTask( |
| 140 FROM_HERE, | 140 FROM_HERE, |
| 141 base::Bind(&HintInfoBarDelegate::AllowExpiry, weak_factory_.GetWeakPtr()), | 141 base::Bind(&HintInfoBarDelegate::AllowExpiry, weak_factory_.GetWeakPtr()), |
| 142 base::TimeDelta::FromSeconds(8)); | 142 base::TimeDelta::FromSeconds(8)); |
| 143 } | 143 } |
| 144 | 144 |
| 145 HintInfoBarDelegate::~HintInfoBarDelegate() { | 145 HintInfoBarDelegate::~HintInfoBarDelegate() { |
| 146 if (!action_taken_) | 146 if (!action_taken_) |
| 147 UMA_HISTOGRAM_COUNTS("OmniboxSearchHint.Ignored", 1); | 147 UMA_HISTOGRAM_COUNTS("OmniboxSearchHint.Ignored", 1); |
| 148 } | 148 } |
| 149 | 149 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 } | 254 } |
| 255 | 255 |
| 256 // static | 256 // static |
| 257 bool OmniboxSearchHint::IsEnabled(Profile* profile) { | 257 bool OmniboxSearchHint::IsEnabled(Profile* profile) { |
| 258 // The infobar can only be shown if the correct switch has been provided and | 258 // The infobar can only be shown if the correct switch has been provided and |
| 259 // the user did not dismiss the infobar before. | 259 // the user did not dismiss the infobar before. |
| 260 return profile->GetPrefs()->GetBoolean(prefs::kShowOmniboxSearchHint) && | 260 return profile->GetPrefs()->GetBoolean(prefs::kShowOmniboxSearchHint) && |
| 261 CommandLine::ForCurrentProcess()->HasSwitch( | 261 CommandLine::ForCurrentProcess()->HasSwitch( |
| 262 switches::kSearchInOmniboxHint); | 262 switches::kSearchInOmniboxHint); |
| 263 } | 263 } |
| OLD | NEW |