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

Side by Side Diff: chrome/browser/task_manager/tab_contents_resource_provider.cc

Issue 132733002: InstantExtended: remove dead code related to the non-cacheable NTP. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 6 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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/task_manager/tab_contents_resource_provider.h" 5 #include "chrome/browser/task_manager/tab_contents_resource_provider.h"
6 6
7 #include "chrome/browser/browser_process.h" 7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/chrome_notification_types.h" 8 #include "chrome/browser/chrome_notification_types.h"
9 #include "chrome/browser/devtools/devtools_window.h" 9 #include "chrome/browser/devtools/devtools_window.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/favicon/favicon_tab_helper.h" 11 #include "chrome/browser/favicon/favicon_tab_helper.h"
12 #include "chrome/browser/prerender/prerender_manager.h" 12 #include "chrome/browser/prerender/prerender_manager.h"
13 #include "chrome/browser/prerender/prerender_manager_factory.h" 13 #include "chrome/browser/prerender/prerender_manager_factory.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/profiles/profile_manager.h" 15 #include "chrome/browser/profiles/profile_manager.h"
16 #include "chrome/browser/search/instant_service.h"
17 #include "chrome/browser/search/instant_service_factory.h"
18 #include "chrome/browser/search/search.h" 16 #include "chrome/browser/search/search.h"
19 #include "chrome/browser/tab_contents/tab_util.h" 17 #include "chrome/browser/tab_contents/tab_util.h"
20 #include "chrome/browser/task_manager/renderer_resource.h" 18 #include "chrome/browser/task_manager/renderer_resource.h"
21 #include "chrome/browser/task_manager/resource_provider.h" 19 #include "chrome/browser/task_manager/resource_provider.h"
22 #include "chrome/browser/task_manager/task_manager.h" 20 #include "chrome/browser/task_manager/task_manager.h"
23 #include "chrome/browser/task_manager/task_manager_util.h" 21 #include "chrome/browser/task_manager/task_manager_util.h"
24 #include "chrome/browser/ui/browser.h" 22 #include "chrome/browser/ui/browser.h"
25 #include "chrome/browser/ui/browser_finder.h" 23 #include "chrome/browser/ui/browser_finder.h"
26 #include "chrome/browser/ui/browser_iterator.h" 24 #include "chrome/browser/ui/browser_iterator.h"
27 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" 25 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 virtual content::WebContents* GetWebContents() const OVERRIDE; 80 virtual content::WebContents* GetWebContents() const OVERRIDE;
83 virtual const extensions::Extension* GetExtension() const OVERRIDE; 81 virtual const extensions::Extension* GetExtension() const OVERRIDE;
84 82
85 private: 83 private:
86 // Returns true if contains content rendered by an extension. 84 // Returns true if contains content rendered by an extension.
87 bool HostsExtension() const; 85 bool HostsExtension() const;
88 86
89 static gfx::ImageSkia* prerender_icon_; 87 static gfx::ImageSkia* prerender_icon_;
90 content::WebContents* web_contents_; 88 content::WebContents* web_contents_;
91 Profile* profile_; 89 Profile* profile_;
92 bool is_instant_ntp_;
93 90
94 DISALLOW_COPY_AND_ASSIGN(TabContentsResource); 91 DISALLOW_COPY_AND_ASSIGN(TabContentsResource);
95 }; 92 };
96 93
97 gfx::ImageSkia* TabContentsResource::prerender_icon_ = NULL; 94 gfx::ImageSkia* TabContentsResource::prerender_icon_ = NULL;
98 95
99 TabContentsResource::TabContentsResource( 96 TabContentsResource::TabContentsResource(
100 WebContents* web_contents) 97 WebContents* web_contents)
101 : RendererResource(web_contents->GetRenderProcessHost()->GetHandle(), 98 : RendererResource(web_contents->GetRenderProcessHost()->GetHandle(),
102 web_contents->GetRenderViewHost()), 99 web_contents->GetRenderViewHost()),
103 web_contents_(web_contents), 100 web_contents_(web_contents),
104 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())), 101 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())) {
105 is_instant_ntp_(chrome::IsPreloadedInstantExtendedNTP(web_contents)) {
106 if (!prerender_icon_) { 102 if (!prerender_icon_) {
107 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 103 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
108 prerender_icon_ = rb.GetImageSkiaNamed(IDR_PRERENDER); 104 prerender_icon_ = rb.GetImageSkiaNamed(IDR_PRERENDER);
109 } 105 }
110 } 106 }
111 107
112 TabContentsResource::~TabContentsResource() { 108 TabContentsResource::~TabContentsResource() {
113 } 109 }
114 110
115 bool TabContentsResource::HostsExtension() const { 111 bool TabContentsResource::HostsExtension() const {
(...skipping 15 matching lines...) Expand all
131 ExtensionService* extension_service = profile_->GetExtensionService(); 127 ExtensionService* extension_service = profile_->GetExtensionService();
132 extensions::ProcessMap* process_map = extension_service->process_map(); 128 extensions::ProcessMap* process_map = extension_service->process_map();
133 bool is_app = extension_service->IsInstalledApp(url) && 129 bool is_app = extension_service->IsInstalledApp(url) &&
134 process_map->Contains(web_contents_->GetRenderProcessHost()->GetID()); 130 process_map->Contains(web_contents_->GetRenderProcessHost()->GetID());
135 131
136 int message_id = util::GetMessagePrefixID( 132 int message_id = util::GetMessagePrefixID(
137 is_app, 133 is_app,
138 HostsExtension(), 134 HostsExtension(),
139 profile_->IsOffTheRecord(), 135 profile_->IsOffTheRecord(),
140 IsContentsPrerendering(web_contents_), 136 IsContentsPrerendering(web_contents_),
141 is_instant_ntp_,
142 false); // is_background 137 false); // is_background
143 return l10n_util::GetStringFUTF16(message_id, tab_title); 138 return l10n_util::GetStringFUTF16(message_id, tab_title);
144 } 139 }
145 140
146 base::string16 TabContentsResource::GetProfileName() const { 141 base::string16 TabContentsResource::GetProfileName() const {
147 return util::GetProfileNameFromInfoCache(profile_); 142 return util::GetProfileNameFromInfoCache(profile_);
148 } 143 }
149 144
150 gfx::ImageSkia TabContentsResource::GetIcon() const { 145 gfx::ImageSkia TabContentsResource::GetIcon() const {
151 if (IsContentsPrerendering(web_contents_)) 146 if (IsContentsPrerendering(web_contents_))
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 prerender::PrerenderManager* prerender_manager = 225 prerender::PrerenderManager* prerender_manager =
231 prerender::PrerenderManagerFactory::GetForProfile(profiles[i]); 226 prerender::PrerenderManagerFactory::GetForProfile(profiles[i]);
232 if (prerender_manager) { 227 if (prerender_manager) {
233 const std::vector<content::WebContents*> contentses = 228 const std::vector<content::WebContents*> contentses =
234 prerender_manager->GetAllPrerenderingContents(); 229 prerender_manager->GetAllPrerenderingContents();
235 for (size_t j = 0; j < contentses.size(); ++j) 230 for (size_t j = 0; j < contentses.size(); ++j)
236 Add(contentses[j]); 231 Add(contentses[j]);
237 } 232 }
238 } 233 }
239 234
240 // Add all the Instant Extended prerendered NTPs.
241 for (size_t i = 0; i < profiles.size(); ++i) {
242 const InstantService* instant_service =
243 InstantServiceFactory::GetForProfile(profiles[i]);
244 if (instant_service && instant_service->GetNTPContents())
245 Add(instant_service->GetNTPContents());
246 }
247
248 #if defined(ENABLE_FULL_PRINTING) 235 #if defined(ENABLE_FULL_PRINTING)
249 // Add all the pages being background printed. 236 // Add all the pages being background printed.
250 printing::BackgroundPrintingManager* printing_manager = 237 printing::BackgroundPrintingManager* printing_manager =
251 g_browser_process->background_printing_manager(); 238 g_browser_process->background_printing_manager();
252 for (printing::BackgroundPrintingManager::WebContentsSet::iterator i = 239 for (printing::BackgroundPrintingManager::WebContentsSet::iterator i =
253 printing_manager->begin(); 240 printing_manager->begin();
254 i != printing_manager->end(); ++i) { 241 i != printing_manager->end(); ++i) {
255 Add(*i); 242 Add(*i);
256 } 243 }
257 #endif 244 #endif
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 278
292 void TabContentsResourceProvider::Add(WebContents* web_contents) { 279 void TabContentsResourceProvider::Add(WebContents* web_contents) {
293 if (!updating_) 280 if (!updating_)
294 return; 281 return;
295 282
296 // The contents that are tracked by this resource provider are those that 283 // The contents that are tracked by this resource provider are those that
297 // are tab contents (WebContents serving as a tab in a Browser), Instant 284 // are tab contents (WebContents serving as a tab in a Browser), Instant
298 // pages, prerender pages, and background printed pages. 285 // pages, prerender pages, and background printed pages.
299 if (!chrome::FindBrowserWithWebContents(web_contents) && 286 if (!chrome::FindBrowserWithWebContents(web_contents) &&
300 !IsContentsPrerendering(web_contents) && 287 !IsContentsPrerendering(web_contents) &&
301 !chrome::IsPreloadedInstantExtendedNTP(web_contents) &&
302 !IsContentsBackgroundPrinted(web_contents) && 288 !IsContentsBackgroundPrinted(web_contents) &&
303 !DevToolsWindow::IsDevToolsWindow(web_contents->GetRenderViewHost())) { 289 !DevToolsWindow::IsDevToolsWindow(web_contents->GetRenderViewHost())) {
304 return; 290 return;
305 } 291 }
306 292
307 // Don't add dead tabs or tabs that haven't yet connected. 293 // Don't add dead tabs or tabs that haven't yet connected.
308 if (!web_contents->GetRenderProcessHost()->GetHandle() || 294 if (!web_contents->GetRenderProcessHost()->GetHandle() ||
309 !web_contents->WillNotifyDisconnection()) { 295 !web_contents->WillNotifyDisconnection()) {
310 return; 296 return;
311 } 297 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 case content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED: 345 case content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED:
360 Remove(web_contents); 346 Remove(web_contents);
361 break; 347 break;
362 default: 348 default:
363 NOTREACHED() << "Unexpected notification."; 349 NOTREACHED() << "Unexpected notification.";
364 return; 350 return;
365 } 351 }
366 } 352 }
367 353
368 } // namespace task_manager 354 } // namespace task_manager
OLDNEW
« no previous file with comments | « chrome/browser/task_manager/panel_resource_provider.cc ('k') | chrome/browser/task_manager/task_manager_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698