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

Side by Side Diff: chrome/browser/history/history_tab_helper.cc

Issue 10978016: Remove two functions on WebContentsDelegate which didn't belong in content. They were only called f… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: don't log history for prerender on android Created 8 years, 2 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) 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/history/history_tab_helper.h" 5 #include "chrome/browser/history/history_tab_helper.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "chrome/browser/history/history.h" 9 #include "chrome/browser/history/history.h"
10 #include "chrome/browser/history/history_service_factory.h" 10 #include "chrome/browser/history/history_service_factory.h"
11 #include "chrome/browser/history/top_sites.h" 11 #include "chrome/browser/history/top_sites.h"
12 #include "chrome/browser/prerender/prerender_manager.h"
13 #include "chrome/browser/prerender/prerender_manager_factory.h"
12 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/common/render_messages.h" 15 #include "chrome/common/render_messages.h"
14 #include "content/public/browser/navigation_details.h" 16 #include "content/public/browser/navigation_details.h"
15 #include "content/public/browser/navigation_entry.h" 17 #include "content/public/browser/navigation_entry.h"
16 #include "content/public/browser/notification_details.h" 18 #include "content/public/browser/notification_details.h"
17 #include "content/public/browser/notification_source.h" 19 #include "content/public/browser/notification_source.h"
18 #include "content/public/browser/notification_types.h" 20 #include "content/public/browser/notification_types.h"
19 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
20 #include "content/public/browser/web_contents_delegate.h" 22 #include "content/public/browser/web_contents_delegate.h"
21 #include "content/public/common/frame_navigate_params.h" 23 #include "content/public/common/frame_navigate_params.h"
22 24
25 #if !defined(OS_ANDROID)
26 #include "chrome/browser/ui/browser.h"
27 #include "chrome/browser/ui/browser_finder.h"
28 #endif
29
23 using content::NavigationEntry; 30 using content::NavigationEntry;
24 using content::WebContents; 31 using content::WebContents;
25 32
26 HistoryTabHelper::HistoryTabHelper(WebContents* web_contents) 33 HistoryTabHelper::HistoryTabHelper(WebContents* web_contents)
27 : content::WebContentsObserver(web_contents), 34 : content::WebContentsObserver(web_contents),
28 received_page_title_(false) { 35 received_page_title_(false) {
29 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED, 36 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED,
30 content::Source<WebContents>(web_contents)); 37 content::Source<WebContents>(web_contents));
31 } 38 }
32 39
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 // which WillNavigate[Main,Sub]Frame will do before this function is called. 105 // which WillNavigate[Main,Sub]Frame will do before this function is called.
99 if (!params.should_update_history) 106 if (!params.should_update_history)
100 return; 107 return;
101 108
102 // Most of the time, the displayURL matches the loaded URL, but for about: 109 // Most of the time, the displayURL matches the loaded URL, but for about:
103 // URLs, we use a data: URL as the real value. We actually want to save the 110 // URLs, we use a data: URL as the real value. We actually want to save the
104 // about: URL to the history db and keep the data: URL hidden. This is what 111 // about: URL to the history db and keep the data: URL hidden. This is what
105 // the WebContents' URL getter does. 112 // the WebContents' URL getter does.
106 const history::HistoryAddPageArgs& add_page_args = 113 const history::HistoryAddPageArgs& add_page_args =
107 CreateHistoryAddPageArgs(web_contents()->GetURL(), details, params); 114 CreateHistoryAddPageArgs(web_contents()->GetURL(), details, params);
108 if (!web_contents()->GetDelegate() || 115
109 !web_contents()->GetDelegate()->ShouldAddNavigationToHistory( 116 #if !defined(OS_ANDROID)
110 add_page_args, details.type)) 117 // Don't update history if this web contents isn't associatd with a tab (i.e.
118 // instant or prerender) or is used for running an app.
119 Browser* browser = browser::FindBrowserWithWebContents(web_contents());
120 if (!browser || browser->is_app())
111 return; 121 return;
122 #else
123 // The above check is more thorough, but since we don't have Browser* on
124 // Android, at least check prerendering.
125 prerender::PrerenderManager* prerender_manager =
126 prerender::PrerenderManagerFactory::GetForProfile(
127 Profile::FromBrowserContext(web_contents()->GetBrowserContext()));
128 if (prerender_manager &&
129 prerender_manager->IsWebContentsPrerendering(web_contents())) {
130 return;
131 }
132 #endif
112 133
113 UpdateHistoryForNavigation(add_page_args); 134 UpdateHistoryForNavigation(add_page_args);
114 } 135 }
115 136
116 void HistoryTabHelper::Observe(int type, 137 void HistoryTabHelper::Observe(int type,
117 const content::NotificationSource& source, 138 const content::NotificationSource& source,
118 const content::NotificationDetails& details) { 139 const content::NotificationDetails& details) {
119 DCHECK(type == content::NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED); 140 DCHECK(type == content::NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED);
120 std::pair<content::NavigationEntry*, bool>* title = 141 std::pair<content::NavigationEntry*, bool>* title =
121 content::Details<std::pair<content::NavigationEntry*, bool> >( 142 content::Details<std::pair<content::NavigationEntry*, bool> >(
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 HistoryService* hs = 208 HistoryService* hs =
188 HistoryServiceFactory::GetForProfile(profile, Profile::IMPLICIT_ACCESS); 209 HistoryServiceFactory::GetForProfile(profile, Profile::IMPLICIT_ACCESS);
189 if (hs) { 210 if (hs) {
190 NavigationEntry* entry = tab->GetController().GetLastCommittedEntry(); 211 NavigationEntry* entry = tab->GetController().GetLastCommittedEntry();
191 if (entry) { 212 if (entry) {
192 hs->UpdateWithPageEndTime(tab, entry->GetPageID(), tab->GetURL(), 213 hs->UpdateWithPageEndTime(tab, entry->GetPageID(), tab->GetURL(),
193 base::Time::Now()); 214 base::Time::Now());
194 } 215 }
195 } 216 }
196 } 217 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698