image/decoders/icon/nsIconURI.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
michael@0 2 *
michael@0 3 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #include "mozilla/ArrayUtils.h"
michael@0 8
michael@0 9 #include "nsIconURI.h"
michael@0 10 #include "nsNetUtil.h"
michael@0 11 #include "nsIIOService.h"
michael@0 12 #include "nsIURL.h"
michael@0 13 #include "prprf.h"
michael@0 14 #include "plstr.h"
michael@0 15 #include <stdlib.h>
michael@0 16
michael@0 17 using namespace mozilla;
michael@0 18
michael@0 19 #define DEFAULT_IMAGE_SIZE 16
michael@0 20
michael@0 21 #if defined(MAX_PATH)
michael@0 22 #define SANE_FILE_NAME_LEN MAX_PATH
michael@0 23 #elif defined(PATH_MAX)
michael@0 24 #define SANE_FILE_NAME_LEN PATH_MAX
michael@0 25 #else
michael@0 26 #define SANE_FILE_NAME_LEN 1024
michael@0 27 #endif
michael@0 28
michael@0 29 // helper function for parsing out attributes like size, and contentType
michael@0 30 // from the icon url.
michael@0 31 static void extractAttributeValue(const char * searchString, const char * attributeName, nsCString& aResult);
michael@0 32
michael@0 33 static const char *kSizeStrings[] =
michael@0 34 {
michael@0 35 "button",
michael@0 36 "toolbar",
michael@0 37 "toolbarsmall",
michael@0 38 "menu",
michael@0 39 "dnd",
michael@0 40 "dialog"
michael@0 41 };
michael@0 42
michael@0 43 static const char *kStateStrings[] =
michael@0 44 {
michael@0 45 "normal",
michael@0 46 "disabled"
michael@0 47 };
michael@0 48
michael@0 49 ////////////////////////////////////////////////////////////////////////////////
michael@0 50
michael@0 51 nsMozIconURI::nsMozIconURI()
michael@0 52 : mSize(DEFAULT_IMAGE_SIZE),
michael@0 53 mIconSize(-1),
michael@0 54 mIconState(-1)
michael@0 55 {
michael@0 56 }
michael@0 57
michael@0 58 nsMozIconURI::~nsMozIconURI()
michael@0 59 {
michael@0 60 }
michael@0 61
michael@0 62 NS_IMPL_ISUPPORTS(nsMozIconURI, nsIMozIconURI, nsIURI)
michael@0 63
michael@0 64 #define MOZICON_SCHEME "moz-icon:"
michael@0 65 #define MOZICON_SCHEME_LEN (sizeof(MOZICON_SCHEME) - 1)
michael@0 66
michael@0 67 ////////////////////////////////////////////////////////////////////////////////
michael@0 68 // nsIURI methods:
michael@0 69
michael@0 70 NS_IMETHODIMP
michael@0 71 nsMozIconURI::GetSpec(nsACString &aSpec)
michael@0 72 {
michael@0 73 aSpec = MOZICON_SCHEME;
michael@0 74
michael@0 75 if (mIconURL)
michael@0 76 {
michael@0 77 nsAutoCString fileIconSpec;
michael@0 78 nsresult rv = mIconURL->GetSpec(fileIconSpec);
michael@0 79 NS_ENSURE_SUCCESS(rv, rv);
michael@0 80 aSpec += fileIconSpec;
michael@0 81 }
michael@0 82 else if (!mStockIcon.IsEmpty())
michael@0 83 {
michael@0 84 aSpec += "//stock/";
michael@0 85 aSpec += mStockIcon;
michael@0 86 }
michael@0 87 else
michael@0 88 {
michael@0 89 aSpec += "//";
michael@0 90 aSpec += mFileName;
michael@0 91 }
michael@0 92
michael@0 93 aSpec += "?size=";
michael@0 94 if (mIconSize >= 0)
michael@0 95 {
michael@0 96 aSpec += kSizeStrings[mIconSize];
michael@0 97 }
michael@0 98 else
michael@0 99 {
michael@0 100 char buf[20];
michael@0 101 PR_snprintf(buf, sizeof(buf), "%d", mSize);
michael@0 102 aSpec.Append(buf);
michael@0 103 }
michael@0 104
michael@0 105 if (mIconState >= 0) {
michael@0 106 aSpec += "&state=";
michael@0 107 aSpec += kStateStrings[mIconState];
michael@0 108 }
michael@0 109
michael@0 110 if (!mContentType.IsEmpty())
michael@0 111 {
michael@0 112 aSpec += "&contentType=";
michael@0 113 aSpec += mContentType.get();
michael@0 114 }
michael@0 115
michael@0 116 return NS_OK;
michael@0 117 }
michael@0 118
michael@0 119 NS_IMETHODIMP
michael@0 120 nsMozIconURI::GetSpecIgnoringRef(nsACString &result)
michael@0 121 {
michael@0 122 return GetSpec(result);
michael@0 123 }
michael@0 124
michael@0 125 NS_IMETHODIMP
michael@0 126 nsMozIconURI::GetHasRef(bool *result)
michael@0 127 {
michael@0 128 *result = false;
michael@0 129 return NS_OK;
michael@0 130 }
michael@0 131
michael@0 132 // takes a string like ?size=32&contentType=text/html and returns a new string
michael@0 133 // containing just the attribute value. i.e you could pass in this string with
michael@0 134 // an attribute name of 'size=', this will return 32
michael@0 135 // Assumption: attribute pairs in the string are separated by '&'.
michael@0 136 void extractAttributeValue(const char * searchString, const char * attributeName, nsCString& result)
michael@0 137 {
michael@0 138 //NS_ENSURE_ARG_POINTER(extractAttributeValue);
michael@0 139
michael@0 140 result.Truncate();
michael@0 141
michael@0 142 if (searchString && attributeName)
michael@0 143 {
michael@0 144 // search the string for attributeName
michael@0 145 uint32_t attributeNameSize = strlen(attributeName);
michael@0 146 const char * startOfAttribute = PL_strcasestr(searchString, attributeName);
michael@0 147 if (startOfAttribute &&
michael@0 148 ( *(startOfAttribute-1) == '?' || *(startOfAttribute-1) == '&') )
michael@0 149 {
michael@0 150 startOfAttribute += attributeNameSize; // skip over the attributeName
michael@0 151 if (*startOfAttribute) // is there something after the attribute name
michael@0 152 {
michael@0 153 const char * endofAttribute = strchr(startOfAttribute, '&');
michael@0 154 if (endofAttribute)
michael@0 155 result.Assign(Substring(startOfAttribute, endofAttribute));
michael@0 156 else
michael@0 157 result.Assign(startOfAttribute);
michael@0 158 } // if we have a attribute value
michael@0 159 } // if we have a attribute name
michael@0 160 } // if we got non-null search string and attribute name values
michael@0 161 }
michael@0 162
michael@0 163 NS_IMETHODIMP
michael@0 164 nsMozIconURI::SetSpec(const nsACString &aSpec)
michael@0 165 {
michael@0 166 // Reset everything to default values.
michael@0 167 mIconURL = nullptr;
michael@0 168 mSize = DEFAULT_IMAGE_SIZE;
michael@0 169 mContentType.Truncate();
michael@0 170 mFileName.Truncate();
michael@0 171 mStockIcon.Truncate();
michael@0 172 mIconSize = -1;
michael@0 173 mIconState = -1;
michael@0 174
michael@0 175 nsAutoCString iconSpec(aSpec);
michael@0 176 if (!Substring(iconSpec, 0, MOZICON_SCHEME_LEN).EqualsLiteral(MOZICON_SCHEME))
michael@0 177 return NS_ERROR_MALFORMED_URI;
michael@0 178
michael@0 179 int32_t questionMarkPos = iconSpec.Find("?");
michael@0 180 if (questionMarkPos != -1 && static_cast<int32_t>(iconSpec.Length()) > (questionMarkPos + 1))
michael@0 181 {
michael@0 182 extractAttributeValue(iconSpec.get(), "contentType=", mContentType);
michael@0 183
michael@0 184 nsAutoCString sizeString;
michael@0 185 extractAttributeValue(iconSpec.get(), "size=", sizeString);
michael@0 186 if (!sizeString.IsEmpty())
michael@0 187 {
michael@0 188 const char *sizeStr = sizeString.get();
michael@0 189 for (uint32_t i = 0; i < ArrayLength(kSizeStrings); i++)
michael@0 190 {
michael@0 191 if (PL_strcasecmp(sizeStr, kSizeStrings[i]) == 0)
michael@0 192 {
michael@0 193 mIconSize = i;
michael@0 194 break;
michael@0 195 }
michael@0 196 }
michael@0 197
michael@0 198 int32_t sizeValue = atoi(sizeString.get());
michael@0 199 if (sizeValue)
michael@0 200 mSize = sizeValue;
michael@0 201 }
michael@0 202
michael@0 203 nsAutoCString stateString;
michael@0 204 extractAttributeValue(iconSpec.get(), "state=", stateString);
michael@0 205 if (!stateString.IsEmpty())
michael@0 206 {
michael@0 207 const char *stateStr = stateString.get();
michael@0 208 for (uint32_t i = 0; i < ArrayLength(kStateStrings); i++)
michael@0 209 {
michael@0 210 if (PL_strcasecmp(stateStr, kStateStrings[i]) == 0)
michael@0 211 {
michael@0 212 mIconState = i;
michael@0 213 break;
michael@0 214 }
michael@0 215 }
michael@0 216 }
michael@0 217 }
michael@0 218
michael@0 219 int32_t pathLength = iconSpec.Length() - MOZICON_SCHEME_LEN;
michael@0 220 if (questionMarkPos != -1)
michael@0 221 pathLength = questionMarkPos - MOZICON_SCHEME_LEN;
michael@0 222 if (pathLength < 3)
michael@0 223 return NS_ERROR_MALFORMED_URI;
michael@0 224
michael@0 225 nsAutoCString iconPath(Substring(iconSpec, MOZICON_SCHEME_LEN, pathLength));
michael@0 226
michael@0 227 // Icon URI path can have three forms:
michael@0 228 // (1) //stock/<icon-identifier>
michael@0 229 // (2) //<some dummy file with an extension>
michael@0 230 // (3) a valid URL
michael@0 231
michael@0 232 if (!strncmp("//stock/", iconPath.get(), 8))
michael@0 233 {
michael@0 234 mStockIcon.Assign(Substring(iconPath, 8));
michael@0 235 // An icon identifier must always be specified.
michael@0 236 if (mStockIcon.IsEmpty())
michael@0 237 return NS_ERROR_MALFORMED_URI;
michael@0 238 return NS_OK;
michael@0 239 }
michael@0 240
michael@0 241 if (StringBeginsWith(iconPath, NS_LITERAL_CSTRING("//")))
michael@0 242 {
michael@0 243 // Sanity check this supposed dummy file name.
michael@0 244 if (iconPath.Length() > SANE_FILE_NAME_LEN)
michael@0 245 return NS_ERROR_MALFORMED_URI;
michael@0 246 iconPath.Cut(0, 2);
michael@0 247 mFileName.Assign(iconPath);
michael@0 248 }
michael@0 249
michael@0 250 nsresult rv;
michael@0 251 nsCOMPtr<nsIIOService> ioService(do_GetService(NS_IOSERVICE_CONTRACTID, &rv));
michael@0 252 NS_ENSURE_SUCCESS(rv, rv);
michael@0 253
michael@0 254 nsCOMPtr<nsIURI> uri;
michael@0 255 ioService->NewURI(iconPath, nullptr, nullptr, getter_AddRefs(uri));
michael@0 256 mIconURL = do_QueryInterface(uri);
michael@0 257 if (mIconURL)
michael@0 258 mFileName.Truncate();
michael@0 259 else if (mFileName.IsEmpty())
michael@0 260 return NS_ERROR_MALFORMED_URI;
michael@0 261
michael@0 262 return NS_OK;
michael@0 263 }
michael@0 264
michael@0 265 NS_IMETHODIMP
michael@0 266 nsMozIconURI::GetPrePath(nsACString &prePath)
michael@0 267 {
michael@0 268 prePath = MOZICON_SCHEME;
michael@0 269 return NS_OK;
michael@0 270 }
michael@0 271
michael@0 272 NS_IMETHODIMP
michael@0 273 nsMozIconURI::GetScheme(nsACString &aScheme)
michael@0 274 {
michael@0 275 aScheme = "moz-icon";
michael@0 276 return NS_OK;
michael@0 277 }
michael@0 278
michael@0 279 NS_IMETHODIMP
michael@0 280 nsMozIconURI::SetScheme(const nsACString &aScheme)
michael@0 281 {
michael@0 282 // doesn't make sense to set the scheme of a moz-icon URL
michael@0 283 return NS_ERROR_FAILURE;
michael@0 284 }
michael@0 285
michael@0 286 NS_IMETHODIMP
michael@0 287 nsMozIconURI::GetUsername(nsACString &aUsername)
michael@0 288 {
michael@0 289 return NS_ERROR_FAILURE;
michael@0 290 }
michael@0 291
michael@0 292 NS_IMETHODIMP
michael@0 293 nsMozIconURI::SetUsername(const nsACString &aUsername)
michael@0 294 {
michael@0 295 return NS_ERROR_FAILURE;
michael@0 296 }
michael@0 297
michael@0 298 NS_IMETHODIMP
michael@0 299 nsMozIconURI::GetPassword(nsACString &aPassword)
michael@0 300 {
michael@0 301 return NS_ERROR_FAILURE;
michael@0 302 }
michael@0 303
michael@0 304 NS_IMETHODIMP
michael@0 305 nsMozIconURI::SetPassword(const nsACString &aPassword)
michael@0 306 {
michael@0 307 return NS_ERROR_FAILURE;
michael@0 308 }
michael@0 309
michael@0 310 NS_IMETHODIMP
michael@0 311 nsMozIconURI::GetUserPass(nsACString &aUserPass)
michael@0 312 {
michael@0 313 return NS_ERROR_FAILURE;
michael@0 314 }
michael@0 315
michael@0 316 NS_IMETHODIMP
michael@0 317 nsMozIconURI::SetUserPass(const nsACString &aUserPass)
michael@0 318 {
michael@0 319 return NS_ERROR_FAILURE;
michael@0 320 }
michael@0 321
michael@0 322 NS_IMETHODIMP
michael@0 323 nsMozIconURI::GetHostPort(nsACString &aHostPort)
michael@0 324 {
michael@0 325 return NS_ERROR_FAILURE;
michael@0 326 }
michael@0 327
michael@0 328 NS_IMETHODIMP
michael@0 329 nsMozIconURI::SetHostPort(const nsACString &aHostPort)
michael@0 330 {
michael@0 331 return NS_ERROR_FAILURE;
michael@0 332 }
michael@0 333
michael@0 334 NS_IMETHODIMP
michael@0 335 nsMozIconURI::GetHost(nsACString &aHost)
michael@0 336 {
michael@0 337 return NS_ERROR_FAILURE;
michael@0 338 }
michael@0 339
michael@0 340 NS_IMETHODIMP
michael@0 341 nsMozIconURI::SetHost(const nsACString &aHost)
michael@0 342 {
michael@0 343 return NS_ERROR_FAILURE;
michael@0 344 }
michael@0 345
michael@0 346 NS_IMETHODIMP
michael@0 347 nsMozIconURI::GetPort(int32_t *aPort)
michael@0 348 {
michael@0 349 return NS_ERROR_FAILURE;
michael@0 350 }
michael@0 351
michael@0 352 NS_IMETHODIMP
michael@0 353 nsMozIconURI::SetPort(int32_t aPort)
michael@0 354 {
michael@0 355 return NS_ERROR_FAILURE;
michael@0 356 }
michael@0 357
michael@0 358 NS_IMETHODIMP
michael@0 359 nsMozIconURI::GetPath(nsACString &aPath)
michael@0 360 {
michael@0 361 aPath.Truncate();
michael@0 362 return NS_OK;
michael@0 363 }
michael@0 364
michael@0 365 NS_IMETHODIMP
michael@0 366 nsMozIconURI::SetPath(const nsACString &aPath)
michael@0 367 {
michael@0 368 return NS_ERROR_FAILURE;
michael@0 369 }
michael@0 370
michael@0 371 NS_IMETHODIMP
michael@0 372 nsMozIconURI::GetRef(nsACString &aRef)
michael@0 373 {
michael@0 374 aRef.Truncate();
michael@0 375 return NS_OK;
michael@0 376 }
michael@0 377
michael@0 378 NS_IMETHODIMP
michael@0 379 nsMozIconURI::SetRef(const nsACString &aRef)
michael@0 380 {
michael@0 381 return NS_ERROR_FAILURE;
michael@0 382 }
michael@0 383
michael@0 384 NS_IMETHODIMP
michael@0 385 nsMozIconURI::Equals(nsIURI *other, bool *result)
michael@0 386 {
michael@0 387 NS_ENSURE_ARG_POINTER(other);
michael@0 388 NS_PRECONDITION(result, "null pointer");
michael@0 389
michael@0 390 nsAutoCString spec1;
michael@0 391 nsAutoCString spec2;
michael@0 392
michael@0 393 other->GetSpec(spec2);
michael@0 394 GetSpec(spec1);
michael@0 395 if (!PL_strcasecmp(spec1.get(), spec2.get()))
michael@0 396 *result = true;
michael@0 397 else
michael@0 398 *result = false;
michael@0 399 return NS_OK;
michael@0 400 }
michael@0 401
michael@0 402 NS_IMETHODIMP
michael@0 403 nsMozIconURI::EqualsExceptRef(nsIURI *other, bool *result)
michael@0 404 {
michael@0 405 // GetRef/SetRef not supported by nsMozIconURI, so
michael@0 406 // EqualsExceptRef() is the same as Equals().
michael@0 407 return Equals(other, result);
michael@0 408 }
michael@0 409
michael@0 410 NS_IMETHODIMP
michael@0 411 nsMozIconURI::SchemeIs(const char *i_Scheme, bool *o_Equals)
michael@0 412 {
michael@0 413 NS_ENSURE_ARG_POINTER(o_Equals);
michael@0 414 if (!i_Scheme) return NS_ERROR_INVALID_ARG;
michael@0 415
michael@0 416 *o_Equals = PL_strcasecmp("moz-icon", i_Scheme) ? false : true;
michael@0 417 return NS_OK;
michael@0 418 }
michael@0 419
michael@0 420 NS_IMETHODIMP
michael@0 421 nsMozIconURI::Clone(nsIURI **result)
michael@0 422 {
michael@0 423 nsCOMPtr<nsIURL> newIconURL;
michael@0 424 if (mIconURL)
michael@0 425 {
michael@0 426 nsCOMPtr<nsIURI> newURI;
michael@0 427 nsresult rv = mIconURL->Clone(getter_AddRefs(newURI));
michael@0 428 if (NS_FAILED(rv))
michael@0 429 return rv;
michael@0 430 newIconURL = do_QueryInterface(newURI, &rv);
michael@0 431 if (NS_FAILED(rv))
michael@0 432 return rv;
michael@0 433 }
michael@0 434
michael@0 435 nsMozIconURI *uri = new nsMozIconURI();
michael@0 436 newIconURL.swap(uri->mIconURL);
michael@0 437 uri->mSize = mSize;
michael@0 438 uri->mContentType = mContentType;
michael@0 439 uri->mFileName = mFileName;
michael@0 440 uri->mStockIcon = mStockIcon;
michael@0 441 uri->mIconSize = mIconSize;
michael@0 442 uri->mIconState = mIconState;
michael@0 443 NS_ADDREF(*result = uri);
michael@0 444
michael@0 445 return NS_OK;
michael@0 446 }
michael@0 447
michael@0 448 NS_IMETHODIMP
michael@0 449 nsMozIconURI::CloneIgnoringRef(nsIURI **result)
michael@0 450 {
michael@0 451 // GetRef/SetRef not supported by nsMozIconURI, so
michael@0 452 // CloneIgnoringRef() is the same as Clone().
michael@0 453 return Clone(result);
michael@0 454 }
michael@0 455
michael@0 456 NS_IMETHODIMP
michael@0 457 nsMozIconURI::Resolve(const nsACString &relativePath, nsACString &result)
michael@0 458 {
michael@0 459 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 460 }
michael@0 461
michael@0 462 NS_IMETHODIMP
michael@0 463 nsMozIconURI::GetAsciiSpec(nsACString &aSpecA)
michael@0 464 {
michael@0 465 return GetSpec(aSpecA);
michael@0 466 }
michael@0 467
michael@0 468 NS_IMETHODIMP
michael@0 469 nsMozIconURI::GetAsciiHost(nsACString &aHostA)
michael@0 470 {
michael@0 471 return GetHost(aHostA);
michael@0 472 }
michael@0 473
michael@0 474 NS_IMETHODIMP
michael@0 475 nsMozIconURI::GetOriginCharset(nsACString &result)
michael@0 476 {
michael@0 477 result.Truncate();
michael@0 478 return NS_OK;
michael@0 479 }
michael@0 480
michael@0 481 ////////////////////////////////////////////////////////////////////////////////
michael@0 482 // nsIIconUri methods:
michael@0 483
michael@0 484 NS_IMETHODIMP
michael@0 485 nsMozIconURI::GetIconURL(nsIURL* * aFileUrl)
michael@0 486 {
michael@0 487 *aFileUrl = mIconURL;
michael@0 488 NS_IF_ADDREF(*aFileUrl);
michael@0 489 return NS_OK;
michael@0 490 }
michael@0 491
michael@0 492 NS_IMETHODIMP
michael@0 493 nsMozIconURI::SetIconURL(nsIURL* aFileUrl)
michael@0 494 {
michael@0 495 // this isn't called anywhere, needs to go through SetSpec parsing
michael@0 496 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 497 }
michael@0 498
michael@0 499 NS_IMETHODIMP
michael@0 500 nsMozIconURI::GetImageSize(uint32_t * aImageSize) // measured by # of pixels in a row. defaults to 16.
michael@0 501 {
michael@0 502 *aImageSize = mSize;
michael@0 503 return NS_OK;
michael@0 504 }
michael@0 505
michael@0 506 NS_IMETHODIMP
michael@0 507 nsMozIconURI::SetImageSize(uint32_t aImageSize) // measured by # of pixels in a row. defaults to 16.
michael@0 508 {
michael@0 509 mSize = aImageSize;
michael@0 510 return NS_OK;
michael@0 511 }
michael@0 512
michael@0 513 NS_IMETHODIMP
michael@0 514 nsMozIconURI::GetContentType(nsACString &aContentType)
michael@0 515 {
michael@0 516 aContentType = mContentType;
michael@0 517 return NS_OK;
michael@0 518 }
michael@0 519
michael@0 520 NS_IMETHODIMP
michael@0 521 nsMozIconURI::SetContentType(const nsACString &aContentType)
michael@0 522 {
michael@0 523 mContentType = aContentType;
michael@0 524 return NS_OK;
michael@0 525 }
michael@0 526
michael@0 527 NS_IMETHODIMP
michael@0 528 nsMozIconURI::GetFileExtension(nsACString &aFileExtension)
michael@0 529 {
michael@0 530 // First, try to get the extension from mIconURL if we have one
michael@0 531 if (mIconURL)
michael@0 532 {
michael@0 533 nsAutoCString fileExt;
michael@0 534 if (NS_SUCCEEDED(mIconURL->GetFileExtension(fileExt)))
michael@0 535 {
michael@0 536 if (!fileExt.IsEmpty())
michael@0 537 {
michael@0 538 // unfortunately, this code doesn't give us the required '.' in front of the extension
michael@0 539 // so we have to do it ourselves..
michael@0 540 aFileExtension.Assign('.');
michael@0 541 aFileExtension.Append(fileExt);
michael@0 542 }
michael@0 543 }
michael@0 544 return NS_OK;
michael@0 545 }
michael@0 546
michael@0 547 if (!mFileName.IsEmpty())
michael@0 548 {
michael@0 549 // truncate the extension out of the file path...
michael@0 550 const char * chFileName = mFileName.get(); // get the underlying buffer
michael@0 551 const char * fileExt = strrchr(chFileName, '.');
michael@0 552 if (!fileExt)
michael@0 553 return NS_OK;
michael@0 554 aFileExtension = fileExt;
michael@0 555 }
michael@0 556
michael@0 557 return NS_OK;
michael@0 558 }
michael@0 559
michael@0 560 NS_IMETHODIMP
michael@0 561 nsMozIconURI::GetStockIcon(nsACString &aStockIcon)
michael@0 562 {
michael@0 563 aStockIcon = mStockIcon;
michael@0 564 return NS_OK;
michael@0 565 }
michael@0 566
michael@0 567 NS_IMETHODIMP
michael@0 568 nsMozIconURI::GetIconSize(nsACString &aSize)
michael@0 569 {
michael@0 570 if (mIconSize >= 0)
michael@0 571 aSize = kSizeStrings[mIconSize];
michael@0 572 else
michael@0 573 aSize.Truncate();
michael@0 574 return NS_OK;
michael@0 575 }
michael@0 576
michael@0 577 NS_IMETHODIMP
michael@0 578 nsMozIconURI::GetIconState(nsACString &aState)
michael@0 579 {
michael@0 580 if (mIconState >= 0)
michael@0 581 aState = kStateStrings[mIconState];
michael@0 582 else
michael@0 583 aState.Truncate();
michael@0 584 return NS_OK;
michael@0 585 }
michael@0 586 ////////////////////////////////////////////////////////////////////////////////

mercurial