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

Side by Side Diff: chrome/browser/extensions/api/system_display/system_display_api.cc

Issue 389633002: Move system.* family of APIs to extensions/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Better comments Created 6 years, 5 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/extensions/api/system_display/system_display_api.h"
6
7 #include <string>
8
9 #include "chrome/browser/extensions/api/system_display/display_info_provider.h"
10 #include "chrome/common/extensions/api/system_display.h"
11
12 #if defined(OS_CHROMEOS)
13 #include "base/memory/scoped_ptr.h"
14 #include "extensions/common/manifest_handlers/kiosk_mode_info.h"
15 #include "ui/gfx/screen.h"
16 #endif
17
18 namespace extensions {
19
20 using api::system_display::DisplayUnitInfo;
21
22 namespace SetDisplayProperties = api::system_display::SetDisplayProperties;
23
24 typedef std::vector<linked_ptr<
25 api::system_display::DisplayUnitInfo> > DisplayInfo;
26
27 bool SystemDisplayGetInfoFunction::RunSync() {
28 DisplayInfo all_displays_info =
29 DisplayInfoProvider::Get()->GetAllDisplaysInfo();
30 results_ = api::system_display::GetInfo::Results::Create(all_displays_info);
31 return true;
32 }
33
34 bool SystemDisplaySetDisplayPropertiesFunction::RunSync() {
35 #if !defined(OS_CHROMEOS)
36 SetError("Function available only on ChromeOS.");
37 return false;
38 #else
39 if (!KioskModeInfo::IsKioskEnabled(GetExtension())) {
40 SetError("The extension needs to be kiosk enabled to use the function.");
41 return false;
42 }
43 std::string error;
44 scoped_ptr<SetDisplayProperties::Params> params(
45 SetDisplayProperties::Params::Create(*args_));
46 bool success = DisplayInfoProvider::Get()->SetInfo(params->id,
47 params->info,
48 &error);
49 if (!success)
50 SetError(error);
51 return true;
52 #endif
53 }
54
55 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698