Chromium Code Reviews| Index: chrome/browser/chromeos/login/helper.cc |
| diff --git a/chrome/browser/chromeos/login/helper.cc b/chrome/browser/chromeos/login/helper.cc |
| index efb98901b709eef42fe1e24b217786b51d76fc61..b5997215967db2a9f18904209871a44bb1f866f8 100644 |
| --- a/chrome/browser/chromeos/login/helper.cc |
| +++ b/chrome/browser/chromeos/login/helper.cc |
| @@ -4,13 +4,19 @@ |
| #include "chrome/browser/chromeos/login/helper.h" |
| +#include "base/bind.h" |
| #include "base/command_line.h" |
| #include "base/strings/utf_string_conversions.h" |
| +#include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
| +#include "chrome/browser/chromeos/login/ui/webui_login_view.h" |
| #include "chrome/grit/generated_resources.h" |
| #include "chromeos/chromeos_switches.h" |
| #include "chromeos/network/network_handler.h" |
| #include "chromeos/network/network_state.h" |
| #include "chromeos/network/network_state_handler.h" |
| +#include "content/public/browser/web_contents.h" |
| +#include "extensions/browser/guest_view/guest_view_manager.h" |
| +#include "extensions/browser/guest_view/web_view/web_view_guest.h" |
| #include "third_party/cros_system_api/dbus/service_constants.h" |
| #include "ui/base/l10n/l10n_util.h" |
| #include "ui/gfx/image/image_skia.h" |
| @@ -18,6 +24,57 @@ |
| namespace chromeos { |
| +namespace { |
| + |
| +// Gets the WebContents instance of current login display. If there is none, |
| +// returns NULL. |
| +content::WebContents* GetLoginWebContents() { |
| + LoginDisplayHost* host = LoginDisplayHostImpl::default_host(); |
| + if (!host || !host->GetWebUILoginView()) |
| + return NULL; |
| + |
| + return host->GetWebUILoginView()->GetWebContents(); |
| +} |
| + |
| +// Callback used by GetPartition below to return the first guest contents with a |
| +// matching partition name. |
| +bool FindGuestByPartitionName(const std::string& partition_name, |
| + content::WebContents** out_guest_contents, |
| + content::WebContents* guest_contents) { |
| + std::string domain; |
| + std::string name; |
| + bool in_memory; |
| + extensions::WebViewGuest::GetGuestPartitionConfigForSite( |
| + guest_contents->GetSiteInstance()->GetSiteURL(), &domain, &name, |
| + &in_memory); |
| + if (partition_name != name) |
| + return false; |
| + |
| + *out_guest_contents = guest_contents; |
| + return true; |
| +} |
| + |
| +// Gets the storage partition of guest contents of a given embedder. |
| +// If a name is given, returns the partition associated with the name. |
| +// Otherwise, returns the default shared in-memory partition. Returns NULL if a |
| +// matching parition could not be found. |
| +content::StoragePartition* GetPartition(content::WebContents* embedder, |
| + const std::string& partition_name) { |
| + extensions::GuestViewManager* manager = |
| + extensions::GuestViewManager::FromBrowserContext( |
| + embedder->GetBrowserContext()); |
| + content::WebContents* guest_contents = nullptr; |
| + manager->ForEachGuest(embedder, base::Bind(&FindGuestByPartitionName, |
| + partition_name, &guest_contents)); |
| + |
| + return guest_contents ? content::BrowserContext::GetStoragePartition( |
| + guest_contents->GetBrowserContext(), |
| + guest_contents->GetSiteInstance()) |
| + : nullptr; |
| +} |
| + |
| +} // namespace |
| + |
| gfx::Rect CalculateScreenBounds(const gfx::Size& size) { |
| gfx::Rect bounds = |
| gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().bounds(); |
| @@ -82,6 +139,12 @@ bool NetworkStateHelper::IsConnecting() const { |
| chromeos::NetworkTypePattern::Default()) != NULL; |
| } |
| +content::StoragePartition* GetSigninPartition() { |
| + // Note the partition name must match the sign-in webview used. For now, |
| + // this is the default unnamed, shared, in-memory partition. |
| + return GetPartition(GetLoginWebContents(), std::string()); |
|
dzhioev_at_google
2015/03/23 23:01:17
I'm adding another <webview> to OOBE page now, use
xiyuan
2015/03/23 23:10:48
I had a long discussion with Ivan in his https://c
|
| +} |
| + |
| } // namespace login |
| } // namespace chromeos |