summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-27 22:16:11 +0000
committermpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-27 22:16:11 +0000
commitea0f18bbf4ecd16dc6ace8f33c99fc29cd97c01f (patch)
tree379cc04c94e5436d12643e7cf12edaddd33cd017
parent97708ca70ee8cb5a316a0a14030efa5e9e963c7d (diff)
downloadchromium_src-ea0f18bbf4ecd16dc6ace8f33c99fc29cd97c01f.zip
chromium_src-ea0f18bbf4ecd16dc6ace8f33c99fc29cd97c01f.tar.gz
chromium_src-ea0f18bbf4ecd16dc6ace8f33c99fc29cd97c01f.tar.bz2
Don't create an ExtensionDOMUI for urls with invalid extension IDs.
This fixes a crash bug. BUG=17546 TEST=Navigate to chrome-extension://baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ with no extensions installed. Chrome should not crash. Review URL: http://codereview.chromium.org/160199 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21721 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/dom_ui/dom_ui_factory.cc24
-rw-r--r--chrome/browser/extensions/extension_dom_ui.cc4
-rw-r--r--chrome/browser/extensions/extension_dom_ui.h4
3 files changed, 28 insertions, 4 deletions
diff --git a/chrome/browser/dom_ui/dom_ui_factory.cc b/chrome/browser/dom_ui/dom_ui_factory.cc
index d7f2e81..d58dc48 100644
--- a/chrome/browser/dom_ui/dom_ui_factory.cc
+++ b/chrome/browser/dom_ui/dom_ui_factory.cc
@@ -10,8 +10,11 @@
#include "chrome/browser/dom_ui/html_dialog_ui.h"
#include "chrome/browser/dom_ui/new_tab_ui.h"
#include "chrome/browser/dom_ui/print_ui.h"
-#include "chrome/browser/extensions/extensions_ui.h"
#include "chrome/browser/extensions/extension_dom_ui.h"
+#include "chrome/browser/extensions/extensions_service.h"
+#include "chrome/browser/extensions/extensions_ui.h"
+#include "chrome/browser/profile.h"
+#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/common/url_constants.h"
#ifdef CHROME_PERSONALIZATION
#include "chrome/personalization/personalization.h"
@@ -37,9 +40,22 @@ static bool CreateDOMUI(const GURL& url, TabContents* tab_contents,
}
if (url.SchemeIs(chrome::kExtensionScheme)) {
- if (new_ui)
- *new_ui = new ExtensionDOMUI(tab_contents);
- return true;
+ // We assume we have a valid extension unless we have a TabContents which
+ // can prove us wrong. This can can happen if the user types in a URL
+ // manually.
+ bool valid_extension = true;
+ if (tab_contents) {
+ // TabContents can be NULL if we're doing a quick UseDOMUIForURL check.
+ ExtensionsService* service =
+ tab_contents->profile()->GetExtensionsService();
+ valid_extension = (service && service->GetExtensionById(url.host()));
+ }
+ if (valid_extension) {
+ if (new_ui)
+ *new_ui = new ExtensionDOMUI(tab_contents);
+ return true;
+ }
+ return false;
}
// TODO(mhm) Make sure this ifdef is removed once print is complete.
diff --git a/chrome/browser/extensions/extension_dom_ui.cc b/chrome/browser/extensions/extension_dom_ui.cc
index 2fa4eb3..ed5abb9 100644
--- a/chrome/browser/extensions/extension_dom_ui.cc
+++ b/chrome/browser/extensions/extension_dom_ui.cc
@@ -1,3 +1,7 @@
+// Copyright (c) 2009 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/extensions/extension_dom_ui.h"
#include "chrome/browser/browser.h"
diff --git a/chrome/browser/extensions/extension_dom_ui.h b/chrome/browser/extensions/extension_dom_ui.h
index d80c503..ff64a9d 100644
--- a/chrome/browser/extensions/extension_dom_ui.h
+++ b/chrome/browser/extensions/extension_dom_ui.h
@@ -1,3 +1,7 @@
+// Copyright (c) 2009 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.
+
#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_DOM_UI_H_
#define CHROME_BROWSER_EXTENSIONS_EXTENSION_DOM_UI_H_