Chromium Code Reviews| 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() | 7 ShortcutInfo::ShortcutInfo() |
| 8 : display(content::Manifest::DISPLAY_MODE_BROWSER), | 8 : display(content::Manifest::DISPLAY_MODE_BROWSER), |
| 9 orientation(blink::WebScreenOrientationLockDefault), | 9 orientation(blink::WebScreenOrientationLockDefault), |
| 10 source(SOURCE_ADD_TO_HOMESCREEN) { | 10 source(SOURCE_ADD_TO_HOMESCREEN) { |
| 11 } | 11 } |
| 12 | 12 |
| 13 ShortcutInfo::ShortcutInfo(const GURL& shortcut_url) | 13 ShortcutInfo::ShortcutInfo(const GURL& shortcut_url) |
| 14 : url(shortcut_url), | 14 : url(shortcut_url), |
| 15 display(content::Manifest::DISPLAY_MODE_BROWSER), | 15 display(content::Manifest::DISPLAY_MODE_BROWSER), |
| 16 orientation(blink::WebScreenOrientationLockDefault), | 16 orientation(blink::WebScreenOrientationLockDefault), |
| 17 source(SOURCE_ADD_TO_HOMESCREEN) { | 17 source(SOURCE_ADD_TO_HOMESCREEN) { |
| 18 } | 18 } |
| 19 | 19 |
| 20 void ShortcutInfo::UpdateFromManifest(const content::Manifest& manifest) { | 20 void ShortcutInfo::UpdateFromManifest(const content::Manifest& manifest) { |
| 21 if (!manifest.short_name.is_null()) | 21 if (manifest.name.is_null()) { |
| 22 title = manifest.short_name.string(); | 22 short_name = manifest.short_name.string(); |
| 23 else if (!manifest.name.is_null()) | 23 name = short_name; |
| 24 title = manifest.name.string(); | 24 } else if (manifest.short_name.is_null()) { |
| 25 name = manifest.name.string(); | |
| 26 short_name = name; | |
| 27 } else { | |
| 28 name = manifest.name.string(); | |
| 29 short_name = manifest.short_name.string(); | |
| 30 } | |
|
mlamouri (slow - plz ping)
2015/07/21 10:24:47
I think this will explode if manifest.short_name a
Lalit Maganti
2015/07/21 10:26:44
Ahhhhh I totally forgot this method gets called re
| |
| 31 if (!short_name.empty()) | |
| 32 user_title = short_name; | |
| 25 | 33 |
| 26 // Set the url based on the manifest value, if any. | 34 // Set the url based on the manifest value, if any. |
| 27 if (manifest.start_url.is_valid()) | 35 if (manifest.start_url.is_valid()) |
| 28 url = manifest.start_url; | 36 url = manifest.start_url; |
| 29 | 37 |
| 30 // Set the display based on the manifest value, if any. | 38 // Set the display based on the manifest value, if any. |
| 31 if (manifest.display != content::Manifest::DISPLAY_MODE_UNSPECIFIED) | 39 if (manifest.display != content::Manifest::DISPLAY_MODE_UNSPECIFIED) |
| 32 display = manifest.display; | 40 display = manifest.display; |
| 33 | 41 |
| 34 // 'fullscreen' and 'minimal-ui' are not yet supported, fallback to the right | 42 // 'fullscreen' and 'minimal-ui' are not yet supported, fallback to the right |
| 35 // mode in those cases. | 43 // mode in those cases. |
| 36 if (manifest.display == content::Manifest::DISPLAY_MODE_FULLSCREEN) | 44 if (manifest.display == content::Manifest::DISPLAY_MODE_FULLSCREEN) |
| 37 display = content::Manifest::DISPLAY_MODE_STANDALONE; | 45 display = content::Manifest::DISPLAY_MODE_STANDALONE; |
| 38 if (manifest.display == content::Manifest::DISPLAY_MODE_MINIMAL_UI) | 46 if (manifest.display == content::Manifest::DISPLAY_MODE_MINIMAL_UI) |
| 39 display = content::Manifest::DISPLAY_MODE_BROWSER; | 47 display = content::Manifest::DISPLAY_MODE_BROWSER; |
| 40 | 48 |
| 41 // Set the orientation based on the manifest value, if any. | 49 // Set the orientation based on the manifest value, if any. |
| 42 if (manifest.orientation != blink::WebScreenOrientationLockDefault) { | 50 if (manifest.orientation != blink::WebScreenOrientationLockDefault) { |
| 43 // Ignore the orientation if the display mode is different from | 51 // Ignore the orientation if the display mode is different from |
| 44 // 'standalone'. | 52 // 'standalone'. |
| 45 // TODO(mlamouri): send a message to the developer console about this. | 53 // TODO(mlamouri): send a message to the developer console about this. |
| 46 if (display == content::Manifest::DISPLAY_MODE_STANDALONE) | 54 if (display == content::Manifest::DISPLAY_MODE_STANDALONE) |
| 47 orientation = manifest.orientation; | 55 orientation = manifest.orientation; |
| 48 } | 56 } |
| 49 } | 57 } |
| 50 | 58 |
| 51 void ShortcutInfo::UpdateSource(const Source new_source) { | 59 void ShortcutInfo::UpdateSource(const Source new_source) { |
| 52 source = new_source; | 60 source = new_source; |
| 53 } | 61 } |
| OLD | NEW |