Update to API changes of Chrome 47

This commit is contained in:
Cheng Zhao 2015-12-07 19:56:23 +08:00
parent 766bbfcb05
commit 73e7773d84
46 changed files with 113 additions and 239 deletions

View file

@ -51,7 +51,7 @@ struct ClearStorageDataOptions {
uint32 GetStorageMask(const std::vector<std::string>& storage_types) {
uint32 storage_mask = 0;
for (const auto& it : storage_types) {
auto type = base::StringToLowerASCII(it);
auto type = base::ToLowerASCII(it);
if (type == "appcache")
storage_mask |= StoragePartition::REMOVE_DATA_MASK_APPCACHE;
else if (type == "cookies")
@ -75,7 +75,7 @@ uint32 GetStorageMask(const std::vector<std::string>& storage_types) {
uint32 GetQuotaMask(const std::vector<std::string>& quota_types) {
uint32 quota_mask = 0;
for (const auto& it : quota_types) {
auto type = base::StringToLowerASCII(it);
auto type = base::ToLowerASCII(it);
if (type == "temporary")
quota_mask |= StoragePartition::QUOTA_MANAGED_STORAGE_MASK_TEMPORARY;
else if (type == "persistent")
@ -233,7 +233,8 @@ void SetProxyInIO(net::URLRequestContextGetter* getter,
const net::ProxyConfig& config,
const base::Closure& callback) {
auto proxy_service = getter->GetURLRequestContext()->proxy_service();
proxy_service->ResetConfigService(new net::ProxyConfigServiceFixed(config));
proxy_service->ResetConfigService(make_scoped_ptr(
new net::ProxyConfigServiceFixed(config)));
// Refetches and applies the new pac script if provided.
proxy_service->ForceReloadProxyConfig();
RunCallbackInUI(callback);

View file

@ -148,7 +148,7 @@ struct Converter<net::HttpResponseHeaders*> {
std::string key;
std::string value;
while (headers->EnumerateHeaderLines(&iter, &key, &value)) {
key = base::StringToLowerASCII(key);
key = base::ToLowerASCII(key);
if (response_headers.HasKey(key)) {
base::ListValue* values = nullptr;
if (response_headers.GetList(key, &values))
@ -171,7 +171,7 @@ struct Converter<content::SavePageType> {
std::string save_type;
if (!ConvertFromV8(isolate, val, &save_type))
return false;
save_type = base::StringToLowerASCII(save_type);
save_type = base::ToLowerASCII(save_type);
if (save_type == "htmlonly") {
*out = content::SAVE_PAGE_TYPE_AS_ONLY_HTML;
} else if (save_type == "htmlcomplete") {

View file

@ -24,12 +24,11 @@ bool FrameSubscriber::ShouldCaptureFrame(
base::TimeTicks present_time,
scoped_refptr<media::VideoFrame>* storage,
DeliverFrameCallback* callback) {
*storage = media::VideoFrame::CreateFrame(media::VideoFrame::YV12, size_,
gfx::Rect(size_), size_,
base::TimeDelta());
*storage = media::VideoFrame::CreateFrame(
media::PIXEL_FORMAT_YV12,
size_, gfx::Rect(size_), size_, base::TimeDelta());
*callback = base::Bind(&FrameSubscriber::OnFrameDelivered,
base::Unretained(this),
*storage);
base::Unretained(this), *storage);
return true;
}

View file

@ -84,7 +84,7 @@ void AtomBrowserClient::SuppressRendererProcessRestartForOnce() {
void AtomBrowserClient::SetCustomSchemes(
const std::vector<std::string>& schemes) {
g_custom_schemes = JoinString(schemes, ',');
g_custom_schemes = base::JoinString(schemes, ",");
}
AtomBrowserClient::AtomBrowserClient() : delegate_(nullptr) {
@ -116,7 +116,6 @@ void AtomBrowserClient::OverrideWebkitPrefs(
prefs->javascript_can_open_windows_automatically = true;
prefs->plugins_enabled = true;
prefs->dom_paste_enabled = true;
prefs->java_enabled = false;
prefs->allow_scripts_to_close_windows = true;
prefs->javascript_can_access_clipboard = true;
prefs->local_storage_enabled = true;

View file

@ -61,7 +61,7 @@ std::string RemoveWhitespace(const std::string& str) {
AtomBrowserContext::AtomBrowserContext(const std::string& partition,
bool in_memory)
: brightray::BrowserContext(partition, in_memory),
cert_verifier_(new AtomCertVerifier),
cert_verifier_(nullptr),
job_factory_(new AtomURLRequestJobFactory),
allow_ntlm_everywhere_(false) {
}
@ -86,7 +86,7 @@ std::string AtomBrowserContext::GetUserAgent() {
return content::BuildUserAgentFromProduct(user_agent);
}
net::URLRequestJobFactory* AtomBrowserContext::CreateURLRequestJobFactory(
scoped_ptr<net::URLRequestJobFactory> AtomBrowserContext::CreateURLRequestJobFactory(
content::ProtocolHandlerMap* handlers,
content::URLRequestInterceptorScopedVector* interceptors) {
scoped_ptr<AtomURLRequestJobFactory> job_factory(job_factory_);
@ -131,7 +131,7 @@ net::URLRequestJobFactory* AtomBrowserContext::CreateURLRequestJobFactory(
top_job_factory.Pass(), make_scoped_ptr(*it)));
interceptors->weak_clear();
return top_job_factory.release();
return top_job_factory.Pass();
}
net::HttpCache::BackendFactory*
@ -160,8 +160,10 @@ content::BrowserPluginGuestManager* AtomBrowserContext::GetGuestManager() {
return guest_manager_.get();
}
net::CertVerifier* AtomBrowserContext::CreateCertVerifier() {
return cert_verifier_;
scoped_ptr<net::CertVerifier> AtomBrowserContext::CreateCertVerifier() {
DCHECK(!cert_verifier_);
cert_verifier_ = new AtomCertVerifier;
return make_scoped_ptr(cert_verifier_);
}
net::SSLConfigService* AtomBrowserContext::CreateSSLConfigService() {

View file

@ -23,12 +23,12 @@ class AtomBrowserContext : public brightray::BrowserContext {
// brightray::URLRequestContextGetter::Delegate:
std::string GetUserAgent() override;
net::URLRequestJobFactory* CreateURLRequestJobFactory(
scoped_ptr<net::URLRequestJobFactory> CreateURLRequestJobFactory(
content::ProtocolHandlerMap* handlers,
content::URLRequestInterceptorScopedVector* interceptors) override;
net::HttpCache::BackendFactory* CreateHttpCacheBackendFactory(
const base::FilePath& base_path) override;
net::CertVerifier* CreateCertVerifier() override;
scoped_ptr<net::CertVerifier> CreateCertVerifier() override;
net::SSLConfigService* CreateSSLConfigService() override;
bool AllowNTLMCredentialsForDomain(const GURL& auth_origin) override;

View file

@ -380,7 +380,7 @@ gfx::ImageSkia CommonWebContentsDelegate::GetDevToolsWindowIcon() {
void CommonWebContentsDelegate::GetDevToolsWindowWMClass(
std::string* name, std::string* class_name) {
*class_name = Browser::Get()->GetName();
*name = base::StringToLowerASCII(*class_name);
*name = base::ToLowerASCII(*class_name);
}
#endif

View file

@ -291,10 +291,10 @@ void NativeWindow::CapturePage(const gfx::Rect& rect,
const float scale =
screen->GetDisplayNearestWindow(native_view).device_scale_factor();
if (scale > 1.0f)
bitmap_size = gfx::ToCeiledSize(gfx::ScaleSize(view_size, scale));
bitmap_size = gfx::ScaleToCeiledSize(view_size, scale);
host->CopyFromBackingStore(
rect.IsEmpty() ? gfx::Rect(view_size) : rect,
gfx::Rect(view_size),
bitmap_size,
base::Bind(&NativeWindow::OnCapturePageDone,
weak_factory_.GetWeakPtr(),

View file

@ -6,7 +6,6 @@
#include <string>
#import "atom/browser/ui/cocoa/event_processing_window.h"
#include "atom/common/draggable_region.h"
#include "atom/common/options_switches.h"
#include "base/mac/mac_util.h"
@ -19,6 +18,7 @@
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host_view.h"
#include "native_mate/dictionary.h"
#import "ui/base/cocoa/command_dispatcher.h"
#include "ui/gfx/skia_util.h"
namespace {
@ -209,10 +209,11 @@ bool ScopedDisableResize::disable_resize_ = false;
@end
@interface AtomNSWindow : EventProcessingWindow {
@interface AtomNSWindow : NSWindow<CommandDispatchingWindow> {
@private
atom::NativeWindowMac* shell_;
bool enable_larger_than_screen_;
base::scoped_nsobject<CommandDispatcher> commandDispatcher_;
}
@property BOOL acceptsFirstMouse;
@property BOOL disableAutoHideCursor;
@ -226,12 +227,15 @@ bool ScopedDisableResize::disable_resize_ = false;
- (void)setShell:(atom::NativeWindowMac*)shell {
shell_ = shell;
commandDispatcher_.reset([[CommandDispatcher alloc] initWithOwner:self]);
}
- (void)setEnableLargerThanScreen:(bool)enable {
enable_larger_than_screen_ = enable;
}
// NSWindow overrides.
- (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen*)screen {
// Resizing is disabled.
if (ScopedDisableResize::IsResizeDisabled())
@ -272,6 +276,25 @@ bool ScopedDisableResize::disable_resize_ = false;
return !self.disableKeyOrMainWindow;
}
// CommandDispatchingWindow implementation.
- (void)setCommandHandler:(id<UserInterfaceItemCommandHandler>)commandHandler {
}
- (BOOL)redispatchKeyEvent:(NSEvent*)event {
return [commandDispatcher_ redispatchKeyEvent:event];
}
- (BOOL)defaultPerformKeyEquivalent:(NSEvent*)event {
return [super performKeyEquivalent:event];
}
- (void)commandDispatch:(id)sender {
}
- (void)commandDispatchUsingKeyModifiers:(id)sender {
}
@end
@interface ControlRegionView : NSView
@ -766,20 +789,14 @@ void NativeWindowMac::HandleKeyboardEvent(
event.type == content::NativeWebKeyboardEvent::Char)
return;
if (event.os_event.window == window_.get()) {
EventProcessingWindow* event_window =
static_cast<EventProcessingWindow*>(window_);
DCHECK([event_window isKindOfClass:[EventProcessingWindow class]]);
[event_window redispatchKeyEvent:event.os_event];
} else {
BOOL handled = [[NSApp mainMenu] performKeyEquivalent:event.os_event];
if (!handled && event.os_event.window != window_.get()) {
// The event comes from detached devtools view, and it has already been
// handled by the devtools itself, we now send it to application menu to
// make menu acclerators work.
BOOL handled = [[NSApp mainMenu] performKeyEquivalent:event.os_event];
// Handle the cmd+~ shortcut.
if (!handled && (event.os_event.modifierFlags & NSCommandKeyMask) &&
(event.os_event.keyCode == 50 /* ~ key */))
(event.os_event.keyCode == 50 /* ~ key */)) {
// Handle the cmd+~ shortcut.
Focus(true);
}
}
}

View file

@ -180,7 +180,7 @@ NativeWindowViews::NativeWindowViews(
// Set WM_WINDOW_ROLE.
params.wm_role_name = "browser-window";
// Set WM_CLASS.
params.wm_class_name = base::StringToLowerASCII(name);
params.wm_class_name = base::ToLowerASCII(name);
params.wm_class_class = name;
#endif

View file

@ -14,6 +14,7 @@
#include "net/http/http_response_headers.h"
#include "net/url_request/url_fetcher.h"
#include "net/url_request/url_fetcher_response_writer.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_builder.h"
#include "net/url_request/url_request_status.h"
@ -23,7 +24,7 @@ namespace {
// Convert string to RequestType.
net::URLFetcher::RequestType GetRequestType(const std::string& raw) {
std::string method = base::StringToUpperASCII(raw);
std::string method = base::ToUpperASCII(raw);
if (method.empty() || method == "GET")
return net::URLFetcher::GET;
else if (method == "POST")
@ -138,8 +139,9 @@ net::URLRequestContextGetter* URLRequestFetchJob::CreateRequestContext() {
auto task_runner = base::ThreadTaskRunnerHandle::Get();
net::URLRequestContextBuilder builder;
builder.set_proxy_service(net::ProxyService::CreateDirect());
url_request_context_getter_ =
new net::TrivialURLRequestContextGetter(builder.Build(), task_runner);
request_context_ = builder.Build();
url_request_context_getter_ = new net::TrivialURLRequestContextGetter(
request_context_.get(), task_runner);
}
return url_request_context_getter_.get();
}

View file

@ -45,6 +45,7 @@ class URLRequestFetchJob : public JsAsker<net::URLRequestJob>,
// Create a independent request context.
net::URLRequestContextGetter* CreateRequestContext();
scoped_ptr<net::URLRequestContext> request_context_;
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
scoped_ptr<net::URLFetcher> fetcher_;
scoped_refptr<net::IOBuffer> pending_buffer_;

View file

@ -24,10 +24,10 @@ bool StringToAccelerator(const std::string& description,
LOG(ERROR) << "The accelerator string can only contain ASCII characters";
return false;
}
std::string shortcut(base::StringToLowerASCII(description));
std::string shortcut(base::ToLowerASCII(description));
std::vector<std::string> tokens;
base::SplitString(shortcut, '+', &tokens);
std::vector<std::string> tokens = base::SplitString(
shortcut, "+", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
// Now, parse it into an accelerator.
int modifiers = ui::EF_NONE;

View file

@ -1,30 +0,0 @@
// Copyright (c) 2013 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ATOM_BROWSER_UI_COCOA_EVENT_PROCESSING_WINDOW_H_
#define ATOM_BROWSER_UI_COCOA_EVENT_PROCESSING_WINDOW_H_
#import <Cocoa/Cocoa.h>
// Override NSWindow to access unhandled keyboard events (for command
// processing); subclassing NSWindow is the only method to do
// this.
@interface EventProcessingWindow : NSWindow {
@private
BOOL redispatchingEvent_;
BOOL eventHandled_;
}
// Sends a key event to |NSApp sendEvent:|, but also makes sure that it's not
// short-circuited to the RWHV. This is used to send keyboard events to the menu
// and the cmd-` handler if a keyboard event comes back unhandled from the
// renderer. The event must be of type |NSKeyDown|, |NSKeyUp|, or
// |NSFlagsChanged|.
// Returns |YES| if |event| has been handled.
- (BOOL)redispatchKeyEvent:(NSEvent*)event;
- (BOOL)performKeyEquivalent:(NSEvent*)theEvent;
@end
#endif // ATOM_BROWSER_UI_COCOA_EVENT_PROCESSING_WINDOW_H_

View file

@ -1,106 +0,0 @@
// Copyright (c) 2013 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#import "atom/browser/ui/cocoa/event_processing_window.h"
#include "base/logging.h"
#import "content/public/browser/render_widget_host_view_mac_base.h"
@interface EventProcessingWindow ()
// Duplicate the given key event, but changing the associated window.
- (NSEvent*)keyEventForWindow:(NSWindow*)window fromKeyEvent:(NSEvent*)event;
@end
@implementation EventProcessingWindow
- (BOOL)redispatchKeyEvent:(NSEvent*)event {
DCHECK(event);
NSEventType eventType = [event type];
if (eventType != NSKeyDown &&
eventType != NSKeyUp &&
eventType != NSFlagsChanged) {
NOTREACHED();
return YES; // Pretend it's been handled in an effort to limit damage.
}
// Ordinarily, the event's window should be this window. However, when
// switching between normal and fullscreen mode, we switch out the window, and
// the event's window might be the previous window (or even an earlier one if
// the renderer is running slowly and several mode switches occur). In this
// rare case, we synthesize a new key event so that its associate window
// (number) is our own.
if ([event window] != self)
event = [self keyEventForWindow:self fromKeyEvent:event];
// Redispatch the event.
eventHandled_ = YES;
redispatchingEvent_ = YES;
[NSApp sendEvent:event];
redispatchingEvent_ = NO;
// If the event was not handled by [NSApp sendEvent:], the sendEvent:
// method below will be called, and because |redispatchingEvent_| is YES,
// |eventHandled_| will be set to NO.
return eventHandled_;
}
- (void)sendEvent:(NSEvent*)event {
if (!redispatchingEvent_)
[super sendEvent:event];
else
eventHandled_ = NO;
}
- (NSEvent*)keyEventForWindow:(NSWindow*)window fromKeyEvent:(NSEvent*)event {
NSEventType eventType = [event type];
// Convert the event's location from the original window's coordinates into
// our own.
NSPoint eventLoc = [event locationInWindow];
eventLoc = [self convertRectFromScreen:
[[event window] convertRectToScreen:NSMakeRect(eventLoc.x, eventLoc.y, 0, 0)]].origin;
// Various things *only* apply to key down/up.
BOOL eventIsARepeat = NO;
NSString* eventCharacters = nil;
NSString* eventUnmodCharacters = nil;
if (eventType == NSKeyDown || eventType == NSKeyUp) {
eventIsARepeat = [event isARepeat];
eventCharacters = [event characters];
eventUnmodCharacters = [event charactersIgnoringModifiers];
}
// This synthesis may be slightly imperfect: we provide nil for the context,
// since I (viettrungluu) am sceptical that putting in the original context
// (if one is given) is valid.
return [NSEvent keyEventWithType:eventType
location:eventLoc
modifierFlags:[event modifierFlags]
timestamp:[event timestamp]
windowNumber:[window windowNumber]
context:nil
characters:eventCharacters
charactersIgnoringModifiers:eventUnmodCharacters
isARepeat:eventIsARepeat
keyCode:[event keyCode]];
}
- (BOOL)performKeyEquivalent:(NSEvent*)event {
if (redispatchingEvent_)
return NO;
// Give the web site a chance to handle the event. If it doesn't want to
// handle it, it will call us back with one of the |handle*| methods above.
NSResponder* r = [self firstResponder];
if ([r conformsToProtocol:@protocol(RenderWidgetHostViewMacBase)])
return [r performKeyEquivalent:event];
if ([super performKeyEquivalent:event])
return YES;
return NO;
}
@end // EventProcessingWindow

View file

@ -92,7 +92,7 @@ class GtkMessageBox {
}
const char* TranslateToStock(int id, const std::string& text) {
std::string lower = base::StringToLowerASCII(text);
std::string lower = base::ToLowerASCII(text);
if (lower == "cancel")
return GTK_STOCK_CANCEL;
else if (lower == "no")

View file

@ -34,7 +34,7 @@ struct CommonButtonID {
int id;
};
CommonButtonID GetCommonID(const base::string16& button) {
base::string16 lower = base::StringToLowerASCII(button);
base::string16 lower = base::ToLowerASCII(button);
if (lower == L"ok")
return { TDCBF_OK_BUTTON, IDOK };
else if (lower == L"yes")

View file

@ -42,7 +42,7 @@ void SetWindowType(::Window xwindow, const std::string& type) {
XDisplay* xdisplay = gfx::GetXDisplay();
std::string type_prefix = "_NET_WM_WINDOW_TYPE_";
::Atom window_type = XInternAtom(
xdisplay, (type_prefix + base::StringToUpperASCII(type)).c_str(), False);
xdisplay, (type_prefix + base::ToUpperASCII(type)).c_str(), False);
XChangeProperty(xdisplay, xwindow,
XInternAtom(xdisplay, "_NET_WM_WINDOW_TYPE", False),
XA_ATOM,

View file

@ -36,8 +36,6 @@ FeaturePair kWebRuntimeFeatures[] = {
switches::kExperimentalCanvasFeatures },
{ options::kOverlayScrollbars,
switches::kOverlayScrollbars },
{ options::kOverlayFullscreenVideo,
switches::kOverlayFullscreenVideo },
{ options::kSharedWorker,
switches::kSharedWorker },
{ options::kPageVisibility,
@ -148,8 +146,6 @@ void WebContentsPreferences::OverrideWebkitPrefs(
prefs->javascript_enabled = b;
if (self->web_preferences_.GetBoolean("images", &b))
prefs->images_enabled = b;
if (self->web_preferences_.GetBoolean("java", &b))
prefs->java_enabled = b;
if (self->web_preferences_.GetBoolean("textAreasAreResizable", &b))
prefs->text_areas_are_resizable = b;
if (self->web_preferences_.GetBoolean("webgl", &b))