Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(202)

Side by Side Diff: chrome/browser/extensions/extension_system_impl.cc

Issue 2182633007: Avoid using ContentBrowserClient::IsIllegalOrigin in ResourceDispatcherHost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove the IsIllegalOrigin function from ContentBrowserClient Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/browser/extensions/extension_system_impl.h" 5 #include "chrome/browser/extensions/extension_system_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/base_switches.h" 9 #include "base/base_switches.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 20 matching lines...) Expand all
31 #include "chrome/browser/extensions/shared_module_service.h" 31 #include "chrome/browser/extensions/shared_module_service.h"
32 #include "chrome/browser/extensions/shared_user_script_master.h" 32 #include "chrome/browser/extensions/shared_user_script_master.h"
33 #include "chrome/browser/extensions/state_store_notification_observer.h" 33 #include "chrome/browser/extensions/state_store_notification_observer.h"
34 #include "chrome/browser/extensions/unpacked_installer.h" 34 #include "chrome/browser/extensions/unpacked_installer.h"
35 #include "chrome/browser/extensions/update_install_gate.h" 35 #include "chrome/browser/extensions/update_install_gate.h"
36 #include "chrome/browser/profiles/profile.h" 36 #include "chrome/browser/profiles/profile.h"
37 #include "chrome/browser/profiles/profile_manager.h" 37 #include "chrome/browser/profiles/profile_manager.h"
38 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" 38 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h"
39 #include "chrome/common/chrome_switches.h" 39 #include "chrome/common/chrome_switches.h"
40 #include "content/public/browser/browser_thread.h" 40 #include "content/public/browser/browser_thread.h"
41 #include "content/public/browser/resource_dispatcher_host.h"
41 #include "content/public/browser/url_data_source.h" 42 #include "content/public/browser/url_data_source.h"
42 #include "extensions/browser/content_verifier.h" 43 #include "extensions/browser/content_verifier.h"
43 #include "extensions/browser/extension_pref_store.h" 44 #include "extensions/browser/extension_pref_store.h"
44 #include "extensions/browser/extension_pref_value_map.h" 45 #include "extensions/browser/extension_pref_value_map.h"
45 #include "extensions/browser/extension_pref_value_map_factory.h" 46 #include "extensions/browser/extension_pref_value_map_factory.h"
46 #include "extensions/browser/extension_prefs.h" 47 #include "extensions/browser/extension_prefs.h"
47 #include "extensions/browser/extension_registry.h" 48 #include "extensions/browser/extension_registry.h"
48 #include "extensions/browser/info_map.h" 49 #include "extensions/browser/info_map.h"
49 #include "extensions/browser/quota_service.h" 50 #include "extensions/browser/quota_service.h"
50 #include "extensions/browser/runtime_data.h" 51 #include "extensions/browser/runtime_data.h"
51 #include "extensions/browser/service_worker_manager.h" 52 #include "extensions/browser/service_worker_manager.h"
52 #include "extensions/browser/state_store.h" 53 #include "extensions/browser/state_store.h"
53 #include "extensions/browser/uninstall_ping_sender.h" 54 #include "extensions/browser/uninstall_ping_sender.h"
54 #include "extensions/browser/value_store/value_store_factory_impl.h" 55 #include "extensions/browser/value_store/value_store_factory_impl.h"
55 #include "extensions/common/constants.h" 56 #include "extensions/common/constants.h"
56 #include "extensions/common/features/feature_channel.h" 57 #include "extensions/common/features/feature_channel.h"
58 #include "extensions/common/manifest_constants.h"
57 #include "extensions/common/manifest_url_handlers.h" 59 #include "extensions/common/manifest_url_handlers.h"
58 60
59 #if defined(ENABLE_NOTIFICATIONS) 61 #if defined(ENABLE_NOTIFICATIONS)
60 #include "chrome/browser/notifications/notifier_state_tracker.h" 62 #include "chrome/browser/notifications/notifier_state_tracker.h"
61 #include "chrome/browser/notifications/notifier_state_tracker_factory.h" 63 #include "chrome/browser/notifications/notifier_state_tracker_factory.h"
62 #include "ui/message_center/notifier_settings.h" 64 #include "ui/message_center/notifier_settings.h"
63 #endif 65 #endif
64 66
65 #if defined(OS_CHROMEOS) 67 #if defined(OS_CHROMEOS)
66 #include "chrome/browser/app_mode/app_mode_utils.h" 68 #include "chrome/browser/app_mode/app_mode_utils.h"
(...skipping 16 matching lines...) Expand all
83 UninstallPingSender::FilterResult ShouldSendUninstallPing( 85 UninstallPingSender::FilterResult ShouldSendUninstallPing(
84 const Extension* extension, 86 const Extension* extension,
85 UninstallReason reason) { 87 UninstallReason reason) {
86 if (extension && (extension->from_webstore() || 88 if (extension && (extension->from_webstore() ||
87 ManifestURL::UpdatesFromGallery(extension))) { 89 ManifestURL::UpdatesFromGallery(extension))) {
88 return UninstallPingSender::SEND_PING; 90 return UninstallPingSender::SEND_PING;
89 } 91 }
90 return UninstallPingSender::DO_NOT_SEND_PING; 92 return UninstallPingSender::DO_NOT_SEND_PING;
91 } 93 }
92 94
95 // Helper functions to register and unregister extensions. These are invoked
96 // on the IO thread.
97 void RegisterExtensionHelper(InfoMap* info_map,
98 const Extension* extension,
99 base::Time install_time,
100 bool incognito_enabled,
101 bool notifications_disabled,
102 const content::ResourceContext* context) {
103 DCHECK_CURRENTLY_ON(BrowserThread::IO);
104
105 info_map->AddExtension(extension, install_time, incognito_enabled,
106 notifications_disabled);
107 // Check for platform app origins. These can only be committed by the app
108 // itself, or by one if its guests if there are accessible_resources.
109 // If the origin is not a platform app, then we assume all processes can
110 // commit to it as we don't have enough information to validate it. This
111 // includes hosted apps and normal extensions.
112 content::ResourceDispatcherHost::OriginAccessCheckMask access_check_mask =
113 content::ResourceDispatcherHost::ALLOW_EVERYTHING;
114 if (extension->is_platform_app() && !!extension->GetManifestData(
115 manifest_keys::kWebviewAccessibleResources)) {
116 access_check_mask =
117 content::ResourceDispatcherHost::ALLOW_REGISTERED_ACCESS;
118 }
119 content::ResourceDispatcherHost::Get()->RegisterOriginForAccessChecks(
120 context, Extension::GetBaseURLFromExtensionId(extension->id()).spec(),
121 access_check_mask);
122 }
123
124 void UnregisterExtensionHelper(InfoMap* info_map,
125 const std::string& extension_id,
126 const UnloadedExtensionInfo::Reason reason,
127 const content::ResourceContext* context) {
128 DCHECK_CURRENTLY_ON(BrowserThread::IO);
129
130 info_map->RemoveExtension(extension_id, reason);
131 content::ResourceDispatcherHost::Get()->UnregisterOriginForAccessChecks(
132 context, Extension::GetBaseURLFromExtensionId(extension_id).spec());
133 }
134
93 } // namespace 135 } // namespace
94 136
95 // 137 //
96 // ExtensionSystemImpl::Shared 138 // ExtensionSystemImpl::Shared
97 // 139 //
98 140
99 ExtensionSystemImpl::Shared::Shared(Profile* profile) 141 ExtensionSystemImpl::Shared::Shared(Profile* profile)
100 : profile_(profile) { 142 : profile_(profile) {
101 } 143 }
102 144
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 extension->id()); 492 extension->id());
451 493
452 NotifierStateTracker* notifier_state_tracker = 494 NotifierStateTracker* notifier_state_tracker =
453 NotifierStateTrackerFactory::GetForProfile(profile_); 495 NotifierStateTrackerFactory::GetForProfile(profile_);
454 notifications_disabled = 496 notifications_disabled =
455 !notifier_state_tracker->IsNotifierEnabled(notifier_id); 497 !notifier_state_tracker->IsNotifierEnabled(notifier_id);
456 #endif 498 #endif
457 499
458 BrowserThread::PostTaskAndReply( 500 BrowserThread::PostTaskAndReply(
459 BrowserThread::IO, FROM_HERE, 501 BrowserThread::IO, FROM_HERE,
460 base::Bind(&InfoMap::AddExtension, info_map(), 502 base::Bind(&RegisterExtensionHelper, base::RetainedRef(info_map()),
461 base::RetainedRef(extension), install_time, incognito_enabled, 503 base::RetainedRef(extension), install_time, incognito_enabled,
462 notifications_disabled), 504 notifications_disabled, profile_->GetResourceContext()),
463 callback); 505 callback);
464 } 506 }
465 507
466 void ExtensionSystemImpl::UnregisterExtensionWithRequestContexts( 508 void ExtensionSystemImpl::UnregisterExtensionWithRequestContexts(
467 const std::string& extension_id, 509 const std::string& extension_id,
468 const UnloadedExtensionInfo::Reason reason) { 510 const UnloadedExtensionInfo::Reason reason) {
469 BrowserThread::PostTask( 511 BrowserThread::PostTask(
470 BrowserThread::IO, 512 BrowserThread::IO,
471 FROM_HERE, 513 FROM_HERE,
472 base::Bind(&InfoMap::RemoveExtension, info_map(), extension_id, reason)); 514 base::Bind(&UnregisterExtensionHelper, base::RetainedRef(info_map()),
515 extension_id, reason, profile_->GetResourceContext()));
473 } 516 }
474 517
475 } // namespace extensions 518 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698