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

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

Issue 494033002: Move AppWindow to extensions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unneeded include in chrome_shell_delegate.cc Created 6 years, 3 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/app_window.h"
8 #include "apps/app_window_registry.h"
9 #include "ash/frame/frame_util.h" 7 #include "ash/frame/frame_util.h"
10 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
11 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
12 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
13 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
14 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/chromeos/drive/file_system_util.h" 13 #include "chrome/browser/chromeos/drive/file_system_util.h"
16 #include "chrome/browser/chromeos/extensions/file_manager/event_router.h" 14 #include "chrome/browser/chromeos/extensions/file_manager/event_router.h"
17 #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"
18 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h" 16 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h"
(...skipping 13 matching lines...) Expand all
32 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" 30 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
33 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" 31 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h"
34 #include "chrome/common/extensions/api/file_browser_private.h" 32 #include "chrome/common/extensions/api/file_browser_private.h"
35 #include "chrome/common/pref_names.h" 33 #include "chrome/common/pref_names.h"
36 #include "components/signin/core/browser/profile_oauth2_token_service.h" 34 #include "components/signin/core/browser/profile_oauth2_token_service.h"
37 #include "components/signin/core/browser/signin_manager.h" 35 #include "components/signin/core/browser/signin_manager.h"
38 #include "components/user_manager/user_manager.h" 36 #include "components/user_manager/user_manager.h"
39 #include "content/public/browser/render_view_host.h" 37 #include "content/public/browser/render_view_host.h"
40 #include "content/public/browser/web_contents.h" 38 #include "content/public/browser/web_contents.h"
41 #include "content/public/common/page_zoom.h" 39 #include "content/public/common/page_zoom.h"
40 #include "extensions/browser/app_window/app_window.h"
41 #include "extensions/browser/app_window/app_window_registry.h"
42 #include "google_apis/drive/auth_service.h" 42 #include "google_apis/drive/auth_service.h"
43 #include "ui/base/webui/web_ui_util.h" 43 #include "ui/base/webui/web_ui_util.h"
44 #include "url/gurl.h" 44 #include "url/gurl.h"
45 45
46 namespace extensions { 46 namespace extensions {
47 47
48 namespace { 48 namespace {
49 const char kCWSScope[] = "https://www.googleapis.com/auth/chromewebstore"; 49 const char kCWSScope[] = "https://www.googleapis.com/auth/chromewebstore";
50 const char kGoogleCastApiExtensionId[] = "mafeflapfdfljijmlienjedomfjfmhpd"; 50 const char kGoogleCastApiExtensionId[] = "mafeflapfdfljijmlienjedomfjfmhpd";
51 51
52 // Obtains the current app window. 52 // Obtains the current app window.
53 apps::AppWindow* GetCurrentAppWindow(ChromeSyncExtensionFunction* function) { 53 AppWindow* GetCurrentAppWindow(ChromeSyncExtensionFunction* function) {
54 apps::AppWindowRegistry* const app_window_registry = 54 AppWindowRegistry* const app_window_registry =
55 apps::AppWindowRegistry::Get(function->GetProfile()); 55 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) {
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 SetResult(base::Value::CreateNullValue()); 376 SetResult(base::Value::CreateNullValue());
377 SendResponse(false); 377 SendResponse(false);
378 } 378 }
379 } 379 }
380 380
381 bool FileBrowserPrivateGetProfilesFunction::RunSync() { 381 bool FileBrowserPrivateGetProfilesFunction::RunSync() {
382 const std::vector<linked_ptr<api::file_browser_private::ProfileInfo> >& 382 const std::vector<linked_ptr<api::file_browser_private::ProfileInfo> >&
383 profiles = GetLoggedInProfileInfoList(GetAssociatedWebContents()); 383 profiles = GetLoggedInProfileInfoList(GetAssociatedWebContents());
384 384
385 // Obtains the display profile ID. 385 // Obtains the display profile ID.
386 apps::AppWindow* const app_window = GetCurrentAppWindow(this); 386 AppWindow* const app_window = GetCurrentAppWindow(this);
387 chrome::MultiUserWindowManager* const window_manager = 387 chrome::MultiUserWindowManager* const window_manager =
388 chrome::MultiUserWindowManager::GetInstance(); 388 chrome::MultiUserWindowManager::GetInstance();
389 const std::string current_profile_id = 389 const std::string current_profile_id =
390 multi_user_util::GetUserIDFromProfile(GetProfile()); 390 multi_user_util::GetUserIDFromProfile(GetProfile());
391 const std::string display_profile_id = 391 const std::string display_profile_id =
392 window_manager && app_window ? window_manager->GetUserPresentingWindow( 392 window_manager && app_window ? window_manager->GetUserPresentingWindow(
393 app_window->GetNativeWindow()) 393 app_window->GetNativeWindow())
394 : ""; 394 : "";
395 395
396 results_ = api::file_browser_private::GetProfiles::Results::Create( 396 results_ = api::file_browser_private::GetProfiles::Results::Create(
(...skipping 20 matching lines...) Expand all
417 logged_in = true; 417 logged_in = true;
418 break; 418 break;
419 } 419 }
420 } 420 }
421 if (!logged_in) { 421 if (!logged_in) {
422 SetError("The user is not logged-in now."); 422 SetError("The user is not logged-in now.");
423 return false; 423 return false;
424 } 424 }
425 425
426 // Look for the current app window. 426 // Look for the current app window.
427 apps::AppWindow* const app_window = GetCurrentAppWindow(this); 427 AppWindow* const app_window = GetCurrentAppWindow(this);
428 if (!app_window) { 428 if (!app_window) {
429 SetError("Target window is not found."); 429 SetError("Target window is not found.");
430 return false; 430 return false;
431 } 431 }
432 432
433 // Observe owner changes of windows. 433 // Observe owner changes of windows.
434 file_manager::EventRouter* const event_router = 434 file_manager::EventRouter* const event_router =
435 file_manager::FileBrowserPrivateAPI::Get(GetProfile())->event_router(); 435 file_manager::FileBrowserPrivateAPI::Get(GetProfile())->event_router();
436 event_router->RegisterMultiUserWindowManagerObserver(); 436 event_router->RegisterMultiUserWindowManagerObserver();
437 437
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 NOTREACHED(); 481 NOTREACHED();
482 SetError( 482 SetError(
483 base::StringPrintf("Unexpected inspection type(%d) is specified.", 483 base::StringPrintf("Unexpected inspection type(%d) is specified.",
484 static_cast<int>(params->type))); 484 static_cast<int>(params->type)));
485 return false; 485 return false;
486 } 486 }
487 return true; 487 return true;
488 } 488 }
489 489
490 } // namespace extensions 490 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698