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

Side by Side Diff: chrome/browser/download/chrome_download_manager_delegate.cc

Issue 10452009: Improve the UI for disabling off-store extension install. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/download/chrome_download_manager_delegate.h" 5 #include "chrome/browser/download/chrome_download_manager_delegate.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 bool ChromeDownloadManagerDelegate::ShouldCompleteDownload( 294 bool ChromeDownloadManagerDelegate::ShouldCompleteDownload(
295 DownloadItem* item, 295 DownloadItem* item,
296 const base::Closure& user_complete_callback) { 296 const base::Closure& user_complete_callback) {
297 return IsDownloadReadyForCompletion(item, base::Bind( 297 return IsDownloadReadyForCompletion(item, base::Bind(
298 &ChromeDownloadManagerDelegate::ShouldCompleteDownloadInternal, this, 298 &ChromeDownloadManagerDelegate::ShouldCompleteDownloadInternal, this,
299 item->GetId(), user_complete_callback)); 299 item->GetId(), user_complete_callback));
300 } 300 }
301 301
302 bool ChromeDownloadManagerDelegate::ShouldOpenDownload(DownloadItem* item) { 302 bool ChromeDownloadManagerDelegate::ShouldOpenDownload(DownloadItem* item) {
303 if (IsExtensionDownload(item)) { 303 if (IsExtensionDownload(item)) {
304 // We can open extensions if either they came from the store, or 304 scoped_refptr<CrxInstaller> crx_installer =
305 // off-store-install is enabled. 305 download_crx_util::OpenChromeExtension(profile_, *item);
306 if (extensions::switch_utils::IsOffStoreInstallEnabled() ||
Aaron Boodman 2012/05/24 09:08:53 Removing this allows us to get further into the in
307 WebstoreInstaller::GetAssociatedApproval(*item)) {
308 scoped_refptr<CrxInstaller> crx_installer =
309 download_crx_util::OpenChromeExtension(profile_, *item);
310 306
311 // CRX_INSTALLER_DONE will fire when the install completes. Observe() 307 // CRX_INSTALLER_DONE will fire when the install completes. Observe()
312 // will call DelayedDownloadOpened() on this item. If this DownloadItem 308 // will call DelayedDownloadOpened() on this item. If this DownloadItem
313 // is not around when CRX_INSTALLER_DONE fires, Complete() will not be 309 // is not around when CRX_INSTALLER_DONE fires, Complete() will not be
314 // called. 310 // called.
315 registrar_.Add(this, 311 registrar_.Add(this,
316 chrome::NOTIFICATION_CRX_INSTALLER_DONE, 312 chrome::NOTIFICATION_CRX_INSTALLER_DONE,
317 content::Source<CrxInstaller>(crx_installer.get())); 313 content::Source<CrxInstaller>(crx_installer.get()));
318 314
319 crx_installers_[crx_installer.get()] = item->GetId(); 315 crx_installers_[crx_installer.get()] = item->GetId();
320 // The status text and percent complete indicator will change now 316 // The status text and percent complete indicator will change now
321 // that we are installing a CRX. Update observers so that they pick 317 // that we are installing a CRX. Update observers so that they pick
322 // up the change. 318 // up the change.
323 item->UpdateObservers(); 319 item->UpdateObservers();
324 return false; 320 return false;
325 }
326 } 321 }
327 322
328 if (ShouldOpenWithWebIntents(item)) { 323 if (ShouldOpenWithWebIntents(item)) {
329 OpenWithWebIntent(item); 324 OpenWithWebIntent(item);
330 item->DelayedDownloadOpened(); 325 item->DelayedDownloadOpened();
331 return false; 326 return false;
332 } 327 }
333 328
334 return true; 329 return true;
335 } 330 }
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 const DownloadStateInfo& state, 731 const DownloadStateInfo& state,
737 bool visited_referrer_before) { 732 bool visited_referrer_before) {
738 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 733 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
739 734
740 // Anything loaded directly from the address bar is OK. 735 // Anything loaded directly from the address bar is OK.
741 if (state.transition_type & content::PAGE_TRANSITION_FROM_ADDRESS_BAR) 736 if (state.transition_type & content::PAGE_TRANSITION_FROM_ADDRESS_BAR)
742 return false; 737 return false;
743 738
744 // Extensions that are not from the gallery are considered dangerous. 739 // Extensions that are not from the gallery are considered dangerous.
745 // When off-store install is disabled we skip this, since in this case, we 740 // When off-store install is disabled we skip this, since in this case, we
746 // will not offer to install the extension. 741 // will cancel the install later.
747 if (extensions::switch_utils::IsOffStoreInstallEnabled() && 742 if (extensions::switch_utils::IsOffStoreInstallEnabled() &&
748 IsExtensionDownload(&download) && 743 IsExtensionDownload(&download) &&
749 !WebstoreInstaller::GetAssociatedApproval(download)) { 744 !WebstoreInstaller::GetAssociatedApproval(download)) {
750 return true; 745 return true;
751 } 746 }
752 747
753 // Anything the user has marked auto-open is OK if it's user-initiated. 748 // Anything the user has marked auto-open is OK if it's user-initiated.
754 if (ShouldOpenFileBasedOnExtension(state.suggested_path) && 749 if (ShouldOpenFileBasedOnExtension(state.suggested_path) &&
755 state.has_user_gesture) 750 state.has_user_gesture)
756 return false; 751 return false;
(...skipping 12 matching lines...) Expand all
769 int32 download_id, int64 db_handle) { 764 int32 download_id, int64 db_handle) {
770 // It's not immediately obvious, but HistoryBackend::CreateDownload() can 765 // It's not immediately obvious, but HistoryBackend::CreateDownload() can
771 // call this function with an invalid |db_handle|. For instance, this can 766 // call this function with an invalid |db_handle|. For instance, this can
772 // happen when the history database is offline. We cannot have multiple 767 // happen when the history database is offline. We cannot have multiple
773 // DownloadItems with the same invalid db_handle, so we need to assign a 768 // DownloadItems with the same invalid db_handle, so we need to assign a
774 // unique |db_handle| here. 769 // unique |db_handle| here.
775 if (db_handle == DownloadItem::kUninitializedHandle) 770 if (db_handle == DownloadItem::kUninitializedHandle)
776 db_handle = download_history_->GetNextFakeDbHandle(); 771 db_handle = download_history_->GetNextFakeDbHandle();
777 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); 772 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle);
778 } 773 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698