• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/extensions/extension_sidebar_utils.h"
6 
7 #include "chrome/common/extensions/extension.h"
8 #include "chrome/common/extensions/extension_error_utils.h"
9 #include "googleurl/src/gurl.h"
10 
11 namespace {
12 
13 // Errors.
14 const char kInvalidPathError[] = "Invalid path: \"*\".";
15 
16 }  // namespace
17 
18 namespace extension_sidebar_utils {
19 
GetExtensionIdByContentId(const std::string & content_id)20 std::string GetExtensionIdByContentId(const std::string& content_id) {
21   // At the moment, content_id == extension_id.
22   return content_id;
23 }
24 
ResolveRelativePath(const std::string & relative_path,const Extension * extension,std::string * error)25 GURL ResolveRelativePath(const std::string& relative_path,
26                          const Extension* extension,
27                          std::string* error) {
28   GURL url(extension->GetResourceURL(relative_path));
29   if (!url.is_valid()) {
30     *error = ExtensionErrorUtils::FormatErrorMessage(kInvalidPathError,
31                                                      relative_path);
32     return GURL();
33   }
34   return url;
35 }
36 
37 }  // namespace extension_sidebar_utils
38