OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 // defined(OS_WIN) | 10 #endif // defined(OS_WIN) |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 #include "chrome/browser/ui/webui/signin/login_ui_service.h" | 136 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
137 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 137 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
138 #include "chrome/browser/ui/window_sizer/window_sizer.h" | 138 #include "chrome/browser/ui/window_sizer/window_sizer.h" |
139 #include "chrome/browser/ui/zoom/zoom_controller.h" | 139 #include "chrome/browser/ui/zoom/zoom_controller.h" |
140 #include "chrome/browser/upgrade_detector.h" | 140 #include "chrome/browser/upgrade_detector.h" |
141 #include "chrome/browser/web_applications/web_app.h" | 141 #include "chrome/browser/web_applications/web_app.h" |
142 #include "chrome/common/chrome_constants.h" | 142 #include "chrome/common/chrome_constants.h" |
143 #include "chrome/common/chrome_notification_types.h" | 143 #include "chrome/common/chrome_notification_types.h" |
144 #include "chrome/common/chrome_switches.h" | 144 #include "chrome/common/chrome_switches.h" |
145 #include "chrome/common/custom_handlers/protocol_handler.h" | 145 #include "chrome/common/custom_handlers/protocol_handler.h" |
| 146 #include "chrome/common/extensions/background_info.h" |
146 #include "chrome/common/extensions/extension.h" | 147 #include "chrome/common/extensions/extension.h" |
147 #include "chrome/common/extensions/extension_constants.h" | 148 #include "chrome/common/extensions/extension_constants.h" |
148 #include "chrome/common/pref_names.h" | 149 #include "chrome/common/pref_names.h" |
149 #include "chrome/common/profiling.h" | 150 #include "chrome/common/profiling.h" |
150 #include "chrome/common/search_types.h" | 151 #include "chrome/common/search_types.h" |
151 #include "chrome/common/startup_metric_utils.h" | 152 #include "chrome/common/startup_metric_utils.h" |
152 #include "chrome/common/url_constants.h" | 153 #include "chrome/common/url_constants.h" |
153 #include "chrome/common/web_apps.h" | 154 #include "chrome/common/web_apps.h" |
154 #include "content/public/browser/color_chooser.h" | 155 #include "content/public/browser/color_chooser.h" |
155 #include "content/public/browser/devtools_manager.h" | 156 #include "content/public/browser/devtools_manager.h" |
(...skipping 2077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2233 // Ensure that we're trying to open this from the extension's process. | 2234 // Ensure that we're trying to open this from the extension's process. |
2234 SiteInstance* opener_site_instance = opener_web_contents->GetSiteInstance(); | 2235 SiteInstance* opener_site_instance = opener_web_contents->GetSiteInstance(); |
2235 extensions::ProcessMap* process_map = extensions_service->process_map(); | 2236 extensions::ProcessMap* process_map = extensions_service->process_map(); |
2236 if (!opener_site_instance->GetProcess() || | 2237 if (!opener_site_instance->GetProcess() || |
2237 !process_map->Contains( | 2238 !process_map->Contains( |
2238 extension->id(), opener_site_instance->GetProcess()->GetID())) { | 2239 extension->id(), opener_site_instance->GetProcess()->GetID())) { |
2239 return false; | 2240 return false; |
2240 } | 2241 } |
2241 | 2242 |
2242 // Only allow a single background contents per app. | 2243 // Only allow a single background contents per app. |
2243 bool allow_js_access = extension->allow_background_js_access(); | 2244 bool allow_js_access = extensions::BackgroundInfo::AllowJSAccess(extension); |
2244 BackgroundContents* existing = | 2245 BackgroundContents* existing = |
2245 service->GetAppBackgroundContents(ASCIIToUTF16(extension->id())); | 2246 service->GetAppBackgroundContents(ASCIIToUTF16(extension->id())); |
2246 if (existing) { | 2247 if (existing) { |
2247 // For non-scriptable background contents, ignore the request altogether, | 2248 // For non-scriptable background contents, ignore the request altogether, |
2248 // (returning true, so that a regular WebContents isn't created either). | 2249 // (returning true, so that a regular WebContents isn't created either). |
2249 if (!allow_js_access) | 2250 if (!allow_js_access) |
2250 return true; | 2251 return true; |
2251 // For scriptable background pages, if one already exists, close it (even | 2252 // For scriptable background pages, if one already exists, close it (even |
2252 // if it was specified in the manifest). | 2253 // if it was specified in the manifest). |
2253 DLOG(INFO) << "Closing existing BackgroundContents for " << opener_url; | 2254 DLOG(INFO) << "Closing existing BackgroundContents for " << opener_url; |
(...skipping 20 matching lines...) Expand all Loading... |
2274 if (contents && !allow_js_access) { | 2275 if (contents && !allow_js_access) { |
2275 contents->web_contents()->GetController().LoadURL( | 2276 contents->web_contents()->GetController().LoadURL( |
2276 target_url, | 2277 target_url, |
2277 content::Referrer(), | 2278 content::Referrer(), |
2278 content::PAGE_TRANSITION_LINK, | 2279 content::PAGE_TRANSITION_LINK, |
2279 std::string()); // No extra headers. | 2280 std::string()); // No extra headers. |
2280 } | 2281 } |
2281 | 2282 |
2282 return contents != NULL; | 2283 return contents != NULL; |
2283 } | 2284 } |
OLD | NEW |