Adapt to API changes of Chromium and node.

This commit is contained in:
Cheng Zhao 2014-06-28 22:33:00 +08:00
parent 58ccb27792
commit cd4c5d976b
55 changed files with 281 additions and 402 deletions

View file

@ -140,4 +140,4 @@ void Initialize(v8::Handle<v8::Object> exports) {
} // namespace
NODE_MODULE(atom_browser_app, Initialize)
NODE_MODULE_X(atom_browser_app, Initialize, NULL, NM_F_BUILTIN)

View file

@ -93,4 +93,4 @@ void Initialize(v8::Handle<v8::Object> exports) {
} // namespace
NODE_MODULE(atom_browser_auto_updater, Initialize)
NODE_MODULE_X(atom_browser_auto_updater, Initialize, NULL, NM_F_BUILTIN)

View file

@ -85,4 +85,4 @@ void Initialize(v8::Handle<v8::Object> exports) {
} // namespace
NODE_MODULE(atom_browser_dialog, Initialize)
NODE_MODULE_X(atom_browser_dialog, Initialize, NULL, NM_F_BUILTIN)

View file

@ -278,4 +278,4 @@ void Initialize(v8::Handle<v8::Object> exports) {
} // namespace
NODE_MODULE(atom_browser_menu, Initialize)
NODE_MODULE_X(atom_browser_menu, Initialize, NULL, NM_F_BUILTIN)

View file

@ -63,4 +63,4 @@ void Initialize(v8::Handle<v8::Object> exports) {
} // namespace
NODE_MODULE(atom_browser_power_monitor, Initialize)
NODE_MODULE_X(atom_browser_power_monitor, Initialize, NULL, NM_F_BUILTIN)

View file

@ -334,4 +334,4 @@ void Initialize(v8::Handle<v8::Object> exports) {
} // namespace
NODE_MODULE(atom_browser_protocol, Initialize)
NODE_MODULE_X(atom_browser_protocol, Initialize, NULL, NM_F_BUILTIN)

View file

@ -80,4 +80,4 @@ void Initialize(v8::Handle<v8::Object> exports) {
} // namespace
NODE_MODULE(atom_browser_tray, Initialize)
NODE_MODULE_X(atom_browser_tray, Initialize, NULL, NM_F_BUILTIN)

View file

@ -399,4 +399,4 @@ void Initialize(v8::Handle<v8::Object> exports) {
} // namespace
NODE_MODULE(atom_browser_window, Initialize)
NODE_MODULE_X(atom_browser_window, Initialize, NULL, NM_F_BUILTIN)

View file

