Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Side by Side Diff: chrome/common/extensions/api/extension_action/page_action_handler.cc

Issue 93793010: Update uses of UTF conversions in chrome/common to use the base:: namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/common/extensions/extension_constants.h" 9 #include "chrome/common/extensions/extension_constants.h"
10 #include "chrome/common/extensions/extension_file_util.h" 10 #include "chrome/common/extensions/extension_file_util.h"
(...skipping 12 matching lines...) Expand all
23 PageActionHandler::~PageActionHandler() { 23 PageActionHandler::~PageActionHandler() {
24 } 24 }
25 25
26 bool PageActionHandler::Parse(Extension* extension, base::string16* error) { 26 bool PageActionHandler::Parse(Extension* extension, base::string16* error) {
27 scoped_ptr<ActionInfo> page_action_info; 27 scoped_ptr<ActionInfo> page_action_info;
28 const base::DictionaryValue* page_action_value = NULL; 28 const base::DictionaryValue* page_action_value = NULL;
29 29
30 if (extension->manifest()->HasKey(keys::kPageActions)) { 30 if (extension->manifest()->HasKey(keys::kPageActions)) {
31 const base::ListValue* list_value = NULL; 31 const base::ListValue* list_value = NULL;
32 if (!extension->manifest()->GetList(keys::kPageActions, &list_value)) { 32 if (!extension->manifest()->GetList(keys::kPageActions, &list_value)) {
33 *error = ASCIIToUTF16(errors::kInvalidPageActionsList); 33 *error = base::ASCIIToUTF16(errors::kInvalidPageActionsList);
34 return false; 34 return false;
35 } 35 }
36 36
37 size_t list_value_length = list_value->GetSize(); 37 size_t list_value_length = list_value->GetSize();
38 38
39 if (list_value_length == 0u) { 39 if (list_value_length == 0u) {
40 // A list with zero items is allowed, and is equivalent to not having 40 // A list with zero items is allowed, and is equivalent to not having
41 // a page_actions key in the manifest. Don't set |page_action_value|. 41 // a page_actions key in the manifest. Don't set |page_action_value|.
42 } else if (list_value_length == 1u) { 42 } else if (list_value_length == 1u) {
43 if (!list_value->GetDictionary(0, &page_action_value)) { 43 if (!list_value->GetDictionary(0, &page_action_value)) {
44 *error = ASCIIToUTF16(errors::kInvalidPageAction); 44 *error = base::ASCIIToUTF16(errors::kInvalidPageAction);
45 return false; 45 return false;
46 } 46 }
47 } else { // list_value_length > 1u. 47 } else { // list_value_length > 1u.
48 *error = ASCIIToUTF16(errors::kInvalidPageActionsListSize); 48 *error = base::ASCIIToUTF16(errors::kInvalidPageActionsListSize);
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 = base::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. 59 // An extension cannot have both browser and page actions.
60 if (extension->manifest()->HasKey(keys::kBrowserAction)) { 60 if (extension->manifest()->HasKey(keys::kBrowserAction)) {
61 *error = ASCIIToUTF16(errors::kOneUISurfaceOnly); 61 *error = base::ASCIIToUTF16(errors::kOneUISurfaceOnly);
62 return false; 62 return false;
63 } 63 }
64 64
65 // 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.
66 if (page_action_value) { 66 if (page_action_value) {
67 page_action_info = ActionInfo::Load(extension, page_action_value, error); 67 page_action_info = ActionInfo::Load(extension, page_action_value, error);
68 if (!page_action_info) 68 if (!page_action_info)
69 return false; // Failed to parse page action definition. 69 return false; // Failed to parse page action definition.
70 } 70 }
71 ActionInfo::SetPageActionInfo(extension, page_action_info.release()); 71 ActionInfo::SetPageActionInfo(extension, page_action_info.release());
(...skipping 18 matching lines...) Expand all
90 } 90 }
91 91
92 const std::vector<std::string> PageActionHandler::Keys() const { 92 const std::vector<std::string> PageActionHandler::Keys() const {
93 std::vector<std::string> keys; 93 std::vector<std::string> keys;
94 keys.push_back(keys::kPageAction); 94 keys.push_back(keys::kPageAction);
95 keys.push_back(keys::kPageActions); 95 keys.push_back(keys::kPageActions);
96 return keys; 96 return keys;
97 } 97 }
98 98
99 } // namespace extensions 99 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698