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

Side by Side Diff: chrome/browser/background/background_contents_service.h

Issue 10298002: No longer start BG mode until a BackgroundContents is loaded (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Prospective fix for cros test failures. Created 8 years, 7 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 | Annotate | Revision Log
OLDNEW
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 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 public BackgroundContents::Delegate, 46 public BackgroundContents::Delegate,
47 public ProfileKeyedService { 47 public ProfileKeyedService {
48 public: 48 public:
49 BackgroundContentsService(Profile* profile, const CommandLine* command_line); 49 BackgroundContentsService(Profile* profile, const CommandLine* command_line);
50 virtual ~BackgroundContentsService(); 50 virtual ~BackgroundContentsService();
51 51
52 // Returns the BackgroundContents associated with the passed application id, 52 // Returns the BackgroundContents associated with the passed application id,
53 // or NULL if none. 53 // or NULL if none.
54 BackgroundContents* GetAppBackgroundContents(const string16& appid); 54 BackgroundContents* GetAppBackgroundContents(const string16& appid);
55 55
56 // Returns true if there's a registered BackgroundContents for this app. It
57 // is possible for this routine to return true when GetAppBackgroundContents()
58 // returns false, if the BackgroundContents closed due to the render process
59 // crashing.
60 bool HasRegisteredBackgroundContents(const string16& appid);
61
56 // Returns all currently opened BackgroundContents (used by the task manager). 62 // Returns all currently opened BackgroundContents (used by the task manager).
57 std::vector<BackgroundContents*> GetBackgroundContents() const; 63 std::vector<BackgroundContents*> GetBackgroundContents() const;
58 64
59 // BackgroundContents::Delegate implementation. 65 // BackgroundContents::Delegate implementation.
60 virtual void AddWebContents(content::WebContents* new_contents, 66 virtual void AddWebContents(content::WebContents* new_contents,
61 WindowOpenDisposition disposition, 67 WindowOpenDisposition disposition,
62 const gfx::Rect& initial_pos, 68 const gfx::Rect& initial_pos,
63 bool user_gesture) OVERRIDE; 69 bool user_gesture) OVERRIDE;
64 70
65 // Gets the parent application id for the passed BackgroundContents. Returns 71 // Gets the parent application id for the passed BackgroundContents. Returns
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 // Stops loading the passed BackgroundContents on startup. 151 // Stops loading the passed BackgroundContents on startup.
146 void UnregisterBackgroundContents(BackgroundContents* contents); 152 void UnregisterBackgroundContents(BackgroundContents* contents);
147 153
148 // Unregisters and deletes the BackgroundContents associated with the 154 // Unregisters and deletes the BackgroundContents associated with the
149 // passed extension. 155 // passed extension.
150 void ShutdownAssociatedBackgroundContents(const string16& appid); 156 void ShutdownAssociatedBackgroundContents(const string16& appid);
151 157
152 // Returns true if this BackgroundContents is in the contents_list_. 158 // Returns true if this BackgroundContents is in the contents_list_.
153 bool IsTracked(BackgroundContents* contents) const; 159 bool IsTracked(BackgroundContents* contents) const;
154 160
161 // Sends out a notification when our association of background contents with
162 // apps may have changed (used by BackgroundApplicationListModel to update the
163 // set of background apps as new background contents are opened/closed).
164 void SendChangeNotification(Profile* profile);
165
155 // PrefService used to store list of background pages (or NULL if this is 166 // PrefService used to store list of background pages (or NULL if this is
156 // running under an incognito profile). 167 // running under an incognito profile).
157 PrefService* prefs_; 168 PrefService* prefs_;
158 content::NotificationRegistrar registrar_; 169 content::NotificationRegistrar registrar_;
159 170
160 // Information we track about each BackgroundContents. 171 // Information we track about each BackgroundContents.
161 struct BackgroundContentsInfo { 172 struct BackgroundContentsInfo {
162 // The BackgroundContents whose information we are tracking. 173 // The BackgroundContents whose information we are tracking.
163 BackgroundContents* contents; 174 BackgroundContents* contents;
164 // The name of the top level frame for this BackgroundContents. 175 // The name of the top level frame for this BackgroundContents.
165 string16 frame_name; 176 string16 frame_name;
166 }; 177 };
167 178
168 // Map associating currently loaded BackgroundContents with their parent 179 // Map associating currently loaded BackgroundContents with their parent
169 // applications. 180 // applications.
170 // Key: application id 181 // Key: application id
171 // Value: BackgroundContentsInfo for the BC associated with that application 182 // Value: BackgroundContentsInfo for the BC associated with that application
172 typedef std::map<string16, BackgroundContentsInfo> BackgroundContentsMap; 183 typedef std::map<string16, BackgroundContentsInfo> BackgroundContentsMap;
173 BackgroundContentsMap contents_map_; 184 BackgroundContentsMap contents_map_;
174 185
175 DISALLOW_COPY_AND_ASSIGN(BackgroundContentsService); 186 DISALLOW_COPY_AND_ASSIGN(BackgroundContentsService);
176 }; 187 };
177 188
178 #endif // CHROME_BROWSER_BACKGROUND_BACKGROUND_CONTENTS_SERVICE_H_ 189 #endif // CHROME_BROWSER_BACKGROUND_BACKGROUND_CONTENTS_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698