| OLD | NEW |
| (Empty) |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_TAB_CONTENTS_RESOURCE_PROVIDER_
H_ | |
| 6 #define CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_TAB_CONTENTS_RESOURCE_PROVIDER_
H_ | |
| 7 | |
| 8 #include <map> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/string16.h" | |
| 12 #include "chrome/browser/task_manager/task_manager_render_resource.h" | |
| 13 #include "content/public/browser/notification_observer.h" | |
| 14 #include "content/public/browser/notification_registrar.h" | |
| 15 #include "ui/gfx/image/image_skia.h" | |
| 16 | |
| 17 class Profile; | |
| 18 class TaskManager; | |
| 19 | |
| 20 namespace content { | |
| 21 class WebContents; | |
| 22 class NotificationSource; | |
| 23 class NotificationDetails; | |
| 24 } | |
| 25 | |
| 26 // Tracks a single tab contents, prerendered page, Instant page, or background | |
| 27 // printing page. | |
| 28 class TaskManagerTabContentsResource : public TaskManagerRendererResource { | |
| 29 public: | |
| 30 explicit TaskManagerTabContentsResource(content::WebContents* web_contents); | |
| 31 virtual ~TaskManagerTabContentsResource(); | |
| 32 | |
| 33 // Called when the underlying web_contents has been committed and is no | |
| 34 // longer an Instant overlay. | |
| 35 void InstantCommitted(); | |
| 36 | |
| 37 // TaskManager::Resource methods: | |
| 38 virtual Type GetType() const OVERRIDE; | |
| 39 virtual string16 GetTitle() const OVERRIDE; | |
| 40 virtual string16 GetProfileName() const OVERRIDE; | |
| 41 virtual gfx::ImageSkia GetIcon() const OVERRIDE; | |
| 42 virtual content::WebContents* GetWebContents() const OVERRIDE; | |
| 43 virtual const extensions::Extension* GetExtension() const OVERRIDE; | |
| 44 | |
| 45 private: | |
| 46 // Returns true if contains content rendered by an extension. | |
| 47 bool HostsExtension() const; | |
| 48 | |
| 49 static gfx::ImageSkia* prerender_icon_; | |
| 50 content::WebContents* web_contents_; | |
| 51 Profile* profile_; | |
| 52 bool is_instant_overlay_; | |
| 53 | |
| 54 DISALLOW_COPY_AND_ASSIGN(TaskManagerTabContentsResource); | |
| 55 }; | |
| 56 | |
| 57 // Provides resources for tab contents, prerendered pages, Instant pages, and | |
| 58 // background printing pages. | |
| 59 class TaskManagerTabContentsResourceProvider | |
| 60 : public TaskManager::ResourceProvider, | |
| 61 public content::NotificationObserver { | |
| 62 public: | |
| 63 explicit TaskManagerTabContentsResourceProvider(TaskManager* task_manager); | |
| 64 | |
| 65 virtual TaskManager::Resource* GetResource(int origin_pid, | |
| 66 int render_process_host_id, | |
| 67 int routing_id) OVERRIDE; | |
| 68 virtual void StartUpdating() OVERRIDE; | |
| 69 virtual void StopUpdating() OVERRIDE; | |
| 70 | |
| 71 // content::NotificationObserver method: | |
| 72 virtual void Observe(int type, | |
| 73 const content::NotificationSource& source, | |
| 74 const content::NotificationDetails& details) OVERRIDE; | |
| 75 | |
| 76 private: | |
| 77 virtual ~TaskManagerTabContentsResourceProvider(); | |
| 78 | |
| 79 void Add(content::WebContents* web_contents); | |
| 80 void Remove(content::WebContents* web_contents); | |
| 81 void InstantCommitted(content::WebContents* web_contents); | |
| 82 | |
| 83 void AddToTaskManager(content::WebContents* web_contents); | |
| 84 | |
| 85 // Whether we are currently reporting to the task manager. Used to ignore | |
| 86 // notifications sent after StopUpdating(). | |
| 87 bool updating_; | |
| 88 | |
| 89 TaskManager* task_manager_; | |
| 90 | |
| 91 // Maps the actual resources (the WebContentses) to the Task Manager | |
| 92 // resources. | |
| 93 std::map<content::WebContents*, TaskManagerTabContentsResource*> resources_; | |
| 94 | |
| 95 // A scoped container for notification registries. | |
| 96 content::NotificationRegistrar registrar_; | |
| 97 | |
| 98 DISALLOW_COPY_AND_ASSIGN(TaskManagerTabContentsResourceProvider); | |
| 99 }; | |
| 100 | |
| 101 #endif // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_TAB_CONTENTS_RESOURCE_PROVID
ER_H_ | |
| OLD | NEW |