summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorasargent@chromium.org <asargent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-28 20:57:42 +0000
committerasargent@chromium.org <asargent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-28 20:57:42 +0000
commit627d044e784b52aec7c7f0aea68c9efd167352c8 (patch)
treefa33422b31304e49bb28e11fea05d75640bffc65
parentecd352a75c143f30f46a82cb7f1e1985bec05ae2 (diff)
downloadchromium_src-627d044e784b52aec7c7f0aea68c9efd167352c8.zip
chromium_src-627d044e784b52aec7c7f0aea68c9efd167352c8.tar.gz
chromium_src-627d044e784b52aec7c7f0aea68c9efd167352c8.tar.bz2
Fix a crash on extensions gallery when using incognito mode.
This is already fixed on trunk and in the m8 branch - I'm backporting a fix to the m7 branch here. BUG=60780 TEST=Open an incognito window and navigate to https://chrome.google.com/extensions. Then open the js console and type in: "chrome.webstorePrivate.getSyncLogin(function(){})" (without the quotes). The browser should no longer crash. Review URL: http://codereview.chromium.org/4178005 git-svn-id: svn://svn.chromium.org/chrome/branches/517/src@64310 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/extensions/extension_webstore_private_api.cc16
1 files changed, 15 insertions, 1 deletions
diff --git a/chrome/browser/extensions/extension_webstore_private_api.cc b/chrome/browser/extensions/extension_webstore_private_api.cc
index 184c9e5..dacac15 100644
--- a/chrome/browser/extensions/extension_webstore_private_api.cc
+++ b/chrome/browser/extensions/extension_webstore_private_api.cc
@@ -4,12 +4,16 @@
#include "chrome/browser/extensions/extension_webstore_private_api.h"
+#include <string>
+#include <vector>
+
#include "base/string_util.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/crx_installer.h"
#include "chrome/browser/extensions/extension_prefs.h"
#include "chrome/browser/extensions/extensions_service.h"
+#include "chrome/browser/profile_manager.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/common/extensions/extension_constants.h"
@@ -19,8 +23,17 @@ namespace {
const char* install_base_url = extension_urls::kGalleryUpdateHttpsUrl;
+// If |profile| is not off the record, returns it. Otherwise returns the real
+// (not off the record) default profile.
+Profile* GetDefaultProfile(Profile* profile) {
+ if (!profile->IsOffTheRecord())
+ return profile;
+ else
+ return g_browser_process->profile_manager()->GetDefaultProfile();
}
+} // namespace
+
static bool IsWebStoreURL(const GURL& url) {
GURL store_url(Extension::ChromeStoreURL());
if (!url.is_valid() || !store_url.is_valid()) {
@@ -75,7 +88,8 @@ bool InstallFunction::RunImpl() {
bool GetSyncLoginFunction::RunImpl() {
if (!IsWebStoreURL(source_url()))
return false;
- ProfileSyncService* sync_service = profile_->GetProfileSyncService();
+ ProfileSyncService* sync_service =
+ GetDefaultProfile(profile_)->GetProfileSyncService();
string16 username = sync_service->GetAuthenticatedUsername();
result_.reset(Value::CreateStringValue(username));
return true;