Add "url" command-line option to cefclient (issue #715).

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@770 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2012-09-07 20:35:43 +00:00
parent 4e6607a343
commit 6834d879d3
7 changed files with 21 additions and 4 deletions

View File

@@ -421,7 +421,7 @@ int main(int argc, char *argv[]) {
CefBrowser::CreateBrowserSync(window_info, CefBrowser::CreateBrowserSync(window_info,
static_cast<CefRefPtr<CefClient> >(g_handler), static_cast<CefRefPtr<CefClient> >(g_handler),
"http://www.google.com", browserSettings); g_handler->GetStartupURL(), browserSettings);
gtk_container_add(GTK_CONTAINER(window), vbox); gtk_container_add(GTK_CONTAINER(window), vbox);
gtk_widget_show_all(GTK_WIDGET(window)); gtk_widget_show_all(GTK_WIDGET(window));

View File

@@ -393,7 +393,7 @@ NSButton* MakeButton(NSRect* rect, NSString* title, NSView* parent) {
window_info.SetAsChild(contentView, 0, 0, kWindowWidth, kWindowHeight); window_info.SetAsChild(contentView, 0, 0, kWindowWidth, kWindowHeight);
CefBrowser::CreateBrowser(window_info, g_handler.get(), CefBrowser::CreateBrowser(window_info, g_handler.get(),
"http://www.google.com", settings); g_handler->GetStartupURL(), settings);
// Show the window. // Show the window.
[mainWnd makeKeyAndOrderFront: nil]; [mainWnd makeKeyAndOrderFront: nil];

View File

@@ -8,6 +8,8 @@
namespace cefclient { namespace cefclient {
const char kUrl[] = "url";
// CefSettings attributes. // CefSettings attributes.
const char kMultiThreadedMessageLoop[] = "multi-threaded-message-loop"; const char kMultiThreadedMessageLoop[] = "multi-threaded-message-loop";
const char kCachePath[] = "cache-path"; const char kCachePath[] = "cache-path";

View File

@@ -10,6 +10,8 @@
namespace cefclient { namespace cefclient {
extern const char kUrl[];
// CefSettings attributes. // CefSettings attributes.
extern const char kMultiThreadedMessageLoop[]; extern const char kMultiThreadedMessageLoop[];
extern const char kCachePath[]; extern const char kCachePath[];

View File

@@ -350,7 +350,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
// Creat the new child browser window // Creat the new child browser window
CefBrowser::CreateBrowser(info, CefBrowser::CreateBrowser(info,
static_cast<CefRefPtr<CefClient> >(g_handler), static_cast<CefRefPtr<CefClient> >(g_handler),
"http://www.google.com", settings); g_handler->GetStartupURL(), settings);
return 0; return 0;
} }

View File

@@ -7,13 +7,14 @@
#include <sstream> #include <sstream>
#include <string> #include <string>
#include "include/cef_browser.h" #include "include/cef_browser.h"
#include "include/cef_command_line.h"
#include "include/cef_frame.h" #include "include/cef_frame.h"
#include "cefclient/binding_test.h" #include "cefclient/binding_test.h"
#include "cefclient/cefclient.h" #include "cefclient/cefclient.h"
#include "cefclient/cefclient_switches.h"
#include "cefclient/download_handler.h" #include "cefclient/download_handler.h"
#include "cefclient/string_util.h" #include "cefclient/string_util.h"
ClientHandler::ClientHandler() ClientHandler::ClientHandler()
: m_MainHwnd(NULL), : m_MainHwnd(NULL),
m_BrowserHwnd(NULL), m_BrowserHwnd(NULL),
@@ -23,6 +24,13 @@ ClientHandler::ClientHandler()
m_StopHwnd(NULL), m_StopHwnd(NULL),
m_ReloadHwnd(NULL), m_ReloadHwnd(NULL),
m_bFormElementHasFocus(false) { m_bFormElementHasFocus(false) {
CefRefPtr<CefCommandLine> commandLine = AppGetCommandLine();
if (commandLine.get()) {
if (commandLine->HasSwitch(cefclient::kUrl))
m_StartupURL = commandLine->GetSwitchValue(cefclient::kUrl);
else
m_StartupURL = "http://www.google.com/";
}
} }
ClientHandler::~ClientHandler() { ClientHandler::~ClientHandler() {

View File

@@ -181,6 +181,8 @@ class ClientHandler : public CefClient,
std::string GetLogFile(); std::string GetLogFile();
std::string GetStartupURL() const { return m_StartupURL; }
void SetLastDownloadFile(const std::string& fileName); void SetLastDownloadFile(const std::string& fileName);
std::string GetLastDownloadFile(); std::string GetLastDownloadFile();
@@ -233,6 +235,9 @@ class ClientHandler : public CefClient,
// True if a form element currently has focus // True if a form element currently has focus
bool m_bFormElementHasFocus; bool m_bFormElementHasFocus;
// The URL to be loaded at application startup.
std::string m_StartupURL;
// Include the default reference counting implementation. // Include the default reference counting implementation.
IMPLEMENT_REFCOUNTING(ClientHandler); IMPLEMENT_REFCOUNTING(ClientHandler);
// Include the default locking implementation. // Include the default locking implementation.