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

Unified Diff: third_party/grpc/src/objective-c/GRPCClient/GRPCCall+OAuth2.m

Issue 1932353002: Initial checkin of gRPC to third_party/ Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: third_party/grpc/src/objective-c/GRPCClient/GRPCCall+OAuth2.m
diff --git a/third_party/WebKit/Source/core/loader/PrerendererClient.h b/third_party/grpc/src/objective-c/GRPCClient/GRPCCall+OAuth2.m
similarity index 64%
copy from third_party/WebKit/Source/core/loader/PrerendererClient.h
copy to third_party/grpc/src/objective-c/GRPCClient/GRPCCall+OAuth2.m
index 72c1f2055bc0723fbe7d5e15ca38e035f38ffec6..83b0de18e32e45c3a150802efbc998a4ebfcc35e 100644
--- a/third_party/WebKit/Source/core/loader/PrerendererClient.h
+++ b/third_party/grpc/src/objective-c/GRPCClient/GRPCCall+OAuth2.m
@@ -1,5 +1,7 @@
/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Copyright 2015, Google Inc.
+ * All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -29,31 +31,33 @@
*
*/
-#ifndef PrerendererClient_h
-#define PrerendererClient_h
-
-#include "core/CoreExport.h"
-#include "core/page/Page.h"
-#include "platform/Supplementable.h"
-
-namespace blink {
-
-class Page;
-class Prerender;
+#import "GRPCCall+OAuth2.h"
-class CORE_EXPORT PrerendererClient : public Supplement<Page> {
-public:
- virtual void willAddPrerender(Prerender*) = 0;
+static NSString * const kAuthorizationHeader = @"authorization";
+static NSString * const kBearerPrefix = @"Bearer ";
+static NSString * const kChallengeHeader = @"www-authenticate";
- static const char* supplementName();
- static PrerendererClient* from(Page*);
+@implementation GRPCCall (OAuth2)
-protected:
- PrerendererClient() { }
-};
+- (NSString *)oauth2AccessToken {
+ NSString *headerValue = self.requestHeaders[kAuthorizationHeader];
+ if ([headerValue hasPrefix:kBearerPrefix]) {
+ return [headerValue substringFromIndex:kBearerPrefix.length];
+ } else {
+ return nil;
+ }
+}
-CORE_EXPORT void providePrerendererClientTo(Page&, PrerendererClient*);
+- (void)setOauth2AccessToken:(NSString *)token {
+ if (token) {
+ self.requestHeaders[kAuthorizationHeader] = [kBearerPrefix stringByAppendingString:token];
+ } else {
+ [self.requestHeaders removeObjectForKey:kAuthorizationHeader];
+ }
+}
-} // namespace blink
+- (NSString *)oauth2ChallengeHeader {
+ return self.responseHeaders[kChallengeHeader];
+}
-#endif // PrerendererClient_h
+@end

Powered by Google App Engine
This is Rietveld 408576698