OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/signin/signin_header_helper.h" | 5 #include "chrome/browser/signin/signin_header_helper.h" |
6 | 6 |
7 #include "chrome/browser/extensions/extension_renderer_state.h" | 7 #include "chrome/browser/extensions/extension_renderer_state.h" |
| 8 #include "chrome/browser/google/google_util.h" |
8 #include "chrome/browser/profiles/profile_io_data.h" | 9 #include "chrome/browser/profiles/profile_io_data.h" |
9 #include "chrome/browser/tab_contents/tab_util.h" | 10 #include "chrome/browser/tab_contents/tab_util.h" |
10 #include "chrome/browser/ui/browser_finder.h" | 11 #include "chrome/browser/ui/browser_finder.h" |
11 #include "chrome/browser/ui/browser_window.h" | 12 #include "chrome/browser/ui/browser_window.h" |
12 #include "chrome/common/profile_management_switches.h" | 13 #include "chrome/common/profile_management_switches.h" |
13 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
14 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
15 #include "google_apis/gaia/gaia_auth_util.h" | 16 #include "google_apis/gaia/gaia_auth_util.h" |
16 #include "net/http/http_response_headers.h" | 17 #include "net/http/http_response_headers.h" |
17 #include "net/url_request/url_request.h" | 18 #include "net/url_request/url_request.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 ProfileIOData* io_data, | 66 ProfileIOData* io_data, |
66 int child_id, | 67 int child_id, |
67 int route_id) { | 68 int route_id) { |
68 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 69 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
69 | 70 |
70 if (io_data->is_incognito() || | 71 if (io_data->is_incognito() || |
71 io_data->google_services_username()->GetValue().empty()) { | 72 io_data->google_services_username()->GetValue().empty()) { |
72 return; | 73 return; |
73 } | 74 } |
74 | 75 |
75 // Only set the header for Gaia (in the mirror world) and Drive. Gaia needs | 76 // Only set the header for Drive always, and other Google properties if |
76 // the header to redirect certain user actions to Chrome native UI. Drive | 77 // new-profile-management is enabled. |
77 // needs the header to tell if the current user is connected. The drive path | 78 // Vasquette, which is integrated with most Google properties, needs the |
78 // is a temporary workaround until the more generic chrome.principals API is | 79 // header to redirect certain user actions to Chrome native UI. Drive needs |
| 80 // the header to tell if the current user is connected. The drive path is a |
| 81 // temporary workaround until the more generic chrome.principals API is |
79 // available. | 82 // available. |
80 const GURL& url = redirect_url.is_empty() ? request->url() : redirect_url; | 83 const GURL& url = redirect_url.is_empty() ? request->url() : redirect_url; |
81 GURL origin(url.GetOrigin()); | 84 GURL origin(url.GetOrigin()); |
82 bool is_gaia_origin = !switches::IsEnableWebBasedSignin() && | 85 bool is_google_url = |
| 86 !switches::IsEnableWebBasedSignin() && |
83 switches::IsNewProfileManagement() && | 87 switches::IsNewProfileManagement() && |
84 gaia::IsGaiaSignonRealm(origin); | 88 google_util::IsGoogleDomainUrl( |
85 if (!is_gaia_origin && !IsDriveOrigin(origin)) | 89 url, |
| 90 google_util::ALLOW_SUBDOMAIN, |
| 91 google_util::DISALLOW_NON_STANDARD_PORTS); |
| 92 if (!is_google_url && !IsDriveOrigin(origin)) |
86 return; | 93 return; |
87 | 94 |
88 ExtensionRendererState* renderer_state = | 95 ExtensionRendererState* renderer_state = |
89 ExtensionRendererState::GetInstance(); | 96 ExtensionRendererState::GetInstance(); |
90 ExtensionRendererState::WebViewInfo webview_info; | 97 ExtensionRendererState::WebViewInfo webview_info; |
91 bool is_guest = renderer_state->GetWebViewInfo( | 98 bool is_guest = renderer_state->GetWebViewInfo( |
92 child_id, route_id, &webview_info); | 99 child_id, route_id, &webview_info); |
93 if (is_guest && webview_info.embedder_extension_id == kGaiaAuthExtensionID){ | 100 if (is_guest && webview_info.embedder_extension_id == kGaiaAuthExtensionID){ |
94 return; | 101 return; |
95 } | 102 } |
(...skipping 17 matching lines...) Expand all Loading... |
113 request->response_headers()->HasHeader(kChromeManageAccountsHeader)) { | 120 request->response_headers()->HasHeader(kChromeManageAccountsHeader)) { |
114 DCHECK(switches::IsNewProfileManagement() && | 121 DCHECK(switches::IsNewProfileManagement() && |
115 !io_data->is_incognito()); | 122 !io_data->is_incognito()); |
116 content::BrowserThread::PostTask( | 123 content::BrowserThread::PostTask( |
117 content::BrowserThread::UI, FROM_HERE, | 124 content::BrowserThread::UI, FROM_HERE, |
118 base::Bind(ShowAvatarBubbleUIThread, child_id, route_id)); | 125 base::Bind(ShowAvatarBubbleUIThread, child_id, route_id)); |
119 } | 126 } |
120 } | 127 } |
121 | 128 |
122 } // namespace signin | 129 } // namespace signin |
OLD | NEW |