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