This source file includes following definitions.
- web_contents_
- GetType
- GetTitle
- GetIcon
- GetWebContents
- CheckOwnership
- GetAll
- MakeResource
#include "chrome/browser/task_manager/printing_information.h"
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/favicon/favicon_tab_helper.h"
#include "chrome/browser/printing/background_printing_manager.h"
#include "chrome/browser/printing/print_preview_dialog_controller.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/task_manager/renderer_resource.h"
#include "chrome/browser/task_manager/task_manager.h"
#include "chrome/browser/task_manager/task_manager_util.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/image/image_skia.h"
using content::WebContents;
namespace task_manager {
class PrintingResource : public RendererResource {
public:
explicit PrintingResource(content::WebContents* web_contents);
virtual ~PrintingResource();
virtual Type GetType() const OVERRIDE;
virtual base::string16 GetTitle() const OVERRIDE;
virtual gfx::ImageSkia GetIcon() const OVERRIDE;
virtual content::WebContents* GetWebContents() const OVERRIDE;
private:
content::WebContents* web_contents_;
DISALLOW_COPY_AND_ASSIGN(PrintingResource);
};
PrintingResource::PrintingResource(WebContents* web_contents)
: RendererResource(web_contents->GetRenderProcessHost()->GetHandle(),
web_contents->GetRenderViewHost()),
web_contents_(web_contents) {}
PrintingResource::~PrintingResource() {}
Resource::Type PrintingResource::GetType() const { return RENDERER; }
base::string16 PrintingResource::GetTitle() const {
return l10n_util::GetStringFUTF16(
IDS_TASK_MANAGER_PRINT_PREFIX,
util::GetTitleFromWebContents(web_contents_));
}
gfx::ImageSkia PrintingResource::GetIcon() const {
FaviconTabHelper::CreateForWebContents(web_contents_);
return FaviconTabHelper::FromWebContents(web_contents_)->
GetFavicon().AsImageSkia();
}
WebContents* PrintingResource::GetWebContents() const { return web_contents_; }
PrintingInformation::PrintingInformation() {}
PrintingInformation::~PrintingInformation() {}
bool PrintingInformation::CheckOwnership(WebContents* web_contents) {
printing::BackgroundPrintingManager* backgrounded_print_jobs =
g_browser_process->background_printing_manager();
if (backgrounded_print_jobs->HasPrintPreviewDialog(web_contents)) {
return true;
}
if (printing::PrintPreviewDialogController::IsPrintPreviewDialog(
web_contents)) {
return true;
}
return false;
}
void PrintingInformation::GetAll(const NewWebContentsCallback& callback) {
printing::BackgroundPrintingManager* printing_manager =
g_browser_process->background_printing_manager();
std::set<content::WebContents*> printing_contents =
printing_manager->CurrentContentSet();
for (std::set<content::WebContents*>::iterator i = printing_contents.begin();
i != printing_contents.end();
++i) {
callback.Run(*i);
}
printing::PrintPreviewDialogController::GetInstance()->ForEachPreviewDialog(
callback);
}
scoped_ptr<RendererResource> PrintingInformation::MakeResource(
WebContents* web_contents) {
return scoped_ptr<RendererResource>(new PrintingResource(web_contents));
}
}