| 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/android/shortcut_info.h" | 5 #include "chrome/browser/android/shortcut_info.h" |
| 6 | 6 |
| 7 ShortcutInfo::ShortcutInfo(const GURL& shortcut_url) | 7 ShortcutInfo::ShortcutInfo(const GURL& shortcut_url) |
| 8 : url(shortcut_url), | 8 : url(shortcut_url), |
| 9 display(blink::kWebDisplayModeBrowser), | 9 display(blink::kWebDisplayModeBrowser), |
| 10 orientation(blink::kWebScreenOrientationLockDefault), | 10 orientation(blink::kWebScreenOrientationLockDefault), |
| 11 source(SOURCE_ADD_TO_HOMESCREEN_SHORTCUT), | 11 source(SOURCE_ADD_TO_HOMESCREEN_SHORTCUT), |
| 12 theme_color(content::Manifest::kInvalidOrMissingColor), | 12 theme_color(content::Manifest::kInvalidOrMissingColor), |
| 13 background_color(content::Manifest::kInvalidOrMissingColor), | 13 background_color(content::Manifest::kInvalidOrMissingColor), |
| 14 ideal_splash_image_size_in_px(0), | 14 ideal_splash_image_size_in_px(0), |
| 15 minimum_splash_image_size_in_px(0) {} | 15 minimum_splash_image_size_in_px(0) {} |
| 16 | 16 |
| 17 ShortcutInfo::ShortcutInfo(const ShortcutInfo& other) = default; | 17 ShortcutInfo::ShortcutInfo(const ShortcutInfo& other) = default; |
| 18 | 18 |
| 19 ShortcutInfo::~ShortcutInfo() { | 19 ShortcutInfo::~ShortcutInfo() { |
| 20 } | 20 } |
| 21 | 21 |
| 22 void ShortcutInfo::UpdateFromManifest(const content::Manifest& manifest) { | 22 void ShortcutInfo::UpdateFromManifest(const content::Manifest& manifest) { |
| 23 if (!manifest.short_name.is_null()) | 23 if (!manifest.short_name.string().empty() || |
| 24 !manifest.name.string().empty()) { |
| 24 short_name = manifest.short_name.string(); | 25 short_name = manifest.short_name.string(); |
| 25 if (!manifest.name.is_null()) | |
| 26 name = manifest.name.string(); | 26 name = manifest.name.string(); |
| 27 if (manifest.short_name.is_null() != manifest.name.is_null()) { | 27 if (short_name.empty()) |
| 28 if (manifest.short_name.is_null()) | |
| 29 short_name = name; | 28 short_name = name; |
| 30 else | 29 else if (name.empty()) |
| 31 name = short_name; | 30 name = short_name; |
| 32 } | 31 } |
| 33 user_title = short_name; | |
| 34 | 32 |
| 35 // Set the url based on the manifest value, if any. | 33 // Set the url based on the manifest value, if any. |
| 36 if (manifest.start_url.is_valid()) | 34 if (manifest.start_url.is_valid()) |
| 37 url = manifest.start_url; | 35 url = manifest.start_url; |
| 38 | 36 |
| 39 if (manifest.scope.is_valid()) | 37 if (manifest.scope.is_valid()) |
| 40 scope = manifest.scope; | 38 scope = manifest.scope; |
| 41 | 39 |
| 42 // Set the display based on the manifest value, if any. | 40 // Set the display based on the manifest value, if any. |
| 43 if (manifest.display != blink::kWebDisplayModeUndefined) | 41 if (manifest.display != blink::kWebDisplayModeUndefined) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 73 | 71 |
| 74 // Set the icon urls based on the icons in the manifest, if any. | 72 // Set the icon urls based on the icons in the manifest, if any. |
| 75 icon_urls.clear(); | 73 icon_urls.clear(); |
| 76 for (const content::Manifest::Icon& icon : manifest.icons) | 74 for (const content::Manifest::Icon& icon : manifest.icons) |
| 77 icon_urls.push_back(icon.src.spec()); | 75 icon_urls.push_back(icon.src.spec()); |
| 78 } | 76 } |
| 79 | 77 |
| 80 void ShortcutInfo::UpdateSource(const Source new_source) { | 78 void ShortcutInfo::UpdateSource(const Source new_source) { |
| 81 source = new_source; | 79 source = new_source; |
| 82 } | 80 } |
| OLD | NEW |