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

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

Issue 8342048: Make NotificationService an interface in the content namespace, and switch callers to use it. Mov... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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/crx_installer.h" 5 #include "chrome/browser/extensions/crx_installer.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 16 matching lines...) Expand all
27 #include "chrome/browser/extensions/extension_error_reporter.h" 27 #include "chrome/browser/extensions/extension_error_reporter.h"
28 #include "chrome/browser/extensions/extension_service.h" 28 #include "chrome/browser/extensions/extension_service.h"
29 #include "chrome/browser/shell_integration.h" 29 #include "chrome/browser/shell_integration.h"
30 #include "chrome/browser/web_applications/web_app.h" 30 #include "chrome/browser/web_applications/web_app.h"
31 #include "chrome/common/chrome_notification_types.h" 31 #include "chrome/common/chrome_notification_types.h"
32 #include "chrome/common/chrome_paths.h" 32 #include "chrome/common/chrome_paths.h"
33 #include "chrome/common/extensions/extension_constants.h" 33 #include "chrome/common/extensions/extension_constants.h"
34 #include "chrome/common/extensions/extension_file_util.h" 34 #include "chrome/common/extensions/extension_file_util.h"
35 #include "content/browser/browser_thread.h" 35 #include "content/browser/browser_thread.h"
36 #include "content/browser/user_metrics.h" 36 #include "content/browser/user_metrics.h"
37 #include "content/common/notification_service.h" 37 #include "content/public/browser/notification_service.h"
38 #include "grit/chromium_strings.h" 38 #include "grit/chromium_strings.h"
39 #include "grit/generated_resources.h" 39 #include "grit/generated_resources.h"
40 #include "grit/theme_resources.h" 40 #include "grit/theme_resources.h"
41 #include "third_party/skia/include/core/SkBitmap.h" 41 #include "third_party/skia/include/core/SkBitmap.h"
42 #include "ui/base/l10n/l10n_util.h" 42 #include "ui/base/l10n/l10n_util.h"
43 #include "ui/base/resource/resource_bundle.h" 43 #include "ui/base/resource/resource_bundle.h"
44 44
45 namespace { 45 namespace {
46 46
47 struct Whitelist { 47 struct Whitelist {
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 } 437 }
438 438
439 void CrxInstaller::InstallUIAbort(bool user_initiated) { 439 void CrxInstaller::InstallUIAbort(bool user_initiated) {
440 std::string histogram_name = user_initiated ? 440 std::string histogram_name = user_initiated ?
441 "Extensions.Permissions_InstallCancel" : 441 "Extensions.Permissions_InstallCancel" :
442 "Extensions.Permissions_InstallAbort"; 442 "Extensions.Permissions_InstallAbort";
443 ExtensionService::RecordPermissionMessagesHistogram( 443 ExtensionService::RecordPermissionMessagesHistogram(
444 extension_, histogram_name.c_str()); 444 extension_, histogram_name.c_str());
445 445
446 // Kill the theme loading bubble. 446 // Kill the theme loading bubble.
447 NotificationService* service = NotificationService::current(); 447 content::NotificationService* service =
448 content::NotificationService::current();
448 service->Notify(chrome::NOTIFICATION_NO_THEME_DETECTED, 449 service->Notify(chrome::NOTIFICATION_NO_THEME_DETECTED,
449 content::Source<CrxInstaller>(this), 450 content::Source<CrxInstaller>(this),
450 NotificationService::NoDetails()); 451 content::NotificationService::NoDetails());
451 Release(); // balanced in ConfirmInstall(). 452 Release(); // balanced in ConfirmInstall().
452 453
453 NotifyCrxInstallComplete(); 454 NotifyCrxInstallComplete();
454 455
455 // We're done. Since we don't post any more tasks to ourself, our ref count 456 // We're done. Since we don't post any more tasks to ourself, our ref count
456 // should go to zero and we die. The destructor will clean up the temp dir. 457 // should go to zero and we die. The destructor will clean up the temp dir.
457 } 458 }
458 459
459 void CrxInstaller::CompleteInstall() { 460 void CrxInstaller::CompleteInstall() {
460 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 461 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 512 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
512 if (!BrowserThread::PostTask( 513 if (!BrowserThread::PostTask(
513 BrowserThread::UI, FROM_HERE, 514 BrowserThread::UI, FROM_HERE,
514 base::Bind(&CrxInstaller::ReportFailureFromUIThread, this, error))) 515 base::Bind(&CrxInstaller::ReportFailureFromUIThread, this, error)))
515 NOTREACHED(); 516 NOTREACHED();
516 } 517 }
517 518
518 void CrxInstaller::ReportFailureFromUIThread(const std::string& error) { 519 void CrxInstaller::ReportFailureFromUIThread(const std::string& error) {
519 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 520 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
520 521
521 NotificationService* service = NotificationService::current(); 522 content::NotificationService* service =
523 content::NotificationService::current();
522 service->Notify(chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR, 524 service->Notify(chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR,
523 content::Source<CrxInstaller>(this), 525 content::Source<CrxInstaller>(this),
524 content::Details<const std::string>(&error)); 526 content::Details<const std::string>(&error));
525 527
526 // This isn't really necessary, it is only used because unit tests expect to 528 // This isn't really necessary, it is only used because unit tests expect to
527 // see errors get reported via this interface. 529 // see errors get reported via this interface.
528 // 530 //
529 // TODO(aa): Need to go through unit tests and clean them up too, probably get 531 // TODO(aa): Need to go through unit tests and clean them up too, probably get
530 // rid of this line. 532 // rid of this line.
531 ExtensionErrorReporter::GetInstance()->ReportError(error, false); // quiet 533 ExtensionErrorReporter::GetInstance()->ReportError(error, false); // quiet
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 // We're done. We don't post any more tasks to ourselves so we are deleted 589 // We're done. We don't post any more tasks to ourselves so we are deleted
588 // soon. 590 // soon.
589 } 591 }
590 592
591 void CrxInstaller::NotifyCrxInstallComplete() { 593 void CrxInstaller::NotifyCrxInstallComplete() {
592 // Some users (such as the download shelf) need to know when a 594 // Some users (such as the download shelf) need to know when a
593 // CRXInstaller is done. Listening for the EXTENSION_* events 595 // CRXInstaller is done. Listening for the EXTENSION_* events
594 // is problematic because they don't know anything about the 596 // is problematic because they don't know anything about the
595 // extension before it is unpacked, so they can not filter based 597 // extension before it is unpacked, so they can not filter based
596 // on the extension. 598 // on the extension.
597 NotificationService::current()->Notify( 599 content::NotificationService::current()->Notify(
598 chrome::NOTIFICATION_CRX_INSTALLER_DONE, 600 chrome::NOTIFICATION_CRX_INSTALLER_DONE,
599 content::Source<CrxInstaller>(this), 601 content::Source<CrxInstaller>(this),
600 NotificationService::NoDetails()); 602 content::NotificationService::NoDetails());
601 } 603 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/convert_web_app_browsertest.cc ('k') | chrome/browser/extensions/execute_code_in_tab_function.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698