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

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

Issue 105193002: Replace string16 with base::string16. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 BackgroundContentsService(Profile* profile, const CommandLine* command_line); 56 BackgroundContentsService(Profile* profile, const CommandLine* command_line);
57 virtual ~BackgroundContentsService(); 57 virtual ~BackgroundContentsService();
58 58
59 // Allows tests to reduce the time between a force-installed app/extension 59 // Allows tests to reduce the time between a force-installed app/extension
60 // crashing and when we reload it. 60 // crashing and when we reload it.
61 static void SetRestartDelayForForceInstalledAppsAndExtensionsForTesting( 61 static void SetRestartDelayForForceInstalledAppsAndExtensionsForTesting(
62 int restart_delay_in_ms); 62 int restart_delay_in_ms);
63 63
64 // Returns the BackgroundContents associated with the passed application id, 64 // Returns the BackgroundContents associated with the passed application id,
65 // or NULL if none. 65 // or NULL if none.
66 BackgroundContents* GetAppBackgroundContents(const string16& appid); 66 BackgroundContents* GetAppBackgroundContents(const base::string16& appid);
67 67
68 // Returns true if there's a registered BackgroundContents for this app. It 68 // Returns true if there's a registered BackgroundContents for this app. It
69 // is possible for this routine to return true when GetAppBackgroundContents() 69 // is possible for this routine to return true when GetAppBackgroundContents()
70 // returns false, if the BackgroundContents closed due to the render process 70 // returns false, if the BackgroundContents closed due to the render process
71 // crashing. 71 // crashing.
72 bool HasRegisteredBackgroundContents(const string16& appid); 72 bool HasRegisteredBackgroundContents(const base::string16& appid);
73 73
74 // Returns all currently opened BackgroundContents (used by the task manager). 74 // Returns all currently opened BackgroundContents (used by the task manager).
75 std::vector<BackgroundContents*> GetBackgroundContents() const; 75 std::vector<BackgroundContents*> GetBackgroundContents() const;
76 76
77 // BackgroundContents::Delegate implementation. 77 // BackgroundContents::Delegate implementation.
78 virtual void AddWebContents(content::WebContents* new_contents, 78 virtual void AddWebContents(content::WebContents* new_contents,
79 WindowOpenDisposition disposition, 79 WindowOpenDisposition disposition,
80 const gfx::Rect& initial_pos, 80 const gfx::Rect& initial_pos,
81 bool user_gesture, 81 bool user_gesture,
82 bool* was_blocked) OVERRIDE; 82 bool* was_blocked) OVERRIDE;
83 83
84 // Gets the parent application id for the passed BackgroundContents. Returns 84 // Gets the parent application id for the passed BackgroundContents. Returns
85 // an empty string if no parent application found (e.g. passed 85 // an empty string if no parent application found (e.g. passed
86 // BackgroundContents has already shut down). 86 // BackgroundContents has already shut down).
87 const string16& GetParentApplicationId(BackgroundContents* contents) const; 87 const base::string16& GetParentApplicationId(BackgroundContents* contents) con st;
88 88
89 // Creates a new BackgroundContents using the passed |site| and 89 // Creates a new BackgroundContents using the passed |site| and
90 // the |route_id| and begins tracking the object internally so it can be 90 // the |route_id| and begins tracking the object internally so it can be
91 // shutdown if the parent application is uninstalled. 91 // shutdown if the parent application is uninstalled.
92 // A BACKGROUND_CONTENTS_OPENED notification will be generated with the passed 92 // A BACKGROUND_CONTENTS_OPENED notification will be generated with the passed
93 // |frame_name| and |application_id| values, using the passed |profile| as the 93 // |frame_name| and |application_id| values, using the passed |profile| as the
94 // Source.. 94 // Source..
95 BackgroundContents* CreateBackgroundContents( 95 BackgroundContents* CreateBackgroundContents(
96 content::SiteInstance* site, 96 content::SiteInstance* site,
97 int route_id, 97 int route_id,
98 Profile* profile, 98 Profile* profile,
99 const string16& frame_name, 99 const base::string16& frame_name,
100 const string16& application_id, 100 const base::string16& application_id,
101 const std::string& partition_id, 101 const std::string& partition_id,
102 content::SessionStorageNamespace* session_storage_namespace); 102 content::SessionStorageNamespace* session_storage_namespace);
103 103
104 // Load the manifest-specified background page for the specified hosted app. 104 // Load the manifest-specified background page for the specified hosted app.
105 // If the manifest doesn't specify one, then load the BackgroundContents 105 // If the manifest doesn't specify one, then load the BackgroundContents
106 // registered in the pref. This is typically used to reload a crashed 106 // registered in the pref. This is typically used to reload a crashed
107 // background page. 107 // background page.
108 void LoadBackgroundContentsForExtension(Profile* profile, 108 void LoadBackgroundContentsForExtension(Profile* profile,
109 const std::string& extension_id); 109 const std::string& extension_id);
110 110
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 147
148 // Load the manifest-specified BackgroundContents for all apps for the 148 // Load the manifest-specified BackgroundContents for all apps for the
149 // profile. 149 // profile.
150 void LoadBackgroundContentsFromManifests(Profile* profile); 150 void LoadBackgroundContentsFromManifests(Profile* profile);
151 151
152 // Creates a single BackgroundContents associated with the specified |appid|, 152 // Creates a single BackgroundContents associated with the specified |appid|,
153 // creates an associated RenderView with the name specified by |frame_name|, 153 // creates an associated RenderView with the name specified by |frame_name|,
154 // and navigates to the passed |url|. 154 // and navigates to the passed |url|.
155 void LoadBackgroundContents(Profile* profile, 155 void LoadBackgroundContents(Profile* profile,
156 const GURL& url, 156 const GURL& url,
157 const string16& frame_name, 157 const base::string16& frame_name,
158 const string16& appid); 158 const base::string16& appid);
159 159
160 // Invoked when a new BackgroundContents is opened. 160 // Invoked when a new BackgroundContents is opened.
161 void BackgroundContentsOpened(BackgroundContentsOpenedDetails* details); 161 void BackgroundContentsOpened(BackgroundContentsOpenedDetails* details);
162 162
163 // Invoked when a BackgroundContents object is destroyed. 163 // Invoked when a BackgroundContents object is destroyed.
164 void BackgroundContentsShutdown(BackgroundContents* contents); 164 void BackgroundContentsShutdown(BackgroundContents* contents);
165 165
166 // Registers the |contents->GetURL()| to be run at startup. Only happens for 166 // Registers the |contents->GetURL()| to be run at startup. Only happens for
167 // the first navigation after window.open() (future calls to 167 // the first navigation after window.open() (future calls to
168 // RegisterBackgroundContents() for the same BackgroundContents will do 168 // RegisterBackgroundContents() for the same BackgroundContents will do
169 // nothing). 169 // nothing).
170 void RegisterBackgroundContents(BackgroundContents* contents); 170 void RegisterBackgroundContents(BackgroundContents* contents);
171 171
172 // Stops loading the passed BackgroundContents on startup. 172 // Stops loading the passed BackgroundContents on startup.
173 void UnregisterBackgroundContents(BackgroundContents* contents); 173 void UnregisterBackgroundContents(BackgroundContents* contents);
174 174
175 // Unregisters and deletes the BackgroundContents associated with the 175 // Unregisters and deletes the BackgroundContents associated with the
176 // passed extension. 176 // passed extension.
177 void ShutdownAssociatedBackgroundContents(const string16& appid); 177 void ShutdownAssociatedBackgroundContents(const base::string16& appid);
178 178
179 // Returns true if this BackgroundContents is in the contents_list_. 179 // Returns true if this BackgroundContents is in the contents_list_.
180 bool IsTracked(BackgroundContents* contents) const; 180 bool IsTracked(BackgroundContents* contents) const;
181 181
182 // Sends out a notification when our association of background contents with 182 // Sends out a notification when our association of background contents with
183 // apps may have changed (used by BackgroundApplicationListModel to update the 183 // apps may have changed (used by BackgroundApplicationListModel to update the
184 // set of background apps as new background contents are opened/closed). 184 // set of background apps as new background contents are opened/closed).
185 void SendChangeNotification(Profile* profile); 185 void SendChangeNotification(Profile* profile);
186 186
187 // Delay (in ms) before restarting a force-installed extension that crashed. 187 // Delay (in ms) before restarting a force-installed extension that crashed.
188 static int restart_delay_in_ms_; 188 static int restart_delay_in_ms_;
189 189
190 // PrefService used to store list of background pages (or NULL if this is 190 // PrefService used to store list of background pages (or NULL if this is
191 // running under an incognito profile). 191 // running under an incognito profile).
192 PrefService* prefs_; 192 PrefService* prefs_;
193 content::NotificationRegistrar registrar_; 193 content::NotificationRegistrar registrar_;
194 194
195 // Information we track about each BackgroundContents. 195 // Information we track about each BackgroundContents.
196 struct BackgroundContentsInfo { 196 struct BackgroundContentsInfo {
197 // The BackgroundContents whose information we are tracking. 197 // The BackgroundContents whose information we are tracking.
198 BackgroundContents* contents; 198 BackgroundContents* contents;
199 // The name of the top level frame for this BackgroundContents. 199 // The name of the top level frame for this BackgroundContents.
200 string16 frame_name; 200 base::string16 frame_name;
201 }; 201 };
202 202
203 // Map associating currently loaded BackgroundContents with their parent 203 // Map associating currently loaded BackgroundContents with their parent
204 // applications. 204 // applications.
205 // Key: application id 205 // Key: application id
206 // Value: BackgroundContentsInfo for the BC associated with that application 206 // Value: BackgroundContentsInfo for the BC associated with that application
207 typedef std::map<string16, BackgroundContentsInfo> BackgroundContentsMap; 207 typedef std::map<string16, BackgroundContentsInfo> BackgroundContentsMap;
208 BackgroundContentsMap contents_map_; 208 BackgroundContentsMap contents_map_;
209 209
210 DISALLOW_COPY_AND_ASSIGN(BackgroundContentsService); 210 DISALLOW_COPY_AND_ASSIGN(BackgroundContentsService);
211 }; 211 };
212 212
213 #endif // CHROME_BROWSER_BACKGROUND_BACKGROUND_CONTENTS_SERVICE_H_ 213 #endif // CHROME_BROWSER_BACKGROUND_BACKGROUND_CONTENTS_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698