| OLD | NEW |
| 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/renderer/web_apps.h" | 5 #include "chrome/renderer/web_apps.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/command_line.h" | |
| 13 #include "base/feature_list.h" | |
| 14 #include "base/json/json_reader.h" | 12 #include "base/json/json_reader.h" |
| 15 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 16 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 17 #include "base/strings/string_split.h" | 15 #include "base/strings/string_split.h" |
| 18 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 19 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 20 #include "base/values.h" | 18 #include "base/values.h" |
| 21 #include "build/build_config.h" | 19 #include "build/build_config.h" |
| 22 #include "chrome/common/chrome_features.h" | |
| 23 #include "chrome/common/web_application_info.h" | 20 #include "chrome/common/web_application_info.h" |
| 24 #include "third_party/WebKit/public/platform/WebIconSizesParser.h" | 21 #include "third_party/WebKit/public/platform/WebIconSizesParser.h" |
| 25 #include "third_party/WebKit/public/platform/WebString.h" | 22 #include "third_party/WebKit/public/platform/WebString.h" |
| 26 #include "third_party/WebKit/public/platform/WebURL.h" | 23 #include "third_party/WebKit/public/platform/WebURL.h" |
| 27 #include "third_party/WebKit/public/web/WebDocument.h" | 24 #include "third_party/WebKit/public/web/WebDocument.h" |
| 28 #include "third_party/WebKit/public/web/WebElement.h" | 25 #include "third_party/WebKit/public/web/WebElement.h" |
| 29 #include "third_party/WebKit/public/web/WebFrame.h" | 26 #include "third_party/WebKit/public/web/WebFrame.h" |
| 30 #include "third_party/WebKit/public/web/WebNode.h" | 27 #include "third_party/WebKit/public/web/WebNode.h" |
| 31 #include "ui/gfx/geometry/size.h" | 28 #include "ui/gfx/geometry/size.h" |
| 32 #include "url/gurl.h" | 29 #include "url/gurl.h" |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 | 140 |
| 144 if (elem.HasHTMLTagName("link")) { | 141 if (elem.HasHTMLTagName("link")) { |
| 145 std::string rel = elem.GetAttribute("rel").Utf8(); | 142 std::string rel = elem.GetAttribute("rel").Utf8(); |
| 146 // "rel" attribute may use either "icon" or "shortcut icon". | 143 // "rel" attribute may use either "icon" or "shortcut icon". |
| 147 // see also | 144 // see also |
| 148 // <http://en.wikipedia.org/wiki/Favicon> | 145 // <http://en.wikipedia.org/wiki/Favicon> |
| 149 // <http://dev.w3.org/html5/spec/Overview.html#rel-icon> | 146 // <http://dev.w3.org/html5/spec/Overview.html#rel-icon> |
| 150 // | 147 // |
| 151 // Bookmark apps also support "apple-touch-icon" and | 148 // Bookmark apps also support "apple-touch-icon" and |
| 152 // "apple-touch-icon-precomposed". | 149 // "apple-touch-icon-precomposed". |
| 153 #if defined(OS_MACOSX) | |
| 154 bool bookmark_apps_enabled = | |
| 155 base::FeatureList::IsEnabled(features::kBookmarkApps); | |
| 156 #else | |
| 157 bool bookmark_apps_enabled = true; | |
| 158 #endif | |
| 159 if (base::LowerCaseEqualsASCII(rel, "icon") || | 150 if (base::LowerCaseEqualsASCII(rel, "icon") || |
| 160 base::LowerCaseEqualsASCII(rel, "shortcut icon") || | 151 base::LowerCaseEqualsASCII(rel, "shortcut icon") || |
| 161 (bookmark_apps_enabled && | 152 base::LowerCaseEqualsASCII(rel, "apple-touch-icon") || |
| 162 (base::LowerCaseEqualsASCII(rel, "apple-touch-icon") || | 153 base::LowerCaseEqualsASCII(rel, "apple-touch-icon-precomposed")) { |
| 163 base::LowerCaseEqualsASCII(rel, "apple-touch-icon-precomposed")))) { | |
| 164 AddInstallIcon(elem, &app_info->icons); | 154 AddInstallIcon(elem, &app_info->icons); |
| 165 } | 155 } |
| 166 } else if (elem.HasHTMLTagName("meta") && elem.HasAttribute("name")) { | 156 } else if (elem.HasHTMLTagName("meta") && elem.HasAttribute("name")) { |
| 167 std::string name = elem.GetAttribute("name").Utf8(); | 157 std::string name = elem.GetAttribute("name").Utf8(); |
| 168 WebString content = elem.GetAttribute("content"); | 158 WebString content = elem.GetAttribute("content"); |
| 169 if (name == "application-name") { | 159 if (name == "application-name") { |
| 170 app_info->title = content.Utf16(); | 160 app_info->title = content.Utf16(); |
| 171 } else if (name == "description") { | 161 } else if (name == "description") { |
| 172 app_info->description = content.Utf16(); | 162 app_info->description = content.Utf16(); |
| 173 } else if (name == "application-url") { | 163 } else if (name == "application-url") { |
| 174 std::string url = content.Utf8(); | 164 std::string url = content.Utf8(); |
| 175 app_info->app_url = document_url.is_valid() ? | 165 app_info->app_url = document_url.is_valid() ? |
| 176 document_url.Resolve(url) : GURL(url); | 166 document_url.Resolve(url) : GURL(url); |
| 177 if (!app_info->app_url.is_valid()) | 167 if (!app_info->app_url.is_valid()) |
| 178 app_info->app_url = GURL(); | 168 app_info->app_url = GURL(); |
| 179 } else if (name == "mobile-web-app-capable" && | 169 } else if (name == "mobile-web-app-capable" && |
| 180 base::LowerCaseEqualsASCII(content.Utf16(), "yes")) { | 170 base::LowerCaseEqualsASCII(content.Utf16(), "yes")) { |
| 181 app_info->mobile_capable = WebApplicationInfo::MOBILE_CAPABLE; | 171 app_info->mobile_capable = WebApplicationInfo::MOBILE_CAPABLE; |
| 182 } else if (name == "apple-mobile-web-app-capable" && | 172 } else if (name == "apple-mobile-web-app-capable" && |
| 183 base::LowerCaseEqualsASCII(content.Utf16(), "yes") && | 173 base::LowerCaseEqualsASCII(content.Utf16(), "yes") && |
| 184 app_info->mobile_capable == | 174 app_info->mobile_capable == |
| 185 WebApplicationInfo::MOBILE_CAPABLE_UNSPECIFIED) { | 175 WebApplicationInfo::MOBILE_CAPABLE_UNSPECIFIED) { |
| 186 app_info->mobile_capable = WebApplicationInfo::MOBILE_CAPABLE_APPLE; | 176 app_info->mobile_capable = WebApplicationInfo::MOBILE_CAPABLE_APPLE; |
| 187 } | 177 } |
| 188 } | 178 } |
| 189 } | 179 } |
| 190 } | 180 } |
| 191 | 181 |
| 192 } // namespace web_apps | 182 } // namespace web_apps |
| OLD | NEW |