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/chromeos/extensions/file_manager/private_api_misc.h" | 5 #include "chrome/browser/chromeos/extensions/file_manager/private_api_misc.h" |
6 | 6 |
7 #include "apps/app_window.h" | 7 #include "apps/app_window.h" |
8 #include "apps/app_window_registry.h" | 8 #include "apps/app_window_registry.h" |
9 #include "ash/frame/frame_util.h" | 9 #include "ash/frame/frame_util.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
55 apps::AppWindowRegistry::Get(function->GetProfile()); | 55 apps::AppWindowRegistry::Get(function->GetProfile()); |
56 content::WebContents* const contents = function->GetAssociatedWebContents(); | 56 content::WebContents* const contents = function->GetAssociatedWebContents(); |
57 content::RenderViewHost* const render_view_host = | 57 content::RenderViewHost* const render_view_host = |
58 contents ? contents->GetRenderViewHost() : NULL; | 58 contents ? contents->GetRenderViewHost() : NULL; |
59 return render_view_host ? app_window_registry->GetAppWindowForRenderViewHost( | 59 return render_view_host ? app_window_registry->GetAppWindowForRenderViewHost( |
60 render_view_host) | 60 render_view_host) |
61 : NULL; | 61 : NULL; |
62 } | 62 } |
63 | 63 |
64 std::vector<linked_ptr<api::file_browser_private::ProfileInfo> > | 64 std::vector<linked_ptr<api::file_browser_private::ProfileInfo> > |
65 GetLoggedInProfileInfoList(content::WebContents* contents) { | 65 GetLoggedInProfileInfoList(content::WebContents* contents) { |
hirono
2014/08/29 11:13:26
We can remove contents also.
fukino
2014/08/29 11:22:08
Done.
| |
66 DCHECK(user_manager::UserManager::IsInitialized()); | 66 DCHECK(user_manager::UserManager::IsInitialized()); |
67 const std::vector<Profile*>& profiles = | 67 const std::vector<Profile*>& profiles = |
68 g_browser_process->profile_manager()->GetLoadedProfiles(); | 68 g_browser_process->profile_manager()->GetLoadedProfiles(); |
69 std::set<Profile*> original_profiles; | 69 std::set<Profile*> original_profiles; |
70 std::vector<linked_ptr<api::file_browser_private::ProfileInfo> > | 70 std::vector<linked_ptr<api::file_browser_private::ProfileInfo> > |
71 result_profiles; | 71 result_profiles; |
72 | 72 |
73 for (size_t i = 0; i < profiles.size(); ++i) { | 73 for (size_t i = 0; i < profiles.size(); ++i) { |
74 // Filter the profile. | 74 // Filter the profile. |
75 Profile* const profile = profiles[i]->GetOriginalProfile(); | 75 Profile* const profile = profiles[i]->GetOriginalProfile(); |
76 if (original_profiles.count(profile)) | 76 if (original_profiles.count(profile)) |
77 continue; | 77 continue; |
78 original_profiles.insert(profile); | 78 original_profiles.insert(profile); |
79 const user_manager::User* const user = | 79 const user_manager::User* const user = |
80 chromeos::ProfileHelper::Get()->GetUserByProfile(profile); | 80 chromeos::ProfileHelper::Get()->GetUserByProfile(profile); |
81 if (!user || !user->is_logged_in()) | 81 if (!user || !user->is_logged_in()) |
82 continue; | 82 continue; |
83 | 83 |
84 // Make a ProfileInfo. | 84 // Make a ProfileInfo. |
85 linked_ptr<api::file_browser_private::ProfileInfo> profile_info( | 85 linked_ptr<api::file_browser_private::ProfileInfo> profile_info( |
86 new api::file_browser_private::ProfileInfo()); | 86 new api::file_browser_private::ProfileInfo()); |
87 profile_info->profile_id = multi_user_util::GetUserIDFromProfile(profile); | 87 profile_info->profile_id = multi_user_util::GetUserIDFromProfile(profile); |
88 profile_info->display_name = UTF16ToUTF8(user->GetDisplayName()); | 88 profile_info->display_name = UTF16ToUTF8(user->GetDisplayName()); |
89 // TODO(hirono): Remove the property from the profile_info. | 89 // TODO(hirono): Remove the property from the profile_info. |
90 profile_info->is_current_profile = true; | 90 profile_info->is_current_profile = true; |
91 | 91 |
92 // Make an icon URL of the profile. | |
93 if (contents) { | |
94 const gfx::Image& image = | |
95 ash::GetAvatarImageForContext(contents->GetBrowserContext()); | |
96 const gfx::ImageSkia& skia = image.AsImageSkia(); | |
97 profile_info->profile_image.reset( | |
98 new api::file_browser_private::ImageSet); | |
99 profile_info->profile_image->scale1x_url = | |
100 webui::GetBitmapDataUrl(skia.GetRepresentation(1.0f).sk_bitmap()); | |
101 profile_info->profile_image->scale2x_url = | |
102 webui::GetBitmapDataUrl(skia.GetRepresentation(2.0f).sk_bitmap()); | |
103 } | |
104 result_profiles.push_back(profile_info); | 92 result_profiles.push_back(profile_info); |
105 } | 93 } |
106 | 94 |
107 return result_profiles; | 95 return result_profiles; |
108 } | 96 } |
109 } // namespace | 97 } // namespace |
110 | 98 |
111 bool FileBrowserPrivateLogoutUserForReauthenticationFunction::RunSync() { | 99 bool FileBrowserPrivateLogoutUserForReauthenticationFunction::RunSync() { |
112 user_manager::User* user = | 100 user_manager::User* user = |
113 chromeos::ProfileHelper::Get()->GetUserByProfile(GetProfile()); | 101 chromeos::ProfileHelper::Get()->GetUserByProfile(GetProfile()); |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
481 NOTREACHED(); | 469 NOTREACHED(); |
482 SetError( | 470 SetError( |
483 base::StringPrintf("Unexpected inspection type(%d) is specified.", | 471 base::StringPrintf("Unexpected inspection type(%d) is specified.", |
484 static_cast<int>(params->type))); | 472 static_cast<int>(params->type))); |
485 return false; | 473 return false; |
486 } | 474 } |
487 return true; | 475 return true; |
488 } | 476 } |
489 | 477 |
490 } // namespace extensions | 478 } // namespace extensions |
OLD | NEW |