Chromium Code Reviews| Index: chrome/common/extensions/api/url_parser/url_info.cc |
| diff --git a/chrome/common/extensions/api/url_parser/url_info.cc b/chrome/common/extensions/api/url_parser/url_info.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6e45e6192c314c3adeb65064290d2fd572320a50 |
| --- /dev/null |
| +++ b/chrome/common/extensions/api/url_parser/url_info.cc |
| @@ -0,0 +1,42 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/common/extensions/api/url_parser/url_info.h" |
| + |
| +#include "chrome/common/extensions/extension_manifest_constants.h" |
| + |
| +namespace keys = extension_manifest_keys; |
| + |
| +namespace extensions { |
| + |
| +// static |
| +const GURL URLInfo::url(const Extension* extension, const URLType url_type) { |
| + URLInfo* info = NULL; |
| + switch (url_type) { |
| + case DEVTOOLS_PAGE: |
| + info = static_cast<URLInfo*>( |
| + extension->GetManifestData(keys::kDevToolsPage)); |
| + if (info) |
| + return info->url_; |
| + return GURL(); |
|
Yoyo Zhou
2012/12/27 17:16:17
You can use GURL::EmptyGURL for the missing value
Joe Thomas
2012/12/30 04:26:00
Done.
|
| + |
| + case HOMEPAGE_URL: |
| + // Returns the Homepage URL for this extension. If homepage_url was not |
| + // specified in the manifest, this returns the Google Gallery URL. For |
| + // third-party extensions, this returns a blank GURL. |
| + info = static_cast<URLInfo*>( |
| + extension->GetManifestData(keys::kHomepageURL)); |
| + if (info && info->url_.is_valid()) |
| + return info->url_; |
| + return extension->UpdatesFromGallery() ? |
| + GURL(extension_urls::GetWebstoreItemDetailURLPrefix() + |
| + extension->id()) : GURL(); |
| + |
| + default: |
| + NOTREACHED() << "URL type need to be handled"; |
| + } |
| + return GURL(); |
| +} |
| + |
| +} // namespace extensions |