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

Unified Diff: chrome/browser/task_manager/task_manager_resource_providers.cc

Issue 12386019: Instant: Use only one hidden WebContents per profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/task_manager/task_manager_resource_providers.cc
diff --git a/chrome/browser/task_manager/task_manager_resource_providers.cc b/chrome/browser/task_manager/task_manager_resource_providers.cc
index 63f92e12e9a2ebcf8c437f83f8270e76efd39b0c..23ffc6a0c2553db5b8eac80b59e3778769d78d9a 100644
--- a/chrome/browser/task_manager/task_manager_resource_providers.cc
+++ b/chrome/browser/task_manager/task_manager_resource_providers.cc
@@ -28,6 +28,10 @@
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/favicon/favicon_tab_helper.h"
+#include "chrome/browser/instant/instant_controller.h"
+#include "chrome/browser/instant/instant_loader.h"
+#include "chrome/browser/instant/instant_service.h"
+#include "chrome/browser/instant/instant_service_factory.h"
#include "chrome/browser/prerender/prerender_manager.h"
#include "chrome/browser/prerender/prerender_manager_factory.h"
#include "chrome/browser/printing/background_printing_manager.h"
@@ -91,7 +95,7 @@ int GetMessagePrefixID(bool is_app,
bool is_extension,
bool is_incognito,
bool is_prerender,
- bool is_instant_preview,
+ bool is_instant_overlay,
bool is_background) {
if (is_app) {
if (is_background) {
@@ -108,8 +112,8 @@ int GetMessagePrefixID(bool is_app,
return IDS_TASK_MANAGER_EXTENSION_PREFIX;
} else if (is_prerender) {
return IDS_TASK_MANAGER_PRERENDER_PREFIX;
- } else if (is_instant_preview) {
- return IDS_TASK_MANAGER_INSTANT_PREVIEW_PREFIX;
+ } else if (is_instant_overlay) {
+ return IDS_TASK_MANAGER_INSTANT_OVERLAY_PREFIX;
} else {
return IDS_TASK_MANAGER_TAB_PREFIX;
}
@@ -158,10 +162,17 @@ bool IsContentsPrerendering(WebContents* web_contents) {
}
bool IsContentsInstant(WebContents* web_contents) {
+ Profile* profile =
+ Profile::FromBrowserContext(web_contents->GetBrowserContext());
+ InstantService* instant_service =
+ InstantServiceFactory::GetForProfile(profile);
+ if (instant_service && instant_service->loader()->contents() == web_contents)
+ return true;
+
for (chrome::BrowserIterator it; !it.done(); it.Next()) {
if (it->instant_controller() &&
it->instant_controller()->instant()->
- GetPreviewContents() == web_contents) {
+ GetOverlayContents() == web_contents) {
return true;
}
}
@@ -305,7 +316,7 @@ TaskManagerTabContentsResource::TaskManagerTabContentsResource(
web_contents->GetRenderViewHost()),
web_contents_(web_contents),
profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())),
- is_instant_preview_(IsContentsInstant(web_contents)) {
+ is_instant_overlay_(IsContentsInstant(web_contents)) {
if (!prerender_icon_) {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
prerender_icon_ = rb.GetImageSkiaNamed(IDR_PRERENDER);
@@ -316,8 +327,8 @@ TaskManagerTabContentsResource::~TaskManagerTabContentsResource() {
}
void TaskManagerTabContentsResource::InstantCommitted() {
- DCHECK(is_instant_preview_);
- is_instant_preview_ = false;
+ DCHECK(is_instant_overlay_);
+ is_instant_overlay_ = false;
}
bool TaskManagerTabContentsResource::HostsExtension() const {
@@ -346,7 +357,7 @@ string16 TaskManagerTabContentsResource::GetTitle() const {
HostsExtension(),
profile_->IsOffTheRecord(),
IsContentsPrerendering(web_contents_),
- is_instant_preview_,
+ is_instant_overlay_,
false);
return l10n_util::GetStringFUTF16(message_id, tab_title);
}
@@ -419,25 +430,25 @@ void TaskManagerTabContentsResourceProvider::StartUpdating() {
updating_ = true;
// The contents that are tracked by this resource provider are those that
- // are tab contents (WebContents serving as a tab in a Browser), instant
+ // are tab contents (WebContents serving as a tab in a Browser), Instant
// pages, prerender pages, and background printed pages.
// Add all the existing WebContentses.
for (TabContentsIterator iterator; !iterator.done(); iterator.Next())
Add(*iterator);
- // Add all the instant pages.
+ // Add all the Instant pages.
for (chrome::BrowserIterator it; !it.done(); it.Next()) {
if (it->instant_controller() &&
- it->instant_controller()->instant()->GetPreviewContents()) {
- Add(it->instant_controller()->instant()->GetPreviewContents());
+ it->instant_controller()->instant()->GetOverlayContents()) {
+ Add(it->instant_controller()->instant()->GetOverlayContents());
}
}
- // Add all the prerender pages.
std::vector<Profile*> profiles(
g_browser_process->profile_manager()->GetLoadedProfiles());
for (size_t i = 0; i < profiles.size(); ++i) {
+ // Add all the prerender pages.
prerender::PrerenderManager* prerender_manager =
prerender::PrerenderManagerFactory::GetForProfile(profiles[i]);
if (prerender_manager) {
@@ -446,6 +457,12 @@ void TaskManagerTabContentsResourceProvider::StartUpdating() {
for (size_t j = 0; j < contentses.size(); ++j)
Add(contentses[j]);
}
+
+ // Add the Instant per-profile page.
+ InstantService* instant_service =
+ InstantServiceFactory::GetForProfile(profiles[i]);
+ if (instant_service && instant_service->loader()->contents())
+ Add(instant_service->loader()->contents());
}
// Add all the pages being background printed.
@@ -501,7 +518,7 @@ void TaskManagerTabContentsResourceProvider::Add(WebContents* web_contents) {
return;
// The contents that are tracked by this resource provider are those that
- // are tab contents (WebContents serving as a tab in a Browser), instant
+ // are tab contents (WebContents serving as a tab in a Browser), Instant
// pages, prerender pages, and background printed pages.
if (!chrome::FindBrowserWithWebContents(web_contents) &&
!IsContentsPrerendering(web_contents) &&

Powered by Google App Engine
This is Rietveld 408576698