summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_process_manager.h
blob: 0d4048b95807bf9b71c0c6ed62b46f1c8c8804dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_
#define CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_

#include "base/ref_counted.h"

#include <map>

class BrowsingInstance;
class Extension;
class ExtensionView;
class GURL;
class Profile;
class SiteInstance;

// This class controls what process new extension instances use.  We use the
// BrowsingInstance site grouping rules to group extensions.  Since all
// resources in a given extension have the same origin, they will be grouped
// into the same process.
//
// We separate further by Profile: each Profile has its own group of extension
// processes that never overlap with other Profiles.
class ExtensionProcessManager {
 public:
  static ExtensionProcessManager* GetInstance();

  // These are public for use by Singleton.  Do not instantiate or delete
  // manually.
  ExtensionProcessManager();
  ~ExtensionProcessManager();

  // Creates a new ExtensionView, grouping it in the appropriate SiteInstance
  // (and therefore process) based on the URL and profile.
  ExtensionView* CreateView(Extension* extension,
                            const GURL& url,
                            Profile* profile);

  // Returns the SiteInstance that the given URL belongs to in this profile.
  SiteInstance* GetSiteInstanceForURL(const GURL& url, Profile* profile);
 private:
  // Returns our BrowsingInstance for the given profile.  Lazily created and
  // cached.
  BrowsingInstance* GetBrowsingInstance(Profile* profile);

  // Cache of BrowsingInstances grouped by Profile.
  typedef std::map<Profile*, scoped_refptr<BrowsingInstance> >
      BrowsingInstanceMap;
  BrowsingInstanceMap browsing_instance_map_;
};

#endif  // CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_