OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/renderer/extensions/chrome_extensions_dispatcher_delegate.h" | 5 #include "chrome/renderer/extensions/chrome_extensions_dispatcher_delegate.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/sha1.h" | 8 #include "base/sha1.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "chrome/renderer/extensions/notifications_native_handler.h" | 23 #include "chrome/renderer/extensions/notifications_native_handler.h" |
24 #include "chrome/renderer/extensions/page_capture_custom_bindings.h" | 24 #include "chrome/renderer/extensions/page_capture_custom_bindings.h" |
25 #include "chrome/renderer/extensions/sync_file_system_custom_bindings.h" | 25 #include "chrome/renderer/extensions/sync_file_system_custom_bindings.h" |
26 #include "chrome/renderer/extensions/tab_finder.h" | 26 #include "chrome/renderer/extensions/tab_finder.h" |
27 #include "chrome/renderer/extensions/tabs_custom_bindings.h" | 27 #include "chrome/renderer/extensions/tabs_custom_bindings.h" |
28 #include "chrome/renderer/extensions/webstore_bindings.h" | 28 #include "chrome/renderer/extensions/webstore_bindings.h" |
29 #include "content/public/renderer/render_thread.h" | 29 #include "content/public/renderer/render_thread.h" |
30 #include "content/public/renderer/render_view.h" | 30 #include "content/public/renderer/render_view.h" |
31 #include "extensions/common/extension.h" | 31 #include "extensions/common/extension.h" |
32 #include "extensions/common/feature_switch.h" | 32 #include "extensions/common/feature_switch.h" |
33 #include "extensions/common/permissions/api_permission_set.h" | |
34 #include "extensions/common/permissions/manifest_permission_set.h" | 33 #include "extensions/common/permissions/manifest_permission_set.h" |
35 #include "extensions/common/permissions/permission_set.h" | 34 #include "extensions/common/permissions/permission_set.h" |
36 #include "extensions/common/permissions/permissions_data.h" | 35 #include "extensions/common/permissions/permissions_data.h" |
37 #include "extensions/common/switches.h" | 36 #include "extensions/common/switches.h" |
38 #include "extensions/common/url_pattern_set.h" | |
39 #include "extensions/renderer/dispatcher.h" | 37 #include "extensions/renderer/dispatcher.h" |
40 #include "extensions/renderer/native_handler.h" | 38 #include "extensions/renderer/native_handler.h" |
41 #include "extensions/renderer/resource_bundle_source_map.h" | 39 #include "extensions/renderer/resource_bundle_source_map.h" |
42 #include "extensions/renderer/script_context.h" | 40 #include "extensions/renderer/script_context.h" |
43 #include "third_party/WebKit/public/platform/WebString.h" | 41 #include "third_party/WebKit/public/platform/WebString.h" |
44 #include "third_party/WebKit/public/web/WebDocument.h" | |
45 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" | 42 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" |
46 #include "third_party/WebKit/public/web/WebView.h" | |
47 | 43 |
48 #if defined(ENABLE_WEBRTC) | 44 #if defined(ENABLE_WEBRTC) |
49 #include "chrome/renderer/extensions/cast_streaming_native_handler.h" | 45 #include "chrome/renderer/extensions/cast_streaming_native_handler.h" |
50 #endif | 46 #endif |
51 | 47 |
52 using extensions::NativeHandler; | 48 using extensions::NativeHandler; |
53 | 49 |
54 ChromeExtensionsDispatcherDelegate::ChromeExtensionsDispatcherDelegate() { | 50 ChromeExtensionsDispatcherDelegate::ChromeExtensionsDispatcherDelegate() { |
55 } | 51 } |
56 | 52 |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 // In single-process mode, the browser process reports the active extensions. | 271 // In single-process mode, the browser process reports the active extensions. |
276 if (CommandLine::ForCurrentProcess()->HasSwitch(::switches::kSingleProcess)) | 272 if (CommandLine::ForCurrentProcess()->HasSwitch(::switches::kSingleProcess)) |
277 return; | 273 return; |
278 crash_keys::SetActiveExtensions(extension_ids); | 274 crash_keys::SetActiveExtensions(extension_ids); |
279 } | 275 } |
280 | 276 |
281 void ChromeExtensionsDispatcherDelegate::SetChannel(int channel) { | 277 void ChromeExtensionsDispatcherDelegate::SetChannel(int channel) { |
282 extensions::SetCurrentChannel( | 278 extensions::SetCurrentChannel( |
283 static_cast<chrome::VersionInfo::Channel>(channel)); | 279 static_cast<chrome::VersionInfo::Channel>(channel)); |
284 } | 280 } |
285 | |
286 void ChromeExtensionsDispatcherDelegate::ClearTabSpecificPermissions( | |
287 const extensions::Dispatcher* dispatcher, | |
288 int tab_id, | |
289 const std::vector<std::string>& extension_ids) { | |
290 for (std::vector<std::string>::const_iterator it = extension_ids.begin(); | |
291 it != extension_ids.end(); | |
292 ++it) { | |
293 const extensions::Extension* extension = | |
294 dispatcher->extensions()->GetByID(*it); | |
295 if (extension) | |
296 extension->permissions_data()->ClearTabSpecificPermissions(tab_id); | |
297 } | |
298 } | |
299 | |
300 void ChromeExtensionsDispatcherDelegate::UpdateTabSpecificPermissions( | |
301 const extensions::Dispatcher* dispatcher, | |
302 const GURL& url, | |
303 int tab_id, | |
304 const std::string& extension_id, | |
305 const extensions::URLPatternSet& origin_set) { | |
306 content::RenderView* view = extensions::TabFinder::Find(tab_id); | |
307 | |
308 // For now, the message should only be sent to the render view that contains | |
309 // the target tab. This may change. Either way, if this is the target tab it | |
310 // gives us the chance to check against the URL to avoid races. | |
311 DCHECK(view); | |
312 GURL active_url(view->GetWebView()->mainFrame()->document().url()); | |
313 if (active_url != url) | |
314 return; | |
315 | |
316 const extensions::Extension* extension = | |
317 dispatcher->extensions()->GetByID(extension_id); | |
318 if (!extension) | |
319 return; | |
320 | |
321 extension->permissions_data()->UpdateTabSpecificPermissions( | |
322 tab_id, | |
323 new extensions::PermissionSet(extensions::APIPermissionSet(), | |
324 extensions::ManifestPermissionSet(), | |
325 origin_set, | |
326 extensions::URLPatternSet())); | |
327 } | |
OLD | NEW |