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

Side by Side Diff: chrome/browser/ui/webui/options/manage_profile_handler.cc

Issue 2121303003: Remove the "Settings" packaged app (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "chrome/browser/ui/webui/options/manage_profile_handler.h" 5 #include "chrome/browser/ui/webui/options/manage_profile_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 29 matching lines...) Expand all
40 #include "components/prefs/scoped_user_pref_update.h" 40 #include "components/prefs/scoped_user_pref_update.h"
41 #include "components/signin/core/browser/signin_manager.h" 41 #include "components/signin/core/browser/signin_manager.h"
42 #include "components/signin/core/common/profile_management_switches.h" 42 #include "components/signin/core/common/profile_management_switches.h"
43 #include "content/public/browser/browser_thread.h" 43 #include "content/public/browser/browser_thread.h"
44 #include "content/public/browser/notification_service.h" 44 #include "content/public/browser/notification_service.h"
45 #include "content/public/browser/web_ui.h" 45 #include "content/public/browser/web_ui.h"
46 #include "google_apis/gaia/gaia_auth_util.h" 46 #include "google_apis/gaia/gaia_auth_util.h"
47 #include "ui/base/l10n/l10n_util.h" 47 #include "ui/base/l10n/l10n_util.h"
48 #include "ui/base/webui/web_ui_util.h" 48 #include "ui/base/webui/web_ui_util.h"
49 49
50 #if defined(ENABLE_SETTINGS_APP)
51 #include "chrome/browser/ui/app_list/app_list_service.h"
52 #include "content/public/browser/web_contents.h"
53 #endif
54
55 namespace options { 50 namespace options {
56 51
57 namespace { 52 namespace {
58 53
59 const char kCreateProfileIdentifier[] = "create"; 54 const char kCreateProfileIdentifier[] = "create";
60 const char kManageProfileIdentifier[] = "manage"; 55 const char kManageProfileIdentifier[] = "manage";
61 56
62 // Given |args| from the WebUI, parses value 0 as a FilePath |profile_file_path| 57 // Given |args| from the WebUI, parses value 0 as a FilePath |profile_file_path|
63 // and returns true on success. 58 // and returns true on success.
64 bool GetProfilePathFromArgs(const base::ListValue* args, 59 bool GetProfilePathFromArgs(const base::ListValue* args,
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 base::Unretained(this))); 173 base::Unretained(this)));
179 web_ui()->RegisterMessageCallback("requestHasProfileShortcuts", 174 web_ui()->RegisterMessageCallback("requestHasProfileShortcuts",
180 base::Bind(&ManageProfileHandler::RequestHasProfileShortcuts, 175 base::Bind(&ManageProfileHandler::RequestHasProfileShortcuts,
181 base::Unretained(this))); 176 base::Unretained(this)));
182 web_ui()->RegisterMessageCallback("requestCreateProfileUpdate", 177 web_ui()->RegisterMessageCallback("requestCreateProfileUpdate",
183 base::Bind(&ManageProfileHandler::RequestCreateProfileUpdate, 178 base::Bind(&ManageProfileHandler::RequestCreateProfileUpdate,
184 base::Unretained(this))); 179 base::Unretained(this)));
185 web_ui()->RegisterMessageCallback("profileIconSelectionChanged", 180 web_ui()->RegisterMessageCallback("profileIconSelectionChanged",
186 base::Bind(&ManageProfileHandler::ProfileIconSelectionChanged, 181 base::Bind(&ManageProfileHandler::ProfileIconSelectionChanged,
187 base::Unretained(this))); 182 base::Unretained(this)));
188 #if defined(ENABLE_SETTINGS_APP)
189 web_ui()->RegisterMessageCallback("switchAppListProfile",
190 base::Bind(&ManageProfileHandler::SwitchAppListProfile,
191 base::Unretained(this)));
192 #endif
193 web_ui()->RegisterMessageCallback("addProfileShortcut", 183 web_ui()->RegisterMessageCallback("addProfileShortcut",
194 base::Bind(&ManageProfileHandler::AddProfileShortcut, 184 base::Bind(&ManageProfileHandler::AddProfileShortcut,
195 base::Unretained(this))); 185 base::Unretained(this)));
196 web_ui()->RegisterMessageCallback("removeProfileShortcut", 186 web_ui()->RegisterMessageCallback("removeProfileShortcut",
197 base::Bind(&ManageProfileHandler::RemoveProfileShortcut, 187 base::Bind(&ManageProfileHandler::RemoveProfileShortcut,
198 base::Unretained(this))); 188 base::Unretained(this)));
199 web_ui()->RegisterMessageCallback("refreshGaiaPicture", 189 web_ui()->RegisterMessageCallback("refreshGaiaPicture",
200 base::Bind(&ManageProfileHandler::RefreshGaiaPicture, 190 base::Bind(&ManageProfileHandler::RefreshGaiaPicture,
201 base::Unretained(this))); 191 base::Unretained(this)));
202 web_ui()->RegisterMessageCallback( 192 web_ui()->RegisterMessageCallback(
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 396
407 base::string16 new_profile_name; 397 base::string16 new_profile_name;
408 if (!args->GetString(2, &new_profile_name)) 398 if (!args->GetString(2, &new_profile_name))
409 return; 399 return;
410 400
411 base::TrimWhitespace(new_profile_name, base::TRIM_ALL, &new_profile_name); 401 base::TrimWhitespace(new_profile_name, base::TRIM_ALL, &new_profile_name);
412 CHECK(!new_profile_name.empty()); 402 CHECK(!new_profile_name.empty());
413 profiles::UpdateProfileName(profile, new_profile_name); 403 profiles::UpdateProfileName(profile, new_profile_name);
414 } 404 }
415 405
416 #if defined(ENABLE_SETTINGS_APP)
417 void ManageProfileHandler::SwitchAppListProfile(const base::ListValue* args) {
418 DCHECK(args);
419 DCHECK(profiles::IsMultipleProfilesEnabled());
420
421 const base::Value* file_path_value;
422 base::FilePath profile_file_path;
423 if (!args->Get(0, &file_path_value) ||
424 !base::GetValueAsFilePath(*file_path_value, &profile_file_path))
425 return;
426
427 AppListService* app_list_service = AppListService::Get();
428 app_list_service->SetProfilePath(profile_file_path);
429 app_list_service->Show();
430
431 // Close the settings app, since it will now be for the wrong profile.
432 web_ui()->GetWebContents()->Close();
433 }
434 #endif // defined(ENABLE_SETTINGS_APP)
435
436 void ManageProfileHandler::ProfileIconSelectionChanged( 406 void ManageProfileHandler::ProfileIconSelectionChanged(
437 const base::ListValue* args) { 407 const base::ListValue* args) {
438 DCHECK(args); 408 DCHECK(args);
439 409
440 base::FilePath profile_file_path; 410 base::FilePath profile_file_path;
441 if (!GetProfilePathFromArgs(args, &profile_file_path)) 411 if (!GetProfilePathFromArgs(args, &profile_file_path))
442 return; 412 return;
443 413
444 // Currently this only supports editing the current profile's info. 414 // Currently this only supports editing the current profile's info.
445 if (profile_file_path != Profile::FromWebUI(web_ui())->GetPath()) 415 if (profile_file_path != Profile::FromWebUI(web_ui())->GetPath())
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 538
569 // Update the UI buttons. 539 // Update the UI buttons.
570 OnHasProfileShortcuts(false); 540 OnHasProfileShortcuts(false);
571 } 541 }
572 542
573 void ManageProfileHandler::RefreshGaiaPicture(const base::ListValue* args) { 543 void ManageProfileHandler::RefreshGaiaPicture(const base::ListValue* args) {
574 profiles::UpdateGaiaProfileInfoIfNeeded(Profile::FromWebUI(web_ui())); 544 profiles::UpdateGaiaProfileInfoIfNeeded(Profile::FromWebUI(web_ui()));
575 } 545 }
576 546
577 } // namespace options 547 } // namespace options
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/manage_profile_handler.h ('k') | chrome/browser/ui/webui/options/options_ui.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698