Chromium Code Reviews| 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/extension_action/page_action_handler.h" | 5 #include "chrome/common/extensions/api/extension_action/page_action_handler.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/common/extensions/extension.h" | 9 #include "chrome/common/extensions/extension.h" |
| 10 #include "chrome/common/extensions/extension_constants.h" | 10 #include "chrome/common/extensions/extension_constants.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 49 return false; | 49 return false; |
| 50 } | 50 } |
| 51 } else if (extension->manifest()->HasKey(keys::kPageAction)) { | 51 } else if (extension->manifest()->HasKey(keys::kPageAction)) { |
| 52 if (!extension->manifest()->GetDictionary(keys::kPageAction, | 52 if (!extension->manifest()->GetDictionary(keys::kPageAction, |
| 53 &page_action_value)) { | 53 &page_action_value)) { |
| 54 *error = ASCIIToUTF16(errors::kInvalidPageAction); | 54 *error = ASCIIToUTF16(errors::kInvalidPageAction); |
| 55 return false; | 55 return false; |
| 56 } | 56 } |
| 57 } | 57 } |
| 58 | 58 |
| 59 // An extension cannot have both browser and page actions. | |
| 60 if (extension->manifest()->HasKey(keys::kBrowserAction)) { | |
|
Matt Perry
2013/05/30 23:16:14
The asymmetry of this bothers me (as in, why not p
Yoyo Zhou
2013/05/30 23:24:11
It's kind of a hack. A better or worse hack would
| |
| 61 *error = ASCIIToUTF16(errors::kOneUISurfaceOnly); | |
| 62 return false; | |
| 63 } | |
| 64 | |
| 59 // If page_action_value is not NULL, then there was a valid page action. | 65 // If page_action_value is not NULL, then there was a valid page action. |
| 60 if (page_action_value) { | 66 if (page_action_value) { |
| 61 page_action_info = ActionInfo::Load(extension, page_action_value, error); | 67 page_action_info = ActionInfo::Load(extension, page_action_value, error); |
| 62 if (!page_action_info) | 68 if (!page_action_info) |
| 63 return false; // Failed to parse page action definition. | 69 return false; // Failed to parse page action definition. |
| 64 } | 70 } |
| 65 ActionInfo::SetPageActionInfo(extension, page_action_info.release()); | 71 ActionInfo::SetPageActionInfo(extension, page_action_info.release()); |
| 66 | 72 |
| 67 return true; | 73 return true; |
| 68 } | 74 } |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 84 } | 90 } |
| 85 | 91 |
| 86 const std::vector<std::string> PageActionHandler::Keys() const { | 92 const std::vector<std::string> PageActionHandler::Keys() const { |
| 87 std::vector<std::string> keys; | 93 std::vector<std::string> keys; |
| 88 keys.push_back(keys::kPageAction); | 94 keys.push_back(keys::kPageAction); |
| 89 keys.push_back(keys::kPageActions); | 95 keys.push_back(keys::kPageActions); |
| 90 return keys; | 96 return keys; |
| 91 } | 97 } |
| 92 | 98 |
| 93 } // namespace extensions | 99 } // namespace extensions |
| OLD | NEW |