| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/tab_contents/render_view_host_delegate_helper.h" | 5 #include "chrome/browser/tab_contents/render_view_host_delegate_helper.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/background/background_contents_service.h" | 10 #include "chrome/browser/background/background_contents_service.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 if (!opener_url.is_valid() || | 94 if (!opener_url.is_valid() || |
| 95 frame_name.empty() || | 95 frame_name.empty() || |
| 96 !extensions_service || | 96 !extensions_service || |
| 97 !extensions_service->is_ready()) | 97 !extensions_service->is_ready()) |
| 98 return NULL; | 98 return NULL; |
| 99 | 99 |
| 100 // Only hosted apps have web extents, so this ensures that only hosted apps | 100 // Only hosted apps have web extents, so this ensures that only hosted apps |
| 101 // can create BackgroundContents. We don't have to check for background | 101 // can create BackgroundContents. We don't have to check for background |
| 102 // permission as that is checked in RenderMessageFilter when the CreateWindow | 102 // permission as that is checked in RenderMessageFilter when the CreateWindow |
| 103 // message is processed. | 103 // message is processed. |
| 104 const Extension* extension = | 104 const Extension* extension = extensions_service->extensions()->GetByWebExtent( |
| 105 extensions_service->GetExtensionByWebExtent(opener_url); | 105 ExtensionURLInfo(opener_url)); |
| 106 if (!extension) | 106 if (!extension) |
| 107 return NULL; | 107 return NULL; |
| 108 | 108 |
| 109 // No BackgroundContents allowed if BackgroundContentsService doesn't exist. | 109 // No BackgroundContents allowed if BackgroundContentsService doesn't exist. |
| 110 BackgroundContentsService* service = | 110 BackgroundContentsService* service = |
| 111 BackgroundContentsServiceFactory::GetForProfile(profile); | 111 BackgroundContentsServiceFactory::GetForProfile(profile); |
| 112 if (!service) | 112 if (!service) |
| 113 return NULL; | 113 return NULL; |
| 114 | 114 |
| 115 // Ensure that we're trying to open this from the extension's process. | 115 // Ensure that we're trying to open this from the extension's process. |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 if (ChildProcessSecurityPolicy::GetInstance()->HasWebUIBindings( | 541 if (ChildProcessSecurityPolicy::GetInstance()->HasWebUIBindings( |
| 542 rvh->process()->GetID())) { | 542 rvh->process()->GetID())) { |
| 543 web_prefs.loads_images_automatically = true; | 543 web_prefs.loads_images_automatically = true; |
| 544 web_prefs.javascript_enabled = true; | 544 web_prefs.javascript_enabled = true; |
| 545 } | 545 } |
| 546 | 546 |
| 547 web_prefs.is_online = !net::NetworkChangeNotifier::IsOffline(); | 547 web_prefs.is_online = !net::NetworkChangeNotifier::IsOffline(); |
| 548 | 548 |
| 549 ExtensionService* service = profile->GetExtensionService(); | 549 ExtensionService* service = profile->GetExtensionService(); |
| 550 if (service) { | 550 if (service) { |
| 551 const Extension* extension = | 551 const Extension* extension = service->extensions()->GetByURL( |
| 552 service->GetExtensionByURL(rvh->site_instance()->site()); | 552 ExtensionURLInfo(rvh->site_instance()->site())); |
| 553 extension_webkit_preferences::SetPreferences( | 553 extension_webkit_preferences::SetPreferences( |
| 554 extension, rvh->delegate()->GetRenderViewType(), &web_prefs); | 554 extension, rvh->delegate()->GetRenderViewType(), &web_prefs); |
| 555 } | 555 } |
| 556 | 556 |
| 557 if (rvh->delegate()->GetRenderViewType() == chrome::VIEW_TYPE_NOTIFICATION) { | 557 if (rvh->delegate()->GetRenderViewType() == chrome::VIEW_TYPE_NOTIFICATION) { |
| 558 web_prefs.allow_scripts_to_close_windows = true; | 558 web_prefs.allow_scripts_to_close_windows = true; |
| 559 } else if (rvh->delegate()->GetRenderViewType() == | 559 } else if (rvh->delegate()->GetRenderViewType() == |
| 560 chrome::VIEW_TYPE_BACKGROUND_CONTENTS) { | 560 chrome::VIEW_TYPE_BACKGROUND_CONTENTS) { |
| 561 // Disable all kinds of acceleration for background pages. | 561 // Disable all kinds of acceleration for background pages. |
| 562 // See http://crbug.com/96005 and http://crbug.com/96006 | 562 // See http://crbug.com/96005 and http://crbug.com/96006 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 581 DictionaryValue* inspector_settings = update.Get(); | 581 DictionaryValue* inspector_settings = update.Get(); |
| 582 inspector_settings->SetWithoutPathExpansion(key, | 582 inspector_settings->SetWithoutPathExpansion(key, |
| 583 Value::CreateStringValue(value)); | 583 Value::CreateStringValue(value)); |
| 584 } | 584 } |
| 585 | 585 |
| 586 void RenderViewHostDelegateHelper::ClearInspectorSettings( | 586 void RenderViewHostDelegateHelper::ClearInspectorSettings( |
| 587 content::BrowserContext* browser_context) { | 587 content::BrowserContext* browser_context) { |
| 588 Profile::FromBrowserContext(browser_context)->GetPrefs()-> | 588 Profile::FromBrowserContext(browser_context)->GetPrefs()-> |
| 589 ClearPref(prefs::kWebKitInspectorSettings); | 589 ClearPref(prefs::kWebKitInspectorSettings); |
| 590 } | 590 } |
| OLD | NEW |