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

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 compile 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 #if defined(OS_WIN)
34 #include "chrome/browser/web_applications/web_app_win.h"
35 #endif
36
37 namespace {
38
39 #if defined(OS_WIN)
40 void CreateShortcutInWebAppDir(
41 const base::FilePath& app_data_dir,
42 base::Callback<void(const base::FilePath&)> callback,
43 const ShellIntegration::ShortcutInfo& info) {
44 content::BrowserThread::PostTaskAndReplyWithResult(
45 content::BrowserThread::FILE,
46 FROM_HERE,
47 base::Bind(web_app::CreateShortcutInWebAppDir, app_data_dir, info),
48 callback);
49 }
50 #endif
51
52 } // namespace
53
28 AppListViewDelegate::AppListViewDelegate(AppListControllerDelegate* controller, 54 AppListViewDelegate::AppListViewDelegate(AppListControllerDelegate* controller,
29 Profile* profile) 55 Profile* profile)
30 : controller_(controller), 56 : controller_(controller),
31 profile_(profile) {} 57 profile_(profile) {}
32 58
33 AppListViewDelegate::~AppListViewDelegate() {} 59 AppListViewDelegate::~AppListViewDelegate() {}
34 60
35 void AppListViewDelegate::SetModel(app_list::AppListModel* model) { 61 void AppListViewDelegate::SetModel(app_list::AppListModel* model) {
36 if (model) { 62 if (model) {
37 apps_builder_.reset(new AppsModelBuilder(profile_, 63 apps_builder_.reset(new AppsModelBuilder(profile_,
(...skipping 23 matching lines...) Expand all
61 return signin_delegate_.get(); 87 return signin_delegate_.get();
62 } 88 }
63 89
64 void AppListViewDelegate::ActivateAppListItem( 90 void AppListViewDelegate::ActivateAppListItem(
65 app_list::AppListItemModel* item, 91 app_list::AppListItemModel* item,
66 int event_flags) { 92 int event_flags) {
67 content::RecordAction(content::UserMetricsAction("AppList_ClickOnApp")); 93 content::RecordAction(content::UserMetricsAction("AppList_ClickOnApp"));
68 static_cast<ChromeAppListItem*>(item)->Activate(event_flags); 94 static_cast<ChromeAppListItem*>(item)->Activate(event_flags);
69 } 95 }
70 96
97 void AppListViewDelegate::GetShortcutPathForApp(
98 const std::string& app_id,
99 const base::Callback<void(const base::FilePath&)>& callback) {
100 #if defined(OS_WIN)
101 ExtensionService* service = profile_->GetExtensionService();
102 DCHECK(service);
103 const extensions::Extension* extension =
104 service->GetInstalledExtension(app_id);
105 DCHECK(extension);
106
107 base::FilePath app_data_dir(
108 web_app::GetWebAppDataDirectory(profile_->GetPath(),
109 extension->id(),
110 GURL()));
111
112 web_app::UpdateShortcutInfoAndIconForApp(
113 *extension,
114 profile_,
115 base::Bind(CreateShortcutInWebAppDir, app_data_dir, callback));
116 #else
117 callback.Run(base::FilePath());
118 #endif
119 }
120
71 void AppListViewDelegate::StartSearch() { 121 void AppListViewDelegate::StartSearch() {
72 if (search_controller_.get()) 122 if (search_controller_.get())
73 search_controller_->Start(); 123 search_controller_->Start();
74 } 124 }
75 125
76 void AppListViewDelegate::StopSearch() { 126 void AppListViewDelegate::StopSearch() {
77 if (search_controller_.get()) 127 if (search_controller_.get())
78 search_controller_->Stop(); 128 search_controller_->Stop();
79 } 129 }
80 130
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 } 199 }
150 200
151 void AppListViewDelegate::OpenFeedback() { 201 void AppListViewDelegate::OpenFeedback() {
152 chrome::HostDesktopType desktop = chrome::GetHostDesktopTypeForNativeWindow( 202 chrome::HostDesktopType desktop = chrome::GetHostDesktopTypeForNativeWindow(
153 controller_->GetAppListWindow()); 203 controller_->GetAppListWindow());
154 Browser* browser = chrome::FindOrCreateTabbedBrowser( 204 Browser* browser = chrome::FindOrCreateTabbedBrowser(
155 profile_, desktop); 205 profile_, desktop);
156 chrome::ShowFeedbackPage(browser, std::string(), 206 chrome::ShowFeedbackPage(browser, std::string(),
157 chrome::kAppLauncherCategoryTag); 207 chrome::kAppLauncherCategoryTag);
158 } 208 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/app_list_view_delegate.h ('k') | chrome/browser/ui/views/extensions/native_app_window_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698