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 <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
| 10 #include "base/command_line.h" |
10 #include "base/json/json_reader.h" | 11 #include "base/json/json_reader.h" |
11 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
12 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
13 #include "base/strings/string_split.h" | 14 #include "base/strings/string_split.h" |
14 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
15 #include "base/values.h" | 16 #include "base/values.h" |
| 17 #include "chrome/common/chrome_switches.h" |
16 #include "chrome/common/web_application_info.h" | 18 #include "chrome/common/web_application_info.h" |
17 #include "grit/common_resources.h" | 19 #include "grit/common_resources.h" |
18 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
19 #include "third_party/WebKit/public/platform/WebString.h" | 21 #include "third_party/WebKit/public/platform/WebString.h" |
20 #include "third_party/WebKit/public/platform/WebURL.h" | 22 #include "third_party/WebKit/public/platform/WebURL.h" |
21 #include "third_party/WebKit/public/web/WebDocument.h" | 23 #include "third_party/WebKit/public/web/WebDocument.h" |
22 #include "third_party/WebKit/public/web/WebElement.h" | 24 #include "third_party/WebKit/public/web/WebElement.h" |
23 #include "third_party/WebKit/public/web/WebFrame.h" | 25 #include "third_party/WebKit/public/web/WebFrame.h" |
24 #include "third_party/WebKit/public/web/WebNode.h" | 26 #include "third_party/WebKit/public/web/WebNode.h" |
25 #include "third_party/WebKit/public/web/WebNodeList.h" | 27 #include "third_party/WebKit/public/web/WebNodeList.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 if (!child.isElementNode()) | 139 if (!child.isElementNode()) |
138 continue; | 140 continue; |
139 WebElement elem = child.to<WebElement>(); | 141 WebElement elem = child.to<WebElement>(); |
140 | 142 |
141 if (elem.hasTagName("link")) { | 143 if (elem.hasTagName("link")) { |
142 std::string rel = elem.getAttribute("rel").utf8(); | 144 std::string rel = elem.getAttribute("rel").utf8(); |
143 // "rel" attribute may use either "icon" or "shortcut icon". | 145 // "rel" attribute may use either "icon" or "shortcut icon". |
144 // see also | 146 // see also |
145 // <http://en.wikipedia.org/wiki/Favicon> | 147 // <http://en.wikipedia.org/wiki/Favicon> |
146 // <http://dev.w3.org/html5/spec/Overview.html#rel-icon> | 148 // <http://dev.w3.org/html5/spec/Overview.html#rel-icon> |
| 149 // |
| 150 // Streamlined Hosted Apps also support "apple-touch-icon" and |
| 151 // "apple-touch-icon-precomposed". |
147 if (LowerCaseEqualsASCII(rel, "icon") || | 152 if (LowerCaseEqualsASCII(rel, "icon") || |
148 LowerCaseEqualsASCII(rel, "shortcut icon")) { | 153 LowerCaseEqualsASCII(rel, "shortcut icon") || |
| 154 (CommandLine::ForCurrentProcess()-> |
| 155 HasSwitch(switches::kEnableStreamlinedHostedApps) && |
| 156 (LowerCaseEqualsASCII(rel, "apple-touch-icon") || |
| 157 LowerCaseEqualsASCII(rel, "apple-touch-icon-precomposed")))) { |
149 AddInstallIcon(elem, &app_info->icons); | 158 AddInstallIcon(elem, &app_info->icons); |
150 } | 159 } |
151 } else if (elem.hasTagName("meta") && elem.hasAttribute("name")) { | 160 } else if (elem.hasTagName("meta") && elem.hasAttribute("name")) { |
152 std::string name = elem.getAttribute("name").utf8(); | 161 std::string name = elem.getAttribute("name").utf8(); |
153 WebString content = elem.getAttribute("content"); | 162 WebString content = elem.getAttribute("content"); |
154 if (name == "application-name") { | 163 if (name == "application-name") { |
155 app_info->title = content; | 164 app_info->title = content; |
156 } else if (name == "description") { | 165 } else if (name == "description") { |
157 app_info->description = content; | 166 app_info->description = content; |
158 } else if (name == "application-url") { | 167 } else if (name == "application-url") { |
159 std::string url = content.utf8(); | 168 std::string url = content.utf8(); |
160 app_info->app_url = document_url.is_valid() ? | 169 app_info->app_url = document_url.is_valid() ? |
161 document_url.Resolve(url) : GURL(url); | 170 document_url.Resolve(url) : GURL(url); |
162 if (!app_info->app_url.is_valid()) | 171 if (!app_info->app_url.is_valid()) |
163 app_info->app_url = GURL(); | 172 app_info->app_url = GURL(); |
164 } | 173 } |
165 } | 174 } |
166 } | 175 } |
167 | 176 |
168 return true; | 177 return true; |
169 } | 178 } |
170 | 179 |
171 } // namespace web_apps | 180 } // namespace web_apps |
OLD | NEW |