| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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/ui/webui/aura/app_list_ui.h" | 5 #include "chrome/browser/ui/webui/aura/app_list_ui.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/google/google_util.h" | 8 #include "chrome/browser/google/google_util.h" |
| 9 #include "chrome/browser/prefs/pref_service.h" | 9 #include "chrome/browser/prefs/pref_service.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" | 11 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" |
| 12 #include "chrome/browser/ui/webui/aura/app_list_ui_delegate.h" | 12 #include "chrome/browser/ui/webui/aura/app_list_ui_delegate.h" |
| 13 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" | 13 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" |
| 14 #include "chrome/common/extensions/extension_constants.h" | 14 #include "chrome/common/extensions/extension_constants.h" |
| 15 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
| 16 #include "chrome/common/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
| 17 #include "content/browser/tab_contents/tab_contents.h" | 17 #include "content/public/browser/web_contents.h" |
| 18 #include "grit/browser_resources.h" | 18 #include "grit/browser_resources.h" |
| 19 #include "grit/chromium_strings.h" | 19 #include "grit/chromium_strings.h" |
| 20 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
| 21 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
| 22 | 22 |
| 23 using content::WebContents; |
| 24 |
| 23 namespace { | 25 namespace { |
| 24 | 26 |
| 25 static const int kPageIdOffset = 10; | 27 static const int kPageIdOffset = 10; |
| 26 static const int kIndexMask = (1 << kPageIdOffset) - 1; | 28 static const int kIndexMask = (1 << kPageIdOffset) - 1; |
| 27 | 29 |
| 28 // TODO(xiyuan): Merge this with the one on ntp_resource_cache. | 30 // TODO(xiyuan): Merge this with the one on ntp_resource_cache. |
| 29 string16 GetUrlWithLang(const GURL& url) { | 31 string16 GetUrlWithLang(const GURL& url) { |
| 30 return ASCIIToUTF16(google_util::AppendGoogleLocaleParam(url).spec()); | 32 return ASCIIToUTF16(google_util::AppendGoogleLocaleParam(url).spec()); |
| 31 } | 33 } |
| 32 | 34 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 app_list_ui()->delegate()->Close(); | 110 app_list_ui()->delegate()->Close(); |
| 109 } | 111 } |
| 110 | 112 |
| 111 void AppListHandler::HandleAppsLoaded(const base::ListValue* args) { | 113 void AppListHandler::HandleAppsLoaded(const base::ListValue* args) { |
| 112 if (app_list_ui()->delegate()) | 114 if (app_list_ui()->delegate()) |
| 113 app_list_ui()->delegate()->OnAppsLoaded(); | 115 app_list_ui()->delegate()->OnAppsLoaded(); |
| 114 } | 116 } |
| 115 | 117 |
| 116 } // namespace | 118 } // namespace |
| 117 | 119 |
| 118 AppListUI::AppListUI(TabContents* contents) | 120 AppListUI::AppListUI(WebContents* contents) |
| 119 : ChromeWebUI(contents), | 121 : ChromeWebUI(contents), |
| 120 delegate_(NULL) { | 122 delegate_(NULL) { |
| 121 AddMessageHandler(new AppListHandler); | 123 AddMessageHandler(new AppListHandler); |
| 122 | 124 |
| 123 ExtensionService* service = GetProfile()->GetExtensionService(); | 125 ExtensionService* service = GetProfile()->GetExtensionService(); |
| 124 if (service) | 126 if (service) |
| 125 AddMessageHandler(new AppLauncherHandler(service)); | 127 AddMessageHandler(new AppLauncherHandler(service)); |
| 126 | 128 |
| 127 // Set up the source. | 129 // Set up the source. |
| 128 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext()); | 130 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext()); |
| 129 PrefService* prefs = profile->GetPrefs(); | 131 PrefService* prefs = profile->GetPrefs(); |
| 130 profile->GetChromeURLDataManager()->AddDataSource( | 132 profile->GetChromeURLDataManager()->AddDataSource( |
| 131 CreateAppListUIHTMLSource(prefs)); | 133 CreateAppListUIHTMLSource(prefs)); |
| 132 } | 134 } |
| OLD | NEW |