Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 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 "extensions/common/manifest_handlers/launcher_page_info.h" | |
| 6 | |
| 7 #include "base/files/file_util.h" | |
| 8 #include "base/strings/utf_string_conversions.h" | |
| 9 #include "extensions/common/manifest.h" | |
| 10 #include "extensions/common/manifest_constants.h" | |
| 11 #include "grit/extensions_strings.h" | |
| 12 #include "ui/base/l10n/l10n_util.h" | |
| 13 | |
| 14 namespace extensions { | |
| 15 | |
| 16 LauncherPageHandler::LauncherPageHandler() { | |
| 17 } | |
| 18 | |
| 19 LauncherPageHandler::~LauncherPageHandler() { | |
| 20 } | |
| 21 | |
| 22 bool LauncherPageHandler::Parse(Extension* extension, base::string16* error) { | |
| 23 const extensions::Manifest* manifest = extension->manifest(); | |
| 24 scoped_ptr<LauncherPageInfo> launcher_page_info(new LauncherPageInfo); | |
| 25 const base::DictionaryValue* launcher_page_dict = NULL; | |
| 26 if (!manifest->GetDictionary(manifest_keys::kLauncherPage, | |
| 27 &launcher_page_dict)) { | |
| 28 *error = base::ASCIIToUTF16(manifest_errors::kInvalidLauncherPage); | |
| 29 return false; | |
| 30 } | |
| 31 | |
| 32 if (!manifest->HasPath(extensions::manifest_keys::kLauncherPagePage)) { | |
| 33 *error = base::ASCIIToUTF16(manifest_errors::kLauncherPagePageRequired); | |
| 34 return false; | |
| 35 } | |
|
calamity
2014/08/21 02:53:08
nit: blank line after early return
Matt Giuca
2014/08/22 02:48:41
Done.
| |
| 36 std::string launcher_page_page; | |
| 37 if (!manifest->GetString(extensions::manifest_keys::kLauncherPagePage, | |
| 38 &launcher_page_page)) { | |
| 39 *error = base::ASCIIToUTF16(manifest_errors::kInvalidLauncherPagePage); | |
| 40 return false; | |
| 41 } | |
|
calamity
2014/08/21 02:53:08
nit: blank line after early return
Matt Giuca
2014/08/22 02:48:40
Done.
| |
| 42 launcher_page_info->page = launcher_page_page; | |
| 43 | |
| 44 extension->SetManifestData(manifest_keys::kLauncherPage, | |
| 45 launcher_page_info.release()); | |
| 46 return true; | |
| 47 } | |
| 48 | |
| 49 bool LauncherPageHandler::Validate( | |
| 50 const Extension* extension, | |
| 51 std::string* error, | |
| 52 std::vector<InstallWarning>* warnings) const { | |
| 53 LauncherPageInfo* info = static_cast<LauncherPageInfo*>( | |
| 54 extension->GetManifestData(manifest_keys::kLauncherPage)); | |
|
calamity
2014/08/21 02:53:08
Other manufest handlers seem to have a static Get(
Matt Giuca
2014/08/22 02:48:40
Actually icons_handler is what I copied this off a
| |
| 55 const base::FilePath path = extension->GetResource(info->page).GetFilePath(); | |
| 56 if (!base::PathExists(path)) { | |
| 57 *error = l10n_util::GetStringFUTF8(IDS_EXTENSION_LOAD_LAUNCHER_PAGE_FAILED, | |
| 58 base::UTF8ToUTF16(info->page)); | |
| 59 return false; | |
| 60 } | |
|
calamity
2014/08/21 02:53:08
nit: blank line after early return
Matt Giuca
2014/08/22 02:48:41
Done.
| |
| 61 return true; | |
| 62 } | |
| 63 | |
| 64 const std::vector<std::string> LauncherPageHandler::Keys() const { | |
| 65 return SingleKey(manifest_keys::kLauncherPage); | |
| 66 } | |
| 67 | |
| 68 } // namespace extensions | |
| OLD | NEW |