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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/aura/app_list_ui.cc
diff --git a/chrome/browser/ui/webui/aura/app_list_ui.cc b/chrome/browser/ui/webui/aura/app_list_ui.cc
new file mode 100644
index 0000000000000000000000000000000000000000..574a0aac36b4fb8950001f65c58dc797f01766e2
--- /dev/null
+++ b/chrome/browser/ui/webui/aura/app_list_ui.cc
@@ -0,0 +1,92 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/aura/app_list_ui.h"
+
+#include "base/utf_string_conversions.h"
+#include "chrome/browser/google/google_util.h"
+#include "chrome/browser/prefs/pref_service.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
+#include "chrome/browser/ui/webui/ntp/app_launcher_handler.h"
+#include "chrome/common/extensions/extension_constants.h"
+#include "chrome/common/pref_names.h"
+#include "chrome/common/url_constants.h"
+#include "content/browser/tab_contents/tab_contents.h"
+#include "grit/browser_resources.h"
+#include "grit/chromium_strings.h"
+#include "grit/generated_resources.h"
+#include "ui/base/l10n/l10n_util.h"
+
+namespace {
+
+static const int kPageIdOffset = 10;
+static const int kIndexMask = (1 << kPageIdOffset) - 1;
+
+// TODO(xiyuan): Merge this with the one on ntp_resource_cache.
+string16 GetUrlWithLang(const GURL& url) {
+ return ASCIIToUTF16(google_util::AppendGoogleLocaleParam(url).spec());
+}
+
+ChromeWebUIDataSource* CreateAppListUIHTMLSource(PrefService* prefs) {
+ ChromeWebUIDataSource* source =
+ new ChromeWebUIDataSource(chrome::kChromeUIAppListHost);
+
+ string16 apps = l10n_util::GetStringUTF16(IDS_NEW_TAB_APPS);
+ string16 title = l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE);
+
+ DictionaryValue localized_strings;
+ localized_strings.SetString("apps", apps);
+ localized_strings.SetString("title", title);
+ localized_strings.SetString("appuninstall",
+ l10n_util::GetStringFUTF16(
+ IDS_NEW_TAB_APP_UNINSTALL,
+ l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)));
+ localized_strings.SetString("appoptions",
+ l10n_util::GetStringUTF16(IDS_NEW_TAB_APP_OPTIONS));
+ localized_strings.SetString("appcreateshortcut",
+ l10n_util::GetStringUTF16(IDS_NEW_TAB_APP_CREATE_SHORTCUT));
+ localized_strings.SetString("appDefaultPageName",
+ l10n_util::GetStringUTF16(IDS_APP_DEFAULT_PAGE_NAME));
+ localized_strings.SetString("applaunchtypepinned",
+ l10n_util::GetStringUTF16(IDS_APP_CONTEXT_MENU_OPEN_PINNED));
+ localized_strings.SetString("applaunchtyperegular",
+ l10n_util::GetStringUTF16(IDS_APP_CONTEXT_MENU_OPEN_REGULAR));
+ localized_strings.SetString("applaunchtypewindow",
+ l10n_util::GetStringUTF16(IDS_APP_CONTEXT_MENU_OPEN_WINDOW));
+ localized_strings.SetString("applaunchtypefullscreen",
+ l10n_util::GetStringUTF16(IDS_APP_CONTEXT_MENU_OPEN_FULLSCREEN));
+ localized_strings.SetString("web_store_title",
+ l10n_util::GetStringUTF16(IDS_EXTENSION_WEB_STORE_TITLE));
+ localized_strings.SetString("web_store_url",
+ GetUrlWithLang(GURL(extension_urls::GetWebstoreLaunchURL())));
+
+ localized_strings.SetString("search-box-hint",
+ l10n_util::GetStringUTF16(IDS_SEARCH_BOX_HINT));
+
+ // TODO(xiyuan): Maybe need to use another prefs for app list.
+ int shown_page = prefs->GetInteger(prefs::kNTPShownPage);
+ localized_strings.SetInteger("shown_page_type", shown_page & ~kIndexMask);
+ localized_strings.SetInteger("shown_page_index", shown_page & kIndexMask);
+
+ source->AddLocalizedStrings(localized_strings);
+ source->set_json_path("strings.js");
+ source->set_default_resource(IDR_APP_LIST_HTML);
+ return source;
+}
+
+} // namespace
+
+AppListUI::AppListUI(TabContents* contents)
+ : ChromeWebUI(contents) {
+ ExtensionService* service = GetProfile()->GetExtensionService();
+ if (service)
+ AddMessageHandler((new AppLauncherHandler(service))->Attach(this));
+
+ // Set up the source.
+ Profile* profile = Profile::FromBrowserContext(contents->browser_context());
+ PrefService* prefs = profile->GetPrefs();
+ profile->GetChromeURLDataManager()->AddDataSource(
+ CreateAppListUIHTMLSource(prefs));
+}
« 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