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

Side by Side Diff: chrome/browser/ui/toolbar/origin_chip_info.cc

Issue 291173008: [OriginChip] Don't crash for invalid extension URL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fix. Created 6 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/ui/toolbar/origin_chip_info.h" 5 #include "chrome/browser/ui/toolbar/origin_chip_info.h"
6 6
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/extensions/extension_icon_image.h" 10 #include "chrome/browser/extensions/extension_icon_image.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 security_level_ = security_level; 104 security_level_ = security_level;
105 is_url_malware_ = is_url_malware; 105 is_url_malware_ = is_url_malware;
106 106
107 label_ = OriginChip::LabelFromURLForProfile(displayed_url, profile_); 107 label_ = OriginChip::LabelFromURLForProfile(displayed_url, profile_);
108 if (security_level_ == ToolbarModel::EV_SECURE) { 108 if (security_level_ == ToolbarModel::EV_SECURE) {
109 label_ = l10n_util::GetStringFUTF16(IDS_SITE_CHIP_EV_SSL_LABEL, 109 label_ = l10n_util::GetStringFUTF16(IDS_SITE_CHIP_EV_SSL_LABEL,
110 toolbar_model->GetEVCertName(), 110 toolbar_model->GetEVCertName(),
111 label_); 111 label_);
112 } 112 }
113 113
114
114 if (displayed_url_.SchemeIs(extensions::kExtensionScheme)) { 115 if (displayed_url_.SchemeIs(extensions::kExtensionScheme)) {
115 icon_ = IDR_EXTENSIONS_FAVICON;
116
117 const extensions::Extension* extension = 116 const extensions::Extension* extension =
118 extensions::ExtensionSystem::Get(profile_)->extension_service()-> 117 extensions::ExtensionSystem::Get(profile_)->extension_service()->
119 extensions()->GetExtensionOrAppByURL(displayed_url_); 118 extensions()->GetExtensionOrAppByURL(displayed_url_);
120 extension_icon_image_.reset(
121 new extensions::IconImage(profile_,
122 extension,
123 extensions::IconsInfo::GetIcons(extension),
124 extension_misc::EXTENSION_ICON_BITTY,
125 extensions::util::GetDefaultAppIcon(),
126 owner_));
127 119
128 // Forces load of the image. 120 if (extension) {
129 extension_icon_image_->image_skia().GetRepresentation(1.0f); 121 icon_ = IDR_EXTENSIONS_FAVICON;
130 if (!extension_icon_image_->image_skia().image_reps().empty()) 122 extension_icon_image_.reset(
131 owner_->OnExtensionIconImageChanged(extension_icon_image_.get()); 123 new extensions::IconImage(profile_,
132 } else { 124 extension,
133 if (extension_icon_image_) { 125 extensions::IconsInfo::GetIcons(extension),
134 extension_icon_image_.reset(); 126 extension_misc::EXTENSION_ICON_BITTY,
135 owner_->OnExtensionIconImageChanged(NULL); 127 extensions::util::GetDefaultAppIcon(),
128 owner_));
129
130 // Forces load of the image.
131 extension_icon_image_->image_skia().GetRepresentation(1.0f);
132 if (!extension_icon_image_->image_skia().image_reps().empty())
133 owner_->OnExtensionIconImageChanged(extension_icon_image_.get());
134
135 return true;
136 } 136 }
137 }
137 138
138 icon_ = (displayed_url_.is_empty() || 139 if (extension_icon_image_) {
139 displayed_url_.SchemeIs(content::kChromeUIScheme)) ? 140 extension_icon_image_.reset();
140 IDR_PRODUCT_LOGO_16 : 141 owner_->OnExtensionIconImageChanged(NULL);
141 toolbar_model->GetIconForSecurityLevel(security_level_);
142 } 142 }
143 143
144 icon_ = (displayed_url_.is_empty() ||
145 displayed_url_.SchemeIs(content::kChromeUIScheme)) ?
146 IDR_PRODUCT_LOGO_16 :
147 toolbar_model->GetIconForSecurityLevel(security_level_);
148
144 return true; 149 return true;
145 } 150 }
146 151
147 base::string16 OriginChipInfo::Tooltip() const { 152 base::string16 OriginChipInfo::Tooltip() const {
148 return base::UTF8ToUTF16(displayed_url_.spec()); 153 return base::UTF8ToUTF16(displayed_url_.spec());
149 } 154 }
150 155
151 // static 156 // static
152 bool OriginChip::IsMalware(const GURL& url, const content::WebContents* tab) { 157 bool OriginChip::IsMalware(const GURL& url, const content::WebContents* tab) {
153 DCHECK(tab); 158 DCHECK(tab);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 247
243 #if defined(OS_CHROMEOS) 248 #if defined(OS_CHROMEOS)
244 if (url.SchemeIs(chrome::kCrosScheme) || 249 if (url.SchemeIs(chrome::kCrosScheme) ||
245 url.SchemeIs(chrome::kDriveScheme)) 250 url.SchemeIs(chrome::kDriveScheme))
246 return base::UTF8ToUTF16(url.spec()); 251 return base::UTF8ToUTF16(url.spec());
247 #endif 252 #endif
248 253
249 // If all else fails, return the hostname. 254 // If all else fails, return the hostname.
250 return base::UTF8ToUTF16(url.host()); 255 return base::UTF8ToUTF16(url.host());
251 } 256 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698