Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1010)

Side by Side Diff: chrome/browser/chromeos/extensions/file_manager/private_api_misc.cc

Issue 166573005: Rename apps::ShellWindow to apps::AppWindow (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, nits (rename) Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/shell_window.h" 7 #include "apps/app_window.h"
8 #include "apps/shell_window_registry.h" 8 #include "apps/app_window_registry.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/chromeos/drive/file_system_util.h" 13 #include "chrome/browser/chromeos/drive/file_system_util.h"
14 #include "chrome/browser/chromeos/extensions/file_manager/event_router.h" 14 #include "chrome/browser/chromeos/extensions/file_manager/event_router.h"
15 #include "chrome/browser/chromeos/extensions/file_manager/file_browser_private_a pi.h" 15 #include "chrome/browser/chromeos/extensions/file_manager/file_browser_private_a pi.h"
16 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h" 16 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h"
17 #include "chrome/browser/chromeos/file_manager/app_installer.h" 17 #include "chrome/browser/chromeos/file_manager/app_installer.h"
18 #include "chrome/browser/chromeos/login/user_manager.h" 18 #include "chrome/browser/chromeos/login/user_manager.h"
(...skipping 17 matching lines...) Expand all
36 #include "content/public/common/page_zoom.h" 36 #include "content/public/common/page_zoom.h"
37 #include "google_apis/drive/auth_service.h" 37 #include "google_apis/drive/auth_service.h"
38 #include "ui/base/webui/web_ui_util.h" 38 #include "ui/base/webui/web_ui_util.h"
39 #include "url/gurl.h" 39 #include "url/gurl.h"
40 40
41 namespace extensions { 41 namespace extensions {
42 42
43 namespace { 43 namespace {
44 const char kCWSScope[] = "https://www.googleapis.com/auth/chromewebstore"; 44 const char kCWSScope[] = "https://www.googleapis.com/auth/chromewebstore";
45 45
46 // Obtains the current shell window. 46 // Obtains the current app window.
47 apps::ShellWindow* 47 apps::AppWindow* GetCurrentAppWindow(ChromeSyncExtensionFunction* function) {
48 GetCurrentShellWindow(ChromeSyncExtensionFunction* function) { 48 apps::AppWindowRegistry* const app_window_registry =
49 apps::ShellWindowRegistry* const shell_window_registry = 49 apps::AppWindowRegistry::Get(function->GetProfile());
50 apps::ShellWindowRegistry::Get(function->GetProfile());
51 content::WebContents* const contents = function->GetAssociatedWebContents(); 50 content::WebContents* const contents = function->GetAssociatedWebContents();
52 content::RenderViewHost* const render_view_host = 51 content::RenderViewHost* const render_view_host =
53 contents ? contents->GetRenderViewHost() : NULL; 52 contents ? contents->GetRenderViewHost() : NULL;
54 return render_view_host ? 53 return render_view_host ? app_window_registry->GetAppWindowForRenderViewHost(
55 shell_window_registry->GetShellWindowForRenderViewHost(render_view_host) : 54 render_view_host)
56 NULL; 55 : NULL;
57 } 56 }
58 57
59 std::vector<linked_ptr<api::file_browser_private::ProfileInfo> > 58 std::vector<linked_ptr<api::file_browser_private::ProfileInfo> >
60 GetLoggedInProfileInfoList() { 59 GetLoggedInProfileInfoList() {
61 DCHECK(chromeos::UserManager::IsInitialized()); 60 DCHECK(chromeos::UserManager::IsInitialized());
62 const std::vector<Profile*>& profiles = 61 const std::vector<Profile*>& profiles =
63 g_browser_process->profile_manager()->GetLoadedProfiles(); 62 g_browser_process->profile_manager()->GetLoadedProfiles();
64 std::set<Profile*> original_profiles; 63 std::set<Profile*> original_profiles;
65 std::vector<linked_ptr<api::file_browser_private::ProfileInfo> > 64 std::vector<linked_ptr<api::file_browser_private::ProfileInfo> >
66 result_profiles; 65 result_profiles;
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 SetResult(base::Value::CreateNullValue()); 365 SetResult(base::Value::CreateNullValue());
367 SendResponse(false); 366 SendResponse(false);
368 } 367 }
369 } 368 }
370 369
371 bool FileBrowserPrivateGetProfilesFunction::RunImpl() { 370 bool FileBrowserPrivateGetProfilesFunction::RunImpl() {
372 const std::vector<linked_ptr<api::file_browser_private::ProfileInfo> >& 371 const std::vector<linked_ptr<api::file_browser_private::ProfileInfo> >&
373 profiles = GetLoggedInProfileInfoList(); 372 profiles = GetLoggedInProfileInfoList();
374 373
375 // Obtains the display profile ID. 374 // Obtains the display profile ID.
376 apps::ShellWindow* const shell_window = GetCurrentShellWindow(this); 375 apps::AppWindow* const app_window = GetCurrentAppWindow(this);
377 chrome::MultiUserWindowManager* const window_manager = 376 chrome::MultiUserWindowManager* const window_manager =
378 chrome::MultiUserWindowManager::GetInstance(); 377 chrome::MultiUserWindowManager::GetInstance();
379 const std::string current_profile_id = 378 const std::string current_profile_id =
380 multi_user_util::GetUserIDFromProfile(GetProfile()); 379 multi_user_util::GetUserIDFromProfile(GetProfile());
381 const std::string display_profile_id = 380 const std::string display_profile_id =
382 window_manager && shell_window ? 381 window_manager && app_window ? window_manager->GetUserPresentingWindow(
383 window_manager->GetUserPresentingWindow(shell_window->GetNativeWindow()) : 382 app_window->GetNativeWindow())
384 ""; 383 : "";
385 384
386 results_ = api::file_browser_private::GetProfiles::Results::Create( 385 results_ = api::file_browser_private::GetProfiles::Results::Create(
387 profiles, 386 profiles,
388 current_profile_id, 387 current_profile_id,
389 display_profile_id.empty() ? current_profile_id : display_profile_id); 388 display_profile_id.empty() ? current_profile_id : display_profile_id);
390 return true; 389 return true;
391 } 390 }
392 391
393 bool FileBrowserPrivateVisitDesktopFunction::RunImpl() { 392 bool FileBrowserPrivateVisitDesktopFunction::RunImpl() {
394 using api::file_browser_private::VisitDesktop::Params; 393 using api::file_browser_private::VisitDesktop::Params;
(...skipping 17 matching lines...) Expand all
412 if (profiles[i]->profile_id == params->profile_id) { 411 if (profiles[i]->profile_id == params->profile_id) {
413 logged_in = true; 412 logged_in = true;
414 break; 413 break;
415 } 414 }
416 } 415 }
417 if (!logged_in) { 416 if (!logged_in) {
418 SetError("The user is not logged-in now."); 417 SetError("The user is not logged-in now.");
419 return false; 418 return false;
420 } 419 }
421 420
422 // Look for the current shell window. 421 // Look for the current app window.
423 apps::ShellWindow* const shell_window = GetCurrentShellWindow(this); 422 apps::AppWindow* const app_window = GetCurrentAppWindow(this);
424 if (!shell_window) { 423 if (!app_window) {
425 SetError("Target window is not found."); 424 SetError("Target window is not found.");
426 return false; 425 return false;
427 } 426 }
428 427
429 // Observe owner changes of windows. 428 // Observe owner changes of windows.
430 file_manager::EventRouter* const event_router = 429 file_manager::EventRouter* const event_router =
431 file_manager::FileBrowserPrivateAPI::Get(GetProfile())->event_router(); 430 file_manager::FileBrowserPrivateAPI::Get(GetProfile())->event_router();
432 event_router->RegisterMultiUserWindowManagerObserver(); 431 event_router->RegisterMultiUserWindowManagerObserver();
433 432
434 // Move the window to the user's desktop. 433 // Move the window to the user's desktop.
435 window_manager->ShowWindowForUser( 434 window_manager->ShowWindowForUser(app_window->GetNativeWindow(),
436 shell_window->GetNativeWindow(), 435 params->profile_id);
437 params->profile_id);
438 436
439 // Check the result. 437 // Check the result.
440 if (!window_manager->IsWindowOnDesktopOfUser( 438 if (!window_manager->IsWindowOnDesktopOfUser(app_window->GetNativeWindow(),
441 shell_window->GetNativeWindow(), 439 params->profile_id)) {
442 params->profile_id)) {
443 SetError("The window cannot visit the desktop."); 440 SetError("The window cannot visit the desktop.");
444 return false; 441 return false;
445 } 442 }
446 443
447 return true; 444 return true;
448 } 445 }
449 446
450 } // namespace extensions 447 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698