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

Side by Side Diff: ios/chrome/browser/ui/webui/signin_internals_ui_ios.cc

Issue 2580333003: Upstream Chrome on iOS source code [10/11]. (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
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ios/chrome/browser/ui/webui/signin_internals_ui_ios.h"
6
7 #include "base/hash.h"
8 #include "components/grit/components_resources.h"
9 #include "components/signin/core/browser/about_signin_internals.h"
10 #include "components/signin/core/browser/gaia_cookie_manager_service.h"
11 #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
12 #include "ios/chrome/browser/chrome_url_constants.h"
13 #include "ios/chrome/browser/signin/about_signin_internals_factory.h"
14 #include "ios/chrome/browser/signin/gaia_cookie_manager_service_factory.h"
15 #include "ios/web/public/web_ui_ios_data_source.h"
16 #include "ios/web/public/webui/web_ui_ios.h"
17 #include "ui/base/resource/resource_bundle.h"
18
19 namespace {
20
21 web::WebUIIOSDataSource* CreateSignInInternalsHTMLSource() {
22 web::WebUIIOSDataSource* source =
23 web::WebUIIOSDataSource::Create(kChromeUISignInInternalsHost);
24
25 source->SetJsonPath("strings.js");
26 source->AddResourcePath("signin_internals.js", IDR_SIGNIN_INTERNALS_INDEX_JS);
27 source->SetDefaultResource(IDR_SIGNIN_INTERNALS_INDEX_HTML);
28 return source;
29 }
30
31 } // namespace
32
33 SignInInternalsUIIOS::SignInInternalsUIIOS(web::WebUIIOS* web_ui)
34 : WebUIIOSController(web_ui) {
35 ios::ChromeBrowserState* browser_state =
36 ios::ChromeBrowserState::FromWebUIIOS(web_ui);
37 DCHECK(browser_state);
38 web::WebUIIOSDataSource::Add(browser_state,
39 CreateSignInInternalsHTMLSource());
40
41 AboutSigninInternals* about_signin_internals =
42 ios::AboutSigninInternalsFactory::GetForBrowserState(browser_state);
43 if (about_signin_internals)
44 about_signin_internals->AddSigninObserver(this);
45 }
46
47 SignInInternalsUIIOS::~SignInInternalsUIIOS() {
48 ios::ChromeBrowserState* browser_state =
49 ios::ChromeBrowserState::FromWebUIIOS(web_ui());
50 DCHECK(browser_state);
51 AboutSigninInternals* about_signin_internals =
52 ios::AboutSigninInternalsFactory::GetForBrowserState(browser_state);
53 if (about_signin_internals)
54 about_signin_internals->RemoveSigninObserver(this);
55 }
56
57 bool SignInInternalsUIIOS::OverrideHandleWebUIIOSMessage(
58 const GURL& source_url,
59 const std::string& name,
60 const base::ListValue& content) {
61 if (name == "getSigninInfo") {
62 ios::ChromeBrowserState* browser_state =
63 ios::ChromeBrowserState::FromWebUIIOS(web_ui());
64 DCHECK(browser_state);
65
66 AboutSigninInternals* about_signin_internals =
67 ios::AboutSigninInternalsFactory::GetForBrowserState(browser_state);
68 // TODO(vishwath): The UI would look better if we passed in a dict with some
69 // reasonable defaults, so the about:signin-internals page doesn't look
70 // empty in incognito mode. Alternatively, we could force about:signin to
71 // open in non-incognito mode always (like about:settings for ex.).
72 if (about_signin_internals) {
73 const std::string& reply_handler =
74 "chrome.signin.getSigninInfo.handleReply";
75 web_ui()->CallJavascriptFunction(
76 reply_handler, *about_signin_internals->GetSigninStatus());
77 std::vector<gaia::ListedAccount> cookie_accounts;
78 GaiaCookieManagerService* cookie_manager_service =
79 ios::GaiaCookieManagerServiceFactory::GetForBrowserState(
80 browser_state);
81 std::vector<gaia::ListedAccount> signed_out_accounts;
82 if (cookie_manager_service->ListAccounts(
83 &cookie_accounts, &signed_out_accounts,
84 "ChromiumSignInInternalsUIIOS")) {
85 about_signin_internals->OnGaiaAccountsInCookieUpdated(
86 cookie_accounts, signed_out_accounts,
87 GoogleServiceAuthError(GoogleServiceAuthError::NONE));
88 }
89
90 return true;
91 }
92 }
93 return false;
94 }
95
96 void SignInInternalsUIIOS::OnSigninStateChanged(
97 const base::DictionaryValue* info) {
98 const std::string& event_handler = "chrome.signin.onSigninInfoChanged.fire";
99 web_ui()->CallJavascriptFunction(event_handler, *info);
100 }
101
102 void SignInInternalsUIIOS::OnCookieAccountsFetched(
103 const base::DictionaryValue* info) {
104 web_ui()->CallJavascriptFunction("chrome.signin.onCookieAccountsFetched.fire",
105 *info);
106 }
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/webui/signin_internals_ui_ios.h ('k') | ios/chrome/browser/ui/webui/web_ui_egtest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698