OLD | NEW |
1 // Copyright (c) 2011 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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/task.h" | 9 #include "base/task.h" |
10 // TODO(avi): remove when conversions not needed any more | 10 // TODO(avi): remove when conversions not needed any more |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 92 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
93 method_factory_.NewRunnableMethod(&HintInfoBar::AllowExpiry), | 93 method_factory_.NewRunnableMethod(&HintInfoBar::AllowExpiry), |
94 8000); // 8 seconds. | 94 8000); // 8 seconds. |
95 } | 95 } |
96 | 96 |
97 HintInfoBar::~HintInfoBar() { | 97 HintInfoBar::~HintInfoBar() { |
98 } | 98 } |
99 | 99 |
100 bool HintInfoBar::ShouldExpire( | 100 bool HintInfoBar::ShouldExpire( |
101 const NavigationController::LoadCommittedDetails& details) const { | 101 const NavigationController::LoadCommittedDetails& details) const { |
102 return should_expire_; | 102 return details.is_user_initiated_main_frame_load() && should_expire_; |
103 } | 103 } |
104 | 104 |
105 void HintInfoBar::InfoBarDismissed() { | 105 void HintInfoBar::InfoBarDismissed() { |
106 action_taken_ = true; | 106 action_taken_ = true; |
107 UMA_HISTOGRAM_COUNTS("OmniboxSearchHint.Closed", 1); | 107 UMA_HISTOGRAM_COUNTS("OmniboxSearchHint.Closed", 1); |
108 // User closed the infobar, let's not bug him again with this in the future. | 108 // User closed the infobar, let's not bug him again with this in the future. |
109 omnibox_hint_->DisableHint(); | 109 omnibox_hint_->DisableHint(); |
110 } | 110 } |
111 | 111 |
112 void HintInfoBar::InfoBarClosed() { | 112 void HintInfoBar::InfoBarClosed() { |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 } | 228 } |
229 | 229 |
230 // static | 230 // static |
231 bool OmniboxSearchHint::IsEnabled(Profile* profile) { | 231 bool OmniboxSearchHint::IsEnabled(Profile* profile) { |
232 // The infobar can only be shown if the correct switch has been provided and | 232 // The infobar can only be shown if the correct switch has been provided and |
233 // the user did not dismiss the infobar before. | 233 // the user did not dismiss the infobar before. |
234 return profile->GetPrefs()->GetBoolean(prefs::kShowOmniboxSearchHint) && | 234 return profile->GetPrefs()->GetBoolean(prefs::kShowOmniboxSearchHint) && |
235 CommandLine::ForCurrentProcess()->HasSwitch( | 235 CommandLine::ForCurrentProcess()->HasSwitch( |
236 switches::kSearchInOmniboxHint); | 236 switches::kSearchInOmniboxHint); |
237 } | 237 } |
OLD | NEW |