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

Side by Side Diff: chrome/browser/chromeos/display/display_preferences.cc

Issue 11363124: Move DisplayManager and DisplayChangeObserverX11 from aura to ash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix rebase Created 8 years, 1 month 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/display/display_preferences.h" 5 #include "chrome/browser/chromeos/display/display_preferences.h"
6 6
7 #include "ash/display/display_controller.h" 7 #include "ash/display/display_controller.h"
8 #include "ash/display/multi_display_manager.h" 8 #include "ash/display/display_manager.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "base/string16.h" 10 #include "base/string16.h"
11 #include "base/string_number_conversions.h" 11 #include "base/string_number_conversions.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/chromeos/login/user_manager.h" 15 #include "chrome/browser/chromeos/login/user_manager.h"
16 #include "chrome/browser/prefs/pref_service.h" 16 #include "chrome/browser/prefs/pref_service.h"
17 #include "chrome/browser/prefs/scoped_user_pref_update.h" 17 #include "chrome/browser/prefs/scoped_user_pref_update.h"
18 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
19 #include "googleurl/src/url_canon.h" 19 #include "googleurl/src/url_canon.h"
20 #include "googleurl/src/url_util.h" 20 #include "googleurl/src/url_util.h"
21 #include "ui/aura/display_manager.h"
22 #include "ui/aura/env.h"
23 #include "ui/gfx/display.h" 21 #include "ui/gfx/display.h"
24 #include "ui/gfx/insets.h" 22 #include "ui/gfx/insets.h"
25 23
26 namespace chromeos { 24 namespace chromeos {
27 namespace { 25 namespace {
28 26
29 // Replaces dot "." by "%2E" since it's the path separater of base::Value. Also 27 // Replaces dot "." by "%2E" since it's the path separater of base::Value. Also
30 // replaces "%" by "%25" for unescaping. 28 // replaces "%" by "%25" for unescaping.
31 void EscapeDisplayName(const std::string& name, std::string* escaped) { 29 void EscapeDisplayName(const std::string& name, std::string* escaped) {
32 DCHECK(escaped); 30 DCHECK(escaped);
(...skipping 30 matching lines...) Expand all
63 } 61 }
64 62
65 void InsetsToValue(const gfx::Insets& insets, base::DictionaryValue* value) { 63 void InsetsToValue(const gfx::Insets& insets, base::DictionaryValue* value) {
66 DCHECK(value); 64 DCHECK(value);
67 value->SetInteger("top", insets.top()); 65 value->SetInteger("top", insets.top());
68 value->SetInteger("left", insets.left()); 66 value->SetInteger("left", insets.left());
69 value->SetInteger("bottom", insets.bottom()); 67 value->SetInteger("bottom", insets.bottom());
70 value->SetInteger("right", insets.right()); 68 value->SetInteger("right", insets.right());
71 } 69 }
72 70
73 ash::internal::MultiDisplayManager* GetDisplayManager() { 71 ash::internal::DisplayManager* GetDisplayManager() {
74 return static_cast<ash::internal::MultiDisplayManager*>( 72 return ash::Shell::GetInstance()->display_manager();
75 aura::Env::GetInstance()->display_manager());
76 } 73 }
77 74
78 // Returns true id the current user can write display preferences to 75 // Returns true id the current user can write display preferences to
79 // Local State. 76 // Local State.
80 bool IsValidUser() { 77 bool IsValidUser() {
81 UserManager* user_manager = UserManager::Get(); 78 UserManager* user_manager = UserManager::Get();
82 return (user_manager->IsUserLoggedIn() && 79 return (user_manager->IsUserLoggedIn() &&
83 !user_manager->IsLoggedInAsDemoUser() && 80 !user_manager->IsLoggedInAsDemoUser() &&
84 !user_manager->IsLoggedInAsGuest() && 81 !user_manager->IsLoggedInAsGuest() &&
85 !user_manager->IsLoggedInAsStub()); 82 !user_manager->IsLoggedInAsStub());
(...skipping 25 matching lines...) Expand all
111 continue; 108 continue;
112 } 109 }
113 110
114 display_controller->SetLayoutForDisplayName( 111 display_controller->SetLayoutForDisplayName(
115 UnescapeDisplayName(*it), layout); 112 UnescapeDisplayName(*it), layout);
116 } 113 }
117 } 114 }
118 115
119 void NotifyDisplayOverscans() { 116 void NotifyDisplayOverscans() {
120 PrefService* local_state = g_browser_process->local_state(); 117 PrefService* local_state = g_browser_process->local_state();
121 ash::internal::MultiDisplayManager* display_manager = GetDisplayManager(); 118 ash::internal::DisplayManager* display_manager = GetDisplayManager();
122 119
123 const base::DictionaryValue* overscans = local_state->GetDictionary( 120 const base::DictionaryValue* overscans = local_state->GetDictionary(
124 prefs::kDisplayOverscans); 121 prefs::kDisplayOverscans);
125 for (base::DictionaryValue::key_iterator it = overscans->begin_keys(); 122 for (base::DictionaryValue::key_iterator it = overscans->begin_keys();
126 it != overscans->end_keys(); ++it) { 123 it != overscans->end_keys(); ++it) {
127 int64 display_id = gfx::Display::kInvalidDisplayID; 124 int64 display_id = gfx::Display::kInvalidDisplayID;
128 if (!base::StringToInt64(*it, &display_id)) { 125 if (!base::StringToInt64(*it, &display_id)) {
129 LOG(WARNING) << "Invalid key, cannot convert to display ID: " << *it; 126 LOG(WARNING) << "Invalid key, cannot convert to display ID: " << *it;
130 continue; 127 continue;
131 } 128 }
132 129
133 const base::DictionaryValue* value = NULL; 130 const base::DictionaryValue* value = NULL;
134 if (!overscans->GetDictionary(*it, &value) || value == NULL) { 131 if (!overscans->GetDictionary(*it, &value) || value == NULL) {
135 LOG(WARNING) << "Can't find dictionary value for " << *it; 132 LOG(WARNING) << "Can't find dictionary value for " << *it;
136 continue; 133 continue;
137 } 134 }
138 135
139 gfx::Insets insets; 136 gfx::Insets insets;
140 if (!ValueToInsets(*value, &insets)) { 137 if (!ValueToInsets(*value, &insets)) {
141 LOG(WARNING) << "Can't convert the data into insets for " << *it; 138 LOG(WARNING) << "Can't convert the data into insets for " << *it;
142 continue; 139 continue;
143 } 140 }
144 141
142 // TODO(oshima|mukai): DisplayManager is internal class.
143 // Move |SetOverscanInsets| to display controller.
145 display_manager->SetOverscanInsets(display_id, insets); 144 display_manager->SetOverscanInsets(display_id, insets);
146 } 145 }
147 } 146 }
148 147
149 } // namespace 148 } // namespace
150 149
151 void RegisterDisplayPrefs(PrefService* pref_service) { 150 void RegisterDisplayPrefs(PrefService* pref_service) {
152 // The default secondary display layout. 151 // The default secondary display layout.
153 pref_service->RegisterIntegerPref(prefs::kSecondaryDisplayLayout, 152 pref_service->RegisterIntegerPref(prefs::kSecondaryDisplayLayout,
154 static_cast<int>(ash::DisplayLayout::RIGHT), 153 static_cast<int>(ash::DisplayLayout::RIGHT),
(...skipping 21 matching lines...) Expand all
176 175
177 void SetDisplayLayoutPref(PrefService* pref_service, 176 void SetDisplayLayoutPref(PrefService* pref_service,
178 const gfx::Display& display, 177 const gfx::Display& display,
179 int layout, 178 int layout,
180 int offset) { 179 int offset) {
181 { 180 {
182 DictionaryPrefUpdate update(pref_service, prefs::kSecondaryDisplays); 181 DictionaryPrefUpdate update(pref_service, prefs::kSecondaryDisplays);
183 ash::DisplayLayout display_layout( 182 ash::DisplayLayout display_layout(
184 static_cast<ash::DisplayLayout::Position>(layout), offset); 183 static_cast<ash::DisplayLayout::Position>(layout), offset);
185 184
186 aura::DisplayManager* display_manager =
187 aura::Env::GetInstance()->display_manager();
188 std::string name; 185 std::string name;
189 EscapeDisplayName(display_manager->GetDisplayNameFor(display), 186 EscapeDisplayName(GetDisplayManager()->GetDisplayNameFor(display),
190 &name); 187 &name);
191 DCHECK(!name.empty()); 188 DCHECK(!name.empty());
192 189
193 base::DictionaryValue* pref_data = update.Get(); 190 base::DictionaryValue* pref_data = update.Get();
194 scoped_ptr<base::Value>layout_value(new base::DictionaryValue()); 191 scoped_ptr<base::Value>layout_value(new base::DictionaryValue());
195 if (pref_data->HasKey(name)) { 192 if (pref_data->HasKey(name)) {
196 base::Value* value = NULL; 193 base::Value* value = NULL;
197 if (pref_data->Get(name, &value) && value != NULL) 194 if (pref_data->Get(name, &value) && value != NULL)
198 layout_value.reset(value->DeepCopy()); 195 layout_value.reset(value->DeepCopy());
199 } 196 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 } 245 }
249 246
250 void NotifyDisplayLocalStatePrefChanged() { 247 void NotifyDisplayLocalStatePrefChanged() {
251 PrefService* local_state = g_browser_process->local_state(); 248 PrefService* local_state = g_browser_process->local_state();
252 ash::Shell::GetInstance()->display_controller()->SetPrimaryDisplayId( 249 ash::Shell::GetInstance()->display_controller()->SetPrimaryDisplayId(
253 local_state->GetInt64(prefs::kPrimaryDisplayID)); 250 local_state->GetInt64(prefs::kPrimaryDisplayID));
254 NotifyDisplayOverscans(); 251 NotifyDisplayOverscans();
255 } 252 }
256 253
257 } // namespace chromeos 254 } // namespace chromeos
OLDNEW
« no previous file with comments | « ash/wm/window_cycle_controller_unittest.cc ('k') | chrome/browser/chromeos/login/wallpaper_manager_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698