Chromium Code Reviews| Index: chrome/common/extensions/api/devtools/devtools_page_handler.cc |
| diff --git a/chrome/common/extensions/api/devtools/devtools_page_handler.cc b/chrome/common/extensions/api/devtools/devtools_page_handler.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..cf960141262707d5abaf787811772b68c5b80f3f |
| --- /dev/null |
| +++ b/chrome/common/extensions/api/devtools/devtools_page_handler.cc |
| @@ -0,0 +1,53 @@ |
| +// 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/devtools/devtools_page_handler.h" |
| + |
| +#include "base/logging.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/utf_string_conversions.h" |
| +#include "base/values.h" |
| +#include "chrome/common/extensions/extension_manifest_constants.h" |
| +#include "extensions/common/error_utils.h" |
| + |
| +namespace keys = extension_manifest_keys; |
| +namespace errors = extension_manifest_errors; |
| + |
| +namespace extensions { |
| + |
| +namespace { |
| + |
| +} // namespace |
| + |
| +// static |
| +const GURL DevtoolsPageInfo::devtools_url(const Extension* extension) { |
| + DevtoolsPageInfo* info = static_cast<DevtoolsPageInfo*>( |
| + extension->GetManifestData(keys::kDevToolsPage)); |
| + if (info) |
| + return info->devtools_url_; |
| + return GURL(); |
| +} |
| + |
| + |
| +DevtoolsPageHandler::DevtoolsPageHandler() { |
| +} |
| + |
| +DevtoolsPageHandler::~DevtoolsPageHandler() { |
| +} |
| + |
| +bool DevtoolsPageHandler::Parse(const base::Value* value, |
| + Extension* extension, |
|
pfeldman
2012/12/22 10:01:16
poor indent
|
| + string16* error) { |
| + scoped_ptr<DevtoolsPageInfo> info(new DevtoolsPageInfo); |
| + std::string devtools_str; |
| + if (!value->GetAsString(&devtools_str)) { |
| + *error = ASCIIToUTF16(errors::kInvalidDevToolsPage); |
| + return false; |
| + } |
| + info->devtools_url_ = extension->GetResourceURL(devtools_str); |
| + extension->SetManifestData(keys::kDevToolsPage, info.release()); |
| + return true; |
| +} |
| + |
| +} // namespace extensions |