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

Side by Side Diff: chrome/browser/ui/webui/aura/app_list_ui.cc

Issue 8423055: [Aura] Initial app list webui. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove grabber.js Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 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 #include "chrome/browser/ui/webui/aura/app_list_ui.h"
6
7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/google/google_util.h"
9 #include "chrome/browser/prefs/pref_service.h"
10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
12 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h"
13 #include "chrome/common/extensions/extension_constants.h"
14 #include "chrome/common/pref_names.h"
15 #include "chrome/common/url_constants.h"
16 #include "content/browser/tab_contents/tab_contents.h"
17 #include "grit/browser_resources.h"
18 #include "grit/chromium_strings.h"
19 #include "grit/generated_resources.h"
20 #include "ui/base/l10n/l10n_util.h"
21
22 namespace {
23
24 static const int kPageIdOffset = 10;
25 static const int kIndexMask = (1 << kPageIdOffset) - 1;
26
27 // TODO(xiyuan): Merge this with the one on ntp_resource_cache.
28 string16 GetUrlWithLang(const GURL& url) {
29 return ASCIIToUTF16(google_util::AppendGoogleLocaleParam(url).spec());
30 }
31
32 ChromeWebUIDataSource* CreateAppListUIHTMLSource(PrefService* prefs) {
33 ChromeWebUIDataSource* source =
34 new ChromeWebUIDataSource(chrome::kChromeUIAppListHost);
35
36 string16 apps = l10n_util::GetStringUTF16(IDS_NEW_TAB_APPS);
37 string16 title = l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE);
38
39 DictionaryValue localized_strings;
40 localized_strings.SetString("apps", apps);
41 localized_strings.SetString("title", title);
42 localized_strings.SetString("appuninstall",
43 l10n_util::GetStringFUTF16(
44 IDS_NEW_TAB_APP_UNINSTALL,
45 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)));
46 localized_strings.SetString("appoptions",
47 l10n_util::GetStringUTF16(IDS_NEW_TAB_APP_OPTIONS));
48 localized_strings.SetString("appcreateshortcut",
49 l10n_util::GetStringUTF16(IDS_NEW_TAB_APP_CREATE_SHORTCUT));
50 localized_strings.SetString("appDefaultPageName",
51 l10n_util::GetStringUTF16(IDS_APP_DEFAULT_PAGE_NAME));
52 localized_strings.SetString("applaunchtypepinned",
53 l10n_util::GetStringUTF16(IDS_APP_CONTEXT_MENU_OPEN_PINNED));
54 localized_strings.SetString("applaunchtyperegular",
55 l10n_util::GetStringUTF16(IDS_APP_CONTEXT_MENU_OPEN_REGULAR));
56 localized_strings.SetString("applaunchtypewindow",
57 l10n_util::GetStringUTF16(IDS_APP_CONTEXT_MENU_OPEN_WINDOW));
58 localized_strings.SetString("applaunchtypefullscreen",
59 l10n_util::GetStringUTF16(IDS_APP_CONTEXT_MENU_OPEN_FULLSCREEN));
60 localized_strings.SetString("web_store_title",
61 l10n_util::GetStringUTF16(IDS_EXTENSION_WEB_STORE_TITLE));
62 localized_strings.SetString("web_store_url",
63 GetUrlWithLang(GURL(extension_urls::GetWebstoreLaunchURL())));
64
65 localized_strings.SetString("search-box-hint",
66 l10n_util::GetStringUTF16(IDS_SEARCH_BOX_HINT));
67
68 // TODO(xiyuan): Maybe need to use another prefs for app list.
69 int shown_page = prefs->GetInteger(prefs::kNTPShownPage);
70 localized_strings.SetInteger("shown_page_type", shown_page & ~kIndexMask);
71 localized_strings.SetInteger("shown_page_index", shown_page & kIndexMask);
72
73 source->AddLocalizedStrings(localized_strings);
74 source->set_json_path("strings.js");
75 source->set_default_resource(IDR_APP_LIST_HTML);
76 return source;
77 }
78
79 } // namespace
80
81 AppListUI::AppListUI(TabContents* contents)
82 : ChromeWebUI(contents) {
83 ExtensionService* service = GetProfile()->GetExtensionService();
84 if (service)
85 AddMessageHandler((new AppLauncherHandler(service))->Attach(this));
86
87 // Set up the source.
88 Profile* profile = Profile::FromBrowserContext(contents->browser_context());
89 PrefService* prefs = profile->GetPrefs();
90 profile->GetChromeURLDataManager()->AddDataSource(
91 CreateAppListUIHTMLSource(prefs));
92 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/aura/app_list_ui.h ('k') | chrome/browser/ui/webui/chrome_url_data_manager_backend.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698