Check USB device path access when prompting users to select a device.
[chromium-blink-merge.git] / chrome / browser / profiles / avatar_menu_actions_desktop.cc
blob97102ed5a5744082bd4b616c544c7a60b70ad477
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
3 // found in the LICENSE file.
5 #include "chrome/browser/profiles/avatar_menu_actions_desktop.h"
7 #include "base/compiler_specific.h"
8 #include "base/strings/string_number_conversions.h"
9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/profiles/profile_info_cache.h"
12 #include "chrome/browser/profiles/profile_manager.h"
13 #include "chrome/browser/profiles/profile_window.h"
14 #include "chrome/browser/profiles/profiles_state.h"
15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/browser_dialogs.h"
17 #include "chrome/browser/ui/browser_finder.h"
18 #include "chrome/browser/ui/browser_list.h"
19 #include "chrome/browser/ui/chrome_pages.h"
20 #include "chrome/common/chrome_switches.h"
21 #include "chrome/common/url_constants.h"
22 #include "content/public/browser/site_instance.h"
23 #include "google_apis/gaia/gaia_urls.h"
24 #include "net/base/url_util.h"
26 AvatarMenuActionsDesktop::AvatarMenuActionsDesktop() {
29 AvatarMenuActionsDesktop::~AvatarMenuActionsDesktop() {
32 // static
33 AvatarMenuActions* AvatarMenuActions::Create() {
34 return new AvatarMenuActionsDesktop();
37 void AvatarMenuActionsDesktop::AddNewProfile(ProfileMetrics::ProfileAdd type) {
38 // TODO: Remove dependency on Browser by delegating AddNewProfile and
39 // and EditProfile actions.
41 Browser* settings_browser = browser_;
42 if (!settings_browser) {
43 const Browser::CreateParams params(ProfileManager::GetLastUsedProfile(),
44 chrome::GetActiveDesktop());
45 settings_browser = new Browser(params);
47 chrome::ShowSettingsSubPage(settings_browser, chrome::kCreateProfileSubPage);
48 ProfileMetrics::LogProfileAddNewUser(type);
51 void AvatarMenuActionsDesktop::EditProfile(Profile* profile, size_t index) {
52 Browser* settings_browser = browser_;
53 if (!settings_browser) {
54 settings_browser = new Browser(
55 Browser::CreateParams(profile, chrome::GetActiveDesktop()));
57 // TODO(davidben): The manageProfile page only allows editting the profile
58 // associated with the browser it is opened in. AvatarMenuActionsDesktop
59 // should account for this when picking a browser to open in.
60 chrome::ShowSettingsSubPage(settings_browser, chrome::kManageProfileSubPage);
63 bool AvatarMenuActionsDesktop::ShouldShowAddNewProfileLink() const {
64 // |browser_| can be NULL in unit_tests.
65 if (browser_ && browser_->profile()->IsSupervised())
66 return false;
67 #if defined(OS_WIN)
68 return chrome::GetActiveDesktop() != chrome::HOST_DESKTOP_TYPE_ASH;
69 #else
70 return true;
71 #endif
74 bool AvatarMenuActionsDesktop::ShouldShowEditProfileLink() const {
75 #if defined(OS_WIN)
76 return chrome::GetActiveDesktop() != chrome::HOST_DESKTOP_TYPE_ASH;
77 #else
78 return true;
79 #endif
82 void AvatarMenuActionsDesktop::ActiveBrowserChanged(Browser* browser) {
83 browser_ = browser;