Commit 07107815 authored by groby@chromium.org's avatar groby@chromium.org

[OriginChip] Don't crash for invalid extension URL

If the user enters a chrome-extension:// url with an invalid extension
id, let's not crash. That's rude.

Instead, origin chip will display <id> as extension name, show a "page
not available" message.

BUG=375426

Review URL: https://codereview.chromium.org/291173008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@273020 0039d316-1c4b-4281-b951-d872f2087c98
parent 8b638e3e
......@@ -111,12 +111,14 @@ bool OriginChipInfo::Update(const content::WebContents* web_contents,
label_);
}
if (displayed_url_.SchemeIs(extensions::kExtensionScheme)) {
icon_ = IDR_EXTENSIONS_FAVICON;
if (displayed_url_.SchemeIs(extensions::kExtensionScheme)) {
const extensions::Extension* extension =
extensions::ExtensionSystem::Get(profile_)->extension_service()->
extensions()->GetExtensionOrAppByURL(displayed_url_);
if (extension) {
icon_ = IDR_EXTENSIONS_FAVICON;
extension_icon_image_.reset(
new extensions::IconImage(profile_,
extension,
......@@ -129,7 +131,11 @@ bool OriginChipInfo::Update(const content::WebContents* web_contents,
extension_icon_image_->image_skia().GetRepresentation(1.0f);
if (!extension_icon_image_->image_skia().image_reps().empty())
owner_->OnExtensionIconImageChanged(extension_icon_image_.get());
} else {
return true;
}
}
if (extension_icon_image_) {
extension_icon_image_.reset();
owner_->OnExtensionIconImageChanged(NULL);
......@@ -139,7 +145,6 @@ bool OriginChipInfo::Update(const content::WebContents* web_contents,
displayed_url_.SchemeIs(content::kChromeUIScheme)) ?
IDR_PRODUCT_LOGO_16 :
toolbar_model->GetIconForSecurityLevel(security_level_);
}
return true;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment