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

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

Issue 22577010: Printing: Add a basic printing mode without print preview and cloud print. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 4 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
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/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/favicon/favicon_tab_helper.h" 10 #include "chrome/browser/favicon/favicon_tab_helper.h"
11 #include "chrome/browser/prerender/prerender_manager.h" 11 #include "chrome/browser/prerender/prerender_manager.h"
12 #include "chrome/browser/prerender/prerender_manager_factory.h" 12 #include "chrome/browser/prerender/prerender_manager_factory.h"
13 #include "chrome/browser/printing/background_printing_manager.h"
14 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/profiles/profile_manager.h" 14 #include "chrome/browser/profiles/profile_manager.h"
16 #include "chrome/browser/search/instant_service.h" 15 #include "chrome/browser/search/instant_service.h"
17 #include "chrome/browser/search/instant_service_factory.h" 16 #include "chrome/browser/search/instant_service_factory.h"
18 #include "chrome/browser/search/search.h" 17 #include "chrome/browser/search/search.h"
19 #include "chrome/browser/tab_contents/tab_util.h" 18 #include "chrome/browser/tab_contents/tab_util.h"
20 #include "chrome/browser/task_manager/renderer_resource.h" 19 #include "chrome/browser/task_manager/renderer_resource.h"
21 #include "chrome/browser/task_manager/resource_provider.h" 20 #include "chrome/browser/task_manager/resource_provider.h"
22 #include "chrome/browser/task_manager/task_manager.h" 21 #include "chrome/browser/task_manager/task_manager.h"
23 #include "chrome/browser/task_manager/task_manager_util.h" 22 #include "chrome/browser/task_manager/task_manager_util.h"
24 #include "chrome/browser/ui/browser.h" 23 #include "chrome/browser/ui/browser.h"
25 #include "chrome/browser/ui/browser_finder.h" 24 #include "chrome/browser/ui/browser_finder.h"
26 #include "chrome/browser/ui/browser_iterator.h" 25 #include "chrome/browser/ui/browser_iterator.h"
27 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" 26 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h"
28 #include "content/public/browser/notification_service.h" 27 #include "content/public/browser/notification_service.h"
29 #include "content/public/browser/render_process_host.h" 28 #include "content/public/browser/render_process_host.h"
30 #include "content/public/browser/web_contents.h" 29 #include "content/public/browser/web_contents.h"
31 #include "extensions/common/constants.h" 30 #include "extensions/common/constants.h"
32 #include "grit/theme_resources.h" 31 #include "grit/theme_resources.h"
33 #include "ui/base/l10n/l10n_util.h" 32 #include "ui/base/l10n/l10n_util.h"
34 #include "ui/base/resource/resource_bundle.h" 33 #include "ui/base/resource/resource_bundle.h"
35 #include "ui/gfx/image/image_skia.h" 34 #include "ui/gfx/image/image_skia.h"
36 35
36 #if defined(ENABLE_FULL_PRINTING)
37 #include "chrome/browser/printing/background_printing_manager.h"
38 #endif
39
37 using content::WebContents; 40 using content::WebContents;
38 using extensions::Extension; 41 using extensions::Extension;
39 42
40 namespace { 43 namespace {
41 44
42 bool IsContentsPrerendering(WebContents* web_contents) { 45 bool IsContentsPrerendering(WebContents* web_contents) {
43 Profile* profile = 46 Profile* profile =
44 Profile::FromBrowserContext(web_contents->GetBrowserContext()); 47 Profile::FromBrowserContext(web_contents->GetBrowserContext());
45 prerender::PrerenderManager* prerender_manager = 48 prerender::PrerenderManager* prerender_manager =
46 prerender::PrerenderManagerFactory::GetForProfile(profile); 49 prerender::PrerenderManagerFactory::GetForProfile(profile);
47 return prerender_manager && 50 return prerender_manager &&
48 prerender_manager->IsWebContentsPrerendering(web_contents, NULL); 51 prerender_manager->IsWebContentsPrerendering(web_contents, NULL);
49 } 52 }
50 53
51 bool IsContentsBackgroundPrinted(WebContents* web_contents) { 54 bool IsContentsBackgroundPrinted(WebContents* web_contents) {
55 #if defined(ENABLE_FULL_PRINTING)
52 printing::BackgroundPrintingManager* printing_manager = 56 printing::BackgroundPrintingManager* printing_manager =
53 g_browser_process->background_printing_manager(); 57 g_browser_process->background_printing_manager();
54 return printing_manager->HasPrintPreviewDialog(web_contents); 58 return printing_manager->HasPrintPreviewDialog(web_contents);
59 #else
60 return false;
61 #endif
55 } 62 }
56 63
57 } // namespace 64 } // namespace
58 65
59 namespace task_manager { 66 namespace task_manager {
60 67
61 // Tracks a single tab contents, prerendered page, Instant page, or background 68 // Tracks a single tab contents, prerendered page, Instant page, or background
62 // printing page. 69 // printing page.
63 class TabContentsResource : public RendererResource { 70 class TabContentsResource : public RendererResource {
64 public: 71 public:
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 } 230 }
224 231
225 // Add all the Instant Extended prerendered NTPs. 232 // Add all the Instant Extended prerendered NTPs.
226 for (size_t i = 0; i < profiles.size(); ++i) { 233 for (size_t i = 0; i < profiles.size(); ++i) {
227 const InstantService* instant_service = 234 const InstantService* instant_service =
228 InstantServiceFactory::GetForProfile(profiles[i]); 235 InstantServiceFactory::GetForProfile(profiles[i]);
229 if (instant_service && instant_service->GetNTPContents()) 236 if (instant_service && instant_service->GetNTPContents())
230 Add(instant_service->GetNTPContents()); 237 Add(instant_service->GetNTPContents());
231 } 238 }
232 239
240 #if defined(ENABLE_FULL_PRINTING)
233 // Add all the pages being background printed. 241 // Add all the pages being background printed.
234 printing::BackgroundPrintingManager* printing_manager = 242 printing::BackgroundPrintingManager* printing_manager =
235 g_browser_process->background_printing_manager(); 243 g_browser_process->background_printing_manager();
236 for (printing::BackgroundPrintingManager::WebContentsSet::iterator i = 244 for (printing::BackgroundPrintingManager::WebContentsSet::iterator i =
237 printing_manager->begin(); 245 printing_manager->begin();
238 i != printing_manager->end(); ++i) { 246 i != printing_manager->end(); ++i) {
239 Add(*i); 247 Add(*i);
240 } 248 }
249 #endif
241 250
242 // Then we register for notifications to get new web contents. 251 // Then we register for notifications to get new web contents.
243 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_CONNECTED, 252 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_CONNECTED,
244 content::NotificationService::AllBrowserContextsAndSources()); 253 content::NotificationService::AllBrowserContextsAndSources());
245 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_SWAPPED, 254 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_SWAPPED,
246 content::NotificationService::AllBrowserContextsAndSources()); 255 content::NotificationService::AllBrowserContextsAndSources());
247 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED, 256 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED,
248 content::NotificationService::AllBrowserContextsAndSources()); 257 content::NotificationService::AllBrowserContextsAndSources());
249 } 258 }
250 259
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 case content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED: 350 case content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED:
342 Remove(web_contents); 351 Remove(web_contents);
343 break; 352 break;
344 default: 353 default:
345 NOTREACHED() << "Unexpected notification."; 354 NOTREACHED() << "Unexpected notification.";
346 return; 355 return;
347 } 356 }
348 } 357 }
349 358
350 } // namespace task_manager 359 } // namespace task_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698