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

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

Issue 1383001: Hook up extension apps notification permission, take two (Closed)
Patch Set: pre commit Created 10 years, 8 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
« no previous file with comments | « no previous file | chrome/browser/net/chrome_url_request_context.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/extensions_service.h" 5 #include "chrome/browser/extensions/extensions_service.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/histogram.h" 10 #include "base/histogram.h"
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 NewRunnableMethod( 571 NewRunnableMethod(
572 backend_.get(), 572 backend_.get(),
573 &ExtensionsServiceBackend::CheckExternalUninstall, 573 &ExtensionsServiceBackend::CheckExternalUninstall,
574 scoped_refptr<ExtensionsService>(this), 574 scoped_refptr<ExtensionsService>(this),
575 info.extension_id, 575 info.extension_id,
576 info.extension_location)); 576 info.extension_location));
577 } 577 }
578 } 578 }
579 579
580 void ExtensionsService::NotifyExtensionLoaded(Extension* extension) { 580 void ExtensionsService::NotifyExtensionLoaded(Extension* extension) {
581 LOG(INFO) << "Sending EXTENSION_LOADED"; 581 // The ChromeURLRequestContexts need to be first to know that the extension
582
583 // The ChromeURLRequestContext needs to be first to know that the extension
584 // was loaded, otherwise a race can arise where a renderer that is created 582 // was loaded, otherwise a race can arise where a renderer that is created
585 // for the extension may try to load an extension URL with an extension id 583 // for the extension may try to load an extension URL with an extension id
586 // that the request context doesn't yet know about. 584 // that the request context doesn't yet know about. The profile is responsible
587 if (profile_ && !profile_->IsOffTheRecord()) { 585 // for ensuring its URLRequestContexts appropriately discover the loaded
588 ChromeURLRequestContextGetter* context_getter = 586 // extension.
589 static_cast<ChromeURLRequestContextGetter*>( 587 if (profile_) {
590 profile_->GetRequestContext()); 588 profile_->RegisterExtensionWithRequestContexts(extension);
591 if (context_getter) {
592 ChromeThread::PostTask(
593 ChromeThread::IO, FROM_HERE,
594 NewRunnableMethod(
595 context_getter,
596 &ChromeURLRequestContextGetter::OnNewExtensions,
597 extension->id(),
598 new ChromeURLRequestContext::ExtensionInfo(
599 extension->path(),
600 extension->default_locale(),
601 std::vector<URLPattern>(),
602 extension->api_permissions())));
603 }
604 589
605 // Check if this permission requires unlimited storage quota 590 // Check if this permission requires unlimited storage quota
606 if (extension->HasApiPermission(Extension::kUnlimitedStoragePermission)) { 591 if (extension->HasApiPermission(Extension::kUnlimitedStoragePermission)) {
607 string16 origin_identifier = 592 string16 origin_identifier =
608 webkit_database::DatabaseUtil::GetOriginIdentifier(extension->url()); 593 webkit_database::DatabaseUtil::GetOriginIdentifier(extension->url());
609 ChromeThread::PostTask( 594 ChromeThread::PostTask(
610 ChromeThread::FILE, FROM_HERE, 595 ChromeThread::FILE, FROM_HERE,
611 NewRunnableMethod( 596 NewRunnableMethod(
612 profile_->GetDatabaseTracker(), 597 profile_->GetDatabaseTracker(),
613 &webkit_database::DatabaseTracker::SetOriginQuotaInMemory, 598 &webkit_database::DatabaseTracker::SetOriginQuotaInMemory,
614 origin_identifier, 599 origin_identifier,
615 kint64max)); 600 kint64max));
616 } 601 }
617 } 602 }
618 603
604 LOG(INFO) << "Sending EXTENSION_LOADED";
605
619 NotificationService::current()->Notify( 606 NotificationService::current()->Notify(
620 NotificationType::EXTENSION_LOADED, 607 NotificationType::EXTENSION_LOADED,
621 Source<Profile>(profile_), 608 Source<Profile>(profile_),
622 Details<Extension>(extension)); 609 Details<Extension>(extension));
623 } 610 }
624 611
625 void ExtensionsService::NotifyExtensionUnloaded(Extension* extension) { 612 void ExtensionsService::NotifyExtensionUnloaded(Extension* extension) {
626 LOG(INFO) << "Sending EXTENSION_UNLOADED"; 613 LOG(INFO) << "Sending EXTENSION_UNLOADED";
627 614
628 NotificationService::current()->Notify( 615 NotificationService::current()->Notify(
629 NotificationType::EXTENSION_UNLOADED, 616 NotificationType::EXTENSION_UNLOADED,
630 Source<Profile>(profile_), 617 Source<Profile>(profile_),
631 Details<Extension>(extension)); 618 Details<Extension>(extension));
632 619
633 if (profile_ && !profile_->IsOffTheRecord()) { 620 if (profile_) {
634 ChromeURLRequestContextGetter* context_getter = 621 profile_->UnregisterExtensionWithRequestContexts(extension);
635 static_cast<ChromeURLRequestContextGetter*>( 622
636 profile_->GetRequestContext()); 623 // Check if this permission required unlimited storage quota, reset its
637 if (context_getter) { 624 // in-memory quota.
625 if (extension->HasApiPermission(Extension::kUnlimitedStoragePermission)) {
626 string16 origin_identifier =
627 webkit_database::DatabaseUtil::GetOriginIdentifier(extension->url());
638 ChromeThread::PostTask( 628 ChromeThread::PostTask(
639 ChromeThread::IO, FROM_HERE, 629 ChromeThread::FILE, FROM_HERE,
640 NewRunnableMethod( 630 NewRunnableMethod(
641 context_getter, 631 profile_->GetDatabaseTracker(),
642 &ChromeURLRequestContextGetter::OnUnloadedExtension, 632 &webkit_database::DatabaseTracker::ResetOriginQuotaInMemory,
643 extension->id())); 633 origin_identifier));
644 } 634 }
645 } 635 }
646 } 636 }
647 637
648 void ExtensionsService::UpdateExtensionBlacklist( 638 void ExtensionsService::UpdateExtensionBlacklist(
649 const std::vector<std::string>& blacklist) { 639 const std::vector<std::string>& blacklist) {
650 // Use this set to indicate if an extension in the blacklist has been used. 640 // Use this set to indicate if an extension in the blacklist has been used.
651 std::set<std::string> blacklist_set; 641 std::set<std::string> blacklist_set;
652 for (unsigned int i = 0; i < blacklist.size(); ++i) { 642 for (unsigned int i = 0; i < blacklist.size(); ++i) {
653 if (Extension::IdIsValid(blacklist[i])) { 643 if (Extension::IdIsValid(blacklist[i])) {
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
1247 // Finish installing on UI thread. 1237 // Finish installing on UI thread.
1248 ChromeThread::PostTask( 1238 ChromeThread::PostTask(
1249 ChromeThread::UI, FROM_HERE, 1239 ChromeThread::UI, FROM_HERE,
1250 NewRunnableMethod( 1240 NewRunnableMethod(
1251 frontend_, 1241 frontend_,
1252 &ExtensionsService::ContinueLoadAllExtensions, 1242 &ExtensionsService::ContinueLoadAllExtensions,
1253 extensions_to_reload, 1243 extensions_to_reload,
1254 start_time, 1244 start_time,
1255 true)); 1245 true));
1256 } 1246 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/net/chrome_url_request_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698