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
3 // found in the LICENSE file.
5 #include "chrome/browser/android/shortcut_info.h"
7 ShortcutInfo::ShortcutInfo()
8 : display(content::Manifest::DISPLAY_MODE_BROWSER
),
9 orientation(blink::WebScreenOrientationLockDefault
),
10 source(SOURCE_ADD_TO_HOMESCREEN
) {
13 ShortcutInfo::ShortcutInfo(const GURL
& shortcut_url
)
15 display(content::Manifest::DISPLAY_MODE_BROWSER
),
16 orientation(blink::WebScreenOrientationLockDefault
),
17 source(SOURCE_ADD_TO_HOMESCREEN
) {
20 ShortcutInfo::~ShortcutInfo() {
23 void ShortcutInfo::UpdateFromManifest(const content::Manifest
& manifest
) {
24 if (!manifest
.short_name
.is_null())
25 short_name
= manifest
.short_name
.string();
26 if (!manifest
.name
.is_null())
27 name
= manifest
.name
.string();
28 if (manifest
.short_name
.is_null() != manifest
.name
.is_null()) {
29 if (manifest
.short_name
.is_null())
33 if (!short_name
.empty())
34 user_title
= short_name
;
36 // Set the url based on the manifest value, if any.
37 if (manifest
.start_url
.is_valid())
38 url
= manifest
.start_url
;
40 // Set the display based on the manifest value, if any.
41 if (manifest
.display
!= content::Manifest::DISPLAY_MODE_UNSPECIFIED
)
42 display
= manifest
.display
;
44 // 'fullscreen' and 'minimal-ui' are not yet supported, fallback to the right
45 // mode in those cases.
46 if (manifest
.display
== content::Manifest::DISPLAY_MODE_FULLSCREEN
)
47 display
= content::Manifest::DISPLAY_MODE_STANDALONE
;
48 if (manifest
.display
== content::Manifest::DISPLAY_MODE_MINIMAL_UI
)
49 display
= content::Manifest::DISPLAY_MODE_BROWSER
;
51 // Set the orientation based on the manifest value, if any.
52 if (manifest
.orientation
!= blink::WebScreenOrientationLockDefault
) {
53 // Ignore the orientation if the display mode is different from
55 // TODO(mlamouri): send a message to the developer console about this.
56 if (display
== content::Manifest::DISPLAY_MODE_STANDALONE
)
57 orientation
= manifest
.orientation
;
61 void ShortcutInfo::UpdateSource(const Source new_source
) {