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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 #include "chrome/browser/ui/webui/signin/login_ui_service.h" | 135 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
136 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 136 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
137 #include "chrome/browser/ui/window_sizer/window_sizer.h" | 137 #include "chrome/browser/ui/window_sizer/window_sizer.h" |
138 #include "chrome/browser/ui/zoom/zoom_controller.h" | 138 #include "chrome/browser/ui/zoom/zoom_controller.h" |
139 #include "chrome/browser/upgrade_detector.h" | 139 #include "chrome/browser/upgrade_detector.h" |
140 #include "chrome/browser/web_applications/web_app.h" | 140 #include "chrome/browser/web_applications/web_app.h" |
141 #include "chrome/common/chrome_constants.h" | 141 #include "chrome/common/chrome_constants.h" |
142 #include "chrome/common/chrome_notification_types.h" | 142 #include "chrome/common/chrome_notification_types.h" |
143 #include "chrome/common/chrome_switches.h" | 143 #include "chrome/common/chrome_switches.h" |
144 #include "chrome/common/custom_handlers/protocol_handler.h" | 144 #include "chrome/common/custom_handlers/protocol_handler.h" |
| 145 #include "chrome/common/extensions/background_info.h" |
145 #include "chrome/common/extensions/extension.h" | 146 #include "chrome/common/extensions/extension.h" |
146 #include "chrome/common/extensions/extension_constants.h" | 147 #include "chrome/common/extensions/extension_constants.h" |
147 #include "chrome/common/pref_names.h" | 148 #include "chrome/common/pref_names.h" |
148 #include "chrome/common/profiling.h" | 149 #include "chrome/common/profiling.h" |
149 #include "chrome/common/search_types.h" | 150 #include "chrome/common/search_types.h" |
150 #include "chrome/common/startup_metric_utils.h" | 151 #include "chrome/common/startup_metric_utils.h" |
151 #include "chrome/common/url_constants.h" | 152 #include "chrome/common/url_constants.h" |
152 #include "chrome/common/web_apps.h" | 153 #include "chrome/common/web_apps.h" |
153 #include "content/public/browser/color_chooser.h" | 154 #include "content/public/browser/color_chooser.h" |
154 #include "content/public/browser/devtools_manager.h" | 155 #include "content/public/browser/devtools_manager.h" |
(...skipping 2050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2205 // Ensure that we're trying to open this from the extension's process. | 2206 // Ensure that we're trying to open this from the extension's process. |
2206 SiteInstance* opener_site_instance = opener_web_contents->GetSiteInstance(); | 2207 SiteInstance* opener_site_instance = opener_web_contents->GetSiteInstance(); |
2207 extensions::ProcessMap* process_map = extensions_service->process_map(); | 2208 extensions::ProcessMap* process_map = extensions_service->process_map(); |
2208 if (!opener_site_instance->GetProcess() || | 2209 if (!opener_site_instance->GetProcess() || |
2209 !process_map->Contains( | 2210 !process_map->Contains( |
2210 extension->id(), opener_site_instance->GetProcess()->GetID())) { | 2211 extension->id(), opener_site_instance->GetProcess()->GetID())) { |
2211 return false; | 2212 return false; |
2212 } | 2213 } |
2213 | 2214 |
2214 // Only allow a single background contents per app. | 2215 // Only allow a single background contents per app. |
2215 bool allow_js_access = extension->allow_background_js_access(); | 2216 bool allow_js_access = extensions::BackgroundInfo::AllowJSAccess(extension); |
2216 BackgroundContents* existing = | 2217 BackgroundContents* existing = |
2217 service->GetAppBackgroundContents(ASCIIToUTF16(extension->id())); | 2218 service->GetAppBackgroundContents(ASCIIToUTF16(extension->id())); |
2218 if (existing) { | 2219 if (existing) { |
2219 // For non-scriptable background contents, ignore the request altogether, | 2220 // For non-scriptable background contents, ignore the request altogether, |
2220 // (returning true, so that a regular WebContents isn't created either). | 2221 // (returning true, so that a regular WebContents isn't created either). |
2221 if (!allow_js_access) | 2222 if (!allow_js_access) |
2222 return true; | 2223 return true; |
2223 // For scriptable background pages, if one already exists, close it (even | 2224 // For scriptable background pages, if one already exists, close it (even |
2224 // if it was specified in the manifest). | 2225 // if it was specified in the manifest). |
2225 DLOG(INFO) << "Closing existing BackgroundContents for " << opener_url; | 2226 DLOG(INFO) << "Closing existing BackgroundContents for " << opener_url; |
(...skipping 20 matching lines...) Expand all Loading... |
2246 if (contents && !allow_js_access) { | 2247 if (contents && !allow_js_access) { |
2247 contents->web_contents()->GetController().LoadURL( | 2248 contents->web_contents()->GetController().LoadURL( |
2248 target_url, | 2249 target_url, |
2249 content::Referrer(), | 2250 content::Referrer(), |
2250 content::PAGE_TRANSITION_LINK, | 2251 content::PAGE_TRANSITION_LINK, |
2251 std::string()); // No extra headers. | 2252 std::string()); // No extra headers. |
2252 } | 2253 } |
2253 | 2254 |
2254 return contents != NULL; | 2255 return contents != NULL; |
2255 } | 2256 } |
OLD | NEW |