| OLD | NEW | 
|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #ifndef CHROME_BROWSER_BACKGROUND_BACKGROUND_CONTENTS_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_BACKGROUND_BACKGROUND_CONTENTS_SERVICE_H_ | 
| 6 #define CHROME_BROWSER_BACKGROUND_BACKGROUND_CONTENTS_SERVICE_H_ | 6 #define CHROME_BROWSER_BACKGROUND_BACKGROUND_CONTENTS_SERVICE_H_ | 
| 7 | 7 | 
| 8 #include <map> | 8 #include <map> | 
| 9 #include <string> | 9 #include <string> | 
| 10 #include <vector> | 10 #include <vector> | 
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 95   // BackgroundContents::Delegate implementation. | 95   // BackgroundContents::Delegate implementation. | 
| 96   void AddWebContents(content::WebContents* new_contents, | 96   void AddWebContents(content::WebContents* new_contents, | 
| 97                       WindowOpenDisposition disposition, | 97                       WindowOpenDisposition disposition, | 
| 98                       const gfx::Rect& initial_rect, | 98                       const gfx::Rect& initial_rect, | 
| 99                       bool user_gesture, | 99                       bool user_gesture, | 
| 100                       bool* was_blocked) override; | 100                       bool* was_blocked) override; | 
| 101 | 101 | 
| 102   // Gets the parent application id for the passed BackgroundContents. Returns | 102   // Gets the parent application id for the passed BackgroundContents. Returns | 
| 103   // an empty string if no parent application found (e.g. passed | 103   // an empty string if no parent application found (e.g. passed | 
| 104   // BackgroundContents has already shut down). | 104   // BackgroundContents has already shut down). | 
| 105   const base::string16& GetParentApplicationId(BackgroundContents* contents) con
     st; | 105   const base::string16& GetParentApplicationId( | 
|  | 106       BackgroundContents* contents) const; | 
| 106 | 107 | 
| 107   // Creates a new BackgroundContents using the passed |site| and | 108   // Creates a new BackgroundContents using the passed |site| and | 
| 108   // the |route_id| and begins tracking the object internally so it can be | 109   // the |route_id| and begins tracking the object internally so it can be | 
| 109   // shutdown if the parent application is uninstalled. | 110   // shutdown if the parent application is uninstalled. | 
| 110   // A BACKGROUND_CONTENTS_OPENED notification will be generated with the passed | 111   // A BACKGROUND_CONTENTS_OPENED notification will be generated with the passed | 
| 111   // |frame_name| and |application_id| values, using the passed |profile| as the | 112   // |frame_name| and |application_id| values, using the passed |profile| as the | 
| 112   // Source.. | 113   // Source.. | 
| 113   BackgroundContents* CreateBackgroundContents( | 114   BackgroundContents* CreateBackgroundContents( | 
| 114       content::SiteInstance* site, | 115       content::SiteInstance* site, | 
| 115       int route_id, | 116       int route_id, | 
| 116       int main_frame_route_id, | 117       int main_frame_route_id, | 
| 117       Profile* profile, | 118       Profile* profile, | 
| 118       const std::string& frame_name, | 119       const std::string& frame_name, | 
| 119       const base::string16& application_id, | 120       const base::string16& application_id, | 
| 120       const std::string& partition_id, | 121       const std::string& partition_id, | 
| 121       content::SessionStorageNamespace* session_storage_namespace); | 122       content::SessionStorageNamespace* session_storage_namespace); | 
| 122 | 123 | 
| 123   // Load the manifest-specified background page for the specified hosted app. | 124   // Load the manifest-specified background page for the specified hosted app. | 
| 124   // If the manifest doesn't specify one, then load the BackgroundContents | 125   // If the manifest doesn't specify one, then load the BackgroundContents | 
| 125   // registered in the pref. This is typically used to reload a crashed | 126   // registered in the pref. This is typically used to reload a crashed | 
| 126   // background page. | 127   // background page. | 
| 127   void LoadBackgroundContentsForExtension(Profile* profile, | 128   void LoadBackgroundContentsForExtension(Profile* profile, | 
| 128                                           const std::string& extension_id); | 129                                           const std::string& extension_id); | 
| 129 | 130 | 
| 130  private: | 131  private: | 
| 131   friend class BackgroundContentsServiceTest; | 132   friend class BackgroundContentsServiceTest; | 
| 132   friend class MockBackgroundContents; | 133   friend class MockBackgroundContents; | 
| 133   friend class TaskManagerNoShowBrowserTest; |  | 
| 134 | 134 | 
| 135   FRIEND_TEST_ALL_PREFIXES(BackgroundContentsServiceTest, | 135   FRIEND_TEST_ALL_PREFIXES(BackgroundContentsServiceTest, | 
| 136                            BackgroundContentsCreateDestroy); | 136                            BackgroundContentsCreateDestroy); | 
| 137   FRIEND_TEST_ALL_PREFIXES(BackgroundContentsServiceTest, | 137   FRIEND_TEST_ALL_PREFIXES(BackgroundContentsServiceTest, | 
| 138                            TestApplicationIDLinkage); | 138                            TestApplicationIDLinkage); | 
| 139   FRIEND_TEST_ALL_PREFIXES(TaskManagerNoShowBrowserTest, |  | 
| 140                            NoticeBGContentsChanges); |  | 
| 141   FRIEND_TEST_ALL_PREFIXES(TaskManagerNoShowBrowserTest, |  | 
| 142                            KillBGContents); |  | 
| 143 | 139 | 
| 144   // Registers for various notifications. | 140   // Registers for various notifications. | 
| 145   void StartObserving(Profile* profile); | 141   void StartObserving(Profile* profile); | 
| 146 | 142 | 
| 147   // content::NotificationObserver implementation. | 143   // content::NotificationObserver implementation. | 
| 148   void Observe(int type, | 144   void Observe(int type, | 
| 149                const content::NotificationSource& source, | 145                const content::NotificationSource& source, | 
| 150                const content::NotificationDetails& details) override; | 146                const content::NotificationDetails& details) override; | 
| 151 | 147 | 
| 152   // extensions::ExtensionRegistryObserver implementation. | 148   // extensions::ExtensionRegistryObserver implementation. | 
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 240   BackgroundContentsMap contents_map_; | 236   BackgroundContentsMap contents_map_; | 
| 241 | 237 | 
| 242   ScopedObserver<extensions::ExtensionRegistry, | 238   ScopedObserver<extensions::ExtensionRegistry, | 
| 243                  extensions::ExtensionRegistryObserver> | 239                  extensions::ExtensionRegistryObserver> | 
| 244       extension_registry_observer_; | 240       extension_registry_observer_; | 
| 245 | 241 | 
| 246   DISALLOW_COPY_AND_ASSIGN(BackgroundContentsService); | 242   DISALLOW_COPY_AND_ASSIGN(BackgroundContentsService); | 
| 247 }; | 243 }; | 
| 248 | 244 | 
| 249 #endif  // CHROME_BROWSER_BACKGROUND_BACKGROUND_CONTENTS_SERVICE_H_ | 245 #endif  // CHROME_BROWSER_BACKGROUND_BACKGROUND_CONTENTS_SERVICE_H_ | 
| OLD | NEW | 
|---|