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

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

Issue 8747021: [Aura] Polish app list. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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
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"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 int shown_page = prefs->GetInteger(prefs::kNTPShownPage); 69 int shown_page = prefs->GetInteger(prefs::kNTPShownPage);
70 localized_strings.SetInteger("shown_page_type", shown_page & ~kIndexMask); 70 localized_strings.SetInteger("shown_page_type", shown_page & ~kIndexMask);
71 localized_strings.SetInteger("shown_page_index", shown_page & kIndexMask); 71 localized_strings.SetInteger("shown_page_index", shown_page & kIndexMask);
72 72
73 source->AddLocalizedStrings(localized_strings); 73 source->AddLocalizedStrings(localized_strings);
74 source->set_json_path("strings.js"); 74 source->set_json_path("strings.js");
75 source->set_default_resource(IDR_APP_LIST_HTML); 75 source->set_default_resource(IDR_APP_LIST_HTML);
76 return source; 76 return source;
77 } 77 }
78 78
79 class AppListHandler : public WebUIMessageHandler {
80 public:
81 AppListHandler() {}
82 virtual ~AppListHandler() {}
83
84 // WebUIMessageHandler
85 virtual void RegisterMessages() OVERRIDE;
86
87 private:
88 AppListUI* app_list_ui() const {
89 return static_cast<AppListUI*>(web_ui_);
90 }
91
92 void HandleClose(const base::ListValue* args);
93 void HandleAppsLoaded(const base::ListValue* args);
94
95 DISALLOW_COPY_AND_ASSIGN(AppListHandler);
96 };
97
98 void AppListHandler::RegisterMessages() {
99 web_ui_->RegisterMessageCallback("close",
100 base::Bind(&AppListHandler::HandleClose, base::Unretained(this)));
101 web_ui_->RegisterMessageCallback("onAppsLoaded",
102 base::Bind(&AppListHandler::HandleAppsLoaded, base::Unretained(this)));
103 }
104
105 void AppListHandler::HandleClose(const base::ListValue* args) {
106 app_list_ui()->delegate()->Close();
sky 2011/11/30 21:50:21 Might the delegate be NULL here and on 110?
xiyuan 2011/11/30 22:26:34 It should never be NULL. Added a DCHECK to catch t
107 }
108
109 void AppListHandler::HandleAppsLoaded(const base::ListValue* args) {
110 app_list_ui()->delegate()->OnAppsLoaded();
111 }
112
79 } // namespace 113 } // namespace
80 114
81 AppListUI::AppListUI(TabContents* contents) 115 AppListUI::AppListUI(TabContents* contents)
82 : ChromeWebUI(contents) { 116 : ChromeWebUI(contents),
117 delegate_(NULL) {
118 AddMessageHandler((new AppListHandler)->Attach(this));
119
83 ExtensionService* service = GetProfile()->GetExtensionService(); 120 ExtensionService* service = GetProfile()->GetExtensionService();
84 if (service) 121 if (service)
85 AddMessageHandler((new AppLauncherHandler(service))->Attach(this)); 122 AddMessageHandler((new AppLauncherHandler(service))->Attach(this));
86 123
87 // Set up the source. 124 // Set up the source.
88 Profile* profile = Profile::FromBrowserContext(contents->browser_context()); 125 Profile* profile = Profile::FromBrowserContext(contents->browser_context());
89 PrefService* prefs = profile->GetPrefs(); 126 PrefService* prefs = profile->GetPrefs();
90 profile->GetChromeURLDataManager()->AddDataSource( 127 profile->GetChromeURLDataManager()->AddDataSource(
91 CreateAppListUIHTMLSource(prefs)); 128 CreateAppListUIHTMLSource(prefs));
92 } 129 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698