Skip to content

Commit

Permalink
Upstream more leaf files in ios/web/web_state
Browse files Browse the repository at this point in the history
Also updates a few related files that had become stale relative to
downstream.

BUG=464810

Review URL: https://codereview.chromium.org/1107083002

Cr-Commit-Position: refs/heads/master@{#327081}
  • Loading branch information
stuartmorgan authored and Commit bot committed Apr 27, 2015
1 parent 95a989f commit cd59886
Show file tree
Hide file tree
Showing 19 changed files with 631 additions and 52 deletions.
1 change: 1 addition & 0 deletions ios/web/DEPS
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include_rules = [
"+crypto",
"+ios/public/provider/web",
"+ios/net",
"+ios/web",
Expand Down
10 changes: 10 additions & 0 deletions ios/web/ios_web.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
'public/user_metrics.h',
'public/web_client.h',
'public/web_client.mm',
'public/web_state/credential.h',
'public/web_state/crw_native_content.h',
'public/web_state/crw_native_content_provider.h',
'public/web_state/crw_web_controller_observer.h',
Expand Down Expand Up @@ -119,11 +120,20 @@
'weak_nsobject_counter.mm',
'web_state/blocked_popup_info.h',
'web_state/blocked_popup_info.mm',
'web_state/credential.cc',
'web_state/crw_recurring_task_delegate.h',
'web_state/js/credential_util.h',
'web_state/js/credential_util.mm',
'web_state/js/crw_js_early_script_manager.h',
'web_state/js/crw_js_early_script_manager.mm',
'web_state/js/crw_js_injection_manager.mm',
'web_state/js/crw_js_injection_receiver.mm',
'web_state/js/crw_js_invoke_parameter_queue.h',
'web_state/js/crw_js_invoke_parameter_queue.mm',
'web_state/js/crw_js_plugin_placeholder_manager.h',
'web_state/js/crw_js_plugin_placeholder_manager.mm',
'web_state/js/crw_js_window_id_manager.h',
'web_state/js/crw_js_window_id_manager.mm',
'web_state/js/page_script_util.h',
'web_state/js/page_script_util.mm',
'web_state/ui/crw_context_menu_provider.h',
Expand Down
47 changes: 47 additions & 0 deletions ios/web/public/web_state/credential.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef IOS_WEB_PUBLIC_WEB_STATE_CREDENTIAL_H_
#define IOS_WEB_PUBLIC_WEB_STATE_CREDENTIAL_H_

#include "base/strings/string16.h"
#include "url/gurl.h"

namespace web {

// Indicates the specific type of a Credential object.
enum CredentialType {
CREDENTIAL_TYPE_EMPTY = 0,
CREDENTIAL_TYPE_LOCAL,
CREDENTIAL_TYPE_FEDERATED,
CREDENTIAL_TYPE_LAST = CREDENTIAL_TYPE_FEDERATED
};

// Represents an instance of the JavaScript Credential type.
struct Credential {
Credential();
~Credential();

// The specific type of this credential.
CredentialType type;

// An identifier for the credential.
base::string16 id;

// A human-understandable name corresponding to the credential.
base::string16 name;

// The URL of the user's avatar.
GURL avatar_url;

// The password for a local credential.
base::string16 password;

// The federation URL for a federated credential.
GURL federation_url;
};

} // namespace web

#endif // IOS_WEB_PUBLIC_WEB_STATE_CREDENTIAL_H_
36 changes: 2 additions & 34 deletions ios/web/public/web_state/crw_web_controller_observer.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <string>

@class CRWWebController;
@class CRWWebViewProxy;
@protocol CRWWebViewProxy;
class GURL;
@class UIWebView;

Expand All @@ -33,38 +33,6 @@ class DictionaryValue;
// DEPRECATED: Use WebStateObserver instead.
- (void)pageLoaded:(CRWWebController*)webController;

// Called when a form is being submitted.
- (void)documentSubmit:(CRWWebController*)webController
formName:(const std::string&)formName
userInteraction:(BOOL)userInteraction;

// Called when the user is typing on a form field, with |error| indicating if
// there is any error when parsing the form field information. Currently these
// events will not be sent if the Disable Autofill experiment is set.
- (void)formActivity:(CRWWebController*)webController
formName:(const std::string&)formName
fieldName:(const std::string&)fieldName
type:(const std::string&)type
value:(const std::string&)value
error:(bool)error;

// Identical to |formActivity:formName:fieldName:type:value:error:|, but
// indicates that the activity was triggered by typing the key specified by
// |keyCode|.
- (void)formActivity:(CRWWebController*)webController
formName:(const std::string&)formName
fieldName:(const std::string&)fieldName
type:(const std::string&)type
value:(const std::string&)value
keyCode:(int)keyCode
error:(bool)error;

// The page requested autocomplete.
- (void)requestAutocomplete:(CRWWebController*)webController
sourceURL:(const GURL&)sourceURL
formName:(const std::string&)formName
userInteraction:(BOOL)userInteraction;

// Called when the web controller is about to close.
- (void)webControllerWillClose:(CRWWebController*)webController;

Expand All @@ -77,7 +45,7 @@ class DictionaryValue;
originURL:(const GURL&)originURL;

// Gives CRWWebControllerObservers access to the CRWWebViewProxy.
- (void)setWebViewProxy:(CRWWebViewProxy*)webView
- (void)setWebViewProxy:(id<CRWWebViewProxy>)webView
controller:(CRWWebController*)webController;

@end
Expand Down
4 changes: 0 additions & 4 deletions ios/web/public/web_state/crw_web_view_scroll_view_proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@
// Used by the CRWWebViewProxy to set the UIScrollView to be managed.
- (void)setScrollView:(UIScrollView*)scrollView;

// Copies all display properties that can be set on a CRWWebViewScrollViewProxy
// from the underlying UIScrollView into |scrollView|.
- (void)copyPropertiesToScrollView:(UIScrollView*)scrollView;

// Adds |observer| to subscribe to change notifications.
- (void)addObserver:(id<CRWWebViewScrollViewProxyObserver>)observer;

Expand Down
55 changes: 55 additions & 0 deletions ios/web/public/web_state/web_state_observer.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class GURL;

namespace web {

struct Credential;
struct FaviconURL;
struct LoadCommittedDetails;
class WebState;
Expand Down Expand Up @@ -42,6 +43,12 @@ class WebStateObserver {
virtual void NavigationItemCommitted(
const LoadCommittedDetails& load_details) {}

// Called when the current page has started loading.
virtual void DidStartLoading() {}

// Called when the current page has stopped loading.
virtual void DidStopLoading() {}

// Called when the current page is loaded.
virtual void PageLoaded(PageLoadCompletionStatus load_completion_status) {}

Expand Down Expand Up @@ -80,6 +87,54 @@ class WebStateObserver {
// Invoked when new favicon URL candidates are received.
virtual void FaviconUrlUpdated(const std::vector<FaviconURL>& candidates) {}

// Notifies the observer that the credential manager API was invoked from
// |source_url| to request a credential from the browser. If |suppress_ui|
// is true, the browser MUST NOT show any UI to the user. If this means that
// no credential will be returned to the page, so be it. Otherwise, the
// browser may show the user any UI that is necessary to get a Credential and
// return it to the page. |federations| specifies a list of acceptable
// federation providers. |user_interaction| indicates whether the API was
// invoked in response to a user interaction. Responses to the page should
// provide the specified |request_id|.
virtual void CredentialsRequested(int request_id,
const GURL& source_url,
bool suppress_ui,
const std::vector<std::string>& federations,
bool is_user_initiated) {}

// Notifies the observer that the credential manager API was invoked from
// |source_url| to notify the browser that the user signed in. |credential|
// specifies the credential that was used to sign in. Responses to the page
// should provide the specified |request_id|.
virtual void SignedIn(int request_id,
const GURL& source_url,
const web::Credential& credential) {}

// Notifies the observer that the credential manager API was invoked from
// |source_url| to notify the browser that the user signed in without
// specifying the credential that was used. Responses to the page should
// provide the specified |request_id|.
virtual void SignedIn(int request_id, const GURL& source_url) {}

// Notifies the observer that the credential manager API was invoked from
// |source_url| to notify the browser that the user signed out. Responses
// to the page should provide the specified |request_id|.
virtual void SignedOut(int request_id, const GURL& source_url) {}

// Notifies the observer that the credential manager API was invoked from
// |source_url| to notify the browser that the user failed to sign in.
// |credential| specifies the credential that failed to sign in. Responses
// to the page should provide the specified |request_id|.
virtual void SignInFailed(int request_id,
const GURL& source_url,
const web::Credential& credential) {}

// Notifies the observer that the credential manager API was invoked from
// |source_url| to notify the browser that the user failed to sign in without
// specifying the credential that failed. Responses to the page should provide
// the specified |request_id|.
virtual void SignInFailed(int request_id, const GURL& source_url) {}

// Invoked when the WebState is being destroyed. Gives subclasses a chance
// to cleanup.
virtual void WebStateDestroyed() {}
Expand Down
8 changes: 8 additions & 0 deletions ios/web/public/web_state/web_state_observer_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ class GURL;
// is no longer valid.
- (void)webStateDestroyed:(web::WebState*)webState;

// Invoked by WebStateObserverBridge::DidStopLoading.
- (void)webStateDidStopLoading:(web::WebState*)webState;

// Invoked by WebStateObserverBridge::DidStartLoading.
- (void)webStateDidStartLoading:(web::WebState*)webState;

@end

namespace web {
Expand Down Expand Up @@ -108,6 +114,8 @@ class WebStateObserverBridge : public web::WebStateObserver {
bool user_initiated) override;
void FaviconUrlUpdated(const std::vector<FaviconURL>& candidates) override;
void WebStateDestroyed() override;
void DidStartLoading() override;
void DidStopLoading() override;

private:
base::WeakNSProtocol<id<CRWWebStateObserver>> observer_;
Expand Down
13 changes: 13 additions & 0 deletions ios/web/web_state/credential.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ios/web/public/web_state/credential.h"

namespace web {

Credential::Credential() = default;

Credential::~Credential() = default;

} // namespace web
47 changes: 47 additions & 0 deletions ios/web/web_state/js/credential_util.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef IOS_WEB_WEB_STATE_JS_CREDENTIAL_UTIL_H_
#define IOS_WEB_WEB_STATE_JS_CREDENTIAL_UTIL_H_

namespace base {
class DictionaryValue;
} // namespace base

namespace web {

struct Credential;

// Populates |credential| from |value|, returning true if successful and false
// otherwise. |value| must contain the following string->string key/value
// pairs:
//
// "type": one of "LocalCredential" of "FederatedCredential"
// "id": a string (possibly empty)
//
// The following pairs are optional:
//
// "name": a string (possibly empty)
// "avatarURL": a valid URL as a string
//
// If "type" is "LocalCredential", then |value| must contain
//
// "password" a string (possibly empty)
//
// If "type" is "FederatedCredential", then |value| must contain
//
// "federation": a valid URL as a string
//
// If passed a |value| that doesn't meet these restrictions, |credential| will
// not be modified and false will be returned. |credential| must not be null.
bool DictionaryValueToCredential(const base::DictionaryValue& value,
Credential* credential);

// Serializes |credential| to |value|.
void CredentialToDictionaryValue(const Credential& credential,
base::DictionaryValue* value);

} // namespace web

#endif // IOS_WEB_WEB_STATE_JS_CREDENTIAL_UTIL_H_
Loading

0 comments on commit cd59886

Please sign in to comment.