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

Unified Diff: chrome/browser/chromeos/login/helper.cc

Issue 2519823006: Chromad: Add authentication flow (Closed)
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/login/helper.cc
diff --git a/chrome/browser/chromeos/login/helper.cc b/chrome/browser/chromeos/login/helper.cc
index 688b1d8331dde98f7a52fa46292d69fc9204c951..eb549f9da7b4e6e79292f83ebbe1d81257f60625 100644
--- a/chrome/browser/chromeos/login/helper.cc
+++ b/chrome/browser/chromeos/login/helper.cc
@@ -22,6 +22,7 @@
#include "chromeos/network/network_state_handler.h"
#include "chromeos/network/network_util.h"
#include "components/guest_view/browser/guest_view_manager.h"
+#include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_contents.h"
#include "extensions/browser/guest_view/web_view/web_view_guest.h"
@@ -85,6 +86,23 @@ content::StoragePartition* GetPartition(content::WebContents* embedder,
: nullptr;
}
+base::ScopedFD GetDataReadPipe(const std::string& data) {
+ DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
+ int pipe_fds[2];
+ if (!base::CreateLocalNonBlockingPipe(pipe_fds)) {
+ LOG(ERROR) << "Failed to create pipe";
+ return base::ScopedFD();
+ }
+ base::ScopedFD pipe_read_end(pipe_fds[0]);
+ base::ScopedFD pipe_write_end(pipe_fds[1]);
+
+ if (!base::WriteFileDescriptor(pipe_write_end.get(), data.c_str(),
+ data.size())) {
+ LOG(ERROR) << "Failed to write to pipe";
+ return base::ScopedFD();
+ }
+ return pipe_read_end;
+}
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.
} // namespace
gfx::Rect CalculateScreenBounds(const gfx::Size& size) {
@@ -249,6 +267,14 @@ net::URLRequestContextGetter* GetSigninContext() {
return ProfileHelper::GetSigninProfile()->GetRequestContext();
}
-} // namespace login
+// Returns file descriptor of a pipe, open for reading. Pipe keeps the passed
+// 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.
+void GetPipeReadEnd(const std::string& data,
+ const OnPipeReadyCallback& callback) {
+ base::PostTaskAndReplyWithResult(
+ content::BrowserThread::GetBlockingPool(), FROM_HERE,
+ base::Bind(&GetDataReadPipe, data), callback);
+}
+} // namespace login
} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698