Home | History | Annotate | Download | only in common
      1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #include "chrome/common/content_settings_helper.h"
      6 
      7 #include "base/utf_string_conversions.h"
      8 #include "base/string_piece.h"
      9 #include "chrome/common/url_constants.h"
     10 #include "googleurl/src/gurl.h"
     11 
     12 namespace content_settings_helper {
     13 
     14 std::string OriginToString(const GURL& origin) {
     15    std::string port_component(origin.IntPort() != url_parse::PORT_UNSPECIFIED ?
     16       ":" + origin.port() : "");
     17   std::string scheme_component(!origin.SchemeIs(chrome::kHttpScheme) ?
     18       origin.scheme() + chrome::kStandardSchemeSeparator : "");
     19   return scheme_component + origin.host() + port_component;
     20 }
     21 
     22 string16 OriginToString16(const GURL& origin) {
     23   return UTF8ToUTF16(OriginToString(origin));
     24 }
     25 
     26 }  // namespace content_settings_helper
     27