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

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

Issue 7595005: Revert 95815 - Make extension file URL access opt-in. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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 | Annotate | Revision Log
OLDNEW
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/extensions/extension_service.h" 5 #include "chrome/browser/extensions/extension_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 297 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
298 NewRunnableMethod(this, 298 NewRunnableMethod(this,
299 &ExtensionServiceBackend::CheckExtensionFileAccess, 299 &ExtensionServiceBackend::CheckExtensionFileAccess,
300 extension_path, prompt_for_plugins)); 300 extension_path, prompt_for_plugins));
301 } 301 }
302 302
303 void ExtensionServiceBackend::CheckExtensionFileAccess( 303 void ExtensionServiceBackend::CheckExtensionFileAccess(
304 const FilePath& extension_path, bool prompt_for_plugins) { 304 const FilePath& extension_path, bool prompt_for_plugins) {
305 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 305 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
306 std::string id = Extension::GenerateIdForPath(extension_path); 306 std::string id = Extension::GenerateIdForPath(extension_path);
307 bool allow_file_access = frontend_->extension_prefs()->AllowFileAccess(id); 307 // Unpacked extensions default to allowing file access, but if that has been
308 // overridden, don't reset the value.
309 bool allow_file_access =
310 Extension::ShouldAlwaysAllowFileAccess(Extension::LOAD);
311 if (frontend_->extension_prefs()->HasAllowFileAccessSetting(id))
312 allow_file_access = frontend_->extension_prefs()->AllowFileAccess(id);
308 313
309 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 314 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
310 NewRunnableMethod( 315 NewRunnableMethod(
311 this, 316 this,
312 &ExtensionServiceBackend::LoadSingleExtensionWithFileAccess, 317 &ExtensionServiceBackend::LoadSingleExtensionWithFileAccess,
313 extension_path, allow_file_access, prompt_for_plugins)); 318 extension_path, allow_file_access, prompt_for_plugins));
314 } 319 }
315 320
316 void ExtensionServiceBackend::LoadSingleExtensionWithFileAccess( 321 void ExtensionServiceBackend::LoadSingleExtensionWithFileAccess(
317 const FilePath& extension_path, 322 const FilePath& extension_path,
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 const FilePath& path_in) { 1027 const FilePath& path_in) {
1023 1028
1024 // Load extensions from the command line synchronously to avoid a race 1029 // Load extensions from the command line synchronously to avoid a race
1025 // between extension loading and loading an URL from the command line. 1030 // between extension loading and loading an URL from the command line.
1026 base::ThreadRestrictions::ScopedAllowIO allow_io; 1031 base::ThreadRestrictions::ScopedAllowIO allow_io;
1027 1032
1028 FilePath extension_path = path_in; 1033 FilePath extension_path = path_in;
1029 file_util::AbsolutePath(&extension_path); 1034 file_util::AbsolutePath(&extension_path);
1030 1035
1031 std::string id = Extension::GenerateIdForPath(extension_path); 1036 std::string id = Extension::GenerateIdForPath(extension_path);
1037 bool allow_file_access =
1038 Extension::ShouldAlwaysAllowFileAccess(Extension::LOAD);
1039 if (extension_prefs()->HasAllowFileAccessSetting(id))
1040 allow_file_access = extension_prefs()->AllowFileAccess(id);
1032 1041
1033 int flags = Extension::NO_FLAGS; 1042 int flags = Extension::NO_FLAGS;
1034 if (extension_prefs()->AllowFileAccess(id)) 1043 if (allow_file_access)
1035 flags |= Extension::ALLOW_FILE_ACCESS; 1044 flags |= Extension::ALLOW_FILE_ACCESS;
1036 if (Extension::ShouldDoStrictErrorChecking(Extension::LOAD)) 1045 if (Extension::ShouldDoStrictErrorChecking(Extension::LOAD))
1037 flags |= Extension::STRICT_ERROR_CHECKS; 1046 flags |= Extension::STRICT_ERROR_CHECKS;
1038 1047
1039 std::string error; 1048 std::string error;
1040 scoped_refptr<const Extension> extension(extension_file_util::LoadExtension( 1049 scoped_refptr<const Extension> extension(extension_file_util::LoadExtension(
1041 extension_path, 1050 extension_path,
1042 Extension::LOAD, 1051 Extension::LOAD,
1043 flags, 1052 flags,
1044 &error)); 1053 &error));
(...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after
2189 RecordPermissionMessagesHistogram( 2198 RecordPermissionMessagesHistogram(
2190 extension, "Extensions.Permissions_Install"); 2199 extension, "Extensions.Permissions_Install");
2191 } 2200 }
2192 2201
2193 ShownSectionsHandler::OnExtensionInstalled(profile_->GetPrefs(), extension); 2202 ShownSectionsHandler::OnExtensionInstalled(profile_->GetPrefs(), extension);
2194 extension_prefs_->OnExtensionInstalled( 2203 extension_prefs_->OnExtensionInstalled(
2195 extension, 2204 extension,
2196 initial_enable ? Extension::ENABLED : Extension::DISABLED, 2205 initial_enable ? Extension::ENABLED : Extension::DISABLED,
2197 from_webstore); 2206 from_webstore);
2198 2207
2208 // Unpacked extensions default to allowing file access, but if that has been
2209 // overridden, don't reset the value.
2210 if (Extension::ShouldAlwaysAllowFileAccess(Extension::LOAD) &&
2211 !extension_prefs_->HasAllowFileAccessSetting(id)) {
2212 extension_prefs_->SetAllowFileAccess(id, true);
2213 }
2214
2199 NotificationService::current()->Notify( 2215 NotificationService::current()->Notify(
2200 chrome::NOTIFICATION_EXTENSION_INSTALLED, 2216 chrome::NOTIFICATION_EXTENSION_INSTALLED,
2201 Source<Profile>(profile_), 2217 Source<Profile>(profile_),
2202 Details<const Extension>(extension)); 2218 Details<const Extension>(extension));
2203 2219
2204 // Transfer ownership of |extension| to AddExtension. 2220 // Transfer ownership of |extension| to AddExtension.
2205 AddExtension(scoped_extension); 2221 AddExtension(scoped_extension);
2206 } 2222 }
2207 2223
2208 const Extension* ExtensionService::GetExtensionByIdInternal( 2224 const Extension* ExtensionService::GetExtensionByIdInternal(
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
2565 2581
2566 ExtensionService::NaClModuleInfoList::iterator 2582 ExtensionService::NaClModuleInfoList::iterator
2567 ExtensionService::FindNaClModule(const GURL& url) { 2583 ExtensionService::FindNaClModule(const GURL& url) {
2568 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); 2584 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin();
2569 iter != nacl_module_list_.end(); ++iter) { 2585 iter != nacl_module_list_.end(); ++iter) {
2570 if (iter->url == url) 2586 if (iter->url == url)
2571 return iter; 2587 return iter;
2572 } 2588 }
2573 return nacl_module_list_.end(); 2589 return nacl_module_list_.end();
2574 } 2590 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_prefs.cc ('k') | chrome/browser/extensions/extension_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698