| 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/ui/browser.h" | 5 #include "chrome/browser/ui/browser.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #include <shellapi.h> | 9 #include <shellapi.h> |
| 10 #endif // OS_WIN | 10 #endif // OS_WIN |
| (...skipping 2321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2332 | 2332 |
| 2333 // Ensure that we're trying to open this from the extension's process. | 2333 // Ensure that we're trying to open this from the extension's process. |
| 2334 SiteInstance* opener_site_instance = opener_web_contents->GetSiteInstance(); | 2334 SiteInstance* opener_site_instance = opener_web_contents->GetSiteInstance(); |
| 2335 extensions::ProcessMap* process_map = extensions_service->process_map(); | 2335 extensions::ProcessMap* process_map = extensions_service->process_map(); |
| 2336 if (!opener_site_instance->GetProcess() || | 2336 if (!opener_site_instance->GetProcess() || |
| 2337 !process_map->Contains( | 2337 !process_map->Contains( |
| 2338 extension->id(), opener_site_instance->GetProcess()->GetID())) { | 2338 extension->id(), opener_site_instance->GetProcess()->GetID())) { |
| 2339 return false; | 2339 return false; |
| 2340 } | 2340 } |
| 2341 | 2341 |
| 2342 // Only allow a single background contents per app. If one already exists, | 2342 // Only allow a single background contents per app. |
| 2343 // close it (even if it was specified in the manifest). | 2343 bool allow_js_access = extension->allow_background_js_access(); |
| 2344 BackgroundContents* existing = | 2344 BackgroundContents* existing = |
| 2345 service->GetAppBackgroundContents(ASCIIToUTF16(extension->id())); | 2345 service->GetAppBackgroundContents(ASCIIToUTF16(extension->id())); |
| 2346 if (existing) { | 2346 if (existing) { |
| 2347 // For non-scriptable background contents, ignore the request altogether, |
| 2348 // (returning true, so that a regular WebContents isn't created either). |
| 2349 if (!allow_js_access) |
| 2350 return true; |
| 2351 // For scriptable background pages, if one already exists, close it (even |
| 2352 // if it was specified in the manifest). |
| 2347 DLOG(INFO) << "Closing existing BackgroundContents for " << opener_url; | 2353 DLOG(INFO) << "Closing existing BackgroundContents for " << opener_url; |
| 2348 delete existing; | 2354 delete existing; |
| 2349 } | 2355 } |
| 2350 | 2356 |
| 2351 // If script access is not allowed, create the the background contents in a | 2357 // If script access is not allowed, create the the background contents in a |
| 2352 // new SiteInstance, so that a separate process is used. | 2358 // new SiteInstance, so that a separate process is used. |
| 2353 bool allow_js_access = extension->allow_background_js_access(); | |
| 2354 scoped_refptr<content::SiteInstance> site_instance = | 2359 scoped_refptr<content::SiteInstance> site_instance = |
| 2355 allow_js_access ? | 2360 allow_js_access ? |
| 2356 opener_site_instance : | 2361 opener_site_instance : |
| 2357 content::SiteInstance::Create(opener_web_contents->GetBrowserContext()); | 2362 content::SiteInstance::Create(opener_web_contents->GetBrowserContext()); |
| 2358 | 2363 |
| 2359 // Passed all the checks, so this should be created as a BackgroundContents. | 2364 // Passed all the checks, so this should be created as a BackgroundContents. |
| 2360 BackgroundContents* contents = service->CreateBackgroundContents( | 2365 BackgroundContents* contents = service->CreateBackgroundContents( |
| 2361 site_instance, | 2366 site_instance, |
| 2362 route_id, | 2367 route_id, |
| 2363 profile_, | 2368 profile_, |
| (...skipping 3323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5687 ShowSingletonTabOverwritingNTP(params); | 5692 ShowSingletonTabOverwritingNTP(params); |
| 5688 } else { | 5693 } else { |
| 5689 LoginUIServiceFactory::GetForProfile( | 5694 LoginUIServiceFactory::GetForProfile( |
| 5690 profile()->GetOriginalProfile())->ShowLoginUI(false); | 5695 profile()->GetOriginalProfile())->ShowLoginUI(false); |
| 5691 } | 5696 } |
| 5692 } | 5697 } |
| 5693 | 5698 |
| 5694 void Browser::ToggleSpeechInput() { | 5699 void Browser::ToggleSpeechInput() { |
| 5695 GetSelectedWebContents()->GetRenderViewHost()->ToggleSpeechInput(); | 5700 GetSelectedWebContents()->GetRenderViewHost()->ToggleSpeechInput(); |
| 5696 } | 5701 } |
| OLD | NEW |