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 <set> | 7 #include <set> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 #include "chrome/browser/signin/signin_manager_factory.h" | 33 #include "chrome/browser/signin/signin_manager_factory.h" |
34 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" | 34 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" |
35 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" | 35 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" |
36 #include "chrome/common/extensions/api/file_manager_private.h" | 36 #include "chrome/common/extensions/api/file_manager_private.h" |
37 #include "chrome/common/extensions/api/file_manager_private_internal.h" | 37 #include "chrome/common/extensions/api/file_manager_private_internal.h" |
38 #include "chrome/common/extensions/api/manifest_types.h" | 38 #include "chrome/common/extensions/api/manifest_types.h" |
39 #include "chrome/common/pref_names.h" | 39 #include "chrome/common/pref_names.h" |
40 #include "chromeos/settings/timezone_settings.h" | 40 #include "chromeos/settings/timezone_settings.h" |
41 #include "components/drive/drive_pref_names.h" | 41 #include "components/drive/drive_pref_names.h" |
42 #include "components/drive/event_logger.h" | 42 #include "components/drive/event_logger.h" |
| 43 #include "components/signin/core/account_id/account_id.h" |
43 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 44 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
44 #include "components/signin/core/browser/signin_manager.h" | 45 #include "components/signin/core/browser/signin_manager.h" |
45 #include "components/user_manager/user_manager.h" | 46 #include "components/user_manager/user_manager.h" |
46 #include "content/public/browser/render_view_host.h" | 47 #include "content/public/browser/render_view_host.h" |
47 #include "content/public/browser/web_contents.h" | 48 #include "content/public/browser/web_contents.h" |
48 #include "content/public/common/page_zoom.h" | 49 #include "content/public/common/page_zoom.h" |
49 #include "extensions/browser/app_window/app_window.h" | 50 #include "extensions/browser/app_window/app_window.h" |
50 #include "extensions/browser/app_window/app_window_registry.h" | 51 #include "extensions/browser/app_window/app_window_registry.h" |
51 #include "google_apis/drive/auth_service.h" | 52 #include "google_apis/drive/auth_service.h" |
52 #include "ui/base/webui/web_ui_util.h" | 53 #include "ui/base/webui/web_ui_util.h" |
(...skipping 28 matching lines...) Expand all Loading... |
81 continue; | 82 continue; |
82 original_profiles.insert(profile); | 83 original_profiles.insert(profile); |
83 const user_manager::User* const user = | 84 const user_manager::User* const user = |
84 chromeos::ProfileHelper::Get()->GetUserByProfile(profile); | 85 chromeos::ProfileHelper::Get()->GetUserByProfile(profile); |
85 if (!user || !user->is_logged_in()) | 86 if (!user || !user->is_logged_in()) |
86 continue; | 87 continue; |
87 | 88 |
88 // Make a ProfileInfo. | 89 // Make a ProfileInfo. |
89 linked_ptr<api::file_manager_private::ProfileInfo> profile_info( | 90 linked_ptr<api::file_manager_private::ProfileInfo> profile_info( |
90 new api::file_manager_private::ProfileInfo()); | 91 new api::file_manager_private::ProfileInfo()); |
91 profile_info->profile_id = multi_user_util::GetUserIDFromProfile(profile); | 92 profile_info->profile_id = |
| 93 multi_user_util::GetAccountIdFromProfile(profile).GetUserEmail(); |
92 profile_info->display_name = UTF16ToUTF8(user->GetDisplayName()); | 94 profile_info->display_name = UTF16ToUTF8(user->GetDisplayName()); |
93 // TODO(hirono): Remove the property from the profile_info. | 95 // TODO(hirono): Remove the property from the profile_info. |
94 profile_info->is_current_profile = true; | 96 profile_info->is_current_profile = true; |
95 | 97 |
96 result_profiles.push_back(profile_info); | 98 result_profiles.push_back(profile_info); |
97 } | 99 } |
98 | 100 |
99 return result_profiles; | 101 return result_profiles; |
100 } | 102 } |
101 | 103 |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 } | 371 } |
370 | 372 |
371 bool FileManagerPrivateGetProfilesFunction::RunSync() { | 373 bool FileManagerPrivateGetProfilesFunction::RunSync() { |
372 const std::vector<linked_ptr<api::file_manager_private::ProfileInfo> >& | 374 const std::vector<linked_ptr<api::file_manager_private::ProfileInfo> >& |
373 profiles = GetLoggedInProfileInfoList(); | 375 profiles = GetLoggedInProfileInfoList(); |
374 | 376 |
375 // Obtains the display profile ID. | 377 // Obtains the display profile ID. |
376 AppWindow* const app_window = GetCurrentAppWindow(this); | 378 AppWindow* const app_window = GetCurrentAppWindow(this); |
377 chrome::MultiUserWindowManager* const window_manager = | 379 chrome::MultiUserWindowManager* const window_manager = |
378 chrome::MultiUserWindowManager::GetInstance(); | 380 chrome::MultiUserWindowManager::GetInstance(); |
379 const std::string current_profile_id = | 381 const AccountId current_profile_id = |
380 multi_user_util::GetUserIDFromProfile(GetProfile()); | 382 multi_user_util::GetAccountIdFromProfile(GetProfile()); |
381 const std::string display_profile_id = | 383 const AccountId display_profile_id = |
382 window_manager && app_window ? window_manager->GetUserPresentingWindow( | 384 window_manager && app_window |
383 app_window->GetNativeWindow()) | 385 ? window_manager->GetUserPresentingWindow( |
384 : ""; | 386 app_window->GetNativeWindow()) |
| 387 : EmptyAccountId(); |
385 | 388 |
386 results_ = api::file_manager_private::GetProfiles::Results::Create( | 389 results_ = api::file_manager_private::GetProfiles::Results::Create( |
387 profiles, | 390 profiles, current_profile_id.GetUserEmail(), |
388 current_profile_id, | 391 display_profile_id.is_valid() ? display_profile_id.GetUserEmail() |
389 display_profile_id.empty() ? current_profile_id : display_profile_id); | 392 : current_profile_id.GetUserEmail()); |
390 return true; | 393 return true; |
391 } | 394 } |
392 | 395 |
393 bool FileManagerPrivateOpenInspectorFunction::RunSync() { | 396 bool FileManagerPrivateOpenInspectorFunction::RunSync() { |
394 using extensions::api::file_manager_private::OpenInspector::Params; | 397 using extensions::api::file_manager_private::OpenInspector::Params; |
395 const scoped_ptr<Params> params(Params::Create(*args_)); | 398 const scoped_ptr<Params> params(Params::Create(*args_)); |
396 EXTENSION_FUNCTION_VALIDATE(params); | 399 EXTENSION_FUNCTION_VALIDATE(params); |
397 | 400 |
398 switch (params->type) { | 401 switch (params->type) { |
399 case extensions::api::file_manager_private::INSPECTION_TYPE_NORMAL: | 402 case extensions::api::file_manager_private::INSPECTION_TYPE_NORMAL: |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 base::File::Error result) { | 686 base::File::Error result) { |
684 if (result != base::File::FILE_OK) { | 687 if (result != base::File::FILE_OK) { |
685 Respond(Error("Failed to execute the action.")); | 688 Respond(Error("Failed to execute the action.")); |
686 return; | 689 return; |
687 } | 690 } |
688 | 691 |
689 Respond(NoArguments()); | 692 Respond(NoArguments()); |
690 } | 693 } |
691 | 694 |
692 } // namespace extensions | 695 } // namespace extensions |
OLD | NEW |