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

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

Issue 2519823006: Chromad: Add authentication flow (Closed)
Patch Set: Rename HandleAdAuth. Use system_api enums Created 3 years, 12 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
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/ui/login_display_host.h" 12 #include "chrome/browser/chromeos/login/ui/login_display_host.h"
13 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" 13 #include "chrome/browser/chromeos/login/ui/webui_login_view.h"
14 #include "chrome/browser/chromeos/profiles/profile_helper.h" 14 #include "chrome/browser/chromeos/profiles/profile_helper.h"
15 #include "chrome/grit/generated_resources.h" 15 #include "chrome/grit/generated_resources.h"
16 #include "chromeos/chromeos_switches.h" 16 #include "chromeos/chromeos_switches.h"
17 #include "chromeos/network/managed_network_configuration_handler.h" 17 #include "chromeos/network/managed_network_configuration_handler.h"
18 #include "chromeos/network/network_connection_handler.h" 18 #include "chromeos/network/network_connection_handler.h"
19 #include "chromeos/network/network_handler.h" 19 #include "chromeos/network/network_handler.h"
20 #include "chromeos/network/network_state.h" 20 #include "chromeos/network/network_state.h"
21 #include "chromeos/network/network_state_handler.h" 21 #include "chromeos/network/network_state_handler.h"
22 #include "chromeos/network/network_util.h" 22 #include "chromeos/network/network_util.h"
23 #include "components/guest_view/browser/guest_view_manager.h" 23 #include "components/guest_view/browser/guest_view_manager.h"
24 #include "content/public/browser/browser_thread.h"
24 #include "content/public/browser/storage_partition.h" 25 #include "content/public/browser/storage_partition.h"
25 #include "content/public/browser/web_contents.h" 26 #include "content/public/browser/web_contents.h"
26 #include "extensions/browser/guest_view/web_view/web_view_guest.h" 27 #include "extensions/browser/guest_view/web_view/web_view_guest.h"
27 #include "third_party/cros_system_api/dbus/service_constants.h" 28 #include "third_party/cros_system_api/dbus/service_constants.h"
28 #include "ui/base/l10n/l10n_util.h" 29 #include "ui/base/l10n/l10n_util.h"
29 #include "ui/display/display.h" 30 #include "ui/display/display.h"
30 #include "ui/display/screen.h" 31 #include "ui/display/screen.h"
31 #include "ui/gfx/image/image_skia.h" 32 #include "ui/gfx/image/image_skia.h"
32 33
33 namespace chromeos { 34 namespace chromeos {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 content::WebContents* guest_contents = nullptr; 78 content::WebContents* guest_contents = nullptr;
78 manager->ForEachGuest(embedder, base::Bind(&FindGuestByPartitionName, 79 manager->ForEachGuest(embedder, base::Bind(&FindGuestByPartitionName,
79 partition_name, &guest_contents)); 80 partition_name, &guest_contents));
80 81
81 return guest_contents ? content::BrowserContext::GetStoragePartition( 82 return guest_contents ? content::BrowserContext::GetStoragePartition(
82 guest_contents->GetBrowserContext(), 83 guest_contents->GetBrowserContext(),
83 guest_contents->GetSiteInstance()) 84 guest_contents->GetSiteInstance())
84 : nullptr; 85 : nullptr;
85 } 86 }
86 87
88 base::ScopedFD GetDataReadPipe(const std::string& data) {
89 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
90 int pipe_fds[2];
91 if (!base::CreateLocalNonBlockingPipe(pipe_fds)) {
92 DLOG(ERROR) << "Failed to create pipe";
93 return base::ScopedFD();
94 }
95 base::ScopedFD pipe_read_end(pipe_fds[0]);
96 base::ScopedFD pipe_write_end(pipe_fds[1]);
97
98 if (!base::WriteFileDescriptor(pipe_write_end.get(), data.c_str(),
99 data.size())) {
100 DLOG(ERROR) << "Failed to write to pipe";
101 return base::ScopedFD();
102 }
103 return pipe_read_end;
104 }
105
87 } // namespace 106 } // namespace
88 107
89 gfx::Rect CalculateScreenBounds(const gfx::Size& size) { 108 gfx::Rect CalculateScreenBounds(const gfx::Size& size) {
90 gfx::Rect bounds = display::Screen::GetScreen()->GetPrimaryDisplay().bounds(); 109 gfx::Rect bounds = display::Screen::GetScreen()->GetPrimaryDisplay().bounds();
91 if (!size.IsEmpty()) { 110 if (!size.IsEmpty()) {
92 int horizontal_diff = bounds.width() - size.width(); 111 int horizontal_diff = bounds.width() - size.width();
93 int vertical_diff = bounds.height() - size.height(); 112 int vertical_diff = bounds.height() - size.height();
94 bounds.Inset(horizontal_diff / 2, vertical_diff / 2); 113 bounds.Inset(horizontal_diff / 2, vertical_diff / 2);
95 } 114 }
96 return bounds; 115 return bounds;
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 // webview instance. See http://crbug.com/477402 255 // webview instance. See http://crbug.com/477402
237 if (!signin_partition && !LoginDisplayHost::default_host()) 256 if (!signin_partition && !LoginDisplayHost::default_host())
238 return ProfileHelper::GetSigninProfile()->GetRequestContext(); 257 return ProfileHelper::GetSigninProfile()->GetRequestContext();
239 258
240 if (!signin_partition) 259 if (!signin_partition)
241 return nullptr; 260 return nullptr;
242 261
243 return signin_partition->GetURLRequestContext(); 262 return signin_partition->GetURLRequestContext();
244 } 263 }
245 264
265 void GetPipeReadEnd(const std::string& data,
266 const OnPipeReadyCallback& callback) {
267 base::PostTaskAndReplyWithResult(
268 content::BrowserThread::GetBlockingPool(), FROM_HERE,
269 base::Bind(&GetDataReadPipe, data), callback);
270 }
271
246 } // namespace login 272 } // namespace login
247 273
248 } // namespace chromeos 274 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/helper.h ('k') | chrome/browser/chromeos/login/screens/user_selection_screen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698