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/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 26 matching lines...) Expand all Loading... |
37 #include "content/public/browser/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 // TODO(jstritar): This whitelist is not profile aware. We should move this to |
| 48 // WebstorePendingInstalls. |
47 struct Whitelist { | 49 struct Whitelist { |
48 Whitelist() {} | 50 Whitelist() {} |
49 std::set<std::string> ids; | 51 std::set<std::string> ids; |
50 std::map<std::string, linked_ptr<CrxInstaller::WhitelistEntry> > entries; | 52 std::map<std::string, linked_ptr<CrxInstaller::WhitelistEntry> > entries; |
51 }; | 53 }; |
52 | 54 |
53 static base::LazyInstance<Whitelist> | 55 static base::LazyInstance<Whitelist> |
54 g_whitelisted_install_data(base::LINKER_INITIALIZED); | 56 g_whitelisted_install_data(base::LINKER_INITIALIZED); |
55 | 57 |
56 } // namespace | 58 } // namespace |
57 | 59 |
58 CrxInstaller::WhitelistEntry::WhitelistEntry() | 60 CrxInstaller::WhitelistEntry::WhitelistEntry() |
59 : use_app_installed_bubble(false) {} | 61 : use_app_installed_bubble(false), |
| 62 skip_post_install_ui(false) {} |
60 CrxInstaller::WhitelistEntry::~WhitelistEntry() {} | 63 CrxInstaller::WhitelistEntry::~WhitelistEntry() {} |
61 | 64 |
62 // static | 65 // static |
63 void CrxInstaller::SetWhitelistedInstallId(const std::string& id) { | 66 void CrxInstaller::SetWhitelistedInstallId(const std::string& id) { |
64 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 67 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
65 g_whitelisted_install_data.Get().ids.insert(id); | 68 g_whitelisted_install_data.Get().ids.insert(id); |
66 } | 69 } |
67 | 70 |
68 // static | 71 // static |
69 void CrxInstaller::SetWhitelistEntry(const std::string& id, | 72 void CrxInstaller::SetWhitelistEntry(const std::string& id, |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 RemoveWhitelistEntry(extension_->id())); | 410 RemoveWhitelistEntry(extension_->id())); |
408 if (is_gallery_install_ && entry.get() && original_manifest_.get()) { | 411 if (is_gallery_install_ && entry.get() && original_manifest_.get()) { |
409 if (!(original_manifest_->Equals(entry->parsed_manifest.get()))) { | 412 if (!(original_manifest_->Equals(entry->parsed_manifest.get()))) { |
410 ReportFailureFromUIThread( | 413 ReportFailureFromUIThread( |
411 l10n_util::GetStringUTF8(IDS_EXTENSION_MANIFEST_INVALID)); | 414 l10n_util::GetStringUTF8(IDS_EXTENSION_MANIFEST_INVALID)); |
412 return; | 415 return; |
413 } | 416 } |
414 whitelisted = true; | 417 whitelisted = true; |
415 if (entry->use_app_installed_bubble) | 418 if (entry->use_app_installed_bubble) |
416 client_->set_use_app_installed_bubble(true); | 419 client_->set_use_app_installed_bubble(true); |
| 420 if (entry->skip_post_install_ui) |
| 421 client_->set_skip_post_install_ui(true); |
417 } | 422 } |
418 | 423 |
419 if (client_ && | 424 if (client_ && |
420 (!allow_silent_install_ || !whitelisted)) { | 425 (!allow_silent_install_ || !whitelisted)) { |
421 AddRef(); // Balanced in Proceed() and Abort(). | 426 AddRef(); // Balanced in Proceed() and Abort(). |
422 client_->ConfirmInstall(this, extension_.get()); | 427 client_->ConfirmInstall(this, extension_.get()); |
423 } else { | 428 } else { |
424 if (!BrowserThread::PostTask( | 429 if (!BrowserThread::PostTask( |
425 BrowserThread::FILE, FROM_HERE, | 430 BrowserThread::FILE, FROM_HERE, |
426 base::Bind(&CrxInstaller::CompleteInstall, this))) | 431 base::Bind(&CrxInstaller::CompleteInstall, this))) |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 // Some users (such as the download shelf) need to know when a | 601 // Some users (such as the download shelf) need to know when a |
597 // CRXInstaller is done. Listening for the EXTENSION_* events | 602 // CRXInstaller is done. Listening for the EXTENSION_* events |
598 // is problematic because they don't know anything about the | 603 // is problematic because they don't know anything about the |
599 // extension before it is unpacked, so they can not filter based | 604 // extension before it is unpacked, so they can not filter based |
600 // on the extension. | 605 // on the extension. |
601 content::NotificationService::current()->Notify( | 606 content::NotificationService::current()->Notify( |
602 chrome::NOTIFICATION_CRX_INSTALLER_DONE, | 607 chrome::NOTIFICATION_CRX_INSTALLER_DONE, |
603 content::Source<CrxInstaller>(this), | 608 content::Source<CrxInstaller>(this), |
604 content::NotificationService::NoDetails()); | 609 content::NotificationService::NoDetails()); |
605 } | 610 } |
OLD | NEW |