| 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 #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/browser/view_type_utils.h" |
| 26 #include "chrome/common/chrome_notification_types.h" | 27 #include "chrome/common/chrome_notification_types.h" |
| 27 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Loading... |
| 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 Loading... |
| 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( |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 event_page_idle_time_); | 460 event_page_idle_time_); |
| 460 } | 461 } |
| 461 | 462 |
| 462 return count; | 463 return count; |
| 463 } | 464 } |
| 464 | 465 |
| 465 void ExtensionProcessManager::IncrementLazyKeepaliveCountForView( | 466 void ExtensionProcessManager::IncrementLazyKeepaliveCountForView( |
| 466 RenderViewHost* render_view_host) { | 467 RenderViewHost* render_view_host) { |
| 467 WebContents* web_contents = | 468 WebContents* web_contents = |
| 468 WebContents::FromRenderViewHost(render_view_host); | 469 WebContents::FromRenderViewHost(render_view_host); |
| 469 chrome::ViewType view_type = chrome::GetViewType(web_contents); | 470 extensions::ViewType view_type = chrome::GetViewType(web_contents); |
| 470 if (view_type != chrome::VIEW_TYPE_INVALID && | 471 if (view_type != extensions::VIEW_TYPE_INVALID && |
| 471 view_type != chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { | 472 view_type != extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { |
| 472 const Extension* extension = GetExtensionForRenderViewHost( | 473 const Extension* extension = GetExtensionForRenderViewHost( |
| 473 render_view_host); | 474 render_view_host); |
| 474 if (extension) | 475 if (extension) |
| 475 IncrementLazyKeepaliveCount(extension); | 476 IncrementLazyKeepaliveCount(extension); |
| 476 } | 477 } |
| 477 } | 478 } |
| 478 | 479 |
| 479 void ExtensionProcessManager::OnLazyBackgroundPageIdle( | 480 void ExtensionProcessManager::OnLazyBackgroundPageIdle( |
| 480 const std::string& extension_id, int sequence_id) { | 481 const std::string& extension_id, int sequence_id) { |
| 481 ExtensionHost* host = GetBackgroundHostForExtension(extension_id); | 482 ExtensionHost* host = GetBackgroundHostForExtension(extension_id); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 ClearBackgroundPageData(host->extension()->id()); | 631 ClearBackgroundPageData(host->extension()->id()); |
| 631 background_page_data_[host->extension()->id()].since_suspended.reset( | 632 background_page_data_[host->extension()->id()].since_suspended.reset( |
| 632 new PerfTimer()); | 633 new PerfTimer()); |
| 633 } | 634 } |
| 634 break; | 635 break; |
| 635 } | 636 } |
| 636 | 637 |
| 637 case chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE: { | 638 case chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE: { |
| 638 ExtensionHost* host = content::Details<ExtensionHost>(details).ptr(); | 639 ExtensionHost* host = content::Details<ExtensionHost>(details).ptr(); |
| 639 if (host->extension_host_type() == | 640 if (host->extension_host_type() == |
| 640 chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { | 641 extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { |
| 641 CloseBackgroundHost(host); | 642 CloseBackgroundHost(host); |
| 642 } | 643 } |
| 643 break; | 644 break; |
| 644 } | 645 } |
| 645 | 646 |
| 646 case content::NOTIFICATION_WEB_CONTENTS_SWAPPED: { | 647 case content::NOTIFICATION_WEB_CONTENTS_SWAPPED: { |
| 647 // We get this notification both for new WebContents and when one | 648 // 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 | 649 // 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 | 650 // 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 | 651 // unregister the old RVH so it doesn't count as an active view that would |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 } | 691 } |
| 691 | 692 |
| 692 case content::NOTIFICATION_DEVTOOLS_AGENT_ATTACHED: { | 693 case content::NOTIFICATION_DEVTOOLS_AGENT_ATTACHED: { |
| 693 RenderViewHost* render_view_host = | 694 RenderViewHost* render_view_host = |
| 694 content::Details<RenderViewHost>(details).ptr(); | 695 content::Details<RenderViewHost>(details).ptr(); |
| 695 WebContents* web_contents = | 696 WebContents* web_contents = |
| 696 WebContents::FromRenderViewHost(render_view_host); | 697 WebContents::FromRenderViewHost(render_view_host); |
| 697 // Keep the lazy background page alive while it's being inspected. | 698 // Keep the lazy background page alive while it's being inspected. |
| 698 // Balanced in response to the CLOSING notification. | 699 // Balanced in response to the CLOSING notification. |
| 699 if (chrome::GetViewType(web_contents) == | 700 if (chrome::GetViewType(web_contents) == |
| 700 chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { | 701 extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { |
| 701 const Extension* extension = GetExtensionForRenderViewHost( | 702 const Extension* extension = GetExtensionForRenderViewHost( |
| 702 render_view_host); | 703 render_view_host); |
| 703 if (extension) { | 704 if (extension) { |
| 704 CancelSuspend(extension); | 705 CancelSuspend(extension); |
| 705 IncrementLazyKeepaliveCount(extension); | 706 IncrementLazyKeepaliveCount(extension); |
| 706 } | 707 } |
| 707 } | 708 } |
| 708 break; | 709 break; |
| 709 } | 710 } |
| 710 | 711 |
| 711 case content::NOTIFICATION_DEVTOOLS_AGENT_DETACHED: { | 712 case content::NOTIFICATION_DEVTOOLS_AGENT_DETACHED: { |
| 712 RenderViewHost* render_view_host = | 713 RenderViewHost* render_view_host = |
| 713 content::Details<RenderViewHost>(details).ptr(); | 714 content::Details<RenderViewHost>(details).ptr(); |
| 714 WebContents* web_contents = | 715 WebContents* web_contents = |
| 715 WebContents::FromRenderViewHost(render_view_host); | 716 WebContents::FromRenderViewHost(render_view_host); |
| 716 // Balanced in response to the OPENING notification. | 717 // Balanced in response to the OPENING notification. |
| 717 if (chrome::GetViewType(web_contents) == | 718 if (chrome::GetViewType(web_contents) == |
| 718 chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { | 719 extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { |
| 719 const Extension* extension = GetExtensionForRenderViewHost( | 720 const Extension* extension = GetExtensionForRenderViewHost( |
| 720 render_view_host); | 721 render_view_host); |
| 721 if (extension) | 722 if (extension) |
| 722 DecrementLazyKeepaliveCount(extension); | 723 DecrementLazyKeepaliveCount(extension); |
| 723 } | 724 } |
| 724 break; | 725 break; |
| 725 } | 726 } |
| 726 | 727 |
| 727 default: | 728 default: |
| 728 NOTREACHED(); | 729 NOTREACHED(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 if (since_suspended.get()) { | 763 if (since_suspended.get()) { |
| 763 UMA_HISTOGRAM_LONG_TIMES("Extensions.EventPageIdleTime", | 764 UMA_HISTOGRAM_LONG_TIMES("Extensions.EventPageIdleTime", |
| 764 since_suspended->Elapsed()); | 765 since_suspended->Elapsed()); |
| 765 } | 766 } |
| 766 } | 767 } |
| 767 } | 768 } |
| 768 } | 769 } |
| 769 | 770 |
| 770 void ExtensionProcessManager::CloseBackgroundHost(ExtensionHost* host) { | 771 void ExtensionProcessManager::CloseBackgroundHost(ExtensionHost* host) { |
| 771 CHECK(host->extension_host_type() == | 772 CHECK(host->extension_host_type() == |
| 772 chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); | 773 extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); |
| 773 delete host; | 774 delete host; |
| 774 // |host| should deregister itself from our structures. | 775 // |host| should deregister itself from our structures. |
| 775 CHECK(background_hosts_.find(host) == background_hosts_.end()); | 776 CHECK(background_hosts_.find(host) == background_hosts_.end()); |
| 776 } | 777 } |
| 777 | 778 |
| 778 void ExtensionProcessManager::CloseBackgroundHosts() { | 779 void ExtensionProcessManager::CloseBackgroundHosts() { |
| 779 for (ExtensionHostSet::iterator iter = background_hosts_.begin(); | 780 for (ExtensionHostSet::iterator iter = background_hosts_.begin(); |
| 780 iter != background_hosts_.end(); ) { | 781 iter != background_hosts_.end(); ) { |
| 781 ExtensionHostSet::iterator current = iter++; | 782 ExtensionHostSet::iterator current = iter++; |
| 782 delete *current; | 783 delete *current; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 831 ExtensionService* service = | 832 ExtensionService* service = |
| 832 extensions::ExtensionSystem::Get(GetProfile())->extension_service(); | 833 extensions::ExtensionSystem::Get(GetProfile())->extension_service(); |
| 833 if (service) | 834 if (service) |
| 834 service->menu_manager()->RemoveAllIncognitoContextItems(); | 835 service->menu_manager()->RemoveAllIncognitoContextItems(); |
| 835 } | 836 } |
| 836 | 837 |
| 837 ExtensionHost* IncognitoExtensionProcessManager::CreateViewHost( | 838 ExtensionHost* IncognitoExtensionProcessManager::CreateViewHost( |
| 838 const Extension* extension, | 839 const Extension* extension, |
| 839 const GURL& url, | 840 const GURL& url, |
| 840 Browser* browser, | 841 Browser* browser, |
| 841 chrome::ViewType view_type) { | 842 extensions::ViewType view_type) { |
| 842 if (extensions::IncognitoInfo::IsSplitMode(extension)) { | 843 if (extensions::IncognitoInfo::IsSplitMode(extension)) { |
| 843 if (IsIncognitoEnabled(extension)) { | 844 if (IsIncognitoEnabled(extension)) { |
| 844 return ExtensionProcessManager::CreateViewHost(extension, url, | 845 return ExtensionProcessManager::CreateViewHost(extension, url, |
| 845 browser, view_type); | 846 browser, view_type); |
| 846 } else { | 847 } else { |
| 847 NOTREACHED() << | 848 NOTREACHED() << |
| 848 "We shouldn't be trying to create an incognito extension view unless " | 849 "We shouldn't be trying to create an incognito extension view unless " |
| 849 "it has been enabled for incognito."; | 850 "it has been enabled for incognito."; |
| 850 return NULL; | 851 return NULL; |
| 851 } | 852 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 907 if (service && service->is_ready()) | 908 if (service && service->is_ready()) |
| 908 CreateBackgroundHostsForProfileStartup(); | 909 CreateBackgroundHostsForProfileStartup(); |
| 909 } | 910 } |
| 910 break; | 911 break; |
| 911 } | 912 } |
| 912 default: | 913 default: |
| 913 ExtensionProcessManager::Observe(type, source, details); | 914 ExtensionProcessManager::Observe(type, source, details); |
| 914 break; | 915 break; |
| 915 } | 916 } |
| 916 } | 917 } |
| OLD | NEW |