michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: michael@0: #include "nsHtml5PlainTextUtils.h" michael@0: #include "nsHtml5AttributeName.h" michael@0: #include "nsIServiceManager.h" michael@0: #include "nsIStringBundle.h" michael@0: #include "mozilla/Preferences.h" michael@0: michael@0: // static michael@0: nsHtml5HtmlAttributes* michael@0: nsHtml5PlainTextUtils::NewLinkAttributes() michael@0: { michael@0: nsHtml5HtmlAttributes* linkAttrs = new nsHtml5HtmlAttributes(0); michael@0: nsString* rel = new nsString(NS_LITERAL_STRING("alternate stylesheet")); michael@0: linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_REL, rel); michael@0: nsString* type = new nsString(NS_LITERAL_STRING("text/css")); michael@0: linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_TYPE, type); michael@0: nsString* href = new nsString( michael@0: NS_LITERAL_STRING("resource://gre-resources/plaintext.css")); michael@0: linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_HREF, href); michael@0: michael@0: nsresult rv; michael@0: nsCOMPtr bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv); michael@0: NS_ASSERTION(NS_SUCCEEDED(rv) && bundleService, "The bundle service could not be loaded"); michael@0: nsCOMPtr bundle; michael@0: rv = bundleService->CreateBundle("chrome://global/locale/browser.properties", michael@0: getter_AddRefs(bundle)); michael@0: NS_ASSERTION(NS_SUCCEEDED(rv) && bundle, "chrome://global/locale/browser.properties could not be loaded"); michael@0: nsXPIDLString title; michael@0: if (bundle) { michael@0: bundle->GetStringFromName(MOZ_UTF16("plainText.wordWrap"), getter_Copies(title)); michael@0: } michael@0: michael@0: nsString* titleCopy = new nsString(title); michael@0: linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_TITLE, titleCopy); michael@0: return linkAttrs; michael@0: }