| 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 "chrome/browser/extensions/extension_process_manager.h" | 7 #include "chrome/browser/extensions/extension_process_manager.h" |
| 8 | 8 |
| 9 #include "chrome/browser/extensions/extension_event_router.h" | 9 #include "chrome/browser/extensions/extension_event_router.h" |
| 10 #include "chrome/browser/ui/browser_window.h" | 10 #include "chrome/browser/ui/browser_window.h" |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 // able to save settings from OTR. | 227 // able to save settings from OTR. |
| 228 if (!browser || browser->profile()->IsOffTheRecord()) { | 228 if (!browser || browser->profile()->IsOffTheRecord()) { |
| 229 Profile* profile = GetProfile(); | 229 Profile* profile = GetProfile(); |
| 230 browser = Browser::GetOrCreateTabbedBrowser(profile->GetOriginalProfile()); | 230 browser = Browser::GetOrCreateTabbedBrowser(profile->GetOriginalProfile()); |
| 231 } | 231 } |
| 232 | 232 |
| 233 OpenURLParams params(extension->options_url(), Referrer(), SINGLETON_TAB, | 233 OpenURLParams params(extension->options_url(), Referrer(), SINGLETON_TAB, |
| 234 content::PAGE_TRANSITION_LINK, false); | 234 content::PAGE_TRANSITION_LINK, false); |
| 235 browser->OpenURL(params); | 235 browser->OpenURL(params); |
| 236 browser->window()->Show(); | 236 browser->window()->Show(); |
| 237 browser->GetSelectedWebContents()->GetRenderViewHost()->delegate()-> | 237 browser->GetSelectedWebContents()->GetRenderViewHost()->GetDelegate()-> |
| 238 Activate(); | 238 Activate(); |
| 239 } | 239 } |
| 240 | 240 |
| 241 ExtensionHost* ExtensionProcessManager::GetBackgroundHostForExtension( | 241 ExtensionHost* ExtensionProcessManager::GetBackgroundHostForExtension( |
| 242 const std::string& extension_id) { | 242 const std::string& extension_id) { |
| 243 for (ExtensionHostSet::iterator iter = background_hosts_.begin(); | 243 for (ExtensionHostSet::iterator iter = background_hosts_.begin(); |
| 244 iter != background_hosts_.end(); ++iter) { | 244 iter != background_hosts_.end(); ++iter) { |
| 245 ExtensionHost* host = *iter; | 245 ExtensionHost* host = *iter; |
| 246 if (host->extension_id() == extension_id) | 246 if (host->extension_id() == extension_id) |
| 247 return host; | 247 return host; |
| 248 } | 248 } |
| 249 return NULL; | 249 return NULL; |
| 250 | 250 |
| 251 } | 251 } |
| 252 | 252 |
| 253 std::set<RenderViewHost*> | 253 std::set<RenderViewHost*> |
| 254 ExtensionProcessManager::GetRenderViewHostsForExtension( | 254 ExtensionProcessManager::GetRenderViewHostsForExtension( |
| 255 const std::string& extension_id) { | 255 const std::string& extension_id) { |
| 256 std::set<RenderViewHost*> result; | 256 std::set<RenderViewHost*> result; |
| 257 | 257 |
| 258 SiteInstance* site_instance = GetSiteInstanceForURL( | 258 SiteInstance* site_instance = GetSiteInstanceForURL( |
| 259 Extension::GetBaseURLFromExtensionId(extension_id)); | 259 Extension::GetBaseURLFromExtensionId(extension_id)); |
| 260 if (!site_instance) | 260 if (!site_instance) |
| 261 return result; | 261 return result; |
| 262 | 262 |
| 263 // Gather up all the views for that site. | 263 // Gather up all the views for that site. |
| 264 for (RenderViewHostSet::iterator view = all_extension_views_.begin(); | 264 for (RenderViewHostSet::iterator view = all_extension_views_.begin(); |
| 265 view != all_extension_views_.end(); ++view) { | 265 view != all_extension_views_.end(); ++view) { |
| 266 if ((*view)->site_instance() == site_instance) | 266 if ((*view)->GetSiteInstance() == site_instance) |
| 267 result.insert(*view); | 267 result.insert(*view); |
| 268 } | 268 } |
| 269 | 269 |
| 270 return result; | 270 return result; |
| 271 } | 271 } |
| 272 | 272 |
| 273 void ExtensionProcessManager::RegisterRenderViewHost( | 273 void ExtensionProcessManager::RegisterRenderViewHost( |
| 274 RenderViewHost* render_view_host, | 274 RenderViewHost* render_view_host, |
| 275 const Extension* extension) { | 275 const Extension* extension) { |
| 276 all_extension_views_.insert(render_view_host); | 276 all_extension_views_.insert(render_view_host); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 298 CloseBackgroundHost(host); | 298 CloseBackgroundHost(host); |
| 299 } | 299 } |
| 300 } | 300 } |
| 301 | 301 |
| 302 bool ExtensionProcessManager::HasVisibleViews(const std::string& extension_id) { | 302 bool ExtensionProcessManager::HasVisibleViews(const std::string& extension_id) { |
| 303 const std::set<RenderViewHost*>& views = | 303 const std::set<RenderViewHost*>& views = |
| 304 GetRenderViewHostsForExtension(extension_id); | 304 GetRenderViewHostsForExtension(extension_id); |
| 305 for (std::set<RenderViewHost*>::const_iterator it = views.begin(); | 305 for (std::set<RenderViewHost*>::const_iterator it = views.begin(); |
| 306 it != views.end(); ++it) { | 306 it != views.end(); ++it) { |
| 307 const RenderViewHost* host = *it; | 307 const RenderViewHost* host = *it; |
| 308 if (host->site_instance()->GetSite().host() == extension_id && | 308 if (host->GetSiteInstance()->GetSite().host() == extension_id && |
| 309 host->delegate()->GetRenderViewType() != | 309 host->GetDelegate()->GetRenderViewType() != |
| 310 chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { | 310 chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { |
| 311 return true; | 311 return true; |
| 312 } | 312 } |
| 313 } | 313 } |
| 314 return false; | 314 return false; |
| 315 } | 315 } |
| 316 | 316 |
| 317 void ExtensionProcessManager::Observe( | 317 void ExtensionProcessManager::Observe( |
| 318 int type, | 318 int type, |
| 319 const content::NotificationSource& source, | 319 const content::NotificationSource& source, |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 if (service && service->is_ready()) | 493 if (service && service->is_ready()) |
| 494 CreateBackgroundHostsForProfileStartup(this, service->extensions()); | 494 CreateBackgroundHostsForProfileStartup(this, service->extensions()); |
| 495 } | 495 } |
| 496 break; | 496 break; |
| 497 } | 497 } |
| 498 default: | 498 default: |
| 499 ExtensionProcessManager::Observe(type, source, details); | 499 ExtensionProcessManager::Observe(type, source, details); |
| 500 break; | 500 break; |
| 501 } | 501 } |
| 502 } | 502 } |
| OLD | NEW |