summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-26 22:49:55 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-26 22:49:55 +0000
commit21ca982c8b2d52d5acb0a36d3b5a09d30107e44e (patch)
tree0439eeab8b77b87e3e7ba0374ac75f5ca59d97ac
parent62ec236774d20534069231cab2b98e97691b90aa (diff)
downloadchromium_src-21ca982c8b2d52d5acb0a36d3b5a09d30107e44e.zip
chromium_src-21ca982c8b2d52d5acb0a36d3b5a09d30107e44e.tar.gz
chromium_src-21ca982c8b2d52d5acb0a36d3b5a09d30107e44e.tar.bz2
Add infobar warning user of extension install failure when trying to install in incognito mode.
BUG=27945 Review URL: http://codereview.chromium.org/543155 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37162 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/generated_resources.grd7
-rw-r--r--chrome/browser/download/download_manager.cc30
2 files changed, 31 insertions, 6 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index c4e1e82..5951016 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -2919,7 +2919,7 @@ each locale. -->
</message>
<message name="IDS_EXTENSION_CRASHED_INFOBAR_MESSAGE" desc="Message displayed on the extension crashed infobar.">
The following extension has crashed : <ph name="EXTENSION_NAME">$1<ex>Buildbot Monitor</ex></ph>
- </message>
+ </message>
<!-- Theme preview info bar -->
<message name="IDS_THEME_INSTALL_INFOBAR_LABEL" desc="Text displayed on an infobar when a theme has been installed.">
@@ -2937,6 +2937,11 @@ each locale. -->
Re-enable
</message>
+ <!-- Extension incognito install failure info bar -->
+ <message name="IDS_EXTENSION_INCOGNITO_INSTALL_INFOBAR_LABEL" desc="Text displayed on an infobar when the user attempts to install an extension in incognito mode.">
+ Extension install failed: extensions are not supported in incognito windows.
+ </message>
+
<!-- Extension install prompt -->
<message name="IDS_EXTENSION_INSTALL_PROMPT_TITLE" desc="Titlebar of the extension installation prompt window">
Confirm Installation
diff --git a/chrome/browser/download/download_manager.cc b/chrome/browser/download/download_manager.cc
index 6bbdd93..c327944 100644
--- a/chrome/browser/download/download_manager.cc
+++ b/chrome/browser/download/download_manager.cc
@@ -1,10 +1,11 @@
-// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/download/download_manager.h"
#include "app/l10n_util.h"
+#include "app/resource_bundle.h"
#include "base/file_util.h"
#include "base/logging.h"
#include "base/message_loop.h"
@@ -30,6 +31,7 @@
#include "chrome/browser/renderer_host/render_process_host.h"
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
+#include "chrome/browser/tab_contents/infobar_delegate.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/tab_contents/tab_util.h"
#include "chrome/common/chrome_constants.h"
@@ -44,6 +46,7 @@
#include "googleurl/src/gurl.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
+#include "grit/theme_resources.h"
#include "net/base/mime_util.h"
#include "net/base/net_util.h"
#include "net/url_request/url_request_context.h"
@@ -54,6 +57,8 @@
#include "base/win_util.h"
#endif
+namespace {
+
// Periodically update our observers.
class DownloadItemUpdateTask : public Task {
public:
@@ -65,17 +70,17 @@ class DownloadItemUpdateTask : public Task {
};
// Update frequency (milliseconds).
-static const int kUpdateTimeMs = 1000;
+const int kUpdateTimeMs = 1000;
// Our download table ID starts at 1, so we use 0 to represent a download that
// has started, but has not yet had its data persisted in the table. We use fake
// database handles in incognito mode starting at -1 and progressively getting
// more negative.
-static const int kUninitializedHandle = 0;
+const int kUninitializedHandle = 0;
// Appends the passed the number between parenthesis the path before the
// extension.
-static void AppendNumberToPath(FilePath* path, int number) {
+void AppendNumberToPath(FilePath* path, int number) {
file_util::InsertBeforeExtension(path,
StringPrintf(FILE_PATH_LITERAL(" (%d)"), number));
}
@@ -83,7 +88,7 @@ static void AppendNumberToPath(FilePath* path, int number) {
// Attempts to find a number that can be appended to that path to make it
// unique. If |path| does not exist, 0 is returned. If it fails to find such
// a number, -1 is returned.
-static int GetUniquePathNumber(const FilePath& path) {
+int GetUniquePathNumber(const FilePath& path) {
const int kMaxAttempts = 100;
if (!file_util::PathExists(path))
@@ -110,6 +115,8 @@ static bool DownloadPathIsDangerous(const FilePath& download_path) {
return (download_path == desktop_dir);
}
+} // namespace
+
// DownloadItem implementation -------------------------------------------------
// Constructor for reading from the history service.
@@ -1365,6 +1372,19 @@ void DownloadManager::OpenChromeExtension(const FilePath& full_path,
service,
new ExtensionInstallUI(profile_));
}
+ } else {
+ TabContents* contents = NULL;
+ Browser* last_active = BrowserList::GetLastActiveWithProfile(profile_);
+ if (last_active)
+ contents = last_active->GetSelectedTabContents();
+ if (contents) {
+ contents->AddInfoBar(
+ new SimpleAlertInfoBarDelegate(contents,
+ l10n_util::GetString(
+ IDS_EXTENSION_INCOGNITO_INSTALL_INFOBAR_LABEL),
+ ResourceBundle::GetSharedInstance().GetBitmapNamed(
+ IDR_INFOBAR_PLUGIN_INSTALL)));
+ }
}
}