| OLD | NEW |
| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 #include "ui/views/controls/webview/webview.h" | 69 #include "ui/views/controls/webview/webview.h" |
| 70 | 70 |
| 71 #if defined(USE_AURA) | 71 #if defined(USE_AURA) |
| 72 #include "ui/keyboard/keyboard_util.h" | 72 #include "ui/keyboard/keyboard_util.h" |
| 73 #endif | 73 #endif |
| 74 | 74 |
| 75 #if defined(USE_ASH) | 75 #if defined(USE_ASH) |
| 76 #include "chrome/browser/ui/ash/app_list/app_sync_ui_state_watcher.h" | 76 #include "chrome/browser/ui/ash/app_list/app_sync_ui_state_watcher.h" |
| 77 #endif | 77 #endif |
| 78 | 78 |
| 79 #if defined(OS_WIN) | |
| 80 #include "chrome/browser/web_applications/web_app_win.h" | |
| 81 #endif | |
| 82 | |
| 83 #if !defined(OS_CHROMEOS) | 79 #if !defined(OS_CHROMEOS) |
| 84 #include "chrome/grit/chromium_strings.h" | 80 #include "chrome/grit/chromium_strings.h" |
| 85 #include "chrome/grit/generated_resources.h" | 81 #include "chrome/grit/generated_resources.h" |
| 86 #include "ui/base/l10n/l10n_util.h" | 82 #include "ui/base/l10n/l10n_util.h" |
| 87 #endif | 83 #endif |
| 88 | 84 |
| 89 namespace chrome { | 85 namespace chrome { |
| 90 const char kAppLauncherCategoryTag[] = "AppLauncher"; | 86 const char kAppLauncherCategoryTag[] = "AppLauncher"; |
| 91 } // namespace chrome | 87 } // namespace chrome |
| 92 | 88 |
| 93 namespace { | 89 namespace { |
| 94 | 90 |
| 95 const int kAutoLaunchDefaultTimeoutMilliSec = 50; | 91 const int kAutoLaunchDefaultTimeoutMilliSec = 50; |
| 96 | 92 |
| 97 #if defined(OS_WIN) | |
| 98 void CreateShortcutInWebAppDir( | |
| 99 const base::FilePath& app_data_dir, | |
| 100 base::Callback<void(const base::FilePath&)> callback, | |
| 101 std::unique_ptr<web_app::ShortcutInfo> info) { | |
| 102 content::BrowserThread::PostTaskAndReplyWithResult( | |
| 103 content::BrowserThread::FILE, FROM_HERE, | |
| 104 base::Bind(web_app::CreateShortcutInWebAppDir, app_data_dir, | |
| 105 base::Passed(&info)), | |
| 106 callback); | |
| 107 } | |
| 108 #endif | |
| 109 | |
| 110 void PopulateUsers(const base::FilePath& active_profile_path, | 93 void PopulateUsers(const base::FilePath& active_profile_path, |
| 111 app_list::AppListViewDelegate::Users* users) { | 94 app_list::AppListViewDelegate::Users* users) { |
| 112 users->clear(); | 95 users->clear(); |
| 113 std::vector<ProfileAttributesEntry*> entries = g_browser_process-> | 96 std::vector<ProfileAttributesEntry*> entries = g_browser_process-> |
| 114 profile_manager()->GetProfileAttributesStorage(). | 97 profile_manager()->GetProfileAttributesStorage(). |
| 115 GetAllProfilesAttributesSortedByName(); | 98 GetAllProfilesAttributesSortedByName(); |
| 116 for (const auto entry : entries) { | 99 for (const auto entry : entries) { |
| 117 app_list::AppListViewDelegate::User user; | 100 app_list::AppListViewDelegate::User user; |
| 118 user.name = entry->GetName(); | 101 user.name = entry->GetName(); |
| 119 user.email = entry->GetUserName(); | 102 user.email = entry->GetUserName(); |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 } | 423 } |
| 441 | 424 |
| 442 app_list::AppListModel* AppListViewDelegate::GetModel() { | 425 app_list::AppListModel* AppListViewDelegate::GetModel() { |
| 443 return model_; | 426 return model_; |
| 444 } | 427 } |
| 445 | 428 |
| 446 app_list::SpeechUIModel* AppListViewDelegate::GetSpeechUI() { | 429 app_list::SpeechUIModel* AppListViewDelegate::GetSpeechUI() { |
| 447 return speech_ui_.get(); | 430 return speech_ui_.get(); |
| 448 } | 431 } |
| 449 | 432 |
| 450 void AppListViewDelegate::GetShortcutPathForApp( | |
| 451 const std::string& app_id, | |
| 452 const base::Callback<void(const base::FilePath&)>& callback) { | |
| 453 #if defined(OS_WIN) | |
| 454 const extensions::Extension* extension = | |
| 455 extensions::ExtensionRegistry::Get(profile_)->GetExtensionById( | |
| 456 app_id, extensions::ExtensionRegistry::EVERYTHING); | |
| 457 if (!extension) { | |
| 458 callback.Run(base::FilePath()); | |
| 459 return; | |
| 460 } | |
| 461 | |
| 462 base::FilePath app_data_dir( | |
| 463 web_app::GetWebAppDataDirectory(profile_->GetPath(), | |
| 464 extension->id(), | |
| 465 GURL())); | |
| 466 | |
| 467 web_app::GetShortcutInfoForApp( | |
| 468 extension, | |
| 469 profile_, | |
| 470 base::Bind(CreateShortcutInWebAppDir, app_data_dir, callback)); | |
| 471 #else | |
| 472 callback.Run(base::FilePath()); | |
| 473 #endif | |
| 474 } | |
| 475 | |
| 476 void AppListViewDelegate::StartSearch() { | 433 void AppListViewDelegate::StartSearch() { |
| 477 if (search_controller_) { | 434 if (search_controller_) { |
| 478 search_controller_->Start(is_voice_query_); | 435 search_controller_->Start(is_voice_query_); |
| 479 controller_->OnSearchStarted(); | 436 controller_->OnSearchStarted(); |
| 480 } | 437 } |
| 481 } | 438 } |
| 482 | 439 |
| 483 void AppListViewDelegate::StopSearch() { | 440 void AppListViewDelegate::StopSearch() { |
| 484 if (search_controller_) | 441 if (search_controller_) |
| 485 search_controller_->Stop(); | 442 search_controller_->Stop(); |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 837 FOR_EACH_OBSERVER(app_list::AppListViewDelegateObserver, observers_, | 794 FOR_EACH_OBSERVER(app_list::AppListViewDelegateObserver, observers_, |
| 838 OnShutdown()); | 795 OnShutdown()); |
| 839 | 796 |
| 840 SetProfile(nullptr); // Ensures launcher page web contents are torn down. | 797 SetProfile(nullptr); // Ensures launcher page web contents are torn down. |
| 841 | 798 |
| 842 // SigninManagerFactory is not a leaky singleton (unlike this class), and | 799 // SigninManagerFactory is not a leaky singleton (unlike this class), and |
| 843 // its destructor will check that it has no remaining observers. | 800 // its destructor will check that it has no remaining observers. |
| 844 scoped_observer_.RemoveAll(); | 801 scoped_observer_.RemoveAll(); |
| 845 SigninManagerFactory::GetInstance()->RemoveObserver(this); | 802 SigninManagerFactory::GetInstance()->RemoveObserver(this); |
| 846 } | 803 } |
| OLD | NEW |