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

Side by Side Diff: chrome/browser/ui/search_engines/search_engine_tab_helper.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/ui/search_engines/search_engine_tab_helper.h" 5 #include "chrome/browser/ui/search_engines/search_engine_tab_helper.h"
6 6
7 #include "chrome/browser/profiles/profile.h" 7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/search_engines/template_url.h" 8 #include "chrome/browser/search_engines/template_url.h"
9 #include "chrome/browser/search_engines/template_url_fetcher.h" 9 #include "chrome/browser/search_engines/template_url_fetcher.h"
10 #include "chrome/browser/search_engines/template_url_service.h" 10 #include "chrome/browser/search_engines/template_url_service.h"
11 #include "chrome/browser/search_engines/template_url_service_factory.h" 11 #include "chrome/browser/search_engines/template_url_service_factory.h"
12 #include "chrome/browser/ui/search_engines/template_url_fetcher_ui_callbacks.h" 12 #include "chrome/browser/ui/search_engines/template_url_fetcher_ui_callbacks.h"
13 #include "chrome/common/render_messages.h" 13 #include "chrome/common/render_messages.h"
14 #include "content/public/browser/favicon_status.h" 14 #include "content/public/browser/favicon_status.h"
15 #include "content/public/browser/navigation_controller.h" 15 #include "content/public/browser/navigation_controller.h"
16 #include "content/public/browser/navigation_entry.h" 16 #include "content/public/browser/navigation_entry.h"
17 #include "content/public/browser/web_contents.h" 17 #include "content/public/browser/web_contents.h"
18 #include "content/public/common/frame_navigate_params.h" 18 #include "content/public/common/frame_navigate_params.h"
19 19
20 using content::NavigationController;
20 using content::NavigationEntry; 21 using content::NavigationEntry;
21 using content::WebContents; 22 using content::WebContents;
22 23
23 namespace { 24 namespace {
24 25
25 // Returns true if the entry's transition type is FORM_SUBMIT. 26 // Returns true if the entry's transition type is FORM_SUBMIT.
26 bool IsFormSubmit(const NavigationEntry* entry) { 27 bool IsFormSubmit(const NavigationEntry* entry) {
27 return (content::PageTransitionStripQualifier(entry->GetTransitionType()) == 28 return (content::PageTransitionStripQualifier(entry->GetTransitionType()) ==
28 content::PAGE_TRANSITION_FORM_SUBMIT); 29 content::PAGE_TRANSITION_FORM_SUBMIT);
29 } 30 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 86
86 case search_provider::EXPLICIT_PROVIDER: 87 case search_provider::EXPLICIT_PROVIDER:
87 provider_type = TemplateURLFetcher::EXPLICIT_PROVIDER; 88 provider_type = TemplateURLFetcher::EXPLICIT_PROVIDER;
88 break; 89 break;
89 90
90 default: 91 default:
91 NOTREACHED(); 92 NOTREACHED();
92 return; 93 return;
93 } 94 }
94 95
95 const content::NavigationController& controller = 96 const NavigationController& controller = web_contents()->GetController();
96 web_contents()->GetController();
97 const NavigationEntry* entry = controller.GetLastCommittedEntry(); 97 const NavigationEntry* entry = controller.GetLastCommittedEntry();
98 DCHECK(entry); 98 DCHECK(entry);
99 99
100 const NavigationEntry* base_entry = entry; 100 const NavigationEntry* base_entry = entry;
101 if (IsFormSubmit(base_entry)) { 101 if (IsFormSubmit(base_entry)) {
102 // If the current page is a form submit, find the last page that was not 102 // If the current page is a form submit, find the last page that was not
103 // a form submit and use its url to generate the keyword from. 103 // a form submit and use its url to generate the keyword from.
104 int index = controller.GetLastCommittedEntryIndex() - 1; 104 int index = controller.GetLastCommittedEntryIndex() - 1;
105 while (index >= 0 && IsFormSubmit(controller.GetEntryAtIndex(index))) 105 while (index >= 0 && IsFormSubmit(controller.GetEntryAtIndex(index)))
106 index--; 106 index--;
(...skipping 29 matching lines...) Expand all
136 void SearchEngineTabHelper::GenerateKeywordIfNecessary( 136 void SearchEngineTabHelper::GenerateKeywordIfNecessary(
137 const content::FrameNavigateParams& params) { 137 const content::FrameNavigateParams& params) {
138 if (!params.searchable_form_url.is_valid()) 138 if (!params.searchable_form_url.is_valid())
139 return; 139 return;
140 140
141 Profile* profile = 141 Profile* profile =
142 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); 142 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
143 if (profile->IsOffTheRecord()) 143 if (profile->IsOffTheRecord())
144 return; 144 return;
145 145
146 const content::NavigationController& controller = 146 const NavigationController& controller = web_contents()->GetController();
147 web_contents()->GetController();
148 int last_index = controller.GetLastCommittedEntryIndex(); 147 int last_index = controller.GetLastCommittedEntryIndex();
149 // When there was no previous page, the last index will be 0. This is 148 // When there was no previous page, the last index will be 0. This is
150 // normally due to a form submit that opened in a new tab. 149 // normally due to a form submit that opened in a new tab.
151 // TODO(brettw) bug 916126: we should support keywords when form submits 150 // TODO(brettw) bug 916126: we should support keywords when form submits
152 // happen in new tabs. 151 // happen in new tabs.
153 if (last_index <= 0) 152 if (last_index <= 0)
154 return; 153 return;
155 const NavigationEntry* previous_entry = 154 const NavigationEntry* previous_entry =
156 controller.GetEntryAtIndex(last_index - 1); 155 controller.GetEntryAtIndex(last_index - 1);
157 if (IsFormSubmit(previous_entry)) { 156 if (IsFormSubmit(previous_entry)) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 // or the favicon url wasn't obtained before the load started. This assumes 204 // or the favicon url wasn't obtained before the load started. This assumes
206 // the later. 205 // the later.
207 // TODO(sky): Need a way to set the favicon that doesn't involve generating 206 // TODO(sky): Need a way to set the favicon that doesn't involve generating
208 // its url. 207 // its url.
209 new_url->SetFaviconURL( 208 new_url->SetFaviconURL(
210 TemplateURL::GenerateFaviconURL(params.referrer.url)); 209 TemplateURL::GenerateFaviconURL(params.referrer.url));
211 } 210 }
212 new_url->set_safe_for_autoreplace(true); 211 new_url->set_safe_for_autoreplace(true);
213 url_service->Add(new_url); 212 url_service->Add(new_url);
214 } 213 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/pdf/pdf_browsertest.cc ('k') | chrome/browser/ui/toolbar/back_forward_menu_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698