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

Side by Side Diff: chrome/browser/ui/app_list/app_list_view_delegate.cc

Issue 55433002: Propagates the search result of start page to the app-list search box. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: observer Created 7 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/app_list/app_list_view_delegate.h" 5 #include "chrome/browser/ui/app_list/app_list_view_delegate.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 79
80 AppListViewDelegate::AppListViewDelegate( 80 AppListViewDelegate::AppListViewDelegate(
81 scoped_ptr<AppListControllerDelegate> controller, 81 scoped_ptr<AppListControllerDelegate> controller,
82 Profile* profile) 82 Profile* profile)
83 : controller_(controller.Pass()), 83 : controller_(controller.Pass()),
84 profile_(profile), 84 profile_(profile),
85 model_(NULL) { 85 model_(NULL) {
86 CHECK(controller_); 86 CHECK(controller_);
87 RegisterForNotifications(); 87 RegisterForNotifications();
88 g_browser_process->profile_manager()->GetProfileInfoCache().AddObserver(this); 88 g_browser_process->profile_manager()->GetProfileInfoCache().AddObserver(this);
89 app_list::StartPageService* service =
90 app_list::StartPageService::Get(profile_);
91 if (service)
92 service->AddObserver(this);
89 } 93 }
90 94
91 AppListViewDelegate::~AppListViewDelegate() { 95 AppListViewDelegate::~AppListViewDelegate() {
96 app_list::StartPageService* service =
97 app_list::StartPageService::Get(profile_);
98 if (service)
99 service->RemoveObserver(this);
92 g_browser_process-> 100 g_browser_process->
93 profile_manager()->GetProfileInfoCache().RemoveObserver(this); 101 profile_manager()->GetProfileInfoCache().RemoveObserver(this);
94 } 102 }
95 103
96 void AppListViewDelegate::RegisterForNotifications() { 104 void AppListViewDelegate::RegisterForNotifications() {
97 registrar_.RemoveAll(); 105 registrar_.RemoveAll();
98 DCHECK(profile_); 106 DCHECK(profile_);
99 107
100 registrar_.Add(this, chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL, 108 registrar_.Add(this, chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL,
101 content::NotificationService::AllSources()); 109 content::NotificationService::AllSources());
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 Browser* browser = chrome::FindTabbedBrowser(profile_, false, desktop); 267 Browser* browser = chrome::FindTabbedBrowser(profile_, false, desktop);
260 chrome::ShowFeedbackPage(browser, std::string(), 268 chrome::ShowFeedbackPage(browser, std::string(),
261 chrome::kAppLauncherCategoryTag); 269 chrome::kAppLauncherCategoryTag);
262 } 270 }
263 271
264 void AppListViewDelegate::ShowForProfileByPath( 272 void AppListViewDelegate::ShowForProfileByPath(
265 const base::FilePath& profile_path) { 273 const base::FilePath& profile_path) {
266 controller_->ShowForProfileByPath(profile_path); 274 controller_->ShowForProfileByPath(profile_path);
267 } 275 }
268 276
277 void AppListViewDelegate::OnSearch(const base::string16& query) {
278 model_->search_box()->SetText(query);
279 }
280
269 void AppListViewDelegate::Observe( 281 void AppListViewDelegate::Observe(
270 int type, 282 int type,
271 const content::NotificationSource& source, 283 const content::NotificationSource& source,
272 const content::NotificationDetails& details) { 284 const content::NotificationDetails& details) {
273 OnProfileChanged(); 285 OnProfileChanged();
274 } 286 }
275 287
276 void AppListViewDelegate::OnProfileAdded(const base::FilePath& profile_path) { 288 void AppListViewDelegate::OnProfileAdded(const base::FilePath& profile_path) {
277 OnProfileChanged(); 289 OnProfileChanged();
278 } 290 }
(...skipping 10 matching lines...) Expand all
289 } 301 }
290 302
291 content::WebContents* AppListViewDelegate::GetStartPageContents() { 303 content::WebContents* AppListViewDelegate::GetStartPageContents() {
292 app_list::StartPageService* service = 304 app_list::StartPageService* service =
293 app_list::StartPageService::Get(profile_); 305 app_list::StartPageService::Get(profile_);
294 if (!service) 306 if (!service)
295 return NULL; 307 return NULL;
296 308
297 return service->contents(); 309 return service->contents();
298 } 310 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698