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

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

Issue 19547009: Move ".crx"/".pem" constants and extension_filenames constants into extensions/common/constants.cc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/download_target_determiner.h" 5 #include "chrome/browser/download/download_target_determiner.h"
6 6
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "base/rand_util.h" 8 #include "base/rand_util.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "chrome/browser/download/chrome_download_manager_delegate.h" 11 #include "chrome/browser/download/chrome_download_manager_delegate.h"
12 #include "chrome/browser/download/download_crx_util.h" 12 #include "chrome/browser/download/download_crx_util.h"
13 #include "chrome/browser/download/download_extensions.h" 13 #include "chrome/browser/download/download_extensions.h"
14 #include "chrome/browser/download/download_prefs.h" 14 #include "chrome/browser/download/download_prefs.h"
15 #include "chrome/browser/download/download_util.h" 15 #include "chrome/browser/download/download_util.h"
16 #include "chrome/browser/extensions/webstore_installer.h" 16 #include "chrome/browser/extensions/webstore_installer.h"
17 #include "chrome/browser/history/history_service.h" 17 #include "chrome/browser/history/history_service.h"
18 #include "chrome/browser/history/history_service_factory.h" 18 #include "chrome/browser/history/history_service_factory.h"
19 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/common/extensions/extension.h"
21 #include "chrome/common/extensions/feature_switch.h" 20 #include "chrome/common/extensions/feature_switch.h"
22 #include "chrome/common/pref_names.h" 21 #include "chrome/common/pref_names.h"
23 #include "content/public/browser/browser_context.h" 22 #include "content/public/browser/browser_context.h"
24 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
25 #include "content/public/browser/download_interrupt_reasons.h" 24 #include "content/public/browser/download_interrupt_reasons.h"
25 #include "extensions/common/constants.h"
26 #include "grit/generated_resources.h" 26 #include "grit/generated_resources.h"
27 #include "net/base/net_util.h" 27 #include "net/base/net_util.h"
28 #include "ui/base/l10n/l10n_util.h" 28 #include "ui/base/l10n/l10n_util.h"
29 29
30 using content::BrowserThread; 30 using content::BrowserThread;
31 using content::DownloadItem; 31 using content::DownloadItem;
32 32
33 namespace { 33 namespace {
34 34
35 const base::FilePath::CharType kCrdownloadSuffix[] = 35 const base::FilePath::CharType kCrdownloadSuffix[] =
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 return true; 544 return true;
545 545
546 // Check if the user has the "Always prompt for download location" preference 546 // Check if the user has the "Always prompt for download location" preference
547 // set. If so we prompt for most downloads except for the following scenarios: 547 // set. If so we prompt for most downloads except for the following scenarios:
548 // 1) Extension installation. Note that we only care here about the case where 548 // 1) Extension installation. Note that we only care here about the case where
549 // an extension is installed, not when one is downloaded with "save as...". 549 // an extension is installed, not when one is downloaded with "save as...".
550 // 2) Filetypes marked "always open." If the user just wants this file opened, 550 // 2) Filetypes marked "always open." If the user just wants this file opened,
551 // don't bother asking where to keep it. 551 // don't bother asking where to keep it.
552 if (download_prefs_->PromptForDownload() && 552 if (download_prefs_->PromptForDownload() &&
553 !download_crx_util::IsExtensionDownload(*download_) && 553 !download_crx_util::IsExtensionDownload(*download_) &&
554 !extensions::Extension::IsExtension(filename) && 554 !filename.MatchesExtension(extensions::kExtensionFileExtension) &&
555 !download_prefs_->IsAutoOpenEnabledBasedOnExtension(filename)) 555 !download_prefs_->IsAutoOpenEnabledBasedOnExtension(filename))
556 return true; 556 return true;
557 557
558 // Otherwise, don't prompt. Note that the user might still be prompted if 558 // Otherwise, don't prompt. Note that the user might still be prompted if
559 // there are unresolved conflicts during path reservation (e.g. due to the 559 // there are unresolved conflicts during path reservation (e.g. due to the
560 // target path being unwriteable or because there are too many conflicting 560 // target path being unwriteable or because there are too many conflicting
561 // files), or if an extension signals that the user be prompted on a filename 561 // files), or if an extension signals that the user be prompted on a filename
562 // conflict. 562 // conflict.
563 return false; 563 return false;
564 } 564 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 // asynchronously. 643 // asynchronously.
644 new DownloadTargetDeterminer(download, initial_virtual_path, download_prefs, 644 new DownloadTargetDeterminer(download, initial_virtual_path, download_prefs,
645 delegate, callback); 645 delegate, callback);
646 } 646 }
647 647
648 // static 648 // static
649 base::FilePath DownloadTargetDeterminer::GetCrDownloadPath( 649 base::FilePath DownloadTargetDeterminer::GetCrDownloadPath(
650 const base::FilePath& suggested_path) { 650 const base::FilePath& suggested_path) {
651 return base::FilePath(suggested_path.value() + kCrdownloadSuffix); 651 return base::FilePath(suggested_path.value() + kCrdownloadSuffix);
652 } 652 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698