OLD | NEW |
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 "chrome/browser/ui/views/user_manager_view.h" | 5 #include "chrome/browser/ui/views/user_manager_view.h" |
6 | 6 |
7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/lifetime/application_lifetime.h" | 9 #include "chrome/browser/lifetime/application_lifetime.h" |
10 #include "chrome/browser/profiles/profile_manager.h" | 10 #include "chrome/browser/profiles/profile_manager.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 // Default window size. | 39 // Default window size. |
40 const int kWindowWidth = 900; | 40 const int kWindowWidth = 900; |
41 const int kWindowHeight = 700; | 41 const int kWindowHeight = 700; |
42 | 42 |
43 } | 43 } |
44 | 44 |
45 namespace chrome { | 45 namespace chrome { |
46 | 46 |
47 // Declared in browser_dialogs.h so others don't have to depend on this header. | 47 // Declared in browser_dialogs.h so others don't have to depend on this header. |
48 void ShowUserManager(const base::FilePath& profile_path_to_focus) { | 48 void ShowUserManager(const base::FilePath& profile_path_to_focus) { |
49 UserManagerView::Show(profile_path_to_focus); | 49 UserManagerView::Show(profile_path_to_focus, false); |
50 } | 50 } |
51 | 51 |
52 void HideUserManager() { | 52 void HideUserManager() { |
53 UserManagerView::Hide(); | 53 UserManagerView::Hide(); |
54 } | 54 } |
55 | 55 |
56 } // namespace chrome | 56 } // namespace chrome |
57 | 57 |
58 // static | 58 // static |
59 UserManagerView* UserManagerView::instance_ = NULL; | 59 UserManagerView* UserManagerView::instance_ = NULL; |
60 | 60 |
61 UserManagerView::UserManagerView(Profile* profile) | 61 UserManagerView::UserManagerView(Profile* profile) |
62 : web_view_(new views::WebView(profile)) { | 62 : web_view_(new views::WebView(profile)) { |
63 SetLayoutManager(new views::FillLayout); | 63 SetLayoutManager(new views::FillLayout); |
64 AddChildView(web_view_); | 64 AddChildView(web_view_); |
65 } | 65 } |
66 | 66 |
67 UserManagerView::~UserManagerView() { | 67 UserManagerView::~UserManagerView() { |
68 } | 68 } |
69 | 69 |
70 // static | 70 // static |
71 void UserManagerView::Show(const base::FilePath& profile_path_to_focus) { | 71 void UserManagerView::Show(const base::FilePath& profile_path_to_focus, |
| 72 bool show_tutorial) { |
72 ProfileMetrics::LogProfileSwitchUser(ProfileMetrics::OPEN_USER_MANAGER); | 73 ProfileMetrics::LogProfileSwitchUser(ProfileMetrics::OPEN_USER_MANAGER); |
73 if (instance_) { | 74 if (instance_) { |
74 // If there's a user manager window open already, just activate it. | 75 // If there's a user manager window open already, just activate it. |
75 instance_->GetWidget()->Activate(); | 76 instance_->GetWidget()->Activate(); |
76 return; | 77 return; |
77 } | 78 } |
78 | 79 |
79 // Create the guest profile, if necessary, and open the user manager | 80 // Create the guest profile, if necessary, and open the user manager |
80 // from the guest profile. | 81 // from the guest profile. |
81 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 82 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
82 profile_manager->CreateProfileAsync( | 83 profile_manager->CreateProfileAsync( |
83 ProfileManager::GetGuestProfilePath(), | 84 ProfileManager::GetGuestProfilePath(), |
84 base::Bind(&UserManagerView::OnGuestProfileCreated, | 85 base::Bind(&UserManagerView::OnGuestProfileCreated, |
85 profile_path_to_focus), | 86 profile_path_to_focus, |
| 87 show_tutorial), |
86 base::string16(), | 88 base::string16(), |
87 base::string16(), | 89 base::string16(), |
88 std::string()); | 90 std::string()); |
89 } | 91 } |
90 | 92 |
91 // static | 93 // static |
92 void UserManagerView::Hide() { | 94 void UserManagerView::Hide() { |
93 if (instance_) | 95 if (instance_) |
94 instance_->GetWidget()->Close(); | 96 instance_->GetWidget()->Close(); |
95 } | 97 } |
96 | 98 |
97 // static | 99 // static |
98 bool UserManagerView::IsShowing() { | 100 bool UserManagerView::IsShowing() { |
99 return instance_ ? instance_->GetWidget()->IsActive() : false; | 101 return instance_ ? instance_->GetWidget()->IsActive() : false; |
100 } | 102 } |
101 | 103 |
102 void UserManagerView::OnGuestProfileCreated( | 104 void UserManagerView::OnGuestProfileCreated( |
103 const base::FilePath& profile_path_to_focus, | 105 const base::FilePath& profile_path_to_focus, |
| 106 bool show_tutorial, |
104 Profile* guest_profile, | 107 Profile* guest_profile, |
105 Profile::CreateStatus status) { | 108 Profile::CreateStatus status) { |
106 if (status != Profile::CREATE_STATUS_INITIALIZED) | 109 if (status != Profile::CREATE_STATUS_INITIALIZED) |
107 return; | 110 return; |
108 | 111 |
109 instance_ = new UserManagerView(guest_profile); | 112 instance_ = new UserManagerView(guest_profile); |
110 DialogDelegate::CreateDialogWidget(instance_, NULL, NULL); | 113 DialogDelegate::CreateDialogWidget(instance_, NULL, NULL); |
111 | 114 |
112 gfx::NativeWindow window = instance_->GetWidget()->GetNativeWindow(); | 115 gfx::NativeWindow window = instance_->GetWidget()->GetNativeWindow(); |
113 instance_->keep_alive_.reset(new AutoKeepAlive(window)); | 116 instance_->keep_alive_.reset(new AutoKeepAlive(window)); |
114 | 117 |
115 #if defined(OS_WIN) | 118 #if defined(OS_WIN) |
116 // Set the app id for the task manager to the app id of its parent | 119 // Set the app id for the task manager to the app id of its parent |
117 ui::win::SetAppIdForWindow( | 120 ui::win::SetAppIdForWindow( |
118 ShellIntegration::GetChromiumModelIdForProfile( | 121 ShellIntegration::GetChromiumModelIdForProfile( |
119 guest_profile->GetPath()), | 122 guest_profile->GetPath()), |
120 views::HWNDForWidget(instance_->GetWidget())); | 123 views::HWNDForWidget(instance_->GetWidget())); |
121 #endif | 124 #endif |
122 instance_->GetWidget()->Show(); | 125 instance_->GetWidget()->Show(); |
123 | 126 |
124 // Tell the webui which user pod should be focused. | 127 // Tell the webui which user pod should be focused. |
125 std::string page = chrome::kChromeUIUserManagerURL; | 128 std::string page = chrome::kChromeUIUserManagerURL; |
126 | 129 |
127 if (!profile_path_to_focus.empty()) { | 130 if (show_tutorial) { |
| 131 page += "#tutorial"; |
| 132 } else if (!profile_path_to_focus.empty()) { |
128 ProfileInfoCache& cache = | 133 ProfileInfoCache& cache = |
129 g_browser_process->profile_manager()->GetProfileInfoCache(); | 134 g_browser_process->profile_manager()->GetProfileInfoCache(); |
130 size_t index = cache.GetIndexOfProfileWithPath(profile_path_to_focus); | 135 size_t index = cache.GetIndexOfProfileWithPath(profile_path_to_focus); |
131 if (index != std::string::npos) { | 136 if (index != std::string::npos) { |
132 page += "#"; | 137 page += "#"; |
133 page += base::IntToString(index); | 138 page += base::IntToString(index); |
134 } | 139 } |
135 } | 140 } |
136 | 141 |
137 instance_->web_view_->LoadInitialURL(GURL(page)); | 142 instance_->web_view_->LoadInitialURL(GURL(page)); |
(...skipping 24 matching lines...) Expand all Loading... |
162 // Now that the window is closed, we can allow a new one to be opened. | 167 // Now that the window is closed, we can allow a new one to be opened. |
163 // (WindowClosing comes in asynchronously from the call to Close() and we | 168 // (WindowClosing comes in asynchronously from the call to Close() and we |
164 // may have already opened a new instance). | 169 // may have already opened a new instance). |
165 if (instance_ == this) | 170 if (instance_ == this) |
166 instance_ = NULL; | 171 instance_ = NULL; |
167 } | 172 } |
168 | 173 |
169 bool UserManagerView::UseNewStyleForThisDialog() const { | 174 bool UserManagerView::UseNewStyleForThisDialog() const { |
170 return false; | 175 return false; |
171 } | 176 } |
OLD | NEW |