@ -44,7 +44,8 @@ AtomBrowserClient::~AtomBrowserClient() {
net::URLRequestContextGetter* AtomBrowserClient::CreateRequestContext(
content::BrowserContext* browser_context,
content::ProtocolHandlerMap* protocol_handlers) {
content::ProtocolHandlerMap* protocol_handlers,
content::ProtocolHandlerScopedVector protocol_interceptors) {
return static_cast<AtomBrowserContext*>(browser_context)->
CreateRequestContext(protocol_handlers);
}
@ -77,7 +78,7 @@ void AtomBrowserClient::OverrideWebkitPrefs(
window->OverrideWebkitPrefs(url, prefs);
}
bool AtomBrowserClient::ShouldSwapProcessesForNavigation(
bool AtomBrowserClient::ShouldSwapBrowsingInstancesForNavigation(
content::SiteInstance* site_instance,
const GURL& current_url,
const GURL& new_url) {
@ -94,7 +95,7 @@ std::string AtomBrowserClient::GetApplicationLocale() {
}
void AtomBrowserClient::AppendExtraCommandLineSwitches(
CommandLine* command_line,
base::CommandLine* command_line,
int child_process_id) {
WindowList* list = WindowList::GetInstance();
NativeWindow* window = NULL;

View file

@ -19,16 +19,17 @@ class AtomBrowserClient : public brightray::BrowserClient {
protected:
net::URLRequestContextGetter* CreateRequestContext(
content::BrowserContext* browser_context,
content::ProtocolHandlerMap* protocol_handlers) OVERRIDE;
content::ProtocolHandlerMap* protocol_handlers,
content::ProtocolHandlerScopedVector protocol_interceptors) OVERRIDE;
virtual void OverrideWebkitPrefs(content::RenderViewHost* render_view_host,
const GURL& url,
WebPreferences* prefs) OVERRIDE;
virtual bool ShouldSwapProcessesForNavigation(
virtual bool ShouldSwapBrowsingInstancesForNavigation(
content::SiteInstance* site_instance,
const GURL& current_url,
const GURL& new_url) OVERRIDE;
virtual std::string GetApplicationLocale() OVERRIDE;
virtual void AppendExtraCommandLineSwitches(CommandLine* command_line,
virtual void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
int child_process_id) OVERRIDE;
private:

View file

@ -63,7 +63,7 @@ void AtomBrowserMainParts::PostEarlyInitialization() {
context->Enter();
// Add atom-shell extended APIs.
atom_bindings_->BindTo(global_env->process_object());
atom_bindings_->BindTo(isolate, global_env->process_object());
}
void AtomBrowserMainParts::PreMainMessageLoopRun() {

View file

@ -34,11 +34,13 @@
#include "content/public/browser/notification_source.h"
#include "content/public/browser/notification_types.h"
#include "content/public/browser/plugin_service.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents_view.h"
#include "content/public/common/renderer_preferences.h"
#include "content/public/common/user_agent.h"
#include "ipc/ipc_message_macros.h"
#include "native_mate/dictionary.h"
#include "ui/gfx/codec/png_codec.h"
@ -49,7 +51,6 @@
#include "ui/gfx/size.h"
#include "vendor/brightray/browser/inspectable_web_contents.h"
#include "vendor/brightray/browser/inspectable_web_contents_view.h"
#include "webkit/common/user_agent/user_agent_util.h"
#include "webkit/common/webpreferences.h"
using content::NavigationEntry;
@ -104,7 +105,7 @@ NativeWindow::NativeWindow(content::WebContents* web_contents,
browser->GetVersion().c_str(),
CHROME_VERSION_STRING);
web_contents->GetMutableRendererPrefs()->user_agent_override =
webkit_glue::BuildUserAgentFromProduct(product_name);
content::BuildUserAgentFromProduct(product_name);
// Get notified of title updated message.
registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED,
@ -271,7 +272,8 @@ void NativeWindow::CapturePage(const gfx::Rect& rect,
size,
base::Bind(&NativeWindow::OnCapturePageDone,
weak_factory_.GetWeakPtr(),
callback));
callback),
SkBitmap::kARGB_8888_Config);
}
void NativeWindow::DestroyWebContents() {
@ -305,7 +307,7 @@ void NativeWindow::CloseWebContents() {
ScheduleUnresponsiveEvent(5000);
if (web_contents->NeedToFireBeforeUnload())
web_contents->GetRenderViewHost()->FirePageBeforeUnload(false);
web_contents->GetMainFrame()->DispatchBeforeUnload(false);
else
web_contents->Close();
}
@ -322,8 +324,8 @@ content::WebContents* NativeWindow::GetDevToolsWebContents() const {
return inspectable_web_contents()->devtools_web_contents();
}
void NativeWindow::AppendExtraCommandLineSwitches(CommandLine* command_line,
int child_process_id) {
void NativeWindow::AppendExtraCommandLineSwitches(
base::CommandLine* command_line, int child_process_id) {
// Append --node-integration to renderer process.
command_line->AppendSwitchASCII(switches::kNodeIntegration,
node_integration_);
@ -542,7 +544,7 @@ void NativeWindow::DevToolsSaveToFile(const std::string& url,
}
saved_files_[url] = path;
file_util::WriteFile(path, content.data(), content.size());
base::WriteFile(path, content.data(), content.size());
// Notify devtools.
base::StringValue url_value(url);
@ -557,7 +559,7 @@ void NativeWindow::DevToolsAppendToFile(const std::string& url,
PathsMap::iterator it = saved_files_.find(url);
if (it == saved_files_.end())
return;
file_util::AppendToFile(it->second, content.data(), content.size());
base::AppendToFile(it->second, content.data(), content.size());
// Notify devtools.
base::StringValue url_value(url);
@ -614,7 +616,7 @@ void NativeWindow::CallDevToolsFunction(const std::string& function_name,
}
}
GetDevToolsWebContents()->GetRenderViewHost()->ExecuteJavascriptInWebFrame(
string16(), base::UTF8ToUTF16(function_name + "(" + params + ");"));
base::string16(), base::UTF8ToUTF16(function_name + "(" + params + ");"));
}
} // namespace atom

View file

@ -22,9 +22,12 @@
#include "vendor/brightray/browser/inspectable_web_contents_delegate.h"
#include "vendor/brightray/browser/inspectable_web_contents_impl.h"
class CommandLine;
struct WebPreferences;
namespace base {
class CommandLine;
}
namespace content {
class BrowserContext;
class WebContents;
@ -160,7 +163,7 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
content::WebContents* GetDevToolsWebContents() const;
// Called when renderer process is going to be started.
void AppendExtraCommandLineSwitches(CommandLine* command_line,
void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
int child_process_id);
void OverrideWebkitPrefs(const GURL& url, WebPreferences* prefs);

View file

@ -418,7 +418,7 @@ void NativeWindowGtk::UpdateDraggableRegions(
void NativeWindowGtk::HandleKeyboardEvent(
content::WebContents*,
const content::NativeWebKeyboardEvent& event) {
if (event.type == WebKit::WebInputEvent::RawKeyDown) {
if (event.type == blink::WebInputEvent::RawKeyDown) {
GdkEventKey* os_event = reinterpret_cast<GdkEventKey*>(event.os_event);
ui::Accelerator accelerator = ui::AcceleratorForGdkKeyCodeAndModifier(
os_event->keyval, static_cast<GdkModifierType>(os_event->state));

View file

@ -469,7 +469,7 @@ void NativeWindowWin::UpdateDraggableRegions(
void NativeWindowWin::HandleKeyboardEvent(
content::WebContents*,
const content::NativeWebKeyboardEvent& event) {
if (event.type == WebKit::WebInputEvent::RawKeyDown) {
if (event.type == blink::WebInputEvent::RawKeyDown) {
ui::Accelerator accelerator(
static_cast<ui::KeyboardCode>(event.windowsKeyCode),
content::GetModifiersFromNativeWebKeyboardEvent(event));

View file

@ -111,7 +111,7 @@ class NativeWindowWin : public NativeWindow,
virtual views::View* GetInitiallyFocusedView() OVERRIDE;
virtual bool CanResize() const OVERRIDE;
virtual bool CanMaximize() const OVERRIDE;
virtual string16 GetWindowTitle() const OVERRIDE;
virtual base::string16 GetWindowTitle() const OVERRIDE;
virtual bool ShouldHandleSystemCommands() const OVERRIDE;
virtual gfx::ImageSkia GetWindowAppIcon() OVERRIDE;
virtual gfx::ImageSkia GetWindowIcon() OVERRIDE;
@ -150,7 +150,7 @@ class NativeWindowWin : public NativeWindow,
bool use_content_size_;
bool resizable_;
string16 title_;
base::string16 title_;
gfx::Size minimum_size_;
gfx::Size maximum_size_;

View file

@ -32,6 +32,7 @@
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_storage.h"
#include "vendor/brightray/browser/network_delegate.h"
#include "webkit/browser/quota/special_storage_policy.h"
namespace atom {
@ -75,18 +76,18 @@ net::URLRequestContext* AtomURLRequestContextGetter::GetURLRequestContext() {
url_request_context_->set_network_delegate(network_delegate_.get());
storage_.reset(
new net::URLRequestContextStorage(url_request_context_.get()));
storage_->set_cookie_store(content::CreatePersistentCookieStore(
auto cookie_config = content::CookieStoreConfig(
base_path_.Append(FILE_PATH_LITERAL("Cookies")),
false,
content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES,
nullptr,
nullptr,
nullptr));
nullptr);
storage_->set_cookie_store(content::CreateCookieStore(cookie_config));
storage_->set_server_bound_cert_service(new net::ServerBoundCertService(
new net::DefaultServerBoundCertStore(NULL),
base::WorkerPool::GetTaskRunner(true)));
storage_->set_http_user_agent_settings(
new net::StaticHttpUserAgentSettings(
"en-us,en", EmptyString()));
"en-us,en", base::EmptyString()));
scoped_ptr<net::HostResolver> host_resolver(
net::HostResolver::CreateDefaultResolver(NULL));
@ -163,9 +164,9 @@ net::URLRequestContext* AtomURLRequestContextGetter::GetURLRequestContext() {
content::BrowserThread::GetBlockingPool()->
GetTaskRunnerWithShutdownBehavior(
base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)));
job_factory_->SetProtocolHandler(chrome::kDataScheme,
job_factory_->SetProtocolHandler(content::kDataScheme,
new net::DataProtocolHandler);
job_factory_->SetProtocolHandler(chrome::kFileScheme,
job_factory_->SetProtocolHandler(content::kFileScheme,
file_protocol_handler.release());
storage_->set_job_factory(job_factory_);
}

View file

@ -131,7 +131,7 @@ int EventFlagsFromNSEvent(NSEvent* event) {
- (void)addItemToMenu:(NSMenu*)menu
atIndex:(NSInteger)index
fromModel:(ui::MenuModel*)model {
string16 label16 = model->GetLabelAt(index);
base::string16 label16 = model->GetLabelAt(index);
NSString* label = l10n_util::FixUpWindowsStyleLabel(label16);
base::scoped_nsobject<NSMenuItem> item(
[[NSMenuItem alloc] initWithTitle:label

View file

@ -53,7 +53,7 @@ class MessageDialog : public base::MessageLoop::Dispatcher,
virtual bool Dispatch(const base::NativeEvent& event) OVERRIDE;
// Overridden from views::WidgetDelegate:
virtual string16 GetWindowTitle() const;
virtual base::string16 GetWindowTitle() const;
virtual void WindowClosing() OVERRIDE;
virtual views::Widget* GetWidget() OVERRIDE;
virtual const views::Widget* GetWidget() const OVERRIDE;
@ -73,7 +73,7 @@ class MessageDialog : public base::MessageLoop::Dispatcher,
bool should_close_;
bool delete_on_close_;
int result_;
string16 title_;
base::string16 title_;
views::Widget* widget_;
views::MessageBoxView* message_box_view_;
scoped_ptr<NativeWindow::DialogScope> dialog_scope_;

View file

@ -55,7 +55,7 @@ struct NativeMenuWin::ItemData {
// The Windows API requires that whoever creates the menus must own the
// strings used for labels, and keep them around for the lifetime of the
// created menu. So be it.
string16 label;
base::string16 label;
// Someone needs to own submenus, it may as well be us.
scoped_ptr<Menu2> submenu;
@ -182,7 +182,7 @@ class NativeMenuWin::MenuHostWindow {
if (data->submenu.get())
measure_item_struct->itemWidth += kArrowWidth;
// If the label contains an accelerator, make room for tab.
if (data->label.find(L'\t') != string16::npos)
if (data->label.find(L'\t') != base::string16::npos)
measure_item_struct->itemWidth += font.GetStringWidth(L" ");
measure_item_struct->itemHeight =
font.GetHeight() + kItemBottomMargin + kItemTopMargin;
@ -238,10 +238,10 @@ class NativeMenuWin::MenuHostWindow {
// left and the accelerator on the right.
// TODO(jungshik): This will break in RTL UI. Currently, he/ar use the
// window system UI font and will not hit here.
string16 label = data->label;
string16 accel;
string16::size_type tab_pos = label.find(L'\t');
if (tab_pos != string16::npos) {
base::string16 label = data->label;
base::string16 accel;
base::string16::size_type tab_pos = label.find(L'\t');
if (tab_pos != base::string16::npos) {
accel = label.substr(tab_pos);
label = label.substr(0, tab_pos);
}
@ -635,7 +635,7 @@ void NativeMenuWin::AddMenuItemAt(int menu_index, int model_index) {
mii.fType = MFT_OWNERDRAW;
ItemData* item_data = new ItemData;
item_data->label = string16();
item_data->label = base::string16();
ui::MenuModel::ItemType type = model_->GetTypeAt(model_index);
if (type == ui::MenuModel::TYPE_SUBMENU) {
item_data->submenu.reset(new Menu2(model_->GetSubmenuModelAt(model_index)));
@ -687,7 +687,7 @@ void NativeMenuWin::SetMenuItemState(int menu_index, bool enabled, bool checked,
void NativeMenuWin::SetMenuItemLabel(int menu_index,
int model_index,
const string16& label) {
const base::string16& label) {
if (IsSeparatorItemAt(menu_index))
return;
@ -699,8 +699,8 @@ void NativeMenuWin::SetMenuItemLabel(int menu_index,
void NativeMenuWin::UpdateMenuItemInfoForString(MENUITEMINFO* mii,
int model_index,
const string16& label) {
string16 formatted = label;
const base::string16& label) {
base::string16 formatted = label;
ui::MenuModel::ItemType type = model_->GetTypeAt(model_index);
// Strip out any tabs, otherwise they get interpreted as accelerators and can
// lead to weird behavior.

View file

@ -94,7 +94,7 @@ class NativeMenuWin {
// Sets the label of the item at the specified index.
void SetMenuItemLabel(int menu_index,
int model_index,
const string16& label);
const base::string16& label);
// Updates the local data structure with the correctly formatted version of
// |label| at the specified model_index, and adds string data to |mii| if
@ -102,7 +102,7 @@ class NativeMenuWin {
// of the peculiarities of the Windows menu API.
void UpdateMenuItemInfoForString(MENUITEMINFO* mii,
int model_index,
const string16& label);
const base::string16& label);
// Returns the alignment flags to be passed to TrackPopupMenuEx, based on the
// supplied alignment and the UI text direction.