| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "chrome/browser/extensions/extension_event_router.h" | 8 #include "chrome/browser/extensions/extension_event_router.h" |
| 9 #include "chrome/browser/extensions/extension_process_manager.h" | 9 #include "chrome/browser/extensions/extension_process_manager.h" |
| 10 #include "chrome/browser/extensions/extension_host.h" | 10 #include "chrome/browser/extensions/extension_host.h" |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 // able to save settings from OTR. | 244 // able to save settings from OTR. |
| 245 if (!browser || browser->profile()->IsOffTheRecord()) { | 245 if (!browser || browser->profile()->IsOffTheRecord()) { |
| 246 Profile* profile = GetProfile(); | 246 Profile* profile = GetProfile(); |
| 247 browser = Browser::GetOrCreateTabbedBrowser(profile->GetOriginalProfile()); | 247 browser = Browser::GetOrCreateTabbedBrowser(profile->GetOriginalProfile()); |
| 248 } | 248 } |
| 249 | 249 |
| 250 OpenURLParams params(extension->options_url(), Referrer(), SINGLETON_TAB, | 250 OpenURLParams params(extension->options_url(), Referrer(), SINGLETON_TAB, |
| 251 content::PAGE_TRANSITION_LINK, false); | 251 content::PAGE_TRANSITION_LINK, false); |
| 252 browser->OpenURL(params); | 252 browser->OpenURL(params); |
| 253 browser->window()->Show(); | 253 browser->window()->Show(); |
| 254 browser->GetSelectedWebContents()->GetRenderViewHost()->delegate()-> | 254 browser->GetSelectedWebContents()->GetRenderViewHost()->GetDelegate()-> |
| 255 Activate(); | 255 Activate(); |
| 256 } | 256 } |
| 257 | 257 |
| 258 ExtensionHost* ExtensionProcessManager::GetBackgroundHostForExtension( | 258 ExtensionHost* ExtensionProcessManager::GetBackgroundHostForExtension( |
| 259 const std::string& extension_id) { | 259 const std::string& extension_id) { |
| 260 for (ExtensionHostSet::iterator iter = background_hosts_.begin(); | 260 for (ExtensionHostSet::iterator iter = background_hosts_.begin(); |
| 261 iter != background_hosts_.end(); ++iter) { | 261 iter != background_hosts_.end(); ++iter) { |
| 262 ExtensionHost* host = *iter; | 262 ExtensionHost* host = *iter; |
| 263 if (host->extension_id() == extension_id) | 263 if (host->extension_id() == extension_id) |
| 264 return host; | 264 return host; |
| 265 } | 265 } |
| 266 return NULL; | 266 return NULL; |
| 267 } | 267 } |
| 268 | 268 |
| 269 std::set<RenderViewHost*> | 269 std::set<RenderViewHost*> |
| 270 ExtensionProcessManager::GetRenderViewHostsForExtension( | 270 ExtensionProcessManager::GetRenderViewHostsForExtension( |
| 271 const std::string& extension_id) { | 271 const std::string& extension_id) { |
| 272 std::set<RenderViewHost*> result; | 272 std::set<RenderViewHost*> result; |
| 273 | 273 |
| 274 SiteInstance* site_instance = GetSiteInstanceForURL( | 274 SiteInstance* site_instance = GetSiteInstanceForURL( |
| 275 Extension::GetBaseURLFromExtensionId(extension_id)); | 275 Extension::GetBaseURLFromExtensionId(extension_id)); |
| 276 if (!site_instance) | 276 if (!site_instance) |
| 277 return result; | 277 return result; |
| 278 | 278 |
| 279 // Gather up all the views for that site. | 279 // Gather up all the views for that site. |
| 280 for (RenderViewHostSet::iterator view = all_extension_views_.begin(); | 280 for (RenderViewHostSet::iterator view = all_extension_views_.begin(); |
| 281 view != all_extension_views_.end(); ++view) { | 281 view != all_extension_views_.end(); ++view) { |
| 282 if ((*view)->site_instance() == site_instance) | 282 if ((*view)->GetSiteInstance() == site_instance) |
| 283 result.insert(*view); | 283 result.insert(*view); |
| 284 } | 284 } |
| 285 | 285 |
| 286 return result; | 286 return result; |
| 287 } | 287 } |
| 288 | 288 |
| 289 void ExtensionProcessManager::RegisterRenderViewHost( | 289 void ExtensionProcessManager::RegisterRenderViewHost( |
| 290 RenderViewHost* render_view_host, | 290 RenderViewHost* render_view_host, |
| 291 const Extension* extension) { | 291 const Extension* extension) { |
| 292 all_extension_views_.insert(render_view_host); | 292 all_extension_views_.insert(render_view_host); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 if (host) | 359 if (host) |
| 360 host->OnShouldCloseAck(sequence_id); | 360 host->OnShouldCloseAck(sequence_id); |
| 361 } | 361 } |
| 362 | 362 |
| 363 bool ExtensionProcessManager::HasVisibleViews(const std::string& extension_id) { | 363 bool ExtensionProcessManager::HasVisibleViews(const std::string& extension_id) { |
| 364 const std::set<RenderViewHost*>& views = | 364 const std::set<RenderViewHost*>& views = |
| 365 GetRenderViewHostsForExtension(extension_id); | 365 GetRenderViewHostsForExtension(extension_id); |
| 366 for (std::set<RenderViewHost*>::const_iterator it = views.begin(); | 366 for (std::set<RenderViewHost*>::const_iterator it = views.begin(); |
| 367 it != views.end(); ++it) { | 367 it != views.end(); ++it) { |
| 368 const RenderViewHost* host = *it; | 368 const RenderViewHost* host = *it; |
| 369 if (host->site_instance()->GetSite().host() == extension_id && | 369 if (host->GetSiteInstance()->GetSite().host() == extension_id && |
| 370 host->delegate()->GetRenderViewType() != | 370 host->GetDelegate()->GetRenderViewType() != |
| 371 chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { | 371 chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { |
| 372 return true; | 372 return true; |
| 373 } | 373 } |
| 374 } | 374 } |
| 375 return false; | 375 return false; |
| 376 } | 376 } |
| 377 | 377 |
| 378 void ExtensionProcessManager::Observe( | 378 void ExtensionProcessManager::Observe( |
| 379 int type, | 379 int type, |
| 380 const content::NotificationSource& source, | 380 const content::NotificationSource& source, |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 if (service && service->is_ready()) | 554 if (service && service->is_ready()) |
| 555 CreateBackgroundHostsForProfileStartup(this, service->extensions()); | 555 CreateBackgroundHostsForProfileStartup(this, service->extensions()); |
| 556 } | 556 } |
| 557 break; | 557 break; |
| 558 } | 558 } |
| 559 default: | 559 default: |
| 560 ExtensionProcessManager::Observe(type, source, details); | 560 ExtensionProcessManager::Observe(type, source, details); |
| 561 break; | 561 break; |
| 562 } | 562 } |
| 563 } | 563 } |
| OLD | NEW |