| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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" |
| 11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 : ConfirmInfoBarDelegate(omnibox_hint->tab()->infobar_tab_helper()), | 93 : ConfirmInfoBarDelegate(omnibox_hint->tab()->infobar_tab_helper()), |
| 94 omnibox_hint_(omnibox_hint), | 94 omnibox_hint_(omnibox_hint), |
| 95 action_taken_(false), | 95 action_taken_(false), |
| 96 should_expire_(false), | 96 should_expire_(false), |
| 97 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { | 97 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { |
| 98 // We want the info-bar to stick-around for few seconds and then be hidden | 98 // We want the info-bar to stick-around for few seconds and then be hidden |
| 99 // on the next navigation after that. | 99 // on the next navigation after that. |
| 100 MessageLoop::current()->PostDelayedTask( | 100 MessageLoop::current()->PostDelayedTask( |
| 101 FROM_HERE, | 101 FROM_HERE, |
| 102 base::Bind(&HintInfoBar::AllowExpiry, weak_factory_.GetWeakPtr()), | 102 base::Bind(&HintInfoBar::AllowExpiry, weak_factory_.GetWeakPtr()), |
| 103 base::TimeDelta::FromSeconds(8)); | 103 8000); // 8 seconds. |
| 104 } | 104 } |
| 105 | 105 |
| 106 HintInfoBar::~HintInfoBar() { | 106 HintInfoBar::~HintInfoBar() { |
| 107 if (!action_taken_) | 107 if (!action_taken_) |
| 108 UMA_HISTOGRAM_COUNTS("OmniboxSearchHint.Ignored", 1); | 108 UMA_HISTOGRAM_COUNTS("OmniboxSearchHint.Ignored", 1); |
| 109 } | 109 } |
| 110 | 110 |
| 111 bool HintInfoBar::ShouldExpire( | 111 bool HintInfoBar::ShouldExpire( |
| 112 const content::LoadCommittedDetails& details) const { | 112 const content::LoadCommittedDetails& details) const { |
| 113 return details.is_navigation_to_different_page() && should_expire_; | 113 return details.is_navigation_to_different_page() && should_expire_; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 } | 234 } |
| 235 | 235 |
| 236 // static | 236 // static |
| 237 bool OmniboxSearchHint::IsEnabled(Profile* profile) { | 237 bool OmniboxSearchHint::IsEnabled(Profile* profile) { |
| 238 // The infobar can only be shown if the correct switch has been provided and | 238 // The infobar can only be shown if the correct switch has been provided and |
| 239 // the user did not dismiss the infobar before. | 239 // the user did not dismiss the infobar before. |
| 240 return profile->GetPrefs()->GetBoolean(prefs::kShowOmniboxSearchHint) && | 240 return profile->GetPrefs()->GetBoolean(prefs::kShowOmniboxSearchHint) && |
| 241 CommandLine::ForCurrentProcess()->HasSwitch( | 241 CommandLine::ForCurrentProcess()->HasSwitch( |
| 242 switches::kSearchInOmniboxHint); | 242 switches::kSearchInOmniboxHint); |
| 243 } | 243 } |
| OLD | NEW |