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

Side by Side Diff: chrome/browser/chromeos/extensions/screenlock_private_api.cc

Issue 179243002: Change ProfileKeyedAPIFactory to build instances with BrowserContext instead of Profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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/screenlock_private_api.h" 5 #include "chrome/browser/chromeos/extensions/screenlock_private_api.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/chromeos/login/screen_locker.h" 9 #include "chrome/browser/chromeos/login/screen_locker.h"
10 #include "chrome/browser/extensions/image_loader.h" 10 #include "chrome/browser/extensions/image_loader.h"
11 #include "chrome/common/extensions/api/screenlock_private.h" 11 #include "chrome/common/extensions/api/screenlock_private.h"
12 #include "chromeos/dbus/dbus_thread_manager.h" 12 #include "chromeos/dbus/dbus_thread_manager.h"
13 #include "extensions/browser/event_router.h" 13 #include "extensions/browser/event_router.h"
14 #include "extensions/browser/extension_system.h" 14 #include "extensions/browser/extension_system.h"
15 #include "ui/gfx/image/image.h"
15 16
16 namespace screenlock = extensions::api::screenlock_private; 17 namespace screenlock = extensions::api::screenlock_private;
17 18
18 namespace extensions { 19 namespace extensions {
19 20
20 ScreenlockPrivateGetLockedFunction::ScreenlockPrivateGetLockedFunction() {} 21 ScreenlockPrivateGetLockedFunction::ScreenlockPrivateGetLockedFunction() {}
21 22
22 ScreenlockPrivateGetLockedFunction::~ScreenlockPrivateGetLockedFunction() {} 23 ScreenlockPrivateGetLockedFunction::~ScreenlockPrivateGetLockedFunction() {}
23 24
24 bool ScreenlockPrivateGetLockedFunction::RunImpl() { 25 bool ScreenlockPrivateGetLockedFunction::RunImpl() {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 ScreenlockPrivateEventRouter* router = 104 ScreenlockPrivateEventRouter* router =
104 ScreenlockPrivateEventRouter::GetFactoryInstance()->GetForProfile( 105 ScreenlockPrivateEventRouter::GetFactoryInstance()->GetForProfile(
105 GetProfile()); 106 GetProfile());
106 locker->ShowUserPodButton( 107 locker->ShowUserPodButton(
107 GetProfile()->GetProfileName(), image, 108 GetProfile()->GetProfileName(), image,
108 base::Bind(&ScreenlockPrivateEventRouter::OnButtonClicked, 109 base::Bind(&ScreenlockPrivateEventRouter::OnButtonClicked,
109 base::Unretained(router))); 110 base::Unretained(router)));
110 SendResponse(error_.empty()); 111 SendResponse(error_.empty());
111 } 112 }
112 113
113 ScreenlockPrivateEventRouter::ScreenlockPrivateEventRouter(Profile* profile) 114 ScreenlockPrivateEventRouter::ScreenlockPrivateEventRouter(
114 : profile_(profile) { 115 content::BrowserContext* context)
116 : browser_context_(context) {
115 chromeos::SessionManagerClient* session_manager = 117 chromeos::SessionManagerClient* session_manager =
116 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(); 118 chromeos::DBusThreadManager::Get()->GetSessionManagerClient();
117 if (!session_manager->HasObserver(this)) 119 if (!session_manager->HasObserver(this))
118 session_manager->AddObserver(this); 120 session_manager->AddObserver(this);
119 } 121 }
120 122
121 ScreenlockPrivateEventRouter::~ScreenlockPrivateEventRouter() {} 123 ScreenlockPrivateEventRouter::~ScreenlockPrivateEventRouter() {}
122 124
123 void ScreenlockPrivateEventRouter::ScreenIsLocked() { 125 void ScreenlockPrivateEventRouter::ScreenIsLocked() {
124 DispatchEvent(screenlock::OnChanged::kEventName, 126 DispatchEvent(screenlock::OnChanged::kEventName,
125 new base::FundamentalValue(true)); 127 new base::FundamentalValue(true));
126 } 128 }
127 129
128 void ScreenlockPrivateEventRouter::ScreenIsUnlocked() { 130 void ScreenlockPrivateEventRouter::ScreenIsUnlocked() {
129 DispatchEvent(screenlock::OnChanged::kEventName, 131 DispatchEvent(screenlock::OnChanged::kEventName,
130 new base::FundamentalValue(false)); 132 new base::FundamentalValue(false));
131 } 133 }
132 134
133 void ScreenlockPrivateEventRouter::DispatchEvent( 135 void ScreenlockPrivateEventRouter::DispatchEvent(
134 const std::string& event_name, 136 const std::string& event_name,
135 base::Value* arg) { 137 base::Value* arg) {
136 scoped_ptr<base::ListValue> args(new base::ListValue()); 138 scoped_ptr<base::ListValue> args(new base::ListValue());
137 if (arg) 139 if (arg)
138 args->Append(arg); 140 args->Append(arg);
139 scoped_ptr<extensions::Event> event(new extensions::Event( 141 scoped_ptr<extensions::Event> event(new extensions::Event(
140 event_name, args.Pass())); 142 event_name, args.Pass()));
141 extensions::ExtensionSystem::Get(profile_)->event_router()-> 143 extensions::ExtensionSystem::Get(browser_context_)
142 BroadcastEvent(event.Pass()); 144 ->event_router()
145 ->BroadcastEvent(event.Pass());
143 } 146 }
144 147
145 static base::LazyInstance<extensions::ProfileKeyedAPIFactory< 148 static base::LazyInstance<extensions::ProfileKeyedAPIFactory<
146 ScreenlockPrivateEventRouter> > 149 ScreenlockPrivateEventRouter> >
147 g_factory = LAZY_INSTANCE_INITIALIZER; 150 g_factory = LAZY_INSTANCE_INITIALIZER;
148 151
149 // static 152 // static
150 extensions::ProfileKeyedAPIFactory<ScreenlockPrivateEventRouter>* 153 extensions::ProfileKeyedAPIFactory<ScreenlockPrivateEventRouter>*
151 ScreenlockPrivateEventRouter::GetFactoryInstance() { 154 ScreenlockPrivateEventRouter::GetFactoryInstance() {
152 return g_factory.Pointer(); 155 return g_factory.Pointer();
153 } 156 }
154 157
155 void ScreenlockPrivateEventRouter::Shutdown() { 158 void ScreenlockPrivateEventRouter::Shutdown() {
156 chromeos::SessionManagerClient* session_manager = 159 chromeos::SessionManagerClient* session_manager =
157 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(); 160 chromeos::DBusThreadManager::Get()->GetSessionManagerClient();
158 if (session_manager->HasObserver(this)) 161 if (session_manager->HasObserver(this))
159 session_manager->RemoveObserver(this); 162 session_manager->RemoveObserver(this);
160 } 163 }
161 164
162 void ScreenlockPrivateEventRouter::OnButtonClicked() { 165 void ScreenlockPrivateEventRouter::OnButtonClicked() {
163 DispatchEvent(screenlock::OnButtonClicked::kEventName, NULL); 166 DispatchEvent(screenlock::OnButtonClicked::kEventName, NULL);
164 } 167 }
165 168
166 } // namespace extensions 169 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698