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

Side by Side Diff: chrome/browser/extensions/extension_process_manager.h

Issue 155707: Changed the extension.connect() API not to broadcast to all tabs. Added a (Closed)
Patch Set: review comments Created 11 years, 5 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 (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 11
12 #include "base/ref_counted.h" 12 #include "base/ref_counted.h"
13 #include "chrome/common/notification_registrar.h" 13 #include "chrome/common/notification_registrar.h"
14 14
15 class Browser; 15 class Browser;
16 class BrowsingInstance; 16 class BrowsingInstance;
17 class Extension; 17 class Extension;
18 class ExtensionHost; 18 class ExtensionHost;
19 #if defined(TOOLKIT_VIEWS) 19 #if defined(TOOLKIT_VIEWS)
20 class ExtensionView; 20 class ExtensionView;
21 #endif 21 #endif
22 class GURL; 22 class GURL;
23 class Profile; 23 class Profile;
24 class RenderProcessHost;
24 class SiteInstance; 25 class SiteInstance;
25 26
26 // Manages dynamic state of running Chromium extensions. There is one instance 27 // Manages dynamic state of running Chromium extensions. There is one instance
27 // of this class per Profile (including OTR). 28 // of this class per Profile (including OTR).
28 class ExtensionProcessManager : public NotificationObserver { 29 class ExtensionProcessManager : public NotificationObserver {
29 public: 30 public:
30 explicit ExtensionProcessManager(Profile* profile); 31 explicit ExtensionProcessManager(Profile* profile);
31 ~ExtensionProcessManager(); 32 ~ExtensionProcessManager();
32 33
33 // Creates a new ExtensionHost with its associated view, grouping it in the 34 // Creates a new ExtensionHost with its associated view, grouping it in the
34 // appropriate SiteInstance (and therefore process) based on the URL and 35 // appropriate SiteInstance (and therefore process) based on the URL and
35 // profile. 36 // profile.
36 ExtensionHost* CreateView(Extension* extension, 37 ExtensionHost* CreateView(Extension* extension,
37 const GURL& url, 38 const GURL& url,
38 Browser* browser); 39 Browser* browser);
39 ExtensionHost* CreateView(const GURL& url, Browser* browser); 40 ExtensionHost* CreateView(const GURL& url, Browser* browser);
40 41
41 // Creates a new UI-less extension instance. Like CreateView, but not 42 // Creates a new UI-less extension instance. Like CreateView, but not
42 // displayed anywhere. 43 // displayed anywhere.
43 ExtensionHost* CreateBackgroundHost(Extension* extension, const GURL& url); 44 ExtensionHost* CreateBackgroundHost(Extension* extension, const GURL& url);
44 45
45 // Returns the SiteInstance that the given URL belongs to. 46 // Returns the SiteInstance that the given URL belongs to.
46 SiteInstance* GetSiteInstanceForURL(const GURL& url); 47 SiteInstance* GetSiteInstanceForURL(const GURL& url);
47 48
48 // Register an extension process by |extension_id| and specifying which 49 // Registers an extension process by |extension_id| and specifying which
49 // |process_id| it belongs to. 50 // |process_id| it belongs to.
50 void RegisterExtensionProcess(std::string extension_id, int process_id); 51 void RegisterExtensionProcess(const std::string& extension_id,
52 int process_id);
51 53
52 // Unregister an extension process with specified |process_id|. 54 // Unregisters an extension process with specified |process_id|.
53 void UnregisterExtensionProcess(int process_id); 55 void UnregisterExtensionProcess(int process_id);
54 56
57 // Returns the process that the extension with the given ID is running in.
58 RenderProcessHost* GetExtensionProcess(const std::string& extension_id);
59
55 // NotificationObserver: 60 // NotificationObserver:
56 virtual void Observe(NotificationType type, 61 virtual void Observe(NotificationType type,
57 const NotificationSource& source, 62 const NotificationSource& source,
58 const NotificationDetails& details); 63 const NotificationDetails& details);
59 64
60 typedef std::set<ExtensionHost*> ExtensionHostSet; 65 typedef std::set<ExtensionHost*> ExtensionHostSet;
61 typedef ExtensionHostSet::const_iterator const_iterator; 66 typedef ExtensionHostSet::const_iterator const_iterator;
62 const_iterator begin() const { return all_hosts_.begin(); } 67 const_iterator begin() const { return all_hosts_.begin(); }
63 const_iterator end() const { return all_hosts_.end(); } 68 const_iterator end() const { return all_hosts_.end(); }
64 69
(...skipping 14 matching lines...) Expand all
79 scoped_refptr<BrowsingInstance> browsing_instance_; 84 scoped_refptr<BrowsingInstance> browsing_instance_;
80 85
81 // A map of extension ID to the render_process_id that the extension lives in. 86 // A map of extension ID to the render_process_id that the extension lives in.
82 typedef std::map<std::string, int> ProcessIDMap; 87 typedef std::map<std::string, int> ProcessIDMap;
83 ProcessIDMap process_ids_; 88 ProcessIDMap process_ids_;
84 89
85 DISALLOW_COPY_AND_ASSIGN(ExtensionProcessManager); 90 DISALLOW_COPY_AND_ASSIGN(ExtensionProcessManager);
86 }; 91 };
87 92
88 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_ 93 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_messages_unittest.cc ('k') | chrome/browser/extensions/extension_process_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698