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

Side by Side Diff: chrome/common/extensions/api/spellcheck/spellcheck_handler.cc

Issue 1880143002: Convert chrome/common to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 8 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
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/spellcheck/spellcheck_handler.h" 5 #include "chrome/common/extensions/api/spellcheck/spellcheck_handler.h"
6 6
7 #include <memory>
8
7 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
8 #include "extensions/common/manifest_constants.h" 10 #include "extensions/common/manifest_constants.h"
9 11
10 namespace extensions { 12 namespace extensions {
11 13
12 namespace keys = manifest_keys; 14 namespace keys = manifest_keys;
13 namespace errors = manifest_errors; 15 namespace errors = manifest_errors;
14 16
15 SpellcheckDictionaryInfo::SpellcheckDictionaryInfo() { 17 SpellcheckDictionaryInfo::SpellcheckDictionaryInfo() {
16 } 18 }
17 19
18 SpellcheckDictionaryInfo::~SpellcheckDictionaryInfo() { 20 SpellcheckDictionaryInfo::~SpellcheckDictionaryInfo() {
19 } 21 }
20 22
21 SpellcheckHandler::SpellcheckHandler() { 23 SpellcheckHandler::SpellcheckHandler() {
22 } 24 }
23 25
24 SpellcheckHandler::~SpellcheckHandler() { 26 SpellcheckHandler::~SpellcheckHandler() {
25 } 27 }
26 28
27 bool SpellcheckHandler::Parse(Extension* extension, base::string16* error) { 29 bool SpellcheckHandler::Parse(Extension* extension, base::string16* error) {
28 const base::DictionaryValue* spellcheck_value = NULL; 30 const base::DictionaryValue* spellcheck_value = NULL;
29 if (!extension->manifest()->GetDictionary(keys::kSpellcheck, 31 if (!extension->manifest()->GetDictionary(keys::kSpellcheck,
30 &spellcheck_value)) { 32 &spellcheck_value)) {
31 *error = base::ASCIIToUTF16(errors::kInvalidSpellcheck); 33 *error = base::ASCIIToUTF16(errors::kInvalidSpellcheck);
32 return false; 34 return false;
33 } 35 }
34 scoped_ptr<SpellcheckDictionaryInfo> spellcheck_info( 36 std::unique_ptr<SpellcheckDictionaryInfo> spellcheck_info(
35 new SpellcheckDictionaryInfo); 37 new SpellcheckDictionaryInfo);
36 if (!spellcheck_value->HasKey(keys::kSpellcheckDictionaryLanguage) || 38 if (!spellcheck_value->HasKey(keys::kSpellcheckDictionaryLanguage) ||
37 !spellcheck_value->GetString(keys::kSpellcheckDictionaryLanguage, 39 !spellcheck_value->GetString(keys::kSpellcheckDictionaryLanguage,
38 &spellcheck_info->language)) { 40 &spellcheck_info->language)) {
39 *error = base::ASCIIToUTF16(errors::kInvalidSpellcheckDictionaryLanguage); 41 *error = base::ASCIIToUTF16(errors::kInvalidSpellcheckDictionaryLanguage);
40 return false; 42 return false;
41 } 43 }
42 if (!spellcheck_value->HasKey(keys::kSpellcheckDictionaryLocale) || 44 if (!spellcheck_value->HasKey(keys::kSpellcheckDictionaryLocale) ||
43 !spellcheck_value->GetString(keys::kSpellcheckDictionaryLocale, 45 !spellcheck_value->GetString(keys::kSpellcheckDictionaryLocale,
44 &spellcheck_info->locale)) { 46 &spellcheck_info->locale)) {
(...skipping 14 matching lines...) Expand all
59 } 61 }
60 extension->SetManifestData(keys::kSpellcheck, spellcheck_info.release()); 62 extension->SetManifestData(keys::kSpellcheck, spellcheck_info.release());
61 return true; 63 return true;
62 } 64 }
63 65
64 const std::vector<std::string> SpellcheckHandler::Keys() const { 66 const std::vector<std::string> SpellcheckHandler::Keys() const {
65 return SingleKey(keys::kSpellcheck); 67 return SingleKey(keys::kSpellcheck);
66 } 68 }
67 69
68 } // namespace extensions 70 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698