Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(288)

Side by Side Diff: chrome/browser/omnibox_search_hint.cc

Issue 8983012: Get rid of content::NavigationController in cc file and use "using" instead. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/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 20 matching lines...) Expand all
31 #include "content/public/browser/navigation_details.h" 31 #include "content/public/browser/navigation_details.h"
32 #include "content/public/browser/navigation_entry.h" 32 #include "content/public/browser/navigation_entry.h"
33 #include "content/public/browser/notification_details.h" 33 #include "content/public/browser/notification_details.h"
34 #include "content/public/browser/notification_source.h" 34 #include "content/public/browser/notification_source.h"
35 #include "content/public/browser/notification_types.h" 35 #include "content/public/browser/notification_types.h"
36 #include "grit/generated_resources.h" 36 #include "grit/generated_resources.h"
37 #include "grit/theme_resources_standard.h" 37 #include "grit/theme_resources_standard.h"
38 #include "ui/base/l10n/l10n_util.h" 38 #include "ui/base/l10n/l10n_util.h"
39 #include "ui/base/resource/resource_bundle.h" 39 #include "ui/base/resource/resource_bundle.h"
40 40
41 using content::NavigationController;
41 using content::NavigationEntry; 42 using content::NavigationEntry;
42 43
43 // The URLs of search engines for which we want to trigger the infobar. 44 // The URLs of search engines for which we want to trigger the infobar.
44 const char* const kSearchEngineURLs[] = { 45 const char* const kSearchEngineURLs[] = {
45 "http://www.google.com/", 46 "http://www.google.com/",
46 "http://www.yahoo.com/", 47 "http://www.yahoo.com/",
47 "http://www.bing.com/", 48 "http://www.bing.com/",
48 "http://www.altavista.com/", 49 "http://www.altavista.com/",
49 "http://www.ask.com/", 50 "http://www.ask.com/",
50 "http://www.wolframalpha.com/", 51 "http://www.wolframalpha.com/",
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 UMA_HISTOGRAM_COUNTS("OmniboxSearchHint.ShowMe", 1); 148 UMA_HISTOGRAM_COUNTS("OmniboxSearchHint.ShowMe", 1);
148 omnibox_hint_->DisableHint(); 149 omnibox_hint_->DisableHint();
149 omnibox_hint_->ShowEnteringQuery(); 150 omnibox_hint_->ShowEnteringQuery();
150 return true; 151 return true;
151 } 152 }
152 153
153 154
154 // OmniboxSearchHint ---------------------------------------------------------- 155 // OmniboxSearchHint ----------------------------------------------------------
155 156
156 OmniboxSearchHint::OmniboxSearchHint(TabContentsWrapper* tab) : tab_(tab) { 157 OmniboxSearchHint::OmniboxSearchHint(TabContentsWrapper* tab) : tab_(tab) {
157 content::NavigationController* controller = 158 NavigationController* controller = &(tab->web_contents()->GetController());
158 &(tab->web_contents()->GetController());
159 notification_registrar_.Add( 159 notification_registrar_.Add(
160 this, 160 this,
161 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 161 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
162 content::Source<content::NavigationController>(controller)); 162 content::Source<NavigationController>(controller));
163 // Fill the search_engine_urls_ map, used for faster look-up (overkill?). 163 // Fill the search_engine_urls_ map, used for faster look-up (overkill?).
164 for (size_t i = 0; i < arraysize(kSearchEngineURLs); ++i) 164 for (size_t i = 0; i < arraysize(kSearchEngineURLs); ++i)
165 search_engine_urls_[kSearchEngineURLs[i]] = 1; 165 search_engine_urls_[kSearchEngineURLs[i]] = 1;
166 166
167 // Listen for omnibox to figure-out when the user searches from the omnibox. 167 // Listen for omnibox to figure-out when the user searches from the omnibox.
168 notification_registrar_.Add(this, 168 notification_registrar_.Add(this,
169 chrome::NOTIFICATION_OMNIBOX_OPENED_URL, 169 chrome::NOTIFICATION_OMNIBOX_OPENED_URL,
170 content::Source<Profile>(tab->profile())); 170 content::Source<Profile>(tab->profile()));
171 } 171 }
172 172
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW
« no previous file with comments | « chrome/browser/instant/instant_loader.cc ('k') | chrome/browser/prerender/prerender_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698