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(const GURL
& shortcut_url
)
9 display(blink::WebDisplayModeBrowser
),
10 orientation(blink::WebScreenOrientationLockDefault
),
11 source(SOURCE_ADD_TO_HOMESCREEN
),
12 theme_color(content::Manifest::kInvalidOrMissingColor
),
13 background_color(content::Manifest::kInvalidOrMissingColor
) {
16 ShortcutInfo::~ShortcutInfo() {
19 void ShortcutInfo::UpdateFromManifest(const content::Manifest
& manifest
) {
20 if (!manifest
.short_name
.is_null())
21 short_name
= manifest
.short_name
.string();
22 if (!manifest
.name
.is_null())
23 name
= manifest
.name
.string();
24 if (manifest
.short_name
.is_null() != manifest
.name
.is_null()) {
25 if (manifest
.short_name
.is_null())
30 user_title
= short_name
;
32 // Set the url based on the manifest value, if any.
33 if (manifest
.start_url
.is_valid())
34 url
= manifest
.start_url
;
36 // Set the display based on the manifest value, if any.
37 if (manifest
.display
!= blink::WebDisplayModeUndefined
)
38 display
= manifest
.display
;
40 // 'fullscreen' and 'minimal-ui' are not yet supported, fallback to the right
41 // mode in those cases.
42 if (manifest
.display
== blink::WebDisplayModeFullscreen
)
43 display
= blink::WebDisplayModeStandalone
;
44 if (manifest
.display
== blink::WebDisplayModeMinimalUi
)
45 display
= blink::WebDisplayModeBrowser
;
47 // Set the orientation based on the manifest value, if any.
48 if (manifest
.orientation
!= blink::WebScreenOrientationLockDefault
) {
49 // Ignore the orientation if the display mode is different from
51 // TODO(mlamouri): send a message to the developer console about this.
52 if (display
== blink::WebDisplayModeStandalone
)
53 orientation
= manifest
.orientation
;
56 // Set the theme color based on the manifest value, if any.
57 if (manifest
.theme_color
!= content::Manifest::kInvalidOrMissingColor
)
58 theme_color
= manifest
.theme_color
;
60 // Set the background color based on the manifest value, if any.
61 if (manifest
.background_color
!= content::Manifest::kInvalidOrMissingColor
)
62 background_color
= manifest
.background_color
;
65 void ShortcutInfo::UpdateSource(const Source new_source
) {