I'm trying to create ChromiumOSR programmatically but I keep getting an error (access violation). Here is sample code that causes the problem:
var
pChromiumOSR: TChromiumOSR;
begin
pChromiumOSR := TChromiumOSR.Create(Self);
pChromiumOSR.OnLoadEnd := pChromiumOSRLoadEnd;
pChromiumOSR.Browser.MainFrame.LoadUrl('www.google.com');
end;
The problem is that pChromiumOSR.Browser.MainFrame is always nil. If I do pChromiumOSR.load('www.google.com'); I don't get any errors but it doesn't fire the onLoadend.
Can anyone give me any suggestions on what I might be doing wrong? I'm using Delphi XE2 but not sure which version of chromium (where can I find the version?)
without play support yes, but they can run android apps through ARC and the android runtime given they don't need local storage or google play services.
What's the difference between Chromium OS and Google Chrome OS? Google Chrome OS is to Chromium OS what Google Chrome browser is to Chromium. Chromium OS is the open source project, used primarily by developers, with code that is available for anyone to checkout, modify, and build.
What is Chrome OS Developer Mode? The Chrome OS has a Developer Mode that gives you root access to the operating system of your Chromebook. To enable Developer Mode, restart your laptop pressing the Esc, Refresh, and Power keys, then Ctrl+D. Developer Mode may void your warranty and make you susceptible to malware.
Your attempt to use Load
method for loading a page was correct. The other one was wrong and failed because the Browser
instance was not created. It's because the TChromiumOSR
was designed to be a design time component rather than to be created dynamically.
Now, the only place where the Browser
instance is created is the Loaded
method, which is called for a component after its parent form is loaded from a stream. And since you are creating it dynamically, the Browser
instance is never created.
For some reason also the CreateBrowser
method (which creates the Browser
instance) is declared as private, which complicates its calling a bit (unless you decide to modify the source and make it public). If you don't want to change your DCEF source code, you can use a class helper to provide access to the CreateBrowser
method:
uses
ceflib, cefvcl;
type
TChromiumOSRHelper = class helper for TCustomChromiumOSR
public
procedure CreateBrowserInstance;
end;
implementation
{ TChromiumOSRHelper }
procedure TChromiumOSRHelper.CreateBrowserInstance;
begin
Self.CreateBrowser;
end;
Then to create a Browser
instance add the CreateBrowserInstance
call before the first accessing the Browser
instance (which is here the Load
method):
var
pChromiumOSR: TChromiumOSR;
begin
pChromiumOSR := TChromiumOSR.Create(Self);
pChromiumOSR.OnLoadEnd := pChromiumOSRLoadEnd;
pChromiumOSR.CreateBrowserInstance;
pChromiumOSR.Load('www.google.com');
end;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With