| 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" | 12 #include "base/command_line.h" |
| 13 #include "base/feature_list.h" |
| 13 #include "base/json/json_reader.h" | 14 #include "base/json/json_reader.h" |
| 14 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 15 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/strings/string_split.h" | 17 #include "base/strings/string_split.h" |
| 17 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
| 18 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
| 19 #include "base/values.h" | 20 #include "base/values.h" |
| 20 #include "build/build_config.h" | 21 #include "build/build_config.h" |
| 21 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_features.h" |
| 22 #include "chrome/common/web_application_info.h" | 23 #include "chrome/common/web_application_info.h" |
| 23 #include "third_party/WebKit/public/platform/WebIconSizesParser.h" | 24 #include "third_party/WebKit/public/platform/WebIconSizesParser.h" |
| 24 #include "third_party/WebKit/public/platform/WebString.h" | 25 #include "third_party/WebKit/public/platform/WebString.h" |
| 25 #include "third_party/WebKit/public/platform/WebURL.h" | 26 #include "third_party/WebKit/public/platform/WebURL.h" |
| 26 #include "third_party/WebKit/public/web/WebDocument.h" | 27 #include "third_party/WebKit/public/web/WebDocument.h" |
| 27 #include "third_party/WebKit/public/web/WebElement.h" | 28 #include "third_party/WebKit/public/web/WebElement.h" |
| 28 #include "third_party/WebKit/public/web/WebFrame.h" | 29 #include "third_party/WebKit/public/web/WebFrame.h" |
| 29 #include "third_party/WebKit/public/web/WebNode.h" | 30 #include "third_party/WebKit/public/web/WebNode.h" |
| 30 #include "ui/gfx/geometry/size.h" | 31 #include "ui/gfx/geometry/size.h" |
| 31 #include "url/gurl.h" | 32 #include "url/gurl.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 if (elem.hasHTMLTagName("link")) { | 144 if (elem.hasHTMLTagName("link")) { |
| 144 std::string rel = elem.getAttribute("rel").utf8(); | 145 std::string rel = elem.getAttribute("rel").utf8(); |
| 145 // "rel" attribute may use either "icon" or "shortcut icon". | 146 // "rel" attribute may use either "icon" or "shortcut icon". |
| 146 // see also | 147 // see also |
| 147 // <http://en.wikipedia.org/wiki/Favicon> | 148 // <http://en.wikipedia.org/wiki/Favicon> |
| 148 // <http://dev.w3.org/html5/spec/Overview.html#rel-icon> | 149 // <http://dev.w3.org/html5/spec/Overview.html#rel-icon> |
| 149 // | 150 // |
| 150 // Bookmark apps also support "apple-touch-icon" and | 151 // Bookmark apps also support "apple-touch-icon" and |
| 151 // "apple-touch-icon-precomposed". | 152 // "apple-touch-icon-precomposed". |
| 152 #if defined(OS_MACOSX) | 153 #if defined(OS_MACOSX) |
| 153 bool bookmark_apps_enabled = base::CommandLine::ForCurrentProcess()-> | 154 bool bookmark_apps_enabled = |
| 154 HasSwitch(switches::kEnableNewBookmarkApps); | 155 base::FeatureList::IsEnabled(features::kBookmarkApps); |
| 155 #else | 156 #else |
| 156 bool bookmark_apps_enabled = !base::CommandLine::ForCurrentProcess()-> | 157 bool bookmark_apps_enabled = true; |
| 157 HasSwitch(switches::kDisableNewBookmarkApps); | |
| 158 #endif | 158 #endif |
| 159 if (base::LowerCaseEqualsASCII(rel, "icon") || | 159 if (base::LowerCaseEqualsASCII(rel, "icon") || |
| 160 base::LowerCaseEqualsASCII(rel, "shortcut icon") || | 160 base::LowerCaseEqualsASCII(rel, "shortcut icon") || |
| 161 (bookmark_apps_enabled && | 161 (bookmark_apps_enabled && |
| 162 (base::LowerCaseEqualsASCII(rel, "apple-touch-icon") || | 162 (base::LowerCaseEqualsASCII(rel, "apple-touch-icon") || |
| 163 base::LowerCaseEqualsASCII(rel, "apple-touch-icon-precomposed")))) { | 163 base::LowerCaseEqualsASCII(rel, "apple-touch-icon-precomposed")))) { |
| 164 AddInstallIcon(elem, &app_info->icons); | 164 AddInstallIcon(elem, &app_info->icons); |
| 165 } | 165 } |
| 166 } else if (elem.hasHTMLTagName("meta") && elem.hasAttribute("name")) { | 166 } else if (elem.hasHTMLTagName("meta") && elem.hasAttribute("name")) { |
| 167 std::string name = elem.getAttribute("name").utf8(); | 167 std::string name = elem.getAttribute("name").utf8(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 183 base::LowerCaseEqualsASCII(content.utf16(), "yes") && | 183 base::LowerCaseEqualsASCII(content.utf16(), "yes") && |
| 184 app_info->mobile_capable == | 184 app_info->mobile_capable == |
| 185 WebApplicationInfo::MOBILE_CAPABLE_UNSPECIFIED) { | 185 WebApplicationInfo::MOBILE_CAPABLE_UNSPECIFIED) { |
| 186 app_info->mobile_capable = WebApplicationInfo::MOBILE_CAPABLE_APPLE; | 186 app_info->mobile_capable = WebApplicationInfo::MOBILE_CAPABLE_APPLE; |
| 187 } | 187 } |
| 188 } | 188 } |
| 189 } | 189 } |
| 190 } | 190 } |
| 191 | 191 |
| 192 } // namespace web_apps | 192 } // namespace web_apps |
| OLD | NEW |