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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 8000); // 8 seconds. | 93 8000); // 8 seconds. |
94 } | 94 } |
95 | 95 |
96 HintInfoBar::~HintInfoBar() { | 96 HintInfoBar::~HintInfoBar() { |
97 if (!action_taken_) | 97 if (!action_taken_) |
98 UMA_HISTOGRAM_COUNTS("OmniboxSearchHint.Ignored", 1); | 98 UMA_HISTOGRAM_COUNTS("OmniboxSearchHint.Ignored", 1); |
99 } | 99 } |
100 | 100 |
101 bool HintInfoBar::ShouldExpire( | 101 bool HintInfoBar::ShouldExpire( |
102 const NavigationController::LoadCommittedDetails& details) const { | 102 const NavigationController::LoadCommittedDetails& details) const { |
103 return should_expire_; | 103 return details.is_user_initiated_main_frame_load() && should_expire_; |
104 } | 104 } |
105 | 105 |
106 void HintInfoBar::InfoBarDismissed() { | 106 void HintInfoBar::InfoBarDismissed() { |
107 action_taken_ = true; | 107 action_taken_ = true; |
108 UMA_HISTOGRAM_COUNTS("OmniboxSearchHint.Closed", 1); | 108 UMA_HISTOGRAM_COUNTS("OmniboxSearchHint.Closed", 1); |
109 // User closed the infobar, let's not bug him again with this in the future. | 109 // User closed the infobar, let's not bug him again with this in the future. |
110 omnibox_hint_->DisableHint(); | 110 omnibox_hint_->DisableHint(); |
111 } | 111 } |
112 | 112 |
113 gfx::Image* HintInfoBar::GetIcon() const { | 113 gfx::Image* HintInfoBar::GetIcon() const { |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 } | 223 } |
224 | 224 |
225 // static | 225 // static |
226 bool OmniboxSearchHint::IsEnabled(Profile* profile) { | 226 bool OmniboxSearchHint::IsEnabled(Profile* profile) { |
227 // The infobar can only be shown if the correct switch has been provided and | 227 // The infobar can only be shown if the correct switch has been provided and |
228 // the user did not dismiss the infobar before. | 228 // the user did not dismiss the infobar before. |
229 return profile->GetPrefs()->GetBoolean(prefs::kShowOmniboxSearchHint) && | 229 return profile->GetPrefs()->GetBoolean(prefs::kShowOmniboxSearchHint) && |
230 CommandLine::ForCurrentProcess()->HasSwitch( | 230 CommandLine::ForCurrentProcess()->HasSwitch( |
231 switches::kSearchInOmniboxHint); | 231 switches::kSearchInOmniboxHint); |
232 } | 232 } |
OLD | NEW |