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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 profile_info->profile_image->scale2x_url = | 95 profile_info->profile_image->scale2x_url = |
96 webui::GetBitmapDataUrl(skia.GetRepresentation(2.0f).sk_bitmap()); | 96 webui::GetBitmapDataUrl(skia.GetRepresentation(2.0f).sk_bitmap()); |
97 } | 97 } |
98 result_profiles.push_back(profile_info); | 98 result_profiles.push_back(profile_info); |
99 } | 99 } |
100 | 100 |
101 return result_profiles; | 101 return result_profiles; |
102 } | 102 } |
103 } // namespace | 103 } // namespace |
104 | 104 |
105 bool FileBrowserPrivateLogoutUserForReauthenticationFunction::RunImpl() { | 105 bool FileBrowserPrivateLogoutUserForReauthenticationFunction::RunSync() { |
106 chromeos::User* user = | 106 chromeos::User* user = |
107 chromeos::UserManager::Get()->GetUserByProfile(GetProfile()); | 107 chromeos::UserManager::Get()->GetUserByProfile(GetProfile()); |
108 if (user) { | 108 if (user) { |
109 chromeos::UserManager::Get()->SaveUserOAuthStatus( | 109 chromeos::UserManager::Get()->SaveUserOAuthStatus( |
110 user->email(), | 110 user->email(), |
111 chromeos::User::OAUTH2_TOKEN_STATUS_INVALID); | 111 chromeos::User::OAUTH2_TOKEN_STATUS_INVALID); |
112 } | 112 } |
113 | 113 |
114 chrome::AttemptUserExit(); | 114 chrome::AttemptUserExit(); |
115 return true; | 115 return true; |
116 } | 116 } |
117 | 117 |
118 bool FileBrowserPrivateGetPreferencesFunction::RunImpl() { | 118 bool FileBrowserPrivateGetPreferencesFunction::RunSync() { |
119 api::file_browser_private::Preferences result; | 119 api::file_browser_private::Preferences result; |
120 const PrefService* const service = GetProfile()->GetPrefs(); | 120 const PrefService* const service = GetProfile()->GetPrefs(); |
121 | 121 |
122 result.drive_enabled = drive::util::IsDriveEnabledForProfile(GetProfile()); | 122 result.drive_enabled = drive::util::IsDriveEnabledForProfile(GetProfile()); |
123 result.cellular_disabled = | 123 result.cellular_disabled = |
124 service->GetBoolean(prefs::kDisableDriveOverCellular); | 124 service->GetBoolean(prefs::kDisableDriveOverCellular); |
125 result.hosted_files_disabled = | 125 result.hosted_files_disabled = |
126 service->GetBoolean(prefs::kDisableDriveHostedFiles); | 126 service->GetBoolean(prefs::kDisableDriveHostedFiles); |
127 result.use24hour_clock = service->GetBoolean(prefs::kUse24HourClock); | 127 result.use24hour_clock = service->GetBoolean(prefs::kUse24HourClock); |
128 result.allow_redeem_offers = true; | 128 result.allow_redeem_offers = true; |
129 if (!chromeos::CrosSettings::Get()->GetBoolean( | 129 if (!chromeos::CrosSettings::Get()->GetBoolean( |
130 chromeos::kAllowRedeemChromeOsRegistrationOffers, | 130 chromeos::kAllowRedeemChromeOsRegistrationOffers, |
131 &result.allow_redeem_offers)) { | 131 &result.allow_redeem_offers)) { |
132 result.allow_redeem_offers = true; | 132 result.allow_redeem_offers = true; |
133 } | 133 } |
134 | 134 |
135 SetResult(result.ToValue().release()); | 135 SetResult(result.ToValue().release()); |
136 | 136 |
137 drive::EventLogger* logger = file_manager::util::GetLogger(GetProfile()); | 137 drive::EventLogger* logger = file_manager::util::GetLogger(GetProfile()); |
138 if (logger) | 138 if (logger) |
139 logger->Log(logging::LOG_INFO, "%s succeeded.", name().c_str()); | 139 logger->Log(logging::LOG_INFO, "%s succeeded.", name().c_str()); |
140 return true; | 140 return true; |
141 } | 141 } |
142 | 142 |
143 bool FileBrowserPrivateSetPreferencesFunction::RunImpl() { | 143 bool FileBrowserPrivateSetPreferencesFunction::RunSync() { |
144 using extensions::api::file_browser_private::SetPreferences::Params; | 144 using extensions::api::file_browser_private::SetPreferences::Params; |
145 const scoped_ptr<Params> params(Params::Create(*args_)); | 145 const scoped_ptr<Params> params(Params::Create(*args_)); |
146 EXTENSION_FUNCTION_VALIDATE(params); | 146 EXTENSION_FUNCTION_VALIDATE(params); |
147 | 147 |
148 PrefService* const service = GetProfile()->GetPrefs(); | 148 PrefService* const service = GetProfile()->GetPrefs(); |
149 | 149 |
150 if (params->change_info.cellular_disabled) | 150 if (params->change_info.cellular_disabled) |
151 service->SetBoolean(prefs::kDisableDriveOverCellular, | 151 service->SetBoolean(prefs::kDisableDriveOverCellular, |
152 *params->change_info.cellular_disabled); | 152 *params->change_info.cellular_disabled); |
153 | 153 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 zip_file_creator_->Start(); | 226 zip_file_creator_->Start(); |
227 return true; | 227 return true; |
228 } | 228 } |
229 | 229 |
230 void FileBrowserPrivateZipSelectionFunction::OnZipDone(bool success) { | 230 void FileBrowserPrivateZipSelectionFunction::OnZipDone(bool success) { |
231 SetResult(new base::FundamentalValue(success)); | 231 SetResult(new base::FundamentalValue(success)); |
232 SendResponse(true); | 232 SendResponse(true); |
233 Release(); | 233 Release(); |
234 } | 234 } |
235 | 235 |
236 bool FileBrowserPrivateZoomFunction::RunImpl() { | 236 bool FileBrowserPrivateZoomFunction::RunSync() { |
237 using extensions::api::file_browser_private::Zoom::Params; | 237 using extensions::api::file_browser_private::Zoom::Params; |
238 const scoped_ptr<Params> params(Params::Create(*args_)); | 238 const scoped_ptr<Params> params(Params::Create(*args_)); |
239 EXTENSION_FUNCTION_VALIDATE(params); | 239 EXTENSION_FUNCTION_VALIDATE(params); |
240 | 240 |
241 content::PageZoom zoom_type; | 241 content::PageZoom zoom_type; |
242 switch (params->operation) { | 242 switch (params->operation) { |
243 case api::file_browser_private::ZOOM_OPERATION_TYPE_IN: | 243 case api::file_browser_private::ZOOM_OPERATION_TYPE_IN: |
244 zoom_type = content::PAGE_ZOOM_IN; | 244 zoom_type = content::PAGE_ZOOM_IN; |
245 break; | 245 break; |
246 case api::file_browser_private::ZOOM_OPERATION_TYPE_OUT: | 246 case api::file_browser_private::ZOOM_OPERATION_TYPE_OUT: |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 if (logger) { | 363 if (logger) { |
364 logger->Log(logging::LOG_ERROR, | 364 logger->Log(logging::LOG_ERROR, |
365 "CWS OAuth token fetch failed. (GDataErrorCode: %s)", | 365 "CWS OAuth token fetch failed. (GDataErrorCode: %s)", |
366 google_apis::GDataErrorCodeToString(code).c_str()); | 366 google_apis::GDataErrorCodeToString(code).c_str()); |
367 } | 367 } |
368 SetResult(base::Value::CreateNullValue()); | 368 SetResult(base::Value::CreateNullValue()); |
369 SendResponse(false); | 369 SendResponse(false); |
370 } | 370 } |
371 } | 371 } |
372 | 372 |
373 bool FileBrowserPrivateGetProfilesFunction::RunImpl() { | 373 bool FileBrowserPrivateGetProfilesFunction::RunSync() { |
374 const std::vector<linked_ptr<api::file_browser_private::ProfileInfo> >& | 374 const std::vector<linked_ptr<api::file_browser_private::ProfileInfo> >& |
375 profiles = GetLoggedInProfileInfoList(GetAssociatedWebContents()); | 375 profiles = GetLoggedInProfileInfoList(GetAssociatedWebContents()); |
376 | 376 |
377 // Obtains the display profile ID. | 377 // Obtains the display profile ID. |
378 apps::AppWindow* const app_window = GetCurrentAppWindow(this); | 378 apps::AppWindow* const app_window = GetCurrentAppWindow(this); |
379 chrome::MultiUserWindowManager* const window_manager = | 379 chrome::MultiUserWindowManager* const window_manager = |
380 chrome::MultiUserWindowManager::GetInstance(); | 380 chrome::MultiUserWindowManager::GetInstance(); |
381 const std::string current_profile_id = | 381 const std::string current_profile_id = |
382 multi_user_util::GetUserIDFromProfile(GetProfile()); | 382 multi_user_util::GetUserIDFromProfile(GetProfile()); |
383 const std::string display_profile_id = | 383 const std::string display_profile_id = |
384 window_manager && app_window ? window_manager->GetUserPresentingWindow( | 384 window_manager && app_window ? window_manager->GetUserPresentingWindow( |
385 app_window->GetNativeWindow()) | 385 app_window->GetNativeWindow()) |
386 : ""; | 386 : ""; |
387 | 387 |
388 results_ = api::file_browser_private::GetProfiles::Results::Create( | 388 results_ = api::file_browser_private::GetProfiles::Results::Create( |
389 profiles, | 389 profiles, |
390 current_profile_id, | 390 current_profile_id, |
391 display_profile_id.empty() ? current_profile_id : display_profile_id); | 391 display_profile_id.empty() ? current_profile_id : display_profile_id); |
392 return true; | 392 return true; |
393 } | 393 } |
394 | 394 |
395 bool FileBrowserPrivateVisitDesktopFunction::RunImpl() { | 395 bool FileBrowserPrivateVisitDesktopFunction::RunSync() { |
396 using api::file_browser_private::VisitDesktop::Params; | 396 using api::file_browser_private::VisitDesktop::Params; |
397 const scoped_ptr<Params> params(Params::Create(*args_)); | 397 const scoped_ptr<Params> params(Params::Create(*args_)); |
398 const std::vector<linked_ptr<api::file_browser_private::ProfileInfo> >& | 398 const std::vector<linked_ptr<api::file_browser_private::ProfileInfo> >& |
399 profiles = GetLoggedInProfileInfoList(GetAssociatedWebContents()); | 399 profiles = GetLoggedInProfileInfoList(GetAssociatedWebContents()); |
400 | 400 |
401 // Check the multi-profile support. | 401 // Check the multi-profile support. |
402 if (!profiles::IsMultipleProfilesEnabled()) { | 402 if (!profiles::IsMultipleProfilesEnabled()) { |
403 SetError("Multi-profile support is not enabled."); | 403 SetError("Multi-profile support is not enabled."); |
404 return false; | 404 return false; |
405 } | 405 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 if (!window_manager->IsWindowOnDesktopOfUser(app_window->GetNativeWindow(), | 441 if (!window_manager->IsWindowOnDesktopOfUser(app_window->GetNativeWindow(), |
442 params->profile_id)) { | 442 params->profile_id)) { |
443 SetError("The window cannot visit the desktop."); | 443 SetError("The window cannot visit the desktop."); |
444 return false; | 444 return false; |
445 } | 445 } |
446 | 446 |
447 return true; | 447 return true; |
448 } | 448 } |
449 | 449 |
450 } // namespace extensions | 450 } // namespace extensions |
OLD | NEW |