mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Rename the current CEF runtime to Alloy (see issue #2969)
As part of introducing the Chrome runtime we now need to distinguish between the classes that implement the current CEF runtime and the classes the implement the shared CEF library/runtime structure and public API. We choose the name Alloy for the current CEF runtime because it describes a combination of Chrome and other elements. Shared CEF library/runtime classes will continue to use the Cef prefix. Classes that implement the Alloy or Chrome runtime will use the Alloy or Chrome prefixes respectively. Classes that extend an existing Chrome-prefixed class will add the Cef or Alloy suffix, thereby following the existing naming pattern of Chrome-derived classes. This change applies the new naming pattern to an initial set of runtime-related classes. Additional classes/files will be renamed and moved as the Chrome runtime implementation progresses.
This commit is contained in:
63
libcef/browser/alloy/chrome_profile_manager_alloy.cc
Normal file
63
libcef/browser/alloy/chrome_profile_manager_alloy.cc
Normal file
@@ -0,0 +1,63 @@
|
||||
// Copyright (c) 2016 The Chromium Embedded Framework Authors.
|
||||
// Portions copyright (c) 2012 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 "libcef/browser/alloy/chrome_profile_manager_alloy.h"
|
||||
|
||||
#include "libcef/browser/alloy/alloy_content_browser_client.h"
|
||||
#include "libcef/browser/browser_context.h"
|
||||
|
||||
namespace {
|
||||
|
||||
// Return the active browser context. This is primarily called from Chrome code
|
||||
// that handles WebUI views and wishes to associate the view's data with a
|
||||
// particular context (profile). Chrome stores multiple profiles in sub-
|
||||
// directories of |user_data_dir| and then uses ProfileManager to track which
|
||||
// profile (sub-directory name) was last active.
|
||||
//
|
||||
// TODO(cef): To most closely match Chrome behavior this should return the
|
||||
// context for the currently active browser (e.g. the browser with input focus).
|
||||
// Return the main context for now since we don't currently have a good way to
|
||||
// determine that.
|
||||
CefBrowserContext* GetActiveBrowserContext() {
|
||||
return static_cast<CefBrowserContext*>(
|
||||
AlloyContentBrowserClient::Get()->request_context()->GetBrowserContext());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
ChromeProfileManagerAlloy::ChromeProfileManagerAlloy()
|
||||
: ProfileManager(base::FilePath()) {}
|
||||
|
||||
ChromeProfileManagerAlloy::~ChromeProfileManagerAlloy() {}
|
||||
|
||||
Profile* ChromeProfileManagerAlloy::GetProfile(
|
||||
const base::FilePath& profile_dir) {
|
||||
CefBrowserContext* browser_context =
|
||||
CefBrowserContext::GetForCachePath(profile_dir);
|
||||
if (!browser_context) {
|
||||
// ProfileManager makes assumptions about profile directory paths that do
|
||||
// not match CEF usage. For example, the default Chrome profile name is
|
||||
// "Default" so it will append that sub-directory name to an empty
|
||||
// |user_data_dir| value and then call this method. Use the active context
|
||||
// in cases such as this where we don't understand what ProfileManager is
|
||||
// asking for.
|
||||
browser_context = GetActiveBrowserContext();
|
||||
}
|
||||
return browser_context;
|
||||
}
|
||||
|
||||
bool ChromeProfileManagerAlloy::IsValidProfile(const void* profile) {
|
||||
if (!profile)
|
||||
return false;
|
||||
return !!CefBrowserContext::GetForContext(
|
||||
reinterpret_cast<content::BrowserContext*>(const_cast<void*>(profile)));
|
||||
}
|
||||
|
||||
Profile* ChromeProfileManagerAlloy::GetLastUsedProfile(
|
||||
const base::FilePath& user_data_dir) {
|
||||
// Override this method to avoid having to register prefs::kProfileLastUsed,
|
||||
// usage of which doesn't make sense for CEF.
|
||||
return GetActiveBrowserContext();
|
||||
}
|
Reference in New Issue
Block a user