- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / resources / app_list / start_page.js
1 // Copyright 2013 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.
4
5 /**
6  * @fileoverview App launcher start page implementation.
7  */
8
9 <include src="recommended_apps.js"/>
10
11 cr.define('appList.startPage', function() {
12   'use strict';
13
14   /**
15    * Creates a StartPage object.
16    * @constructor
17    * @extends {HTMLDivElement}
18    */
19   var StartPage = cr.ui.define('div');
20
21   StartPage.prototype = {
22     __proto__: HTMLDivElement.prototype,
23
24     /**
25      * Instance of the recommended apps card.
26      * @type {appsList.startPage.RecommendedApps}
27      * @private
28      */
29     recommendedApps_: null,
30
31     /** @override */
32     decorate: function() {
33       this.recommendedApps_ = new appList.startPage.RecommendedApps();
34       this.appendChild(this.recommendedApps_);
35     },
36
37     /**
38      * Sets the recommended apps.
39      * @param {!Array.<!{appId: string,
40      *                   iconUrl: string,
41      *                   textTitle: string}>} apps An array of app info
42      *     dictionary to be displayed in the AppItemView.
43      */
44     setRecommendedApps: function(apps) {
45       this.recommendedApps_.setApps(apps);
46     }
47   };
48
49   /**
50    * Initialize the page.
51    */
52   function initialize() {
53     StartPage.decorate($('start-page'));
54     chrome.send('initialize');
55   }
56
57   /**
58    * Sets the recommended apps.
59    * @param {Array.<Object>} apps An array of app info dictionary.
60    */
61   function setRecommendedApps(apps) {
62     $('start-page').setRecommendedApps(apps);
63   }
64
65   return {
66     initialize: initialize,
67     setRecommendedApps: setRecommendedApps
68   };
69 });
70
71 document.addEventListener('contextmenu', function(e) { e.preventDefault(); });
72 document.addEventListener('DOMContentLoaded', appList.startPage.initialize);