Skip to content

Commit f829f2e

Browse files
committed
Merge pull request electron#1002 from atom/chrome40
Upgrade to Chrome 40
2 parents de151ce + 0087f8d commit f829f2e

File tree

72 files changed

+494
-365
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+494
-365
lines changed

atom/app/atom_content_client.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ class AtomContentClient : public brightray::ContentClient {
1919

2020
protected:
2121
// content::ContentClient:
22-
virtual std::string GetProduct() const OVERRIDE;
23-
virtual void AddAdditionalSchemes(
22+
std::string GetProduct() const override;
23+
void AddAdditionalSchemes(
2424
std::vector<std::string>* standard_schemes,
25-
std::vector<std::string>* savable_schemes) OVERRIDE;
25+
std::vector<std::string>* savable_schemes) override;
2626

2727
private:
2828
DISALLOW_COPY_AND_ASSIGN(AtomContentClient);

atom/app/atom_main.cc

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,14 @@
1313
#include <fcntl.h>
1414

1515
#include <windows.h>
16+
#include <shellscalingapi.h>
17+
#include <tchar.h>
1618
#include <shellapi.h>
1719

1820
#include "atom/app/atom_main_delegate.h"
1921
#include "atom/common/crash_reporter/win/crash_service_main.h"
2022
#include "base/environment.h"
23+
#include "base/win/windows_version.h"
2124
#include "content/public/app/startup_helper_win.h"
2225
#include "sandbox/win/src/sandbox_types.h"
2326
#include "ui/gfx/win/dpi.h"
@@ -37,6 +40,48 @@ int Start(int argc, char *argv[]);
3740

3841
#if defined(OS_WIN)
3942

43+
namespace {
44+
45+
// Win8.1 supports monitor-specific DPI scaling.
46+
bool SetProcessDpiAwarenessWrapper(PROCESS_DPI_AWARENESS value) {
47+
typedef HRESULT(WINAPI *SetProcessDpiAwarenessPtr)(PROCESS_DPI_AWARENESS);
48+
SetProcessDpiAwarenessPtr set_process_dpi_awareness_func =
49+
reinterpret_cast<SetProcessDpiAwarenessPtr>(
50+
GetProcAddress(GetModuleHandleA("user32.dll"),
51+
"SetProcessDpiAwarenessInternal"));
52+
if (set_process_dpi_awareness_func) {
53+
HRESULT hr = set_process_dpi_awareness_func(value);
54+
if (SUCCEEDED(hr)) {
55+
VLOG(1) << "SetProcessDpiAwareness succeeded.";
56+
return true;
57+
} else if (hr == E_ACCESSDENIED) {
58+
LOG(ERROR) << "Access denied error from SetProcessDpiAwareness. "
59+
"Function called twice, or manifest was used.";
60+
}
61+
}
62+
return false;
63+
}
64+
65+
// This function works for Windows Vista through Win8. Win8.1 must use
66+
// SetProcessDpiAwareness[Wrapper].
67+
BOOL SetProcessDPIAwareWrapper() {
68+
typedef BOOL(WINAPI *SetProcessDPIAwarePtr)(VOID);
69+
SetProcessDPIAwarePtr set_process_dpi_aware_func =
70+
reinterpret_cast<SetProcessDPIAwarePtr>(
71+
GetProcAddress(GetModuleHandleA("user32.dll"),
72+
"SetProcessDPIAware"));
73+
return set_process_dpi_aware_func &&
74+
set_process_dpi_aware_func();
75+
}
76+
77+
void EnableHighDPISupport() {
78+
if (!SetProcessDpiAwarenessWrapper(PROCESS_SYSTEM_DPI_AWARE)) {
79+
SetProcessDPIAwareWrapper();
80+
}
81+
}
82+
83+
} // namespace
84+
4085
int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
4186
int argc = 0;
4287
wchar_t** wargv = ::CommandLineToArgvW(::GetCommandLineW(), &argc);
@@ -103,8 +148,11 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
103148
content::InitializeSandboxInfo(&sandbox_info);
104149
atom::AtomMainDelegate delegate;
105150

106-
// Now chrome relies on a regkey to enable high dpi support.
107-
gfx::EnableHighDPISupport();
151+
// We don't want to set DPI awareness on pre-Win7 because we don't support
152+
// DirectWrite there. GDI fonts are kerned very badly, so better to leave
153+
// DPI-unaware and at effective 1.0. See also ShouldUseDirectWrite().
154+
if (base::win::GetVersion() >= base::win::VERSION_WIN7)
155+
EnableHighDPISupport();
108156

109157
content::ContentMainParams params(&delegate);
110158
params.instance = instance;

atom/browser/api/atom_api_auto_updater.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,20 @@ class AutoUpdater : public mate::EventEmitter,
2626
virtual ~AutoUpdater();
2727

2828
// AutoUpdaterDelegate implementations.
29-
virtual void OnError(const std::string& error) OVERRIDE;
30-
virtual void OnCheckingForUpdate() OVERRIDE;
31-
virtual void OnUpdateAvailable() OVERRIDE;
32-
virtual void OnUpdateNotAvailable() OVERRIDE;
33-
virtual void OnUpdateDownloaded(
29+
void OnError(const std::string& error) override;
30+
void OnCheckingForUpdate() override;
31+
void OnUpdateAvailable() override;
32+
void OnUpdateNotAvailable() override;
33+
void OnUpdateDownloaded(
3434
const std::string& release_notes,
3535
const std::string& release_name,
3636
const base::Time& release_date,
3737
const std::string& update_url,
38-
const base::Closure& quit_and_install) OVERRIDE;
38+
const base::Closure& quit_and_install) override;
3939

4040
// mate::Wrappable implementations:
41-
virtual mate::ObjectTemplateBuilder GetObjectTemplateBuilder(
42-
v8::Isolate* isolate);
41+
mate::ObjectTemplateBuilder GetObjectTemplateBuilder(
42+
v8::Isolate* isolate) override;
4343

4444
private:
4545
void QuitAndInstall();

atom/browser/api/atom_api_global_shortcut.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ class GlobalShortcut : public extensions::GlobalShortcutListener::Observer,
2828
virtual ~GlobalShortcut();
2929

3030
// mate::Wrappable implementations:
31-
virtual mate::ObjectTemplateBuilder GetObjectTemplateBuilder(
32-
v8::Isolate* isolate) OVERRIDE;
31+
mate::ObjectTemplateBuilder GetObjectTemplateBuilder(
32+
v8::Isolate* isolate) override;
3333

3434
private:
3535
typedef std::map<ui::Accelerator, base::Closure> AcceleratorCallbackMap;
@@ -41,7 +41,7 @@ class GlobalShortcut : public extensions::GlobalShortcutListener::Observer,
4141
void UnregisterAll();
4242

4343
// GlobalShortcutListener::Observer implementation.
44-
virtual void OnKeyPressed(const ui::Accelerator& accelerator) OVERRIDE;
44+
void OnKeyPressed(const ui::Accelerator& accelerator) override;
4545

4646
AcceleratorCallbackMap accelerator_callback_map_;
4747

atom/browser/api/atom_api_menu_mac.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ class MenuMac : public Menu {
1919
protected:
2020
MenuMac();
2121

22-
virtual void Popup(Window* window) OVERRIDE;
23-
virtual void PopupAt(Window* window, int x, int y) OVERRIDE;
22+
void Popup(Window* window) override;
23+
void PopupAt(Window* window, int x, int y) override;
2424

2525
base::scoped_nsobject<AtomMenuController> menu_controller_;
2626

atom/browser/api/atom_api_menu_views.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ class MenuViews : public Menu {
1717
MenuViews();
1818

1919
protected:
20-
virtual void Popup(Window* window) OVERRIDE;
21-
virtual void PopupAt(Window* window, int x, int y) OVERRIDE;
20+
void Popup(Window* window) override;
21+
void PopupAt(Window* window, int x, int y) override;
2222

2323
private:
2424
void PopupAtPoint(Window* window, const gfx::Point& point);

atom/browser/api/atom_api_power_monitor.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ class PowerMonitor : public mate::EventEmitter,
2424
virtual ~PowerMonitor();
2525

2626
// base::PowerObserver implementations:
27-
virtual void OnPowerStateChange(bool on_battery_power) OVERRIDE;
28-
virtual void OnSuspend() OVERRIDE;
29-
virtual void OnResume() OVERRIDE;
27+
void OnPowerStateChange(bool on_battery_power) override;
28+
void OnSuspend() override;
29+
void OnResume() override;
3030

3131
private:
3232
DISALLOW_COPY_AND_ASSIGN(PowerMonitor);

atom/browser/api/atom_api_protocol.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class CustomProtocolRequestJob : public AdapterRequestJob {
5353
}
5454

5555
// AdapterRequestJob:
56-
virtual void GetJobTypeInUI() OVERRIDE {
56+
void GetJobTypeInUI() override {
5757
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
5858

5959
v8::Isolate* isolate = v8::Isolate::GetCurrent();
@@ -128,9 +128,9 @@ class CustomProtocolHandler : public ProtocolHandler {
128128
: registry_(registry), protocol_handler_(protocol_handler) {
129129
}
130130

131-
virtual net::URLRequestJob* MaybeCreateJob(
131+
net::URLRequestJob* MaybeCreateJob(
132132
net::URLRequest* request,
133-
net::NetworkDelegate* network_delegate) const OVERRIDE {
133+
net::NetworkDelegate* network_delegate) const override {
134134
return new CustomProtocolRequestJob(registry_, protocol_handler_.get(),
135135
request, network_delegate);
136136
}

atom/browser/api/atom_api_web_contents.cc

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -247,14 +247,14 @@ void WebContents::RenderViewReady() {
247247
// WebContents::GetRenderWidgetHostView will return the RWHV of an
248248
// interstitial page if one is showing at this time. We only want opacity
249249
// to apply to web pages.
250-
web_contents()->GetRenderViewHost()->GetView()->
251-
SetBackgroundOpaque(guest_opaque_);
252-
253-
content::RenderViewHost* rvh = web_contents()->GetRenderViewHost();
254-
if (auto_size_enabled_) {
255-
rvh->EnableAutoResize(min_auto_size_, max_auto_size_);
250+
if (guest_opaque_) {
251+
web_contents()
252+
->GetRenderViewHost()
253+
->GetView()
254+
->SetBackgroundColorToDefault();
256255
} else {
257-
rvh->DisableAutoResize(element_size_);
256+
web_contents()->GetRenderViewHost()->GetView()->SetBackgroundColor(
257+
SK_ColorTRANSPARENT);
258258
}
259259
}
260260

@@ -498,7 +498,15 @@ void WebContents::SetAllowTransparency(bool allow) {
498498
if (!web_contents()->GetRenderViewHost()->GetView())
499499
return;
500500

501-
web_contents()->GetRenderViewHost()->GetView()->SetBackgroundOpaque(!allow);
501+
if (guest_opaque_) {
502+
web_contents()
503+
->GetRenderViewHost()
504+
->GetView()
505+
->SetBackgroundColorToDefault();
506+
} else {
507+
web_contents()->GetRenderViewHost()->GetView()->SetBackgroundColor(
508+
SK_ColorTRANSPARENT);
509+
}
502510
}
503511

504512
mate::ObjectTemplateBuilder WebContents::GetObjectTemplateBuilder(

atom/browser/api/event.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ class Event : public Wrappable,
3434
virtual ~Event();
3535

3636
// Wrappable implementations:
37-
virtual ObjectTemplateBuilder GetObjectTemplateBuilder(v8::Isolate* isolate);
37+
ObjectTemplateBuilder GetObjectTemplateBuilder(v8::Isolate* isolate) override;
3838

3939
// content::WebContentsObserver implementations:
40-
virtual void WebContentsDestroyed() OVERRIDE;
40+
void WebContentsDestroyed() override;
4141

4242
private:
4343
// Replyer for the synchronous messages.

0 commit comments

Comments
 (0)