OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/common/extensions/api/page_launcher/page_launcher_handler.h" | 5 #include "chrome/common/extensions/api/page_launcher/page_launcher_handler.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/common/extensions/api/extension_action/action_info.h" | 10 #include "chrome/common/extensions/api/extension_action/action_info.h" |
11 #include "chrome/common/extensions/extension.h" | 11 #include "chrome/common/extensions/extension.h" |
12 #include "chrome/common/extensions/extension_manifest_constants.h" | 12 #include "chrome/common/extensions/extension_manifest_constants.h" |
13 #include "chrome/common/extensions/manifest.h" | 13 #include "chrome/common/extensions/manifest.h" |
14 #include "chrome/common/extensions/manifest_handler_helpers.h" | |
15 | 14 |
16 namespace keys = extension_manifest_keys; | 15 namespace keys = extension_manifest_keys; |
17 | 16 |
18 namespace extensions { | 17 namespace extensions { |
19 | 18 |
20 PageLauncherHandler::PageLauncherHandler() { | 19 PageLauncherHandler::PageLauncherHandler() { |
21 } | 20 } |
22 | 21 |
23 PageLauncherHandler::~PageLauncherHandler() { | 22 PageLauncherHandler::~PageLauncherHandler() { |
24 } | 23 } |
25 | 24 |
26 bool PageLauncherHandler::Parse(Extension* extension, string16* error) { | 25 bool PageLauncherHandler::Parse(Extension* extension, string16* error) { |
27 DCHECK(extension->manifest()->HasKey(keys::kPageLauncher)); | 26 DCHECK(extension->manifest()->HasKey(keys::kPageLauncher)); |
28 | 27 |
29 const base::DictionaryValue* dict; | 28 const base::DictionaryValue* dict; |
30 if (!extension->manifest()->GetDictionary(keys::kPageLauncher, &dict)) { | 29 if (!extension->manifest()->GetDictionary(keys::kPageLauncher, &dict)) { |
31 *error = ASCIIToUTF16(extension_manifest_errors::kInvalidPageLauncher); | 30 *error = ASCIIToUTF16(extension_manifest_errors::kInvalidPageLauncher); |
32 return false; | 31 return false; |
33 } | 32 } |
34 | 33 |
35 scoped_ptr<ActionInfo> action_info = | 34 scoped_ptr<ActionInfo> action_info = ActionInfo::Load(extension, dict, error); |
36 manifest_handler_helpers::LoadActionInfo(extension, dict, error); | |
37 if (!action_info) | 35 if (!action_info) |
38 return false; | 36 return false; |
39 | 37 |
40 ActionInfo::SetPageLauncherInfo(extension, action_info.release()); | 38 ActionInfo::SetPageLauncherInfo(extension, action_info.release()); |
41 return true; | 39 return true; |
42 } | 40 } |
43 | 41 |
44 const std::vector<std::string> PageLauncherHandler::Keys() const { | 42 const std::vector<std::string> PageLauncherHandler::Keys() const { |
45 return SingleKey(keys::kPageLauncher); | 43 return SingleKey(keys::kPageLauncher); |
46 } | 44 } |
47 | 45 |
48 } // namespace extensions | 46 } // namespace extensions |
OLD | NEW |