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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 = |
105 extensions_service->GetExtensionByWebExtent(opener_url); | 105 extensions_service->extensions()->GetHostedAppByURL( |
| 106 ExtensionURLInfo(opener_url)); |
106 if (!extension) | 107 if (!extension) |
107 return NULL; | 108 return NULL; |
108 | 109 |
109 // No BackgroundContents allowed if BackgroundContentsService doesn't exist. | 110 // No BackgroundContents allowed if BackgroundContentsService doesn't exist. |
110 BackgroundContentsService* service = | 111 BackgroundContentsService* service = |
111 BackgroundContentsServiceFactory::GetForProfile(profile); | 112 BackgroundContentsServiceFactory::GetForProfile(profile); |
112 if (!service) | 113 if (!service) |
113 return NULL; | 114 return NULL; |
114 | 115 |
115 // Ensure that we're trying to open this from the extension's process. | 116 // Ensure that we're trying to open this from the extension's process. |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 if (ChildProcessSecurityPolicy::GetInstance()->HasWebUIBindings( | 545 if (ChildProcessSecurityPolicy::GetInstance()->HasWebUIBindings( |
545 rvh->process()->GetID())) { | 546 rvh->process()->GetID())) { |
546 web_prefs.loads_images_automatically = true; | 547 web_prefs.loads_images_automatically = true; |
547 web_prefs.javascript_enabled = true; | 548 web_prefs.javascript_enabled = true; |
548 } | 549 } |
549 | 550 |
550 web_prefs.is_online = !net::NetworkChangeNotifier::IsOffline(); | 551 web_prefs.is_online = !net::NetworkChangeNotifier::IsOffline(); |
551 | 552 |
552 ExtensionService* service = profile->GetExtensionService(); | 553 ExtensionService* service = profile->GetExtensionService(); |
553 if (service) { | 554 if (service) { |
554 const Extension* extension = | 555 const Extension* extension = service->extensions()->GetByID( |
555 service->GetExtensionByURL(rvh->site_instance()->site()); | 556 rvh->site_instance()->site().host()); |
556 extension_webkit_preferences::SetPreferences( | 557 extension_webkit_preferences::SetPreferences( |
557 extension, rvh->delegate()->GetRenderViewType(), &web_prefs); | 558 extension, rvh->delegate()->GetRenderViewType(), &web_prefs); |
558 } | 559 } |
559 | 560 |
560 if (rvh->delegate()->GetRenderViewType() == chrome::VIEW_TYPE_NOTIFICATION) { | 561 if (rvh->delegate()->GetRenderViewType() == chrome::VIEW_TYPE_NOTIFICATION) { |
561 web_prefs.allow_scripts_to_close_windows = true; | 562 web_prefs.allow_scripts_to_close_windows = true; |
562 } else if (rvh->delegate()->GetRenderViewType() == | 563 } else if (rvh->delegate()->GetRenderViewType() == |
563 chrome::VIEW_TYPE_BACKGROUND_CONTENTS) { | 564 chrome::VIEW_TYPE_BACKGROUND_CONTENTS) { |
564 // Disable all kinds of acceleration for background pages. | 565 // Disable all kinds of acceleration for background pages. |
565 // See http://crbug.com/96005 and http://crbug.com/96006 | 566 // See http://crbug.com/96005 and http://crbug.com/96006 |
(...skipping 18 matching lines...) Expand all Loading... |
584 DictionaryValue* inspector_settings = update.Get(); | 585 DictionaryValue* inspector_settings = update.Get(); |
585 inspector_settings->SetWithoutPathExpansion(key, | 586 inspector_settings->SetWithoutPathExpansion(key, |
586 Value::CreateStringValue(value)); | 587 Value::CreateStringValue(value)); |
587 } | 588 } |
588 | 589 |
589 void RenderViewHostDelegateHelper::ClearInspectorSettings( | 590 void RenderViewHostDelegateHelper::ClearInspectorSettings( |
590 content::BrowserContext* browser_context) { | 591 content::BrowserContext* browser_context) { |
591 Profile::FromBrowserContext(browser_context)->GetPrefs()-> | 592 Profile::FromBrowserContext(browser_context)->GetPrefs()-> |
592 ClearPref(prefs::kWebKitInspectorSettings); | 593 ClearPref(prefs::kWebKitInspectorSettings); |
593 } | 594 } |
OLD | NEW |