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 "ash/frame/frame_util.h" | 7 #include "ash/frame/frame_util.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 app_window->GetNativeWindow()) | 381 app_window->GetNativeWindow()) |
382 : ""; | 382 : ""; |
383 | 383 |
384 results_ = api::file_manager_private::GetProfiles::Results::Create( | 384 results_ = api::file_manager_private::GetProfiles::Results::Create( |
385 profiles, | 385 profiles, |
386 current_profile_id, | 386 current_profile_id, |
387 display_profile_id.empty() ? current_profile_id : display_profile_id); | 387 display_profile_id.empty() ? current_profile_id : display_profile_id); |
388 return true; | 388 return true; |
389 } | 389 } |
390 | 390 |
391 bool FileManagerPrivateVisitDesktopFunction::RunSync() { | |
392 using api::file_manager_private::VisitDesktop::Params; | |
393 const scoped_ptr<Params> params(Params::Create(*args_)); | |
394 const std::vector<linked_ptr<api::file_manager_private::ProfileInfo> >& | |
395 profiles = GetLoggedInProfileInfoList(); | |
396 | |
397 chrome::MultiUserWindowManager* const window_manager = | |
398 chrome::MultiUserWindowManager::GetInstance(); | |
399 DCHECK(window_manager); | |
400 | |
401 // Check if the target user is logged-in or not. | |
402 bool logged_in = false; | |
403 for (size_t i = 0; i < profiles.size(); ++i) { | |
404 if (profiles[i]->profile_id == params->profile_id) { | |
405 logged_in = true; | |
406 break; | |
407 } | |
408 } | |
409 if (!logged_in) { | |
410 SetError("The user is not logged-in now."); | |
411 return false; | |
412 } | |
413 | |
414 // Look for the current app window. | |
415 AppWindow* const app_window = GetCurrentAppWindow(this); | |
416 if (!app_window) { | |
417 SetError("Target window is not found."); | |
418 return false; | |
419 } | |
420 | |
421 // Move the window to the user's desktop. | |
422 window_manager->ShowWindowForUser(app_window->GetNativeWindow(), | |
423 params->profile_id); | |
424 | |
425 // Check the result. | |
426 if (!window_manager->IsWindowOnDesktopOfUser(app_window->GetNativeWindow(), | |
427 params->profile_id)) { | |
428 SetError("The window cannot visit the desktop."); | |
429 return false; | |
430 } | |
431 | |
432 return true; | |
433 } | |
434 | |
435 bool FileManagerPrivateOpenInspectorFunction::RunSync() { | 391 bool FileManagerPrivateOpenInspectorFunction::RunSync() { |
436 using extensions::api::file_manager_private::OpenInspector::Params; | 392 using extensions::api::file_manager_private::OpenInspector::Params; |
437 const scoped_ptr<Params> params(Params::Create(*args_)); | 393 const scoped_ptr<Params> params(Params::Create(*args_)); |
438 EXTENSION_FUNCTION_VALIDATE(params); | 394 EXTENSION_FUNCTION_VALIDATE(params); |
439 | 395 |
440 switch (params->type) { | 396 switch (params->type) { |
441 case extensions::api::file_manager_private::INSPECTION_TYPE_NORMAL: | 397 case extensions::api::file_manager_private::INSPECTION_TYPE_NORMAL: |
442 // Open inspector for foreground page. | 398 // Open inspector for foreground page. |
443 DevToolsWindow::OpenDevToolsWindow( | 399 DevToolsWindow::OpenDevToolsWindow( |
444 content::WebContents::FromRenderViewHost(render_view_host())); | 400 content::WebContents::FromRenderViewHost(render_view_host())); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 return true; | 454 return true; |
499 } | 455 } |
500 | 456 |
501 void FileManagerPrivateGetMimeTypeFunction::OnGetMimeType( | 457 void FileManagerPrivateGetMimeTypeFunction::OnGetMimeType( |
502 const std::string& mimeType) { | 458 const std::string& mimeType) { |
503 SetResult(new base::StringValue(mimeType)); | 459 SetResult(new base::StringValue(mimeType)); |
504 SendResponse(true); | 460 SendResponse(true); |
505 } | 461 } |
506 | 462 |
507 } // namespace extensions | 463 } // namespace extensions |
OLD | NEW |