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

Side by Side Diff: chrome/browser/chromeos/login/helper.cc

Issue 2519823006: Chromad: Add authentication flow (Closed)
Patch Set: Created 4 years 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
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/login/helper.h" 5 #include "chrome/browser/chromeos/login/helper.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/browser/chromeos/login/startup_utils.h" 12 #include "chrome/browser/chromeos/login/startup_utils.h"
13 #include "chrome/browser/chromeos/login/ui/login_display_host.h" 13 #include "chrome/browser/chromeos/login/ui/login_display_host.h"
14 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" 14 #include "chrome/browser/chromeos/login/ui/webui_login_view.h"
15 #include "chrome/browser/chromeos/profiles/profile_helper.h" 15 #include "chrome/browser/chromeos/profiles/profile_helper.h"
16 #include "chrome/grit/generated_resources.h" 16 #include "chrome/grit/generated_resources.h"
17 #include "chromeos/chromeos_switches.h" 17 #include "chromeos/chromeos_switches.h"
18 #include "chromeos/network/managed_network_configuration_handler.h" 18 #include "chromeos/network/managed_network_configuration_handler.h"
19 #include "chromeos/network/network_connection_handler.h" 19 #include "chromeos/network/network_connection_handler.h"
20 #include "chromeos/network/network_handler.h" 20 #include "chromeos/network/network_handler.h"
21 #include "chromeos/network/network_state.h" 21 #include "chromeos/network/network_state.h"
22 #include "chromeos/network/network_state_handler.h" 22 #include "chromeos/network/network_state_handler.h"
23 #include "chromeos/network/network_util.h" 23 #include "chromeos/network/network_util.h"
24 #include "components/guest_view/browser/guest_view_manager.h" 24 #include "components/guest_view/browser/guest_view_manager.h"
25 #include "content/public/browser/browser_thread.h"
25 #include "content/public/browser/storage_partition.h" 26 #include "content/public/browser/storage_partition.h"
26 #include "content/public/browser/web_contents.h" 27 #include "content/public/browser/web_contents.h"
27 #include "extensions/browser/guest_view/web_view/web_view_guest.h" 28 #include "extensions/browser/guest_view/web_view/web_view_guest.h"
28 #include "third_party/cros_system_api/dbus/service_constants.h" 29 #include "third_party/cros_system_api/dbus/service_constants.h"
29 #include "ui/base/l10n/l10n_util.h" 30 #include "ui/base/l10n/l10n_util.h"
30 #include "ui/display/display.h" 31 #include "ui/display/display.h"
31 #include "ui/display/screen.h" 32 #include "ui/display/screen.h"
32 #include "ui/gfx/image/image_skia.h" 33 #include "ui/gfx/image/image_skia.h"
33 34
34 namespace chromeos { 35 namespace chromeos {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 content::WebContents* guest_contents = nullptr; 79 content::WebContents* guest_contents = nullptr;
79 manager->ForEachGuest(embedder, base::Bind(&FindGuestByPartitionName, 80 manager->ForEachGuest(embedder, base::Bind(&FindGuestByPartitionName,
80 partition_name, &guest_contents)); 81 partition_name, &guest_contents));
81 82
82 return guest_contents ? content::BrowserContext::GetStoragePartition( 83 return guest_contents ? content::BrowserContext::GetStoragePartition(
83 guest_contents->GetBrowserContext(), 84 guest_contents->GetBrowserContext(),
84 guest_contents->GetSiteInstance()) 85 guest_contents->GetSiteInstance())
85 : nullptr; 86 : nullptr;
86 } 87 }
87 88
89 base::ScopedFD GetDataReadPipe(const std::string& data) {
90 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
91 int pipe_fds[2];
92 if (!base::CreateLocalNonBlockingPipe(pipe_fds)) {
93 LOG(ERROR) << "Failed to create pipe";
94 return base::ScopedFD();
95 }
96 base::ScopedFD pipe_read_end(pipe_fds[0]);
97 base::ScopedFD pipe_write_end(pipe_fds[1]);
98
99 if (!base::WriteFileDescriptor(pipe_write_end.get(), data.c_str(),
100 data.size())) {
101 LOG(ERROR) << "Failed to write to pipe";
102 return base::ScopedFD();
103 }
104 return pipe_read_end;
105 }
xiyuan 2016/11/28 23:43:05 nit: insert an empty line between this line and th
Roman Sorokin (ftl) 2016/12/02 12:35:12 Done.
88 } // namespace 106 } // namespace
89 107
90 gfx::Rect CalculateScreenBounds(const gfx::Size& size) { 108 gfx::Rect CalculateScreenBounds(const gfx::Size& size) {
91 gfx::Rect bounds = display::Screen::GetScreen()->GetPrimaryDisplay().bounds(); 109 gfx::Rect bounds = display::Screen::GetScreen()->GetPrimaryDisplay().bounds();
92 if (!size.IsEmpty()) { 110 if (!size.IsEmpty()) {
93 int horizontal_diff = bounds.width() - size.width(); 111 int horizontal_diff = bounds.width() - size.width();
94 int vertical_diff = bounds.height() - size.height(); 112 int vertical_diff = bounds.height() - size.height();
95 bounds.Inset(horizontal_diff / 2, vertical_diff / 2); 113 bounds.Inset(horizontal_diff / 2, vertical_diff / 2);
96 } 114 }
97 return bounds; 115 return bounds;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 260
243 if (!signin_partition) 261 if (!signin_partition)
244 return nullptr; 262 return nullptr;
245 263
246 return signin_partition->GetURLRequestContext(); 264 return signin_partition->GetURLRequestContext();
247 } 265 }
248 266
249 return ProfileHelper::GetSigninProfile()->GetRequestContext(); 267 return ProfileHelper::GetSigninProfile()->GetRequestContext();
250 } 268 }
251 269
270 // Returns file descriptor of a pipe, open for reading. Pipe keeps the passed
271 // data
xiyuan 2016/11/28 23:43:05 nit: Move the comment to header. And end it with a
Roman Sorokin (ftl) 2016/12/02 12:35:12 Done.
272 void GetPipeReadEnd(const std::string& data,
273 const OnPipeReadyCallback& callback) {
274 base::PostTaskAndReplyWithResult(
275 content::BrowserThread::GetBlockingPool(), FROM_HERE,
276 base::Bind(&GetDataReadPipe, data), callback);
277 }
278
252 } // namespace login 279 } // namespace login
253
254 } // namespace chromeos 280 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698