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 <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
100 const Extension* extension = | 100 const Extension* extension = |
101 extensions_service->GetExtensionByWebExtent(opener_url); | 101 extensions_service->GetExtensionByWebExtent(opener_url); |
102 if (!extension) | 102 if (!extension) |
103 return NULL; | 103 return NULL; |
104 | 104 |
105 // If the extension manifest specifies a background page, then don't allow one | 105 // If the extension manifest specifies a background page, then don't allow one |
106 // to be created here. | 106 // to be created here. |
107 if (extension->background_url().is_valid()) | 107 if (extension->background_url().is_valid()) |
108 return NULL; | 108 return NULL; |
109 | 109 |
110 // Only allow a single background contents per app. | 110 // No BackgroundContents allowed if BackgroundContentsService doesn't exist. |
111 BackgroundContentsService* service = | 111 BackgroundContentsService* service = |
112 BackgroundContentsServiceFactory::GetForProfile(profile); | 112 BackgroundContentsServiceFactory::GetForProfile(profile); |
113 if (!service || service->GetAppBackgroundContents( | 113 if (!service) |
114 ASCIIToUTF16(extension->id()))) | |
115 return NULL; | 114 return NULL; |
116 | 115 |
117 // 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. |
118 ExtensionProcessManager* process_manager = | 117 ExtensionProcessManager* process_manager = |
119 profile->GetExtensionProcessManager(); | 118 profile->GetExtensionProcessManager(); |
120 if (!site->GetProcess() || !process_manager || | 119 if (!site->GetProcess() || !process_manager || |
121 site->GetProcess() != process_manager->GetExtensionProcess(opener_url)) | 120 site->GetProcess() != process_manager->GetExtensionProcess(opener_url)) |
122 return NULL; | 121 return NULL; |
123 | 122 |
123 // Only allow a single background contents per app. If one already exists, | |
124 // close it. | |
125 BackgroundContents* existing = | |
126 service->GetAppBackgroundContents(ASCIIToUTF16(extension->id())); | |
127 if (existing) { | |
128 DLOG(WARNING) << "Closing existing BackgroundContents for " << opener_url; | |
brettw
2011/10/04 22:03:47
I don't quite get this code. Is this an illegal co
Andrew T Wilson (Slow)
2011/10/05 19:45:58
The warning is because "reopening an existing Back
brettw
2011/10/05 20:03:34
Let's think about this in terms of somebody random
Andrew T Wilson (Slow)
2011/10/05 20:49:13
Done.
| |
129 existing->render_view_host()->ClosePage(); | |
130 delete existing; | |
131 } | |
132 | |
124 // Passed all the checks, so this should be created as a BackgroundContents. | 133 // Passed all the checks, so this should be created as a BackgroundContents. |
125 return service->CreateBackgroundContents(site, route_id, profile, frame_name, | 134 return service->CreateBackgroundContents(site, route_id, profile, frame_name, |
126 ASCIIToUTF16(extension->id())); | 135 ASCIIToUTF16(extension->id())); |
127 } | 136 } |
128 | 137 |
129 TabContents* RenderViewHostDelegateViewHelper::CreateNewWindow( | 138 TabContents* RenderViewHostDelegateViewHelper::CreateNewWindow( |
130 int route_id, | 139 int route_id, |
131 Profile* profile, | 140 Profile* profile, |
132 SiteInstance* site, | 141 SiteInstance* site, |
133 WebUI::TypeID webui_type, | 142 WebUI::TypeID webui_type, |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
534 DictionaryValue* inspector_settings = update.Get(); | 543 DictionaryValue* inspector_settings = update.Get(); |
535 inspector_settings->SetWithoutPathExpansion(key, | 544 inspector_settings->SetWithoutPathExpansion(key, |
536 Value::CreateStringValue(value)); | 545 Value::CreateStringValue(value)); |
537 } | 546 } |
538 | 547 |
539 void RenderViewHostDelegateHelper::ClearInspectorSettings( | 548 void RenderViewHostDelegateHelper::ClearInspectorSettings( |
540 content::BrowserContext* browser_context) { | 549 content::BrowserContext* browser_context) { |
541 Profile::FromBrowserContext(browser_context)->GetPrefs()-> | 550 Profile::FromBrowserContext(browser_context)->GetPrefs()-> |
542 ClearPref(prefs::kWebKitInspectorSettings); | 551 ClearPref(prefs::kWebKitInspectorSettings); |
543 } | 552 } |
OLD | NEW |