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

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

Powered by Google App Engine
This is Rietveld 408576698