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

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

Issue 7574017: 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 // Unpacked extensions default to allowing file access, but if that has been 307 bool allow_file_access = frontend_->extension_prefs()->AllowFileAccess(id);
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);
313 308
314 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 309 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
315 NewRunnableMethod( 310 NewRunnableMethod(
316 this, 311 this,
317 &ExtensionServiceBackend::LoadSingleExtensionWithFileAccess, 312 &ExtensionServiceBackend::LoadSingleExtensionWithFileAccess,
318 extension_path, allow_file_access, prompt_for_plugins)); 313 extension_path, allow_file_access, prompt_for_plugins));
319 } 314 }
320 315
321 void ExtensionServiceBackend::LoadSingleExtensionWithFileAccess( 316 void ExtensionServiceBackend::LoadSingleExtensionWithFileAccess(
322 const FilePath& extension_path, 317 const FilePath& extension_path,
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 const FilePath& path_in) { 1022 const FilePath& path_in) {
1028 1023
1029 // Load extensions from the command line synchronously to avoid a race 1024 // Load extensions from the command line synchronously to avoid a race
1030 // between extension loading and loading an URL from the command line. 1025 // between extension loading and loading an URL from the command line.
1031 base::ThreadRestrictions::ScopedAllowIO allow_io; 1026 base::ThreadRestrictions::ScopedAllowIO allow_io;
1032 1027
1033 FilePath extension_path = path_in; 1028 FilePath extension_path = path_in;
1034 file_util::AbsolutePath(&extension_path); 1029 file_util::AbsolutePath(&extension_path);
1035 1030
1036 std::string id = Extension::GenerateIdForPath(extension_path); 1031 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);
1041 1032
1042 int flags = Extension::NO_FLAGS; 1033 int flags = Extension::NO_FLAGS;
1043 if (allow_file_access) 1034 if (extension_prefs()->AllowFileAccess(id))
1044 flags |= Extension::ALLOW_FILE_ACCESS; 1035 flags |= Extension::ALLOW_FILE_ACCESS;
1045 if (Extension::ShouldDoStrictErrorChecking(Extension::LOAD)) 1036 if (Extension::ShouldDoStrictErrorChecking(Extension::LOAD))
1046 flags |= Extension::STRICT_ERROR_CHECKS; 1037 flags |= Extension::STRICT_ERROR_CHECKS;
1047 1038
1048 std::string error; 1039 std::string error;
1049 scoped_refptr<const Extension> extension(extension_file_util::LoadExtension( 1040 scoped_refptr<const Extension> extension(extension_file_util::LoadExtension(
1050 extension_path, 1041 extension_path,
1051 Extension::LOAD, 1042 Extension::LOAD,
1052 flags, 1043 flags,
1053 &error)); 1044 &error));
(...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after
2198 RecordPermissionMessagesHistogram( 2189 RecordPermissionMessagesHistogram(
2199 extension, "Extensions.Permissions_Install"); 2190 extension, "Extensions.Permissions_Install");
2200 } 2191 }
2201 2192
2202 ShownSectionsHandler::OnExtensionInstalled(profile_->GetPrefs(), extension); 2193 ShownSectionsHandler::OnExtensionInstalled(profile_->GetPrefs(), extension);
2203 extension_prefs_->OnExtensionInstalled( 2194 extension_prefs_->OnExtensionInstalled(
2204 extension, 2195 extension,
2205 initial_enable ? Extension::ENABLED : Extension::DISABLED, 2196 initial_enable ? Extension::ENABLED : Extension::DISABLED,
2206 from_webstore); 2197 from_webstore);
2207 2198
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);
asargent_no_longer_on_chrome 2011/08/04 21:56:03 Ah, I guess this is the actual location of the bug
jstritar 2011/08/05 15:13:29 Yep. The ShouldAlwaysAllowFileAccess method seemed
2213 }
2214
2215 NotificationService::current()->Notify( 2199 NotificationService::current()->Notify(
2216 chrome::NOTIFICATION_EXTENSION_INSTALLED, 2200 chrome::NOTIFICATION_EXTENSION_INSTALLED,
2217 Source<Profile>(profile_), 2201 Source<Profile>(profile_),
2218 Details<const Extension>(extension)); 2202 Details<const Extension>(extension));
2219 2203
2220 // Transfer ownership of |extension| to AddExtension. 2204 // Transfer ownership of |extension| to AddExtension.
2221 AddExtension(scoped_extension); 2205 AddExtension(scoped_extension);
2222 } 2206 }
2223 2207
2224 const Extension* ExtensionService::GetExtensionByIdInternal( 2208 const Extension* ExtensionService::GetExtensionByIdInternal(
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
2581 2565
2582 ExtensionService::NaClModuleInfoList::iterator 2566 ExtensionService::NaClModuleInfoList::iterator
2583 ExtensionService::FindNaClModule(const GURL& url) { 2567 ExtensionService::FindNaClModule(const GURL& url) {
2584 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); 2568 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin();
2585 iter != nacl_module_list_.end(); ++iter) { 2569 iter != nacl_module_list_.end(); ++iter) {
2586 if (iter->url == url) 2570 if (iter->url == url)
2587 return iter; 2571 return iter;
2588 } 2572 }
2589 return nacl_module_list_.end(); 2573 return nacl_module_list_.end();
2590 } 2574 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698