| 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> |
| 11 | 11 |
| 12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "chrome/browser/tab_contents/background_contents.h" | 14 #include "chrome/browser/tab_contents/background_contents.h" |
| 15 #include "components/keyed_service/core/keyed_service.h" | 15 #include "components/keyed_service/core/keyed_service.h" |
| 16 #include "content/public/browser/notification_observer.h" | 16 #include "content/public/browser/notification_observer.h" |
| 17 #include "content/public/browser/notification_registrar.h" | 17 #include "content/public/browser/notification_registrar.h" |
| 18 #include "content/public/common/window_container_type.h" | 18 #include "content/public/common/window_container_type.h" |
| 19 #include "ui/base/window_open_disposition.h" | 19 #include "ui/base/window_open_disposition.h" |
| 20 #include "url/gurl.h" | 20 #include "url/gurl.h" |
| 21 | 21 |
| 22 class CommandLine; | |
| 23 class PrefService; | 22 class PrefService; |
| 24 class Profile; | 23 class Profile; |
| 25 | 24 |
| 26 namespace base { | 25 namespace base { |
| 26 class CommandLine; |
| 27 class DictionaryValue; | 27 class DictionaryValue; |
| 28 } | 28 } |
| 29 | 29 |
| 30 namespace content { | 30 namespace content { |
| 31 class SessionStorageNamespace; | 31 class SessionStorageNamespace; |
| 32 } | 32 } |
| 33 | 33 |
| 34 namespace extensions { | 34 namespace extensions { |
| 35 class Extension; | 35 class Extension; |
| 36 } | 36 } |
| 37 | 37 |
| 38 namespace gfx { | 38 namespace gfx { |
| 39 class Rect; | 39 class Rect; |
| 40 } | 40 } |
| 41 | 41 |
| 42 struct BackgroundContentsOpenedDetails; | 42 struct BackgroundContentsOpenedDetails; |
| 43 | 43 |
| 44 // BackgroundContentsService is owned by the profile, and is responsible for | 44 // BackgroundContentsService is owned by the profile, and is responsible for |
| 45 // managing the lifetime of BackgroundContents (tracking the set of background | 45 // managing the lifetime of BackgroundContents (tracking the set of background |
| 46 // urls, loading them at startup, and keeping the browser process alive as long | 46 // urls, loading them at startup, and keeping the browser process alive as long |
| 47 // as there are BackgroundContents loaded). | 47 // as there are BackgroundContents loaded). |
| 48 // | 48 // |
| 49 // It is also responsible for tracking the association between | 49 // It is also responsible for tracking the association between |
| 50 // BackgroundContents and their parent app, and shutting them down when the | 50 // BackgroundContents and their parent app, and shutting them down when the |
| 51 // parent app is unloaded. | 51 // parent app is unloaded. |
| 52 class BackgroundContentsService : private content::NotificationObserver, | 52 class BackgroundContentsService : private content::NotificationObserver, |
| 53 public BackgroundContents::Delegate, | 53 public BackgroundContents::Delegate, |
| 54 public KeyedService { | 54 public KeyedService { |
| 55 public: | 55 public: |
| 56 BackgroundContentsService(Profile* profile, const CommandLine* command_line); | 56 BackgroundContentsService(Profile* profile, |
| 57 const base::CommandLine* command_line); |
| 57 virtual ~BackgroundContentsService(); | 58 virtual ~BackgroundContentsService(); |
| 58 | 59 |
| 59 // Allows tests to reduce the time between a force-installed app/extension | 60 // Allows tests to reduce the time between a force-installed app/extension |
| 60 // crashing and when we reload it. | 61 // crashing and when we reload it. |
| 61 static void SetRestartDelayForForceInstalledAppsAndExtensionsForTesting( | 62 static void SetRestartDelayForForceInstalledAppsAndExtensionsForTesting( |
| 62 int restart_delay_in_ms); | 63 int restart_delay_in_ms); |
| 63 | 64 |
| 64 // Get the crash notification's id for the extension. | 65 // Get the crash notification's id for the extension. |
| 65 static std::string GetNotificationIdForExtensionForTesting( | 66 static std::string GetNotificationIdForExtensionForTesting( |
| 66 const std::string& extension_id); | 67 const std::string& extension_id); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 // Key: application id | 215 // Key: application id |
| 215 // Value: BackgroundContentsInfo for the BC associated with that application | 216 // Value: BackgroundContentsInfo for the BC associated with that application |
| 216 typedef std::map<base::string16, BackgroundContentsInfo> | 217 typedef std::map<base::string16, BackgroundContentsInfo> |
| 217 BackgroundContentsMap; | 218 BackgroundContentsMap; |
| 218 BackgroundContentsMap contents_map_; | 219 BackgroundContentsMap contents_map_; |
| 219 | 220 |
| 220 DISALLOW_COPY_AND_ASSIGN(BackgroundContentsService); | 221 DISALLOW_COPY_AND_ASSIGN(BackgroundContentsService); |
| 221 }; | 222 }; |
| 222 | 223 |
| 223 #endif // CHROME_BROWSER_BACKGROUND_BACKGROUND_CONTENTS_SERVICE_H_ | 224 #endif // CHROME_BROWSER_BACKGROUND_BACKGROUND_CONTENTS_SERVICE_H_ |
| OLD | NEW |