OLD | NEW |
1 // Copyright (c) 2011 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/common/web_apps.h" | 5 #include "chrome/common/web_apps.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
11 #include "base/string16.h" | 11 #include "base/string16.h" |
12 #include "base/string_number_conversions.h" | 12 #include "base/string_number_conversions.h" |
13 #include "base/string_split.h" | 13 #include "base/string_split.h" |
14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "chrome/common/json_schema_validator.h" | 16 #include "chrome/common/json_schema_validator.h" |
17 #include "googleurl/src/gurl.h" | 17 #include "googleurl/src/gurl.h" |
18 #include "grit/common_resources.h" | 18 #include "grit/common_resources.h" |
19 #include "grit/generated_resources.h" | 19 #include "grit/generated_resources.h" |
20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" |
22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" | 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" |
24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNodeList.h" | 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNodeList.h" |
25 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | 25 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
26 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" | 26 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" |
27 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
| 28 #include "ui/base/layout.h" |
28 #include "ui/base/resource/resource_bundle.h" | 29 #include "ui/base/resource/resource_bundle.h" |
29 #include "ui/gfx/size.h" | 30 #include "ui/gfx/size.h" |
30 #include "webkit/glue/dom_operations.h" | 31 #include "webkit/glue/dom_operations.h" |
31 | 32 |
32 using WebKit::WebDocument; | 33 using WebKit::WebDocument; |
33 using WebKit::WebElement; | 34 using WebKit::WebElement; |
34 using WebKit::WebFrame; | 35 using WebKit::WebFrame; |
35 using WebKit::WebNode; | 36 using WebKit::WebNode; |
36 using WebKit::WebNodeList; | 37 using WebKit::WebNodeList; |
37 using WebKit::WebString; | 38 using WebKit::WebString; |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 bool ParseWebAppFromDefinitionFile(Value* definition_value, | 210 bool ParseWebAppFromDefinitionFile(Value* definition_value, |
210 WebApplicationInfo* web_app, | 211 WebApplicationInfo* web_app, |
211 string16* error) { | 212 string16* error) { |
212 DCHECK(web_app->manifest_url.is_valid()); | 213 DCHECK(web_app->manifest_url.is_valid()); |
213 | 214 |
214 int error_code = 0; | 215 int error_code = 0; |
215 std::string error_message; | 216 std::string error_message; |
216 scoped_ptr<Value> schema( | 217 scoped_ptr<Value> schema( |
217 base::JSONReader::ReadAndReturnError( | 218 base::JSONReader::ReadAndReturnError( |
218 ResourceBundle::GetSharedInstance().GetRawDataResource( | 219 ResourceBundle::GetSharedInstance().GetRawDataResource( |
219 IDR_WEB_APP_SCHEMA).as_string(), | 220 IDR_WEB_APP_SCHEMA, |
| 221 ui::SCALE_FACTOR_NONE).as_string(), |
220 base::JSON_PARSE_RFC, // options | 222 base::JSON_PARSE_RFC, // options |
221 &error_code, | 223 &error_code, |
222 &error_message)); | 224 &error_message)); |
223 DCHECK(schema.get()) | 225 DCHECK(schema.get()) |
224 << "Error parsing JSON schema: " << error_code << ": " << error_message; | 226 << "Error parsing JSON schema: " << error_code << ": " << error_message; |
225 DCHECK(schema->IsType(Value::TYPE_DICTIONARY)) | 227 DCHECK(schema->IsType(Value::TYPE_DICTIONARY)) |
226 << "schema root must be dictionary."; | 228 << "schema root must be dictionary."; |
227 | 229 |
228 JSONSchemaValidator validator(static_cast<DictionaryValue*>(schema.get())); | 230 JSONSchemaValidator validator(static_cast<DictionaryValue*>(schema.get())); |
229 | 231 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 web_app->app_url = app_url; | 322 web_app->app_url = app_url; |
321 web_app->urls = urls; | 323 web_app->urls = urls; |
322 web_app->permissions = permissions; | 324 web_app->permissions = permissions; |
323 web_app->icons = icons; | 325 web_app->icons = icons; |
324 | 326 |
325 return true; | 327 return true; |
326 | 328 |
327 } | 329 } |
328 | 330 |
329 } // namespace web_apps | 331 } // namespace web_apps |
OLD | NEW |