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

Side by Side Diff: chrome/browser/task_management/providers/web_contents/web_contents_task_provider.cc

Issue 2148083002: Fix interstitial pages not updating the task manager renderers' titles and favicons (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 5 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
« no previous file with comments | « chrome/browser/task_management/providers/web_contents/guest_task.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/task_management/providers/web_contents/web_contents_tas k_provider.h" 5 #include "chrome/browser/task_management/providers/web_contents/web_contents_tas k_provider.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "chrome/browser/task_management/providers/web_contents/subframe_task.h" 10 #include "chrome/browser/task_management/providers/web_contents/subframe_task.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 RendererTask* GetTaskForFrame(RenderFrameHost* render_frame_host) const; 48 RendererTask* GetTaskForFrame(RenderFrameHost* render_frame_host) const;
49 49
50 // content::WebContentsObserver: 50 // content::WebContentsObserver:
51 void RenderFrameDeleted(RenderFrameHost* render_frame_host) override; 51 void RenderFrameDeleted(RenderFrameHost* render_frame_host) override;
52 void RenderFrameHostChanged(RenderFrameHost* old_host, 52 void RenderFrameHostChanged(RenderFrameHost* old_host,
53 RenderFrameHost* new_host) override; 53 RenderFrameHost* new_host) override;
54 void RenderViewReady() override; 54 void RenderViewReady() override;
55 void WebContentsDestroyed() override; 55 void WebContentsDestroyed() override;
56 void RenderProcessGone(base::TerminationStatus status) override; 56 void RenderProcessGone(base::TerminationStatus status) override;
57 void OnRendererUnresponsive(RenderWidgetHost* render_widget_host) override; 57 void OnRendererUnresponsive(RenderWidgetHost* render_widget_host) override;
58 void DidNavigateMainFrame( 58 void DidFinishNavigation(
59 const content::LoadCommittedDetails& details, 59 content::NavigationHandle* navigation_handle) override;
60 const content::FrameNavigateParams& params) override;
61 void TitleWasSet(content::NavigationEntry* entry, bool explicit_set) override; 60 void TitleWasSet(content::NavigationEntry* entry, bool explicit_set) override;
62 61
63 private: 62 private:
64 // Defines a callback for WebContents::ForEachFrame() to create a 63 // Defines a callback for WebContents::ForEachFrame() to create a
65 // corresponding task for the given |render_frame_host| and notifying the 64 // corresponding task for the given |render_frame_host| and notifying the
66 // provider's observer of the new task. 65 // provider's observer of the new task.
67 void CreateTaskForFrame(RenderFrameHost* render_frame_host); 66 void CreateTaskForFrame(RenderFrameHost* render_frame_host);
68 67
69 // Clears the task that corresponds to the given |render_frame_host| and 68 // Clears the task that corresponds to the given |render_frame_host| and
70 // notifies the provider's observer of the tasks removal. 69 // notifies the provider's observer of the tasks removal.
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 ClearAllTasks(true); 155 ClearAllTasks(true);
157 provider_->DeleteEntry(web_contents()); 156 provider_->DeleteEntry(web_contents());
158 } 157 }
159 158
160 void WebContentsEntry::RenderProcessGone(base::TerminationStatus status) { 159 void WebContentsEntry::RenderProcessGone(base::TerminationStatus status) {
161 ClearAllTasks(true); 160 ClearAllTasks(true);
162 } 161 }
163 162
164 void WebContentsEntry::OnRendererUnresponsive( 163 void WebContentsEntry::OnRendererUnresponsive(
165 RenderWidgetHost* render_widget_host) { 164 RenderWidgetHost* render_widget_host) {
166 auto itr = tasks_by_frames_.find(web_contents()->GetMainFrame()); 165 RendererTask* task = GetTaskForFrame(web_contents()->GetMainFrame());
167 if (itr == tasks_by_frames_.end()) 166 if (!task)
168 return; 167 return;
169 168
170 DCHECK_EQ(render_widget_host->GetProcess(), 169 DCHECK_EQ(render_widget_host->GetProcess(),
171 web_contents()->GetMainFrame()->GetProcess()); 170 web_contents()->GetMainFrame()->GetProcess());
172 171
173 provider_->NotifyObserverTaskUnresponsive(itr->second); 172 provider_->NotifyObserverTaskUnresponsive(task);
174 } 173 }
175 174
176 void WebContentsEntry::DidNavigateMainFrame( 175 void WebContentsEntry::DidFinishNavigation(
177 const content::LoadCommittedDetails& details, 176 content::NavigationHandle* navigation_handle) {
178 const content::FrameNavigateParams& params) { 177 RendererTask* task = GetTaskForFrame(web_contents()->GetMainFrame());
179 auto itr = tasks_by_frames_.find(web_contents()->GetMainFrame()); 178 if (!task)
180 if (itr == tasks_by_frames_.end())
181 return; 179 return;
182 180
183 // Listening to WebContentsObserver::TitleWasSet() only is not enough in 181 // Listening to WebContentsObserver::TitleWasSet() only is not enough in
184 // some cases when the the webpage doesn't have a title. That's why we update 182 // some cases when the the webpage doesn't have a title. That's why we update
185 // the title here as well. 183 // the title here as well.
186 itr->second->UpdateTitle(); 184 task->UpdateTitle();
187 185
188 // Call RendererTask::UpdateFavicon() to set the current favicon to the 186 // Call RendererTask::UpdateFavicon() to set the current favicon to the
189 // default favicon. If the page has a non-default favicon, 187 // default favicon. If the page has a non-default favicon,
190 // RendererTask::OnFaviconUpdated() will update the current favicon once 188 // RendererTask::OnFaviconUpdated() will update the current favicon once
191 // FaviconDriver figures out the correct favicon for the page. 189 // FaviconDriver figures out the correct favicon for the page.
192 itr->second->UpdateFavicon(); 190 task->UpdateFavicon();
193 itr->second->UpdateRapporSampleName(); 191 task->UpdateRapporSampleName();
194 } 192 }
195 193
196 void WebContentsEntry::TitleWasSet(content::NavigationEntry* entry, 194 void WebContentsEntry::TitleWasSet(content::NavigationEntry* entry,
197 bool explicit_set) { 195 bool explicit_set) {
198 auto itr = tasks_by_frames_.find(web_contents()->GetMainFrame()); 196 RendererTask* task = GetTaskForFrame(web_contents()->GetMainFrame());
199 if (itr == tasks_by_frames_.end()) 197 if (!task)
200 return; 198 return;
201 199
202 itr->second->UpdateTitle(); 200 task->UpdateTitle();
201 task->UpdateFavicon();
203 } 202 }
204 203
205 void WebContentsEntry::CreateTaskForFrame(RenderFrameHost* render_frame_host) { 204 void WebContentsEntry::CreateTaskForFrame(RenderFrameHost* render_frame_host) {
206 DCHECK(!ContainsKey(tasks_by_frames_, render_frame_host)); 205 DCHECK(!ContainsKey(tasks_by_frames_, render_frame_host));
207 206
208 content::SiteInstance* site_instance = render_frame_host->GetSiteInstance(); 207 content::SiteInstance* site_instance = render_frame_host->GetSiteInstance();
209 if (!site_instance->GetProcess()->HasConnection()) 208 if (!site_instance->GetProcess()->HasConnection())
210 return; 209 return;
211 210
212 bool site_instance_exists = 211 bool site_instance_exists =
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 387
389 WebContentsEntry* entry = itr->second; 388 WebContentsEntry* entry = itr->second;
390 entries_map_.erase(itr); 389 entries_map_.erase(itr);
391 390
392 // The entry we're about to delete is our caller, however its' still fine to 391 // The entry we're about to delete is our caller, however its' still fine to
393 // delete it. 392 // delete it.
394 delete entry; 393 delete entry;
395 } 394 }
396 395
397 } // namespace task_management 396 } // namespace task_management
OLDNEW
« no previous file with comments | « chrome/browser/task_management/providers/web_contents/guest_task.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698