| OLD | NEW |
| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 #include "chrome/browser/extensions/external_extension_provider_impl.h" | 57 #include "chrome/browser/extensions/external_extension_provider_impl.h" |
| 58 #include "chrome/browser/extensions/external_extension_provider_interface.h" | 58 #include "chrome/browser/extensions/external_extension_provider_interface.h" |
| 59 #include "chrome/browser/extensions/installed_loader.h" | 59 #include "chrome/browser/extensions/installed_loader.h" |
| 60 #include "chrome/browser/extensions/pending_extension_manager.h" | 60 #include "chrome/browser/extensions/pending_extension_manager.h" |
| 61 #include "chrome/browser/extensions/settings/settings_frontend.h" | 61 #include "chrome/browser/extensions/settings/settings_frontend.h" |
| 62 #include "chrome/browser/extensions/unpacked_installer.h" | 62 #include "chrome/browser/extensions/unpacked_installer.h" |
| 63 #include "chrome/browser/history/history_extension_api.h" | 63 #include "chrome/browser/history/history_extension_api.h" |
| 64 #include "chrome/browser/net/chrome_url_request_context.h" | 64 #include "chrome/browser/net/chrome_url_request_context.h" |
| 65 #include "chrome/browser/prefs/pref_service.h" | 65 #include "chrome/browser/prefs/pref_service.h" |
| 66 #include "chrome/browser/profiles/profile.h" | 66 #include "chrome/browser/profiles/profile.h" |
| 67 #include "chrome/browser/profiles/profile_manager.h" |
| 67 #include "chrome/browser/search_engines/template_url_service.h" | 68 #include "chrome/browser/search_engines/template_url_service.h" |
| 68 #include "chrome/browser/search_engines/template_url_service_factory.h" | 69 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 69 #include "chrome/browser/sync/api/sync_change.h" | 70 #include "chrome/browser/sync/api/sync_change.h" |
| 70 #include "chrome/browser/themes/theme_service.h" | 71 #include "chrome/browser/themes/theme_service.h" |
| 71 #include "chrome/browser/themes/theme_service_factory.h" | 72 #include "chrome/browser/themes/theme_service_factory.h" |
| 72 #include "chrome/browser/ui/browser.h" | 73 #include "chrome/browser/ui/browser.h" |
| 73 #include "chrome/browser/ui/browser_list.h" | 74 #include "chrome/browser/ui/browser_list.h" |
| 74 #include "chrome/browser/ui/global_error_service.h" | 75 #include "chrome/browser/ui/global_error_service.h" |
| 75 #include "chrome/browser/ui/global_error_service_factory.h" | 76 #include "chrome/browser/ui/global_error_service_factory.h" |
| 76 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 77 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 // provide the IO thread message loop needed for those sockets to do their | 487 // provide the IO thread message loop needed for those sockets to do their |
| 487 // job (including destroying themselves at shutdown). | 488 // job (including destroying themselves at shutdown). |
| 488 DCHECK(BrowserThread::IsMessageLoopValid(BrowserThread::IO)); | 489 DCHECK(BrowserThread::IsMessageLoopValid(BrowserThread::IO)); |
| 489 BrowserThread::PostTask( | 490 BrowserThread::PostTask( |
| 490 BrowserThread::IO, FROM_HERE, | 491 BrowserThread::IO, FROM_HERE, |
| 491 new DeleteTask<extensions::SocketController>(socket_controller_)); | 492 new DeleteTask<extensions::SocketController>(socket_controller_)); |
| 492 } | 493 } |
| 493 } | 494 } |
| 494 | 495 |
| 495 void ExtensionService::InitEventRoutersAfterImport() { | 496 void ExtensionService::InitEventRoutersAfterImport() { |
| 496 registrar_.Add(this, chrome::NOTIFICATION_IMPORT_FINISHED, | 497 RegisterForImportFinished(); |
| 497 content::Source<Profile>(profile_)); | 498 } |
| 499 |
| 500 void ExtensionService::RegisterForImportFinished() { |
| 501 if (!registrar_.IsRegistered(this, chrome::NOTIFICATION_IMPORT_FINISHED, |
| 502 content::Source<Profile>(profile_))) { |
| 503 registrar_.Add(this, chrome::NOTIFICATION_IMPORT_FINISHED, |
| 504 content::Source<Profile>(profile_)); |
| 505 } |
| 506 } |
| 507 |
| 508 void ExtensionService::InitAfterImport() { |
| 509 CheckForExternalUpdates(); |
| 510 |
| 511 GarbageCollectExtensions(); |
| 512 |
| 513 // Idempotent, so although there is a possible race if the import |
| 514 // process finished sometime in the middle of ProfileImpl::InitExtensions, |
| 515 // it cannot happen twice. |
| 516 InitEventRouters(); |
| 498 } | 517 } |
| 499 | 518 |
| 500 void ExtensionService::InitEventRouters() { | 519 void ExtensionService::InitEventRouters() { |
| 501 if (event_routers_initialized_) | 520 if (event_routers_initialized_) |
| 502 return; | 521 return; |
| 503 | 522 |
| 504 downloads_event_router_.reset(new ExtensionDownloadsEventRouter(profile_)); | 523 downloads_event_router_.reset(new ExtensionDownloadsEventRouter(profile_)); |
| 505 history_event_router_.reset(new HistoryExtensionEventRouter()); | 524 history_event_router_.reset(new HistoryExtensionEventRouter()); |
| 506 history_event_router_->ObserveProfile(profile_); | 525 history_event_router_->ObserveProfile(profile_); |
| 507 browser_event_router_.reset(new ExtensionBrowserEventRouter(profile_)); | 526 browser_event_router_.reset(new ExtensionBrowserEventRouter(profile_)); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 component_loader_->LoadAll(); | 575 component_loader_->LoadAll(); |
| 557 extensions::InstalledLoader(this).LoadAllExtensions(); | 576 extensions::InstalledLoader(this).LoadAllExtensions(); |
| 558 | 577 |
| 559 // If we are running in the import process, don't bother initializing the | 578 // If we are running in the import process, don't bother initializing the |
| 560 // extension service since this can interfere with the main browser process | 579 // extension service since this can interfere with the main browser process |
| 561 // that is already running an extension service for this profile. | 580 // that is already running an extension service for this profile. |
| 562 // TODO(aa): can we start up even less of ExtensionService? | 581 // TODO(aa): can we start up even less of ExtensionService? |
| 563 // http://crbug.com/107636 | 582 // http://crbug.com/107636 |
| 564 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kImport) && | 583 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kImport) && |
| 565 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kImportFromFile)) { | 584 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kImportFromFile)) { |
| 566 // TODO(erikkay) this should probably be deferred to a future point | 585 if (g_browser_process->profile_manager() && |
| 567 // rather than running immediately at startup. | 586 g_browser_process->profile_manager()->will_import()) { |
| 568 CheckForExternalUpdates(); | 587 RegisterForImportFinished(); |
| 588 } else { |
| 589 // TODO(erikkay) this should probably be deferred to a future point |
| 590 // rather than running immediately at startup. |
| 591 CheckForExternalUpdates(); |
| 569 | 592 |
| 570 // TODO(erikkay) this should probably be deferred as well. | 593 // TODO(erikkay) this should probably be deferred as well. |
| 571 GarbageCollectExtensions(); | 594 GarbageCollectExtensions(); |
| 595 } |
| 572 } | 596 } |
| 573 } | 597 } |
| 574 | 598 |
| 575 bool ExtensionService::UpdateExtension( | 599 bool ExtensionService::UpdateExtension( |
| 576 const std::string& id, | 600 const std::string& id, |
| 577 const FilePath& extension_path, | 601 const FilePath& extension_path, |
| 578 const GURL& download_url, | 602 const GURL& download_url, |
| 579 CrxInstaller** out_crx_installer) { | 603 CrxInstaller** out_crx_installer) { |
| 580 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 604 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 581 | 605 |
| (...skipping 1857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2439 std::string* pref_name = content::Details<std::string>(details).ptr(); | 2463 std::string* pref_name = content::Details<std::string>(details).ptr(); |
| 2440 if (*pref_name == prefs::kExtensionInstallAllowList || | 2464 if (*pref_name == prefs::kExtensionInstallAllowList || |
| 2441 *pref_name == prefs::kExtensionInstallDenyList) { | 2465 *pref_name == prefs::kExtensionInstallDenyList) { |
| 2442 CheckAdminBlacklist(); | 2466 CheckAdminBlacklist(); |
| 2443 } else { | 2467 } else { |
| 2444 NOTREACHED() << "Unexpected preference name."; | 2468 NOTREACHED() << "Unexpected preference name."; |
| 2445 } | 2469 } |
| 2446 break; | 2470 break; |
| 2447 } | 2471 } |
| 2448 case chrome::NOTIFICATION_IMPORT_FINISHED: { | 2472 case chrome::NOTIFICATION_IMPORT_FINISHED: { |
| 2449 registrar_.Remove(this, chrome::NOTIFICATION_IMPORT_FINISHED, | 2473 InitAfterImport(); |
| 2450 content::Source<Profile>(profile_)); | |
| 2451 InitEventRouters(); | |
| 2452 break; | 2474 break; |
| 2453 } | 2475 } |
| 2454 | 2476 |
| 2455 default: | 2477 default: |
| 2456 NOTREACHED() << "Unexpected notification type."; | 2478 NOTREACHED() << "Unexpected notification type."; |
| 2457 } | 2479 } |
| 2458 } | 2480 } |
| 2459 | 2481 |
| 2460 bool ExtensionService::HasApps() const { | 2482 bool ExtensionService::HasApps() const { |
| 2461 return !GetAppIds().empty(); | 2483 return !GetAppIds().empty(); |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2642 // | 2664 // |
| 2643 // To coexist with certain unit tests that don't have an IO thread message | 2665 // To coexist with certain unit tests that don't have an IO thread message |
| 2644 // loop available at ExtensionService shutdown, we lazy-initialize this | 2666 // loop available at ExtensionService shutdown, we lazy-initialize this |
| 2645 // object so that those cases neither create nor destroy a SocketController. | 2667 // object so that those cases neither create nor destroy a SocketController. |
| 2646 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 2668 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 2647 if (!socket_controller_) { | 2669 if (!socket_controller_) { |
| 2648 socket_controller_ = new extensions::SocketController(); | 2670 socket_controller_ = new extensions::SocketController(); |
| 2649 } | 2671 } |
| 2650 return socket_controller_; | 2672 return socket_controller_; |
| 2651 } | 2673 } |
| OLD | NEW |