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

Side by Side Diff: chrome/browser/extensions/api/i18n/i18n_api.cc

Issue 11747025: Run the JSON Schema Compiler's bundle compilation on JSON files. Previously it (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix ms release build Created 7 years, 11 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/browser/extensions/api/i18n/i18n_api.h" 5 #include "chrome/browser/extensions/api/i18n/i18n_api.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/string_piece.h" 11 #include "base/string_piece.h"
12 #include "base/string_split.h" 12 #include "base/string_split.h"
13 #include "chrome/browser/prefs/pref_service.h" 13 #include "chrome/browser/prefs/pref_service.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/common/extensions/api/i18n.h"
15 #include "chrome/common/pref_names.h" 16 #include "chrome/common/pref_names.h"
16 #include "chrome/common/extensions/api/i18n.h"
17 17
18 namespace GetAcceptLanguages = extensions::api::i18n::GetAcceptLanguages; 18 namespace GetAcceptLanguages = extensions::api::i18n::GetAcceptLanguages;
19 19
20 // Errors. 20 // Errors.
21 static const char kEmptyAcceptLanguagesError[] = "accept-languages is empty."; 21 static const char kEmptyAcceptLanguagesError[] = "accept-languages is empty.";
22 22
23 bool GetAcceptLanguagesFunction::RunImpl() { 23 bool I18nGetAcceptLanguagesFunction::RunImpl() {
24 std::string accept_languages = 24 std::string accept_languages =
25 profile()->GetPrefs()->GetString(prefs::kAcceptLanguages); 25 profile()->GetPrefs()->GetString(prefs::kAcceptLanguages);
26 // Currently, there are 2 ways to set browser's accept-languages: through UI 26 // Currently, there are 2 ways to set browser's accept-languages: through UI
27 // or directly modify the preference file. The accept-languages set through 27 // or directly modify the preference file. The accept-languages set through
28 // UI is guranteed to be valid, and the accept-languages string returned from 28 // UI is guranteed to be valid, and the accept-languages string returned from
29 // profile()->GetPrefs()->GetString(prefs::kAcceptLanguages) is guranteed to 29 // profile()->GetPrefs()->GetString(prefs::kAcceptLanguages) is guranteed to
30 // be valid and well-formed, which means each accept-langauge is a valid 30 // be valid and well-formed, which means each accept-langauge is a valid
31 // code, and accept-languages are seperatd by "," without surrrounding 31 // code, and accept-languages are seperatd by "," without surrrounding
32 // spaces. But we do not do any validation (either the format or the validity 32 // spaces. But we do not do any validation (either the format or the validity
33 // of the language code) on accept-languages set through editing preference 33 // of the language code) on accept-languages set through editing preference
(...skipping 10 matching lines...) Expand all
44 languages.end()); 44 languages.end());
45 45
46 if (languages.empty()) { 46 if (languages.empty()) {
47 error_ = kEmptyAcceptLanguagesError; 47 error_ = kEmptyAcceptLanguagesError;
48 return false; 48 return false;
49 } 49 }
50 50
51 results_ = GetAcceptLanguages::Results::Create(languages); 51 results_ = GetAcceptLanguages::Results::Create(languages);
52 return true; 52 return true;
53 } 53 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/i18n/i18n_api.h ('k') | chrome/browser/extensions/api/management/management_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698