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

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

Issue 17370003: [Win] App launcher drag/drop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix ash Created 7 years, 6 months 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 "base/files/file_path.h"
7 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/feedback/feedback_util.h" 10 #include "chrome/browser/feedback/feedback_util.h"
10 #include "chrome/browser/profiles/profile_manager.h" 11 #include "chrome/browser/profiles/profile_manager.h"
11 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h" 12 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h"
12 #include "chrome/browser/ui/app_list/apps_model_builder.h" 13 #include "chrome/browser/ui/app_list/apps_model_builder.h"
13 #include "chrome/browser/ui/app_list/chrome_app_list_item.h" 14 #include "chrome/browser/ui/app_list/chrome_app_list_item.h"
14 #include "chrome/browser/ui/app_list/chrome_signin_delegate.h" 15 #include "chrome/browser/ui/app_list/chrome_signin_delegate.h"
15 #include "chrome/browser/ui/app_list/search/search_controller.h" 16 #include "chrome/browser/ui/app_list/search/search_controller.h"
16 #include "chrome/browser/ui/browser_finder.h" 17 #include "chrome/browser/ui/browser_finder.h"
17 #include "chrome/browser/ui/chrome_pages.h" 18 #include "chrome/browser/ui/chrome_pages.h"
18 #include "chrome/browser/ui/host_desktop.h" 19 #include "chrome/browser/ui/host_desktop.h"
20 #include "chrome/browser/ui/web_applications/web_app_ui.h"
21 #include "chrome/browser/web_applications/web_app.h"
19 #include "chrome/common/extensions/extension_constants.h" 22 #include "chrome/common/extensions/extension_constants.h"
20 #include "chrome/common/url_constants.h" 23 #include "chrome/common/url_constants.h"
24 #include "content/public/browser/browser_thread.h"
21 #include "content/public/browser/page_navigator.h" 25 #include "content/public/browser/page_navigator.h"
22 #include "content/public/browser/user_metrics.h" 26 #include "content/public/browser/user_metrics.h"
23 27
24 #if defined(USE_ASH) 28 #if defined(USE_ASH)
25 #include "chrome/browser/ui/ash/app_list/app_sync_ui_state_watcher.h" 29 #include "chrome/browser/ui/ash/app_list/app_sync_ui_state_watcher.h"
26 #endif 30 #endif
27 31
32
33 namespace {
34
35 void CreateShortcutInWebAppDir(
36 const base::FilePath& app_data_dir,
37 base::Callback<void(const base::FilePath&)> callback,
38 const ShellIntegration::ShortcutInfo& info) {
39 content::BrowserThread::PostTaskAndReplyWithResult(
40 content::BrowserThread::FILE,
41 FROM_HERE,
42 base::Bind(web_app::CreateShortcutInWebAppDir, app_data_dir, info),
43 callback);
44 }
45
46 } // namespace
47
28 AppListViewDelegate::AppListViewDelegate(AppListControllerDelegate* controller, 48 AppListViewDelegate::AppListViewDelegate(AppListControllerDelegate* controller,
29 Profile* profile) 49 Profile* profile)
30 : controller_(controller), 50 : controller_(controller),
31 profile_(profile) {} 51 profile_(profile) {}
32 52
33 AppListViewDelegate::~AppListViewDelegate() {} 53 AppListViewDelegate::~AppListViewDelegate() {}
34 54
35 void AppListViewDelegate::SetModel(app_list::AppListModel* model) { 55 void AppListViewDelegate::SetModel(app_list::AppListModel* model) {
36 if (model) { 56 if (model) {
37 apps_builder_.reset(new AppsModelBuilder(profile_, 57 apps_builder_.reset(new AppsModelBuilder(profile_,
(...skipping 23 matching lines...) Expand all
61 return signin_delegate_.get(); 81 return signin_delegate_.get();
62 } 82 }
63 83
64 void AppListViewDelegate::ActivateAppListItem( 84 void AppListViewDelegate::ActivateAppListItem(
65 app_list::AppListItemModel* item, 85 app_list::AppListItemModel* item,
66 int event_flags) { 86 int event_flags) {
67 content::RecordAction(content::UserMetricsAction("AppList_ClickOnApp")); 87 content::RecordAction(content::UserMetricsAction("AppList_ClickOnApp"));
68 static_cast<ChromeAppListItem*>(item)->Activate(event_flags); 88 static_cast<ChromeAppListItem*>(item)->Activate(event_flags);
69 } 89 }
70 90
91 void AppListViewDelegate::GetShortcutPathForApp(
92 const std::string& app_id,
93 base::Callback<void(const base::FilePath&)> callback) {
94 ExtensionService* service = profile_->GetExtensionService();
95 DCHECK(service);
96 const extensions::Extension* extension =
97 service->GetInstalledExtension(app_id);
98 DCHECK(extension);
99
100 base::FilePath app_data_dir(
101 web_app::GetWebAppDataDirectory(profile_->GetPath(),
102 extension->id(),
103 GURL()));
104
105 web_app::UpdateShortcutInfoAndIconForApp(
106 *extension,
107 profile_,
108 base::Bind(CreateShortcutInWebAppDir, app_data_dir, callback));
109 }
110
71 void AppListViewDelegate::StartSearch() { 111 void AppListViewDelegate::StartSearch() {
72 if (search_controller_.get()) 112 if (search_controller_.get())
73 search_controller_->Start(); 113 search_controller_->Start();
74 } 114 }
75 115
76 void AppListViewDelegate::StopSearch() { 116 void AppListViewDelegate::StopSearch() {
77 if (search_controller_.get()) 117 if (search_controller_.get())
78 search_controller_->Stop(); 118 search_controller_->Stop();
79 } 119 }
80 120
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 } 189 }
150 190
151 void AppListViewDelegate::OpenFeedback() { 191 void AppListViewDelegate::OpenFeedback() {
152 chrome::HostDesktopType desktop = chrome::GetHostDesktopTypeForNativeWindow( 192 chrome::HostDesktopType desktop = chrome::GetHostDesktopTypeForNativeWindow(
153 controller_->GetAppListWindow()); 193 controller_->GetAppListWindow());
154 Browser* browser = chrome::FindOrCreateTabbedBrowser( 194 Browser* browser = chrome::FindOrCreateTabbedBrowser(
155 profile_, desktop); 195 profile_, desktop);
156 chrome::ShowFeedbackPage(browser, std::string(), 196 chrome::ShowFeedbackPage(browser, std::string(),
157 chrome::kAppLauncherCategoryTag); 197 chrome::kAppLauncherCategoryTag);
158 } 198 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698