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

Side by Side Diff: chrome/browser/ui/search_engines/search_engine_tab_helper.cc

Issue 8956059: Rename NavigationController to NavigationControllerImpl and put it into the content namespace. Al... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 12 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_entry.h" 15 #include "content/public/browser/navigation_entry.h"
16 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
17 #include "content/public/common/frame_navigate_params.h" 17 #include "content/public/common/frame_navigate_params.h"
18 18
19 using content::NavigationEntry;
19 using content::WebContents; 20 using content::WebContents;
20 21
21 namespace { 22 namespace {
22 23
23 // Returns true if the entry's transition type is FORM_SUBMIT. 24 // Returns true if the entry's transition type is FORM_SUBMIT.
24 bool IsFormSubmit(const content::NavigationEntry* entry) { 25 bool IsFormSubmit(const NavigationEntry* entry) {
25 return (content::PageTransitionStripQualifier(entry->GetTransitionType()) == 26 return (content::PageTransitionStripQualifier(entry->GetTransitionType()) ==
26 content::PAGE_TRANSITION_FORM_SUBMIT); 27 content::PAGE_TRANSITION_FORM_SUBMIT);
27 } 28 }
28 29
29 } // namespace 30 } // namespace
30 31
31 SearchEngineTabHelper::SearchEngineTabHelper(WebContents* web_contents) 32 SearchEngineTabHelper::SearchEngineTabHelper(WebContents* web_contents)
32 : content::WebContentsObserver(web_contents) { 33 : content::WebContentsObserver(web_contents) {
33 DCHECK(web_contents); 34 DCHECK(web_contents);
34 } 35 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 case search_provider::EXPLICIT_PROVIDER: 85 case search_provider::EXPLICIT_PROVIDER:
85 provider_type = TemplateURLFetcher::EXPLICIT_PROVIDER; 86 provider_type = TemplateURLFetcher::EXPLICIT_PROVIDER;
86 break; 87 break;
87 88
88 default: 89 default:
89 NOTREACHED(); 90 NOTREACHED();
90 return; 91 return;
91 } 92 }
92 93
93 const NavigationController& controller = web_contents()->GetController(); 94 const NavigationController& controller = web_contents()->GetController();
94 const content::NavigationEntry* entry = controller.GetLastCommittedEntry(); 95 const NavigationEntry* entry = controller.GetLastCommittedEntry();
95 DCHECK(entry); 96 DCHECK(entry);
96 97
97 const content::NavigationEntry* base_entry = entry; 98 const NavigationEntry* base_entry = entry;
98 if (IsFormSubmit(base_entry)) { 99 if (IsFormSubmit(base_entry)) {
99 // If the current page is a form submit, find the last page that was not 100 // If the current page is a form submit, find the last page that was not
100 // a form submit and use its url to generate the keyword from. 101 // a form submit and use its url to generate the keyword from.
101 int index = controller.last_committed_entry_index() - 1; 102 int index = controller.last_committed_entry_index() - 1;
102 while (index >= 0 && IsFormSubmit(controller.GetEntryAtIndex(index))) 103 while (index >= 0 && IsFormSubmit(controller.GetEntryAtIndex(index)))
103 index--; 104 index--;
104 if (index >= 0) 105 if (index >= 0)
105 base_entry = controller.GetEntryAtIndex(index); 106 base_entry = controller.GetEntryAtIndex(index);
106 else 107 else
107 base_entry = NULL; 108 base_entry = NULL;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 return; 142 return;
142 143
143 const NavigationController& controller = web_contents()->GetController(); 144 const NavigationController& controller = web_contents()->GetController();
144 int last_index = controller.last_committed_entry_index(); 145 int last_index = controller.last_committed_entry_index();
145 // When there was no previous page, the last index will be 0. This is 146 // When there was no previous page, the last index will be 0. This is
146 // normally due to a form submit that opened in a new tab. 147 // normally due to a form submit that opened in a new tab.
147 // TODO(brettw) bug 916126: we should support keywords when form submits 148 // TODO(brettw) bug 916126: we should support keywords when form submits
148 // happen in new tabs. 149 // happen in new tabs.
149 if (last_index <= 0) 150 if (last_index <= 0)
150 return; 151 return;
151 const content::NavigationEntry* previous_entry = 152 const NavigationEntry* previous_entry =
152 controller.GetEntryAtIndex(last_index - 1); 153 controller.GetEntryAtIndex(last_index - 1);
153 if (IsFormSubmit(previous_entry)) { 154 if (IsFormSubmit(previous_entry)) {
154 // Only generate a keyword if the previous page wasn't itself a form 155 // Only generate a keyword if the previous page wasn't itself a form
155 // submit. 156 // submit.
156 return; 157 return;
157 } 158 }
158 159
159 GURL keyword_url = previous_entry->GetUserTypedURL().is_valid() ? 160 GURL keyword_url = previous_entry->GetUserTypedURL().is_valid() ?
160 previous_entry->GetUserTypedURL() : previous_entry->GetURL(); 161 previous_entry->GetUserTypedURL() : previous_entry->GetURL();
161 string16 keyword = 162 string16 keyword =
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 // or the favicon url wasn't obtained before the load started. This assumes 202 // or the favicon url wasn't obtained before the load started. This assumes
202 // the later. 203 // the later.
203 // TODO(sky): Need a way to set the favicon that doesn't involve generating 204 // TODO(sky): Need a way to set the favicon that doesn't involve generating
204 // its url. 205 // its url.
205 new_url->SetFaviconURL( 206 new_url->SetFaviconURL(
206 TemplateURL::GenerateFaviconURL(params.referrer.url)); 207 TemplateURL::GenerateFaviconURL(params.referrer.url));
207 } 208 }
208 new_url->set_safe_for_autoreplace(true); 209 new_url->set_safe_for_autoreplace(true);
209 url_service->Add(new_url); 210 url_service->Add(new_url);
210 } 211 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/location_bar_view_gtk.cc ('k') | chrome/browser/ui/sync/tab_contents_wrapper_synced_tab_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698