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

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

Issue 1990783002: Mac: Open chrome://apps when a deprecated app launcher shim connects. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@20160518-ShimAppsPage-UPSTREAM
Patch Set: git rebase as well? Created 4 years, 7 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
« no previous file with comments | « no previous file | chrome/browser/ui/app_list/app_list_service_disabled_mac.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/files/file_path.h" 5 #include "base/files/file_path.h"
6 #include "base/macros.h" 6 #include "base/macros.h"
7 #include "base/memory/singleton.h" 7 #include "base/memory/singleton.h"
8 #include "build/build_config.h"
8 #include "chrome/browser/ui/app_list/app_list_service.h" 9 #include "chrome/browser/ui/app_list/app_list_service.h"
9 10
10 #if defined(TOOLKIT_VIEWS) 11 #if defined(TOOLKIT_VIEWS)
11 #include "base/command_line.h" 12 #include "base/command_line.h"
12 #include "chrome/browser/browser_process.h" 13 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/profiles/profile_attributes_entry.h" 14 #include "chrome/browser/profiles/profile_attributes_entry.h"
14 #include "chrome/browser/profiles/profile_attributes_storage.h" 15 #include "chrome/browser/profiles/profile_attributes_storage.h"
15 #include "chrome/browser/profiles/profile_manager.h" 16 #include "chrome/browser/profiles/profile_manager.h"
16 #include "chrome/browser/ui/browser.h" 17 #include "chrome/browser/ui/browser.h"
17 #include "chrome/browser/ui/browser_finder.h" 18 #include "chrome/browser/ui/browser_finder.h"
18 #include "chrome/browser/ui/browser_navigator.h" 19 #include "chrome/browser/ui/browser_navigator.h"
19 #include "chrome/browser/ui/browser_navigator_params.h" 20 #include "chrome/browser/ui/browser_navigator_params.h"
20 #include "chrome/browser/ui/user_manager.h" 21 #include "chrome/browser/ui/user_manager.h"
21 #include "chrome/common/chrome_switches.h" 22 #include "chrome/common/chrome_switches.h"
22 #include "chrome/common/url_constants.h" 23 #include "chrome/common/url_constants.h"
23 #include "components/signin/core/common/profile_management_switches.h" 24 #include "components/signin/core/common/profile_management_switches.h"
24 #include "ui/base/page_transition_types.h" 25 #include "ui/base/page_transition_types.h"
25 #endif 26 #endif
26 27
28 #if defined(OS_MACOSX)
29 #include "chrome/browser/ui/app_list/app_list_service_disabled_mac.h"
30 #endif
31
27 namespace { 32 namespace {
28 33
29 class AppListServiceDisabled : public AppListService { 34 class AppListServiceDisabled : public AppListService {
30 public: 35 public:
31 static AppListServiceDisabled* GetInstance() { 36 static AppListServiceDisabled* GetInstance() {
32 return base::Singleton< 37 return base::Singleton<
33 AppListServiceDisabled, 38 AppListServiceDisabled,
34 base::LeakySingletonTraits<AppListServiceDisabled>>::get(); 39 base::LeakySingletonTraits<AppListServiceDisabled>>::get();
35 } 40 }
36 41
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 // --new-profile-management flag. 85 // --new-profile-management flag.
81 if (!switches::IsNewProfileManagement()) 86 if (!switches::IsNewProfileManagement())
82 return false; 87 return false;
83 ProfileAttributesEntry* entry; 88 ProfileAttributesEntry* entry;
84 bool has_entry = 89 bool has_entry =
85 g_browser_process->profile_manager() 90 g_browser_process->profile_manager()
86 ->GetProfileAttributesStorage() 91 ->GetProfileAttributesStorage()
87 .GetProfileAttributesWithPath(profile->GetPath(), &entry); 92 .GetProfileAttributesWithPath(profile->GetPath(), &entry);
88 return has_entry && entry->IsSigninRequired(); 93 return has_entry && entry->IsSigninRequired();
89 } 94 }
95
96 // Opens a Chrome browser tab at chrome://apps.
97 void OpenAppsPage(Profile* fallback_profile) {
98 Browser* browser = chrome::FindLastActive();
99 Profile* app_list_profile = browser ? browser->profile() : fallback_profile;
100 app_list_profile = app_list_profile->GetOriginalProfile();
101
102 if (IsProfileSignedOut(app_list_profile) ||
103 app_list_profile->IsSystemProfile() ||
104 app_list_profile->IsGuestSession()) {
105 UserManager::Show(base::FilePath(), profiles::USER_MANAGER_NO_TUTORIAL,
106 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION);
107 return;
108 }
109
110 chrome::NavigateParams params(app_list_profile,
111 GURL(chrome::kChromeUIAppsURL),
112 ui::PAGE_TRANSITION_AUTO_BOOKMARK);
113 chrome::Navigate(&params);
114 }
90 #endif 115 #endif
91 116
92 } // namespace 117 } // namespace
93 118
94 // static 119 // static
95 AppListService* AppListService::Get() { 120 AppListService* AppListService::Get() {
96 return AppListServiceDisabled::GetInstance(); 121 return AppListServiceDisabled::GetInstance();
97 } 122 }
98 123
99 // static 124 // static
100 void AppListService::InitAll(Profile* initial_profile, 125 void AppListService::InitAll(Profile* initial_profile,
101 const base::FilePath& profile_path) {} 126 const base::FilePath& profile_path) {
127 #if defined(OS_MACOSX)
128 InitAppsPageLegacyShimHandler(&OpenAppsPage);
129 #endif
130 }
102 131
103 // static 132 // static
104 void AppListService::RegisterPrefs(PrefRegistrySimple* registry) {} 133 void AppListService::RegisterPrefs(PrefRegistrySimple* registry) {}
105 134
106 // static 135 // static
107 bool AppListService::HandleLaunchCommandLine( 136 bool AppListService::HandleLaunchCommandLine(
108 const base::CommandLine& command_line, 137 const base::CommandLine& command_line,
109 Profile* launch_profile) { 138 Profile* launch_profile) {
110 #if defined(TOOLKIT_VIEWS) 139 #if defined(TOOLKIT_VIEWS)
111 if (!command_line.HasSwitch(switches::kShowAppList)) 140 if (!command_line.HasSwitch(switches::kShowAppList))
112 return false; 141 return false;
113 142
114 Browser* browser = chrome::FindLastActive(); 143 OpenAppsPage(launch_profile);
115 Profile* app_list_profile = browser ? browser->profile() : launch_profile;
116
117 if (IsProfileSignedOut(app_list_profile) ||
118 app_list_profile->IsSystemProfile()) {
119 UserManager::Show(base::FilePath(), profiles::USER_MANAGER_NO_TUTORIAL,
120 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION);
121 return true;
122 }
123
124 chrome::NavigateParams params(app_list_profile,
125 GURL(chrome::kChromeUIAppsURL),
126 ui::PAGE_TRANSITION_AUTO_BOOKMARK);
127 chrome::Navigate(&params);
128 return true; 144 return true;
129 #else 145 #else
130 return false; 146 return false;
131 #endif 147 #endif
132 } 148 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/app_list/app_list_service_disabled_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698