OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/resources_private/resources_private_api.
h" | 5 #include "chrome/browser/extensions/api/resources_private/resources_private_api.
h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
11 #include "chrome/common/extensions/api/resources_private.h" | 11 #include "chrome/common/extensions/api/resources_private.h" |
12 #include "chrome/grit/generated_resources.h" | 12 #include "chrome/grit/generated_resources.h" |
| 13 #include "components/strings/grit/components_strings.h" |
13 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" |
14 #include "ui/base/webui/web_ui_util.h" | 15 #include "ui/base/webui/web_ui_util.h" |
15 | 16 |
16 // To add a new component to this API, simply: | 17 // To add a new component to this API, simply: |
17 // 1. Add your component to the Component enum in | 18 // 1. Add your component to the Component enum in |
18 // chrome/common/extensions/api/resources_private.idl | 19 // chrome/common/extensions/api/resources_private.idl |
19 // 2. Create an AddStringsForMyComponent(base::DictionaryValue * dict) method. | 20 // 2. Create an AddStringsForMyComponent(base::DictionaryValue * dict) method. |
20 // 3. Tie in that method to the switch statement in Run() | 21 // 3. Tie in that method to the switch statement in Run() |
21 | 22 |
22 namespace extensions { | 23 namespace extensions { |
23 | 24 |
24 namespace { | 25 namespace { |
25 | 26 |
26 void AddStringsForIdentity(base::DictionaryValue* dict) { | 27 void AddStringsForIdentity(base::DictionaryValue* dict) { |
27 dict->SetString("window-title", | 28 dict->SetString("window-title", |
28 l10n_util::GetStringUTF16(IDS_EXTENSION_CONFIRM_PERMISSIONS)); | 29 l10n_util::GetStringUTF16(IDS_EXTENSION_CONFIRM_PERMISSIONS)); |
29 } | 30 } |
30 | 31 |
| 32 void AddStringsForPdf(base::DictionaryValue* dict) { |
| 33 dict->SetString("passwordPrompt", |
| 34 l10n_util::GetStringUTF16(IDS_PDF_NEED_PASSWORD)); |
| 35 dict->SetString("pageLoading", |
| 36 l10n_util::GetStringUTF16(IDS_PDF_PAGE_LOADING)); |
| 37 dict->SetString("pageLoadFailed", |
| 38 l10n_util::GetStringUTF16(IDS_PDF_PAGE_LOAD_FAILED)); |
| 39 } |
| 40 |
31 } // namespace | 41 } // namespace |
32 | 42 |
33 namespace get_strings = api::resources_private::GetStrings; | 43 namespace get_strings = api::resources_private::GetStrings; |
34 | 44 |
35 ResourcesPrivateGetStringsFunction::ResourcesPrivateGetStringsFunction() {} | 45 ResourcesPrivateGetStringsFunction::ResourcesPrivateGetStringsFunction() {} |
36 | 46 |
37 ResourcesPrivateGetStringsFunction::~ResourcesPrivateGetStringsFunction() {} | 47 ResourcesPrivateGetStringsFunction::~ResourcesPrivateGetStringsFunction() {} |
38 | 48 |
39 ExtensionFunction::ResponseAction ResourcesPrivateGetStringsFunction::Run() { | 49 ExtensionFunction::ResponseAction ResourcesPrivateGetStringsFunction::Run() { |
40 scoped_ptr<get_strings::Params> params(get_strings::Params::Create(*args_)); | 50 scoped_ptr<get_strings::Params> params(get_strings::Params::Create(*args_)); |
41 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); | 51 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); |
42 | 52 |
43 api::resources_private::Component component = params->component; | 53 api::resources_private::Component component = params->component; |
44 | 54 |
45 switch (component) { | 55 switch (component) { |
46 case api::resources_private::COMPONENT_IDENTITY: | 56 case api::resources_private::COMPONENT_IDENTITY: |
47 AddStringsForIdentity(dict.get()); | 57 AddStringsForIdentity(dict.get()); |
48 break; | 58 break; |
| 59 case api::resources_private::COMPONENT_PDF: |
| 60 AddStringsForPdf(dict.get()); |
| 61 break; |
49 case api::resources_private::COMPONENT_NONE: | 62 case api::resources_private::COMPONENT_NONE: |
50 NOTREACHED(); | 63 NOTREACHED(); |
51 } | 64 } |
52 | 65 |
53 const std::string& app_locale = g_browser_process->GetApplicationLocale(); | 66 const std::string& app_locale = g_browser_process->GetApplicationLocale(); |
54 webui::SetLoadTimeDataDefaults(app_locale, dict.get()); | 67 webui::SetLoadTimeDataDefaults(app_locale, dict.get()); |
55 | 68 |
56 return RespondNow(OneArgument(dict.Pass())); | 69 return RespondNow(OneArgument(dict.Pass())); |
57 } | 70 } |
58 | 71 |
59 } // namespace extensions | 72 } // namespace extensions |
OLD | NEW |