Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1014)

Side by Side Diff: chrome/browser/android/shortcut_info.cc

Issue 2697473005: Improve the resolution of the menu item homescreen launch source metric. (Closed)
Patch Set: Nits Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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::WebDisplayModeBrowser), 9 display(blink::WebDisplayModeBrowser),
10 orientation(blink::WebScreenOrientationLockDefault), 10 orientation(blink::WebScreenOrientationLockDefault),
11 source(SOURCE_ADD_TO_HOMESCREEN), 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 }
15 14
16 ShortcutInfo::ShortcutInfo(const ShortcutInfo& other) = default; 15 ShortcutInfo::ShortcutInfo(const ShortcutInfo& other) = default;
17 16
18 ShortcutInfo::~ShortcutInfo() { 17 ShortcutInfo::~ShortcutInfo() {
19 } 18 }
20 19
21 void ShortcutInfo::UpdateFromManifest(const content::Manifest& manifest) { 20 void ShortcutInfo::UpdateFromManifest(const content::Manifest& manifest) {
22 if (!manifest.short_name.is_null()) 21 if (!manifest.short_name.is_null())
23 short_name = manifest.short_name.string(); 22 short_name = manifest.short_name.string();
24 if (!manifest.name.is_null()) 23 if (!manifest.name.is_null())
(...skipping 10 matching lines...) Expand all
35 if (manifest.start_url.is_valid()) 34 if (manifest.start_url.is_valid())
36 url = manifest.start_url; 35 url = manifest.start_url;
37 36
38 if (manifest.scope.is_valid()) 37 if (manifest.scope.is_valid())
39 scope = manifest.scope; 38 scope = manifest.scope;
40 39
41 // Set the display based on the manifest value, if any. 40 // Set the display based on the manifest value, if any.
42 if (manifest.display != blink::WebDisplayModeUndefined) 41 if (manifest.display != blink::WebDisplayModeUndefined)
43 display = manifest.display; 42 display = manifest.display;
44 43
45 // 'minimal-ui' is not yet supported, so fallback in this case. 44 // 'minimal-ui' is not yet supported (see crbug.com/604390). Otherwise, set
46 // See crbug.com/604390. 45 // the source to be standalone if appropriate.
47 if (manifest.display == blink::WebDisplayModeMinimalUi) 46 if (manifest.display == blink::WebDisplayModeMinimalUi) {
48 display = blink::WebDisplayModeBrowser; 47 display = blink::WebDisplayModeBrowser;
48 } else if (display == blink::WebDisplayModeStandalone ||
49 display == blink::WebDisplayModeFullscreen) {
50 source = SOURCE_ADD_TO_HOMESCREEN_STANDALONE;
51 }
49 52
50 // Set the orientation based on the manifest value, if any. 53 // Set the orientation based on the manifest value, if any.
51 if (manifest.orientation != blink::WebScreenOrientationLockDefault) { 54 if (manifest.orientation != blink::WebScreenOrientationLockDefault) {
52 // Ignore the orientation if the display mode is different from 55 // Ignore the orientation if the display mode is different from
53 // 'standalone' or 'fullscreen'. 56 // 'standalone' or 'fullscreen'.
54 // TODO(mlamouri): send a message to the developer console about this. 57 // TODO(mlamouri): send a message to the developer console about this.
55 if (display == blink::WebDisplayModeStandalone || 58 if (display == blink::WebDisplayModeStandalone ||
56 display == blink::WebDisplayModeFullscreen) { 59 display == blink::WebDisplayModeFullscreen) {
57 orientation = manifest.orientation; 60 orientation = manifest.orientation;
58 } 61 }
59 } 62 }
60 63
61 // Set the theme color based on the manifest value, if any. 64 // Set the theme color based on the manifest value, if any.
62 if (manifest.theme_color != content::Manifest::kInvalidOrMissingColor) 65 if (manifest.theme_color != content::Manifest::kInvalidOrMissingColor)
63 theme_color = manifest.theme_color; 66 theme_color = manifest.theme_color;
64 67
65 // Set the background color based on the manifest value, if any. 68 // Set the background color based on the manifest value, if any.
66 if (manifest.background_color != content::Manifest::kInvalidOrMissingColor) 69 if (manifest.background_color != content::Manifest::kInvalidOrMissingColor)
67 background_color = manifest.background_color; 70 background_color = manifest.background_color;
68 71
69 // 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.
70 icon_urls.clear(); 73 icon_urls.clear();
71 for (const content::Manifest::Icon& icon : manifest.icons) 74 for (const content::Manifest::Icon& icon : manifest.icons)
72 icon_urls.push_back(icon.src.spec()); 75 icon_urls.push_back(icon.src.spec());
73 } 76 }
74 77
75 void ShortcutInfo::UpdateSource(const Source new_source) { 78 void ShortcutInfo::UpdateSource(const Source new_source) {
76 source = new_source; 79 source = new_source;
77 } 80 }
OLDNEW
« no previous file with comments | « chrome/browser/android/shortcut_info.h ('k') | chrome/browser/android/webapps/add_to_homescreen_data_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698