| 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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 search_engine_urls_.end()) { | 183 search_engine_urls_.end()) { |
| 184 // The search engine is not in our white-list, bail. | 184 // The search engine is not in our white-list, bail. |
| 185 return; | 185 return; |
| 186 } | 186 } |
| 187 const TemplateURL* const default_provider = | 187 const TemplateURL* const default_provider = |
| 188 TemplateURLServiceFactory::GetForProfile(tab_->profile())-> | 188 TemplateURLServiceFactory::GetForProfile(tab_->profile())-> |
| 189 GetDefaultSearchProvider(); | 189 GetDefaultSearchProvider(); |
| 190 if (!default_provider) | 190 if (!default_provider) |
| 191 return; | 191 return; |
| 192 | 192 |
| 193 if (default_provider->url()->GetHost() == entry->GetURL().host()) | 193 if (default_provider->url_ref().GetHost() == entry->GetURL().host()) |
| 194 ShowInfoBar(); | 194 ShowInfoBar(); |
| 195 } else if (type == chrome::NOTIFICATION_OMNIBOX_OPENED_URL) { | 195 } else if (type == chrome::NOTIFICATION_OMNIBOX_OPENED_URL) { |
| 196 AutocompleteLog* log = content::Details<AutocompleteLog>(details).ptr(); | 196 AutocompleteLog* log = content::Details<AutocompleteLog>(details).ptr(); |
| 197 AutocompleteMatch::Type type = | 197 AutocompleteMatch::Type type = |
| 198 log->result.match_at(log->selected_index).type; | 198 log->result.match_at(log->selected_index).type; |
| 199 if (type == AutocompleteMatch::SEARCH_WHAT_YOU_TYPED || | 199 if (type == AutocompleteMatch::SEARCH_WHAT_YOU_TYPED || |
| 200 type == AutocompleteMatch::SEARCH_HISTORY || | 200 type == AutocompleteMatch::SEARCH_HISTORY || |
| 201 type == AutocompleteMatch::SEARCH_SUGGEST) { | 201 type == AutocompleteMatch::SEARCH_SUGGEST) { |
| 202 // The user performed a search from the omnibox, don't show the infobar | 202 // The user performed a search from the omnibox, don't show the infobar |
| 203 // again. | 203 // again. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 233 } | 233 } |
| 234 | 234 |
| 235 // static | 235 // static |
| 236 bool OmniboxSearchHint::IsEnabled(Profile* profile) { | 236 bool OmniboxSearchHint::IsEnabled(Profile* profile) { |
| 237 // The infobar can only be shown if the correct switch has been provided and | 237 // The infobar can only be shown if the correct switch has been provided and |
| 238 // the user did not dismiss the infobar before. | 238 // the user did not dismiss the infobar before. |
| 239 return profile->GetPrefs()->GetBoolean(prefs::kShowOmniboxSearchHint) && | 239 return profile->GetPrefs()->GetBoolean(prefs::kShowOmniboxSearchHint) && |
| 240 CommandLine::ForCurrentProcess()->HasSwitch( | 240 CommandLine::ForCurrentProcess()->HasSwitch( |
| 241 switches::kSearchInOmniboxHint); | 241 switches::kSearchInOmniboxHint); |
| 242 } | 242 } |
| OLD | NEW |