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

Side by Side Diff: chrome/browser/ui/browser.cc

Issue 10020046: Merge 131370 - Don't recreate background windows when allow_js_access if false (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1084/src/
Patch Set: Created 8 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/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
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 3340 matching lines...) Expand 10 before | Expand all | Expand 10 after
5704 } else { 5709 } else {
5705 LoginUIServiceFactory::GetForProfile( 5710 LoginUIServiceFactory::GetForProfile(
5706 profile()->GetOriginalProfile())->ShowLoginUI(false); 5711 profile()->GetOriginalProfile())->ShowLoginUI(false);
5707 } 5712 }
5708 #endif 5713 #endif
5709 } 5714 }
5710 5715
5711 void Browser::ToggleSpeechInput() { 5716 void Browser::ToggleSpeechInput() {
5712 GetSelectedWebContents()->GetRenderViewHost()->ToggleSpeechInput(); 5717 GetSelectedWebContents()->GetRenderViewHost()->ToggleSpeechInput();
5713 } 5718 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698