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