Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 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/api/devtools/devtools_page_handler.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "base/memory/scoped_ptr.h" | |
| 9 #include "base/utf_string_conversions.h" | |
| 10 #include "base/values.h" | |
| 11 #include "chrome/common/extensions/extension_manifest_constants.h" | |
| 12 #include "extensions/common/error_utils.h" | |
| 13 | |
| 14 namespace keys = extension_manifest_keys; | |
| 15 namespace errors = extension_manifest_errors; | |
| 16 | |
| 17 namespace extensions { | |
| 18 | |
| 19 namespace { | |
| 20 | |
| 21 } // namespace | |
| 22 | |
| 23 // static | |
| 24 const GURL DevtoolsPageInfo::devtools_url(const Extension* extension) { | |
| 25 DevtoolsPageInfo* info = static_cast<DevtoolsPageInfo*>( | |
| 26 extension->GetManifestData(keys::kDevToolsPage)); | |
| 27 if (info) | |
| 28 return info->devtools_url_; | |
| 29 return GURL(); | |
| 30 } | |
| 31 | |
| 32 | |
| 33 DevtoolsPageHandler::DevtoolsPageHandler() { | |
| 34 } | |
| 35 | |
| 36 DevtoolsPageHandler::~DevtoolsPageHandler() { | |
| 37 } | |
| 38 | |
| 39 bool DevtoolsPageHandler::Parse(const base::Value* value, | |
| 40 Extension* extension, | |
|
pfeldman
2012/12/22 10:01:16
poor indent
| |
| 41 string16* error) { | |
| 42 scoped_ptr<DevtoolsPageInfo> info(new DevtoolsPageInfo); | |
| 43 std::string devtools_str; | |
| 44 if (!value->GetAsString(&devtools_str)) { | |
| 45 *error = ASCIIToUTF16(errors::kInvalidDevToolsPage); | |
| 46 return false; | |
| 47 } | |
| 48 info->devtools_url_ = extension->GetResourceURL(devtools_str); | |
| 49 extension->SetManifestData(keys::kDevToolsPage, info.release()); | |
| 50 return true; | |
| 51 } | |
| 52 | |
| 53 } // namespace extensions | |
| OLD | NEW |