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

Side by Side Diff: chrome/browser/extensions/extension_process_manager.cc

Issue 13375017: Move the ViewType enum to extensions\common. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 8 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 #include "chrome/browser/extensions/extension_process_manager.h"
6
5 #include "base/bind.h" 7 #include "base/bind.h"
6 #include "base/command_line.h" 8 #include "base/command_line.h"
7 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
8 #include "base/logging.h" 10 #include "base/logging.h"
9 #include "base/message_loop.h" 11 #include "base/message_loop.h"
10 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
11 #include "base/stl_util.h" 13 #include "base/stl_util.h"
12 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
13 #include "base/time.h" 15 #include "base/time.h"
14 #include "chrome/browser/extensions/api/runtime/runtime_api.h" 16 #include "chrome/browser/extensions/api/runtime/runtime_api.h"
15 #include "chrome/browser/extensions/extension_host.h" 17 #include "chrome/browser/extensions/extension_host.h"
16 #include "chrome/browser/extensions/extension_info_map.h" 18 #include "chrome/browser/extensions/extension_info_map.h"
17 #include "chrome/browser/extensions/extension_process_manager.h"
18 #include "chrome/browser/extensions/extension_service.h" 19 #include "chrome/browser/extensions/extension_service.h"
19 #include "chrome/browser/extensions/extension_system.h" 20 #include "chrome/browser/extensions/extension_system.h"
20 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/ui/browser.h" 22 #include "chrome/browser/ui/browser.h"
22 #include "chrome/browser/ui/browser_finder.h" 23 #include "chrome/browser/ui/browser_finder.h"
23 #include "chrome/browser/ui/browser_window.h" 24 #include "chrome/browser/ui/browser_window.h"
24 #include "chrome/browser/ui/tabs/tab_strip_model.h" 25 #include "chrome/browser/ui/tabs/tab_strip_model.h"
25 #include "chrome/browser/view_type_utils.h"
26 #include "chrome/common/chrome_notification_types.h" 26 #include "chrome/common/chrome_notification_types.h"
27 #include "chrome/common/chrome_switches.h" 27 #include "chrome/common/chrome_switches.h"
28 #include "chrome/common/extensions/background_info.h" 28 #include "chrome/common/extensions/background_info.h"
29 #include "chrome/common/extensions/extension.h" 29 #include "chrome/common/extensions/extension.h"
30 #include "chrome/common/extensions/extension_messages.h" 30 #include "chrome/common/extensions/extension_messages.h"
31 #include "chrome/common/extensions/incognito_handler.h" 31 #include "chrome/common/extensions/incognito_handler.h"
32 #include "chrome/common/extensions/manifest_handler.h" 32 #include "chrome/common/extensions/manifest_handler.h"
33 #include "chrome/common/extensions/manifest_url_handler.h" 33 #include "chrome/common/extensions/manifest_url_handler.h"
34 #include "chrome/common/url_constants.h" 34 #include "chrome/common/url_constants.h"
35 #include "content/public/browser/browser_thread.h" 35 #include "content/public/browser/browser_thread.h"
36 #include "content/public/browser/notification_service.h" 36 #include "content/public/browser/notification_service.h"
37 #include "content/public/browser/render_process_host.h" 37 #include "content/public/browser/render_process_host.h"
38 #include "content/public/browser/render_view_host.h" 38 #include "content/public/browser/render_view_host.h"
39 #include "content/public/browser/site_instance.h" 39 #include "content/public/browser/site_instance.h"
40 #include "content/public/browser/web_contents.h" 40 #include "content/public/browser/web_contents.h"
41 #include "content/public/browser/web_contents_delegate.h" 41 #include "content/public/browser/web_contents_delegate.h"
42 #include "content/public/common/renderer_preferences.h" 42 #include "content/public/common/renderer_preferences.h"
43 #include "extensions/browser/view_type_utils.h"
43 44
44 #if defined(OS_MACOSX) 45 #if defined(OS_MACOSX)
45 #include "chrome/browser/extensions/extension_host_mac.h" 46 #include "chrome/browser/extensions/extension_host_mac.h"
46 #endif 47 #endif
47 48
48 using content::BrowserThread; 49 using content::BrowserThread;
49 using content::OpenURLParams; 50 using content::OpenURLParams;
50 using content::Referrer; 51 using content::Referrer;
51 using content::RenderViewHost; 52 using content::RenderViewHost;
52 using content::SiteInstance; 53 using content::SiteInstance;
(...skipping 18 matching lines...) Expand all
71 // whether to fall back on the original profile's ExtensionProcessManager based 72 // whether to fall back on the original profile's ExtensionProcessManager based
72 // on whether a given extension uses "split" or "spanning" incognito behavior. 73 // on whether a given extension uses "split" or "spanning" incognito behavior.
73 class IncognitoExtensionProcessManager : public ExtensionProcessManager { 74 class IncognitoExtensionProcessManager : public ExtensionProcessManager {
74 public: 75 public:
75 explicit IncognitoExtensionProcessManager(Profile* profile); 76 explicit IncognitoExtensionProcessManager(Profile* profile);
76 virtual ~IncognitoExtensionProcessManager(); 77 virtual ~IncognitoExtensionProcessManager();
77 virtual ExtensionHost* CreateViewHost( 78 virtual ExtensionHost* CreateViewHost(
78 const Extension* extension, 79 const Extension* extension,
79 const GURL& url, 80 const GURL& url,
80 Browser* browser, 81 Browser* browser,
81 chrome::ViewType view_type) OVERRIDE; 82 extensions::ViewType view_type) OVERRIDE;
82 virtual void CreateBackgroundHost(const Extension* extension, 83 virtual void CreateBackgroundHost(const Extension* extension,
83 const GURL& url) OVERRIDE; 84 const GURL& url) OVERRIDE;
84 virtual SiteInstance* GetSiteInstanceForURL(const GURL& url) OVERRIDE; 85 virtual SiteInstance* GetSiteInstanceForURL(const GURL& url) OVERRIDE;
85 86
86 private: 87 private:
87 // content::NotificationObserver: 88 // content::NotificationObserver:
88 virtual void Observe(int type, 89 virtual void Observe(int type,
89 const content::NotificationSource& source, 90 const content::NotificationSource& source,
90 const content::NotificationDetails& details) OVERRIDE; 91 const content::NotificationDetails& details) OVERRIDE;
91 92
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 for (ExtensionRenderViews::const_iterator iter = 197 for (ExtensionRenderViews::const_iterator iter =
197 all_extension_views_.begin(); 198 all_extension_views_.begin();
198 iter != all_extension_views_.end(); ++iter) { 199 iter != all_extension_views_.end(); ++iter) {
199 result.insert(iter->first); 200 result.insert(iter->first);
200 } 201 }
201 return result; 202 return result;
202 } 203 }
203 204
204 void ExtensionProcessManager::EnsureBrowserWhenRequired( 205 void ExtensionProcessManager::EnsureBrowserWhenRequired(
205 Browser* browser, 206 Browser* browser,
206 chrome::ViewType view_type) { 207 extensions::ViewType view_type) {
207 if (!browser) { 208 if (!browser) {
208 #if defined (OS_CHROMEOS) 209 #if defined (OS_CHROMEOS)
209 // On ChromeOS we'll only use ExtensionView, which 210 // On ChromeOS we'll only use ExtensionView, which
210 // does not use the browser parameter. 211 // does not use the browser parameter.
211 // TODO(rkc): Remove all this once we create a new host for 212 // TODO(rkc): Remove all this once we create a new host for
212 // screensaver extensions (crosbug.com/28211). 213 // screensaver extensions (crosbug.com/28211).
213 DCHECK(view_type == chrome::VIEW_TYPE_EXTENSION_POPUP || 214 DCHECK(view_type == extensions::VIEW_TYPE_EXTENSION_POPUP ||
214 view_type == chrome::VIEW_TYPE_EXTENSION_DIALOG); 215 view_type == extensions::VIEW_TYPE_EXTENSION_DIALOG);
215 #else 216 #else
216 // A NULL browser may only be given for pop-up views. 217 // A NULL browser may only be given for pop-up views.
217 DCHECK(view_type == chrome::VIEW_TYPE_EXTENSION_POPUP); 218 DCHECK(view_type == extensions::VIEW_TYPE_EXTENSION_POPUP);
218 #endif 219 #endif
219 } 220 }
220 } 221 }
221 222
222 223
223 ExtensionHost* ExtensionProcessManager::CreateViewHost( 224 ExtensionHost* ExtensionProcessManager::CreateViewHost(
224 const Extension* extension, 225 const Extension* extension,
225 const GURL& url, 226 const GURL& url,
226 Browser* browser, 227 Browser* browser,
227 chrome::ViewType view_type) { 228 extensions::ViewType view_type) {
228 DCHECK(extension); 229 DCHECK(extension);
229 EnsureBrowserWhenRequired(browser, view_type); 230 EnsureBrowserWhenRequired(browser, view_type);
230 ExtensionHost* host = 231 ExtensionHost* host =
231 #if defined(OS_MACOSX) 232 #if defined(OS_MACOSX)
232 new extensions::ExtensionHostMac( 233 new extensions::ExtensionHostMac(
233 extension, GetSiteInstanceForURL(url), url, view_type); 234 extension, GetSiteInstanceForURL(url), url, view_type);
234 #else 235 #else
235 new ExtensionHost(extension, GetSiteInstanceForURL(url), url, view_type); 236 new ExtensionHost(extension, GetSiteInstanceForURL(url), url, view_type);
236 #endif 237 #endif
237 host->CreateView(browser); 238 host->CreateView(browser);
238 OnExtensionHostCreated(host, false); 239 OnExtensionHostCreated(host, false);
239 return host; 240 return host;
240 } 241 }
241 242
242 ExtensionHost* ExtensionProcessManager::CreateViewHost( 243 ExtensionHost* ExtensionProcessManager::CreateViewHost(
243 const GURL& url, Browser* browser, chrome::ViewType view_type) { 244 const GURL& url, Browser* browser, extensions::ViewType view_type) {
244 EnsureBrowserWhenRequired(browser, view_type); 245 EnsureBrowserWhenRequired(browser, view_type);
245 ExtensionService* service = GetProfile()->GetExtensionService(); 246 ExtensionService* service = GetProfile()->GetExtensionService();
246 if (service) { 247 if (service) {
247 std::string extension_id = url.host(); 248 std::string extension_id = url.host();
248 if (url.SchemeIs(chrome::kChromeUIScheme) && 249 if (url.SchemeIs(chrome::kChromeUIScheme) &&
249 url.host() == chrome::kChromeUIExtensionInfoHost) 250 url.host() == chrome::kChromeUIExtensionInfoHost)
250 extension_id = url.path().substr(1); 251 extension_id = url.path().substr(1);
251 const Extension* extension = 252 const Extension* extension =
252 service->extensions()->GetByID(extension_id); 253 service->extensions()->GetByID(extension_id);
253 if (extension) 254 if (extension)
254 return CreateViewHost(extension, url, browser, view_type); 255 return CreateViewHost(extension, url, browser, view_type);
255 } 256 }
256 return NULL; 257 return NULL;
257 } 258 }
258 259
259 ExtensionHost* ExtensionProcessManager::CreatePopupHost( 260 ExtensionHost* ExtensionProcessManager::CreatePopupHost(
260 const Extension* extension, const GURL& url, Browser* browser) { 261 const Extension* extension, const GURL& url, Browser* browser) {
261 return CreateViewHost( 262 return CreateViewHost(
262 extension, url, browser, chrome::VIEW_TYPE_EXTENSION_POPUP); 263 extension, url, browser, extensions::VIEW_TYPE_EXTENSION_POPUP);
263 } 264 }
264 265
265 ExtensionHost* ExtensionProcessManager::CreatePopupHost( 266 ExtensionHost* ExtensionProcessManager::CreatePopupHost(
266 const GURL& url, Browser* browser) { 267 const GURL& url, Browser* browser) {
267 return CreateViewHost(url, browser, chrome::VIEW_TYPE_EXTENSION_POPUP); 268 return CreateViewHost(url, browser, extensions::VIEW_TYPE_EXTENSION_POPUP);
268 } 269 }
269 270
270 ExtensionHost* ExtensionProcessManager::CreateDialogHost(const GURL& url) { 271 ExtensionHost* ExtensionProcessManager::CreateDialogHost(const GURL& url) {
271 return CreateViewHost(url, NULL, chrome::VIEW_TYPE_EXTENSION_DIALOG); 272 return CreateViewHost(url, NULL, extensions::VIEW_TYPE_EXTENSION_DIALOG);
272 } 273 }
273 274
274 ExtensionHost* ExtensionProcessManager::CreateInfobarHost( 275 ExtensionHost* ExtensionProcessManager::CreateInfobarHost(
275 const Extension* extension, const GURL& url, Browser* browser) { 276 const Extension* extension, const GURL& url, Browser* browser) {
276 return CreateViewHost( 277 return CreateViewHost(
277 extension, url, browser, chrome::VIEW_TYPE_EXTENSION_INFOBAR); 278 extension, url, browser, extensions::VIEW_TYPE_EXTENSION_INFOBAR);
278 } 279 }
279 280
280 ExtensionHost* ExtensionProcessManager::CreateInfobarHost( 281 ExtensionHost* ExtensionProcessManager::CreateInfobarHost(
281 const GURL& url, Browser* browser) { 282 const GURL& url, Browser* browser) {
282 return CreateViewHost(url, browser, chrome::VIEW_TYPE_EXTENSION_INFOBAR); 283 return CreateViewHost(url, browser, extensions::VIEW_TYPE_EXTENSION_INFOBAR);
283 } 284 }
284 285
285 void ExtensionProcessManager::CreateBackgroundHost( 286 void ExtensionProcessManager::CreateBackgroundHost(
286 const Extension* extension, const GURL& url) { 287 const Extension* extension, const GURL& url) {
287 // Hosted apps are taken care of from BackgroundContentsService. Ignore them 288 // Hosted apps are taken care of from BackgroundContentsService. Ignore them
288 // here. 289 // here.
289 if (extension->is_hosted_app()) 290 if (extension->is_hosted_app())
290 return; 291 return;
291 292
292 // Don't create multiple background hosts for an extension. 293 // Don't create multiple background hosts for an extension.
293 if (GetBackgroundHostForExtension(extension->id())) 294 if (GetBackgroundHostForExtension(extension->id()))
294 return; 295 return;
295 296
296 ExtensionHost* host = 297 ExtensionHost* host =
297 #if defined(OS_MACOSX) 298 #if defined(OS_MACOSX)
298 new extensions::ExtensionHostMac( 299 new extensions::ExtensionHostMac(
299 extension, GetSiteInstanceForURL(url), url, 300 extension, GetSiteInstanceForURL(url), url,
300 chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); 301 extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE);
301 #else 302 #else
302 new ExtensionHost(extension, GetSiteInstanceForURL(url), url, 303 new ExtensionHost(extension, GetSiteInstanceForURL(url), url,
303 chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); 304 extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE);
304 #endif 305 #endif
305 306
306 host->CreateRenderViewSoon(); 307 host->CreateRenderViewSoon();
307 OnExtensionHostCreated(host, true); 308 OnExtensionHostCreated(host, true);
308 } 309 }
309 310
310 void ExtensionProcessManager::OpenOptionsPage(const Extension* extension, 311 void ExtensionProcessManager::OpenOptionsPage(const Extension* extension,
311 Browser* browser) { 312 Browser* browser) {
312 DCHECK(!extensions::ManifestURL::GetOptionsPage(extension).is_empty()); 313 DCHECK(!extensions::ManifestURL::GetOptionsPage(extension).is_empty());
313 314
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 ExtensionRenderViews::iterator view = 379 ExtensionRenderViews::iterator view =
379 all_extension_views_.find(render_view_host); 380 all_extension_views_.find(render_view_host);
380 if (view == all_extension_views_.end()) 381 if (view == all_extension_views_.end())
381 return; 382 return;
382 383
383 content::NotificationService::current()->Notify( 384 content::NotificationService::current()->Notify(
384 chrome::NOTIFICATION_EXTENSION_VIEW_UNREGISTERED, 385 chrome::NOTIFICATION_EXTENSION_VIEW_UNREGISTERED,
385 content::Source<Profile>(GetProfile()), 386 content::Source<Profile>(GetProfile()),
386 content::Details<RenderViewHost>(render_view_host)); 387 content::Details<RenderViewHost>(render_view_host));
387 388
388 chrome::ViewType view_type = view->second; 389 extensions::ViewType view_type = view->second;
389 all_extension_views_.erase(view); 390 all_extension_views_.erase(view);
390 391
391 // Keepalive count, balanced in RegisterRenderViewHost. 392 // Keepalive count, balanced in RegisterRenderViewHost.
392 if (view_type != chrome::VIEW_TYPE_INVALID && 393 if (view_type != extensions::VIEW_TYPE_INVALID &&
393 view_type != chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { 394 view_type != extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) {
394 const Extension* extension = GetExtensionForRenderViewHost( 395 const Extension* extension = GetExtensionForRenderViewHost(
395 render_view_host); 396 render_view_host);
396 if (extension) 397 if (extension)
397 DecrementLazyKeepaliveCount(extension); 398 DecrementLazyKeepaliveCount(extension);
398 } 399 }
399 } 400 }
400 401
401 void ExtensionProcessManager::RegisterRenderViewHost( 402 void ExtensionProcessManager::RegisterRenderViewHost(
402 RenderViewHost* render_view_host) { 403 RenderViewHost* render_view_host) {
403 const Extension* extension = GetExtensionForRenderViewHost( 404 const Extension* extension = GetExtensionForRenderViewHost(
404 render_view_host); 405 render_view_host);
405 if (!extension) 406 if (!extension)
406 return; 407 return;
407 408
408 WebContents* web_contents = WebContents::FromRenderViewHost(render_view_host); 409 WebContents* web_contents = WebContents::FromRenderViewHost(render_view_host);
409 all_extension_views_[render_view_host] = chrome::GetViewType(web_contents); 410 all_extension_views_[render_view_host] =
411 extensions::GetViewType(web_contents);
410 412
411 // Keep the lazy background page alive as long as any non-background-page 413 // Keep the lazy background page alive as long as any non-background-page
412 // extension views are visible. Keepalive count balanced in 414 // extension views are visible. Keepalive count balanced in
413 // UnregisterRenderViewHost. 415 // UnregisterRenderViewHost.
414 IncrementLazyKeepaliveCountForView(render_view_host); 416 IncrementLazyKeepaliveCountForView(render_view_host);
415 } 417 }
416 418
417 SiteInstance* ExtensionProcessManager::GetSiteInstanceForURL(const GURL& url) { 419 SiteInstance* ExtensionProcessManager::GetSiteInstanceForURL(const GURL& url) {
418 return site_instance_->GetRelatedSiteInstance(url); 420 return site_instance_->GetRelatedSiteInstance(url);
419 } 421 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 event_page_idle_time_); 461 event_page_idle_time_);
460 } 462 }
461 463
462 return count; 464 return count;
463 } 465 }
464 466
465 void ExtensionProcessManager::IncrementLazyKeepaliveCountForView( 467 void ExtensionProcessManager::IncrementLazyKeepaliveCountForView(
466 RenderViewHost* render_view_host) { 468 RenderViewHost* render_view_host) {
467 WebContents* web_contents = 469 WebContents* web_contents =
468 WebContents::FromRenderViewHost(render_view_host); 470 WebContents::FromRenderViewHost(render_view_host);
469 chrome::ViewType view_type = chrome::GetViewType(web_contents); 471 extensions::ViewType view_type = extensions::GetViewType(web_contents);
470 if (view_type != chrome::VIEW_TYPE_INVALID && 472 if (view_type != extensions::VIEW_TYPE_INVALID &&
471 view_type != chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { 473 view_type != extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) {
472 const Extension* extension = GetExtensionForRenderViewHost( 474 const Extension* extension = GetExtensionForRenderViewHost(
473 render_view_host); 475 render_view_host);
474 if (extension) 476 if (extension)
475 IncrementLazyKeepaliveCount(extension); 477 IncrementLazyKeepaliveCount(extension);
476 } 478 }
477 } 479 }
478 480
479 void ExtensionProcessManager::OnLazyBackgroundPageIdle( 481 void ExtensionProcessManager::OnLazyBackgroundPageIdle(
480 const std::string& extension_id, int sequence_id) { 482 const std::string& extension_id, int sequence_id) {
481 ExtensionHost* host = GetBackgroundHostForExtension(extension_id); 483 ExtensionHost* host = GetBackgroundHostForExtension(extension_id);
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 ClearBackgroundPageData(host->extension()->id()); 632 ClearBackgroundPageData(host->extension()->id());
631 background_page_data_[host->extension()->id()].since_suspended.reset( 633 background_page_data_[host->extension()->id()].since_suspended.reset(
632 new PerfTimer()); 634 new PerfTimer());
633 } 635 }
634 break; 636 break;
635 } 637 }
636 638
637 case chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE: { 639 case chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE: {
638 ExtensionHost* host = content::Details<ExtensionHost>(details).ptr(); 640 ExtensionHost* host = content::Details<ExtensionHost>(details).ptr();
639 if (host->extension_host_type() == 641 if (host->extension_host_type() ==
640 chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { 642 extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) {
641 CloseBackgroundHost(host); 643 CloseBackgroundHost(host);
642 } 644 }
643 break; 645 break;
644 } 646 }
645 647
646 case content::NOTIFICATION_WEB_CONTENTS_SWAPPED: { 648 case content::NOTIFICATION_WEB_CONTENTS_SWAPPED: {
647 // We get this notification both for new WebContents and when one 649 // We get this notification both for new WebContents and when one
648 // has its RenderViewHost replaced (e.g. when a user does a cross-site 650 // has its RenderViewHost replaced (e.g. when a user does a cross-site
649 // navigation away from an extension URL). For the replaced case, we must 651 // navigation away from an extension URL). For the replaced case, we must
650 // unregister the old RVH so it doesn't count as an active view that would 652 // unregister the old RVH so it doesn't count as an active view that would
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 break; 691 break;
690 } 692 }
691 693
692 case content::NOTIFICATION_DEVTOOLS_AGENT_ATTACHED: { 694 case content::NOTIFICATION_DEVTOOLS_AGENT_ATTACHED: {
693 RenderViewHost* render_view_host = 695 RenderViewHost* render_view_host =
694 content::Details<RenderViewHost>(details).ptr(); 696 content::Details<RenderViewHost>(details).ptr();
695 WebContents* web_contents = 697 WebContents* web_contents =
696 WebContents::FromRenderViewHost(render_view_host); 698 WebContents::FromRenderViewHost(render_view_host);
697 // Keep the lazy background page alive while it's being inspected. 699 // Keep the lazy background page alive while it's being inspected.
698 // Balanced in response to the CLOSING notification. 700 // Balanced in response to the CLOSING notification.
699 if (chrome::GetViewType(web_contents) == 701 if (extensions::GetViewType(web_contents) ==
700 chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { 702 extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) {
701 const Extension* extension = GetExtensionForRenderViewHost( 703 const Extension* extension = GetExtensionForRenderViewHost(
702 render_view_host); 704 render_view_host);
703 if (extension) { 705 if (extension) {
704 CancelSuspend(extension); 706 CancelSuspend(extension);
705 IncrementLazyKeepaliveCount(extension); 707 IncrementLazyKeepaliveCount(extension);
706 } 708 }
707 } 709 }
708 break; 710 break;
709 } 711 }
710 712
711 case content::NOTIFICATION_DEVTOOLS_AGENT_DETACHED: { 713 case content::NOTIFICATION_DEVTOOLS_AGENT_DETACHED: {
712 RenderViewHost* render_view_host = 714 RenderViewHost* render_view_host =
713 content::Details<RenderViewHost>(details).ptr(); 715 content::Details<RenderViewHost>(details).ptr();
714 WebContents* web_contents = 716 WebContents* web_contents =
715 WebContents::FromRenderViewHost(render_view_host); 717 WebContents::FromRenderViewHost(render_view_host);
716 // Balanced in response to the OPENING notification. 718 // Balanced in response to the OPENING notification.
717 if (chrome::GetViewType(web_contents) == 719 if (extensions::GetViewType(web_contents) ==
718 chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { 720 extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) {
719 const Extension* extension = GetExtensionForRenderViewHost( 721 const Extension* extension = GetExtensionForRenderViewHost(
720 render_view_host); 722 render_view_host);
721 if (extension) 723 if (extension)
722 DecrementLazyKeepaliveCount(extension); 724 DecrementLazyKeepaliveCount(extension);
723 } 725 }
724 break; 726 break;
725 } 727 }
726 728
727 default: 729 default:
728 NOTREACHED(); 730 NOTREACHED();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 if (since_suspended.get()) { 764 if (since_suspended.get()) {
763 UMA_HISTOGRAM_LONG_TIMES("Extensions.EventPageIdleTime", 765 UMA_HISTOGRAM_LONG_TIMES("Extensions.EventPageIdleTime",
764 since_suspended->Elapsed()); 766 since_suspended->Elapsed());
765 } 767 }
766 } 768 }
767 } 769 }
768 } 770 }
769 771
770 void ExtensionProcessManager::CloseBackgroundHost(ExtensionHost* host) { 772 void ExtensionProcessManager::CloseBackgroundHost(ExtensionHost* host) {
771 CHECK(host->extension_host_type() == 773 CHECK(host->extension_host_type() ==
772 chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); 774 extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE);
773 delete host; 775 delete host;
774 // |host| should deregister itself from our structures. 776 // |host| should deregister itself from our structures.
775 CHECK(background_hosts_.find(host) == background_hosts_.end()); 777 CHECK(background_hosts_.find(host) == background_hosts_.end());
776 } 778 }
777 779
778 void ExtensionProcessManager::CloseBackgroundHosts() { 780 void ExtensionProcessManager::CloseBackgroundHosts() {
779 for (ExtensionHostSet::iterator iter = background_hosts_.begin(); 781 for (ExtensionHostSet::iterator iter = background_hosts_.begin();
780 iter != background_hosts_.end(); ) { 782 iter != background_hosts_.end(); ) {
781 ExtensionHostSet::iterator current = iter++; 783 ExtensionHostSet::iterator current = iter++;
782 delete *current; 784 delete *current;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 ExtensionService* service = 833 ExtensionService* service =
832 extensions::ExtensionSystem::Get(GetProfile())->extension_service(); 834 extensions::ExtensionSystem::Get(GetProfile())->extension_service();
833 if (service) 835 if (service)
834 service->menu_manager()->RemoveAllIncognitoContextItems(); 836 service->menu_manager()->RemoveAllIncognitoContextItems();
835 } 837 }
836 838
837 ExtensionHost* IncognitoExtensionProcessManager::CreateViewHost( 839 ExtensionHost* IncognitoExtensionProcessManager::CreateViewHost(
838 const Extension* extension, 840 const Extension* extension,
839 const GURL& url, 841 const GURL& url,
840 Browser* browser, 842 Browser* browser,
841 chrome::ViewType view_type) { 843 extensions::ViewType view_type) {
842 if (extensions::IncognitoInfo::IsSplitMode(extension)) { 844 if (extensions::IncognitoInfo::IsSplitMode(extension)) {
843 if (IsIncognitoEnabled(extension)) { 845 if (IsIncognitoEnabled(extension)) {
844 return ExtensionProcessManager::CreateViewHost(extension, url, 846 return ExtensionProcessManager::CreateViewHost(extension, url,
845 browser, view_type); 847 browser, view_type);
846 } else { 848 } else {
847 NOTREACHED() << 849 NOTREACHED() <<
848 "We shouldn't be trying to create an incognito extension view unless " 850 "We shouldn't be trying to create an incognito extension view unless "
849 "it has been enabled for incognito."; 851 "it has been enabled for incognito.";
850 return NULL; 852 return NULL;
851 } 853 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 if (service && service->is_ready()) 909 if (service && service->is_ready())
908 CreateBackgroundHostsForProfileStartup(); 910 CreateBackgroundHostsForProfileStartup();
909 } 911 }
910 break; 912 break;
911 } 913 }
912 default: 914 default:
913 ExtensionProcessManager::Observe(type, source, details); 915 ExtensionProcessManager::Observe(type, source, details);
914 break; 916 break;
915 } 917 }
916 } 918 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698