Skip to content

Commit fe15442

Browse files
committed
Don't store DictionaryValue in Shell and don't occupy accelarate key.
1 parent f6e4d6b commit fe15442

12 files changed

Lines changed: 84 additions & 221 deletions

src/browser/app_controller_mac.mm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,3 @@ - (void) applicationDidFinishLaunching: (NSNotification *) note {
4545
}
4646

4747
@end
48-

src/browser/shell_application_mac.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
// CrAppControlProtocol:
2121
- (void)setHandlingSendEvent:(BOOL)handlingSendEvent;
2222

23-
- (IBAction)newDocument:(id)sender;
24-
2523
@end
2624

2725
#endif // CONTENT_NW_SRC_BROWSER_SHELL_APPLICATION_MAC_H_

src/browser/shell_application_mac.mm

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,4 @@ - (void)setHandlingSendEvent:(BOOL)handlingSendEvent {
2727
handlingSendEvent_ = handlingSendEvent;
2828
}
2929

30-
- (IBAction)newDocument:(id)sender {
31-
content::ShellBrowserContext* browserContext =
32-
static_cast<content::ShellContentBrowserClient*>(
33-
content::GetContentClient()->browser())->browser_context();
34-
content::Shell::CreateNewWindow(browserContext,
35-
GURL("nw:blank"),
36-
NULL,
37-
MSG_ROUTING_NONE,
38-
NULL);
39-
}
40-
4130
@end

src/nw_package.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ bool Package::InitFromPath() {
211211
return false;
212212
}
213213

214-
// Force window field no empty
214+
// Force window field no empty.
215215
if (!root_->HasKey(switches::kmWindow))
216216
root_->Set(switches::kmWindow, new base::DictionaryValue());
217217

@@ -226,7 +226,7 @@ void Package::InitWithDefault() {
226226
base::DictionaryValue* window = new base::DictionaryValue();
227227
root()->Set(switches::kmWindow, window);
228228

229-
// Hide toolbar is specifed in the command line
229+
// Hide toolbar if specifed in the command line.
230230
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoToolbar))
231231
window->SetBoolean(switches::kmToolbar, false);
232232
}

src/resource.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99

1010

1111
#define IDR_MAINFRAME 128
12-
#define IDM_EXIT 105
13-
#define IDM_CLOSE_WINDOW 106
14-
#define IDM_NEW_WINDOW 107
1512
#define IDM_SHOW_DEVELOPER_TOOLS 108
1613
#define IDC_CONTENTSHELL 109
1714
#define IDD_ALERT 130

src/shell.cc

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,17 @@ Shell::Shell(WebContents* web_contents, base::DictionaryValue* manifest)
5858
url_edit_view_(NULL),
5959
force_close_(false),
6060
id_(-1),
61-
window_manifest_(manifest),
6261
is_show_devtools_(false),
6362
is_toolbar_open_(true),
63+
is_desktop_(false),
64+
x_(-1),
65+
y_(-1),
6466
max_height_(-1),
6567
max_width_(-1),
6668
min_height_(-1),
67-
min_width_(-1)
69+
min_width_(-1),
70+
position_("center"),
71+
title_("node-webkit")
6872
#if defined(OS_WIN)
6973
, default_edit_wnd_proc_(0)
7074
#endif
@@ -77,10 +81,15 @@ Shell::Shell(WebContents* web_contents, base::DictionaryValue* manifest)
7781
// Read manifest into members.
7882
manifest->GetBoolean(switches::kmToolbar, &is_toolbar_open_);
7983
manifest->GetBoolean(switches::kDeveloper, &is_show_devtools_);
84+
manifest->GetBoolean(switches::kmAsDesktop, &is_desktop_);
85+
manifest->GetInteger(switches::kmX, &x_);
86+
manifest->GetInteger(switches::kmY, &y_);
8087
manifest->GetInteger(switches::kmMaxHeight, &max_height_);
8188
manifest->GetInteger(switches::kmMaxWidth, &max_width_);
8289
manifest->GetInteger(switches::kmMinHeight, &min_height_);
8390
manifest->GetInteger(switches::kmMinWidth, &min_width_);
91+
manifest->GetString(switches::kmPosition, &position_);
92+
manifest->GetString(switches::kmTitle, &title_);
8493

8594
int width = 700;
8695
int height = 450;
@@ -153,18 +162,12 @@ Shell* Shell::CreateNewWindow(BrowserContext* browser_context,
153162
routing_id,
154163
base_web_contents);
155164

156-
// Create with package's manifest
157-
base::DictionaryValue *manifest = GetPackage()->window();
158-
manifest->SetBoolean(switches::kDeveloper,
159-
CommandLine::ForCurrentProcess()->HasSwitch(switches::kDeveloper));
160-
161-
// Center window by default
162-
if (!manifest->HasKey(switches::kmPosition))
163-
manifest->SetString(switches::kmPosition, "center");
165+
// Create with package's manifest.
166+
scoped_ptr<base::DictionaryValue> manifest(
167+
GetPackage()->window()->DeepCopy());
164168

165-
Shell* shell = new Shell(web_contents, manifest);
166-
if (!url.is_empty())
167-
shell->LoadURL(url);
169+
Shell* shell = new Shell(web_contents, manifest.get());
170+
shell->LoadURL(url);
168171
return shell;
169172
}
170173

src/shell.h

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -213,13 +213,6 @@ class Shell : public WebContentsDelegate,
213213
CHROMEGTK_CALLBACK_0(Shell, void, OnStopButtonClicked);
214214
CHROMEGTK_CALLBACK_0(Shell, void, OnURLEntryActivate);
215215
CHROMEGTK_CALLBACK_0(Shell, gboolean, OnWindowDestroyed);
216-
217-
CHROMEG_CALLBACK_3(Shell, gboolean, OnCloseWindowKeyPressed, GtkAccelGroup*,
218-
GObject*, guint, GdkModifierType);
219-
CHROMEG_CALLBACK_3(Shell, gboolean, OnNewWindowKeyPressed, GtkAccelGroup*,
220-
GObject*, guint, GdkModifierType);
221-
CHROMEG_CALLBACK_3(Shell, gboolean, OnHighlightURLView, GtkAccelGroup*,
222-
GObject*, guint, GdkModifierType);
223216
#endif
224217

225218
scoped_ptr<ShellJavaScriptDialogCreator> dialog_creator_;
@@ -239,13 +232,14 @@ class Shell : public WebContentsDelegate,
239232
int id_;
240233

241234
// Window manifest
242-
base::DictionaryValue* window_manifest_;
243235
bool is_show_devtools_;
244236
bool is_toolbar_open_;
245-
int max_height_;
246-
int max_width_;
247-
int min_height_;
248-
int min_width_;
237+
bool is_desktop_;
238+
int x_, y_;
239+
int max_height_, max_width_;
240+
int min_height_, min_width_;
241+
std::string position_;
242+
std::string title_;
249243

250244
#if defined(OS_WIN)
251245
WNDPROC default_edit_wnd_proc_;

src/shell.rc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,6 @@ LANGUAGE 9, 1
2424

2525
IDC_CONTENTSHELL MENU
2626
BEGIN
27-
POPUP "&File"
28-
BEGIN
29-
MENUITEM "&New Window", IDM_NEW_WINDOW
30-
MENUITEM "&Close Window", IDM_CLOSE_WINDOW
31-
MENUITEM "E&xit", IDM_EXIT
32-
END
3327
POPUP "&Debug"
3428
BEGIN
3529
MENUITEM "&Show Developer Tools...", IDM_SHOW_DEVELOPER_TOOLS

src/shell_browser_main_parts.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "base/string_number_conversions.h"
2727
#include "base/threading/thread.h"
2828
#include "base/threading/thread_restrictions.h"
29+
#include "base/values.h"
2930
#include "content/nw/src/browser/shell_devtools_delegate.h"
3031
#include "content/nw/src/common/shell_switches.h"
3132
#include "content/nw/src/nw_package.h"
@@ -104,10 +105,14 @@ void ShellBrowserMainParts::Init() {
104105
Shell::PlatformInitialize();
105106
net::NetModule::SetResourceProvider(PlatformResourceProvider);
106107

108+
// See if we're in developer mode.
109+
CommandLine& command_line = *CommandLine::ForCurrentProcess();
110+
package()->root()->SetBoolean(switches::kDeveloper,
111+
command_line.HasSwitch(switches::kDeveloper));
112+
107113
int port = 0;
108114
// See if the user specified a port on the command line (useful for
109115
// automation). If not, use an ephemeral port by specifying 0.
110-
CommandLine& command_line = *CommandLine::ForCurrentProcess();
111116
if (command_line.HasSwitch(switches::kRemoteDebuggingPort)) {
112117
int temp_port;
113118
std::string port_str =

src/shell_gtk.cc

Lines changed: 15 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
// Copyright (c) 2012 Intel Corp
22
// Copyright (c) 2012 The Chromium Authors
3-
//
4-
// Permission is hereby granted, free of charge, to any person obtaining a copy
3+
//
4+
// Permission is hereby granted, free of charge, to any person obtaining a copy
55
// of this software and associated documentation files (the "Software"), to deal
66
// in the Software without restriction, including without limitation the rights
77
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell co
88
// pies of the Software, and to permit persons to whom the Software is furnished
99
// to do so, subject to the following conditions:
10-
//
10+
//
1111
// The above copyright notice and this permission notice shall be included in al
1212
// l copies or substantial portions of the Software.
13-
//
13+
//
1414
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IM
1515
// PLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNES
1616
// S FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
@@ -161,35 +161,23 @@ void Shell::PlatformCreateWindow(int width, int height) {
161161
g_signal_connect(G_OBJECT(window_), "destroy",
162162
G_CALLBACK(OnWindowDestroyedThunk), this);
163163

164-
std::string title = "node-webkit";
165-
166164
// window.as_desktop, the window will be used as a desktop background window
167-
bool as_desktop = false;
168-
if (window_manifest_ &&
169-
window_manifest_->GetBoolean(switches::kmAsDesktop, &as_desktop) &&
170-
as_desktop) {
171-
gtk_window_set_type_hint(window_, GDK_WINDOW_TYPE_HINT_DESKTOP);
165+
if (is_desktop_) {
166+
gtk_window_set_type_hint(window_, GDK_WINDOW_TYPE_HINT_DESKTOP);
172167
GdkScreen* screen = gtk_window_get_screen(window_);
173168
gtk_window_set_default_size(window_,
174169
gdk_screen_get_width(screen),
175170
gdk_screen_get_height(screen));
176-
}
177-
178-
if (window_manifest_ && !as_desktop) {
179-
// window.x and window.y
180-
int x, y;
181-
if (window_manifest_->GetInteger(switches::kmX, &x) &&
182-
window_manifest_->GetInteger(switches::kmY, &y)) {
171+
} else {
172+
if (x_ > 0 && y_ > 0) {
173+
// window.x and window.y
183174
gtk_window_move(window_, x, y);
184175
} else {
185176
// window.postion
186-
std::string desription;
187-
if (window_manifest_->GetString(switches::kmPosition, &desription)) {
188-
if (desription == "center")
189-
gtk_window_set_position(window_, GTK_WIN_POS_CENTER);
190-
else if (desription == "mouse")
191-
gtk_window_set_position(window_, GTK_WIN_POS_MOUSE);
192-
}
177+
if (position_ == "center")
178+
gtk_window_set_position(window_, GTK_WIN_POS_CENTER);
179+
else if (position_ == "mouse")
180+
gtk_window_set_position(window_, GTK_WIN_POS_MOUSE);
193181
}
194182

195183
GdkGeometry geometry = { 0 };
@@ -205,7 +193,7 @@ void Shell::PlatformCreateWindow(int width, int height) {
205193
if (max_width_ > 0) {
206194
hints |= GDK_HINT_MAX_SIZE;
207195
geometry.max_width = max_width_;
208-
}
196+
}
209197
if (max_height_ > 0) {
210198
hints |= GDK_HINT_MAX_SIZE;
211199
geometry.max_height = max_height_;
@@ -214,12 +202,9 @@ void Shell::PlatformCreateWindow(int width, int height) {
214202
gtk_window_set_geometry_hints(
215203
window_, GTK_WIDGET(window_), &geometry, (GdkWindowHints)hints);
216204
}
217-
218-
// window.title
219-
window_manifest_->GetString(switches::kmTitle, &title);
220205
}
221206

222-
gtk_window_set_title(window_, title.c_str());
207+
gtk_window_set_title(window_, title_.c_str());
223208

224209
vbox_ = gtk_vbox_new(FALSE, 0);
225210

@@ -229,23 +214,6 @@ void Shell::PlatformCreateWindow(int width, int height) {
229214
gtk_box_pack_start(GTK_BOX(vbox_), menu_bar, FALSE, FALSE, 0);
230215
}
231216

232-
// Create the object that mediates accelerators.
233-
GtkAccelGroup* accel_group = gtk_accel_group_new();
234-
gtk_window_add_accel_group(GTK_WINDOW(window_), accel_group);
235-
236-
// Set global window handling accelerators:
237-
gtk_accel_group_connect(
238-
accel_group, GDK_w, GDK_CONTROL_MASK,
239-
GTK_ACCEL_VISIBLE,
240-
g_cclosure_new(G_CALLBACK(OnCloseWindowKeyPressedThunk),
241-
this, NULL));
242-
243-
gtk_accel_group_connect(
244-
accel_group, GDK_n, GDK_CONTROL_MASK,
245-
GTK_ACCEL_VISIBLE,
246-
g_cclosure_new(G_CALLBACK(OnNewWindowKeyPressedThunk),
247-
this, NULL));
248-
249217
GtkWidget* toolbar = gtk_toolbar_new();
250218
// Turn off the labels on the toolbar buttons.
251219
gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS);
@@ -254,24 +222,16 @@ void Shell::PlatformCreateWindow(int width, int height) {
254222
g_signal_connect(back_button_, "clicked",
255223
G_CALLBACK(&OnBackButtonClickedThunk), this);
256224
gtk_toolbar_insert(GTK_TOOLBAR(toolbar), back_button_, -1 /* append */);
257-
gtk_widget_add_accelerator(GTK_WIDGET(back_button_), "clicked", accel_group,
258-
GDK_Left, GDK_MOD1_MASK, GTK_ACCEL_VISIBLE);
259225

260226
forward_button_ = gtk_tool_button_new_from_stock(GTK_STOCK_GO_FORWARD);
261227
g_signal_connect(forward_button_, "clicked",
262228
G_CALLBACK(&OnForwardButtonClickedThunk), this);
263229
gtk_toolbar_insert(GTK_TOOLBAR(toolbar), forward_button_, -1 /* append */);
264-
gtk_widget_add_accelerator(GTK_WIDGET(forward_button_), "clicked",
265-
accel_group,
266-
GDK_Right, GDK_MOD1_MASK, GTK_ACCEL_VISIBLE);
267230

268231
reload_button_ = gtk_tool_button_new_from_stock(GTK_STOCK_REFRESH);
269232
g_signal_connect(reload_button_, "clicked",
270233
G_CALLBACK(&OnReloadButtonClickedThunk), this);
271234
gtk_toolbar_insert(GTK_TOOLBAR(toolbar), reload_button_, -1 /* append */);
272-
gtk_widget_add_accelerator(GTK_WIDGET(reload_button_), "clicked",
273-
accel_group,
274-
GDK_r, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
275235

276236
stop_button_ = gtk_tool_button_new_from_stock(GTK_STOCK_STOP);
277237
g_signal_connect(stop_button_, "clicked",
@@ -282,12 +242,6 @@ void Shell::PlatformCreateWindow(int width, int height) {
282242
g_signal_connect(G_OBJECT(url_edit_view_), "activate",
283243
G_CALLBACK(&OnURLEntryActivateThunk), this);
284244

285-
gtk_accel_group_connect(
286-
accel_group, GDK_l, GDK_CONTROL_MASK,
287-
GTK_ACCEL_VISIBLE,
288-
g_cclosure_new(G_CALLBACK(OnHighlightURLViewThunk),
289-
this, NULL));
290-
291245
GtkToolItem* tool_item = gtk_tool_item_new();
292246
gtk_container_add(GTK_CONTAINER(tool_item), url_edit_view_);
293247
gtk_tool_item_set_expand(tool_item, TRUE);
@@ -377,37 +331,6 @@ gboolean Shell::OnWindowDestroyed(GtkWidget* window) {
377331
return FALSE; // Don't stop this message.
378332
}
379333

380-
gboolean Shell::OnCloseWindowKeyPressed(GtkAccelGroup* accel_group,
381-
GObject* acceleratable,
382-
guint keyval,
383-
GdkModifierType modifier) {
384-
gtk_widget_destroy(GTK_WIDGET(window_));
385-
return TRUE;
386-
}
387-
388-
gboolean Shell::OnNewWindowKeyPressed(GtkAccelGroup* accel_group,
389-
GObject* acceleratable,
390-
guint keyval,
391-
GdkModifierType modifier) {
392-
ShellBrowserContext* browser_context =
393-
static_cast<ShellContentBrowserClient*>(
394-
GetContentClient()->browser())->browser_context();
395-
Shell::CreateNewWindow(browser_context,
396-
GURL(),
397-
NULL,
398-
MSG_ROUTING_NONE,
399-
NULL);
400-
return TRUE;
401-
}
402-
403-
gboolean Shell::OnHighlightURLView(GtkAccelGroup* accel_group,
404-
GObject* acceleratable,
405-
guint keyval,
406-
GdkModifierType modifier) {
407-
gtk_widget_grab_focus(GTK_WIDGET(url_edit_view_));
408-
return TRUE;
409-
}
410-
411334
void Shell::PlatformSetTitle(const string16& title) {
412335
std::string title_utf8 = UTF16ToUTF8(title);
413336
gtk_window_set_title(GTK_WINDOW(window_), title_utf8.c_str());

0 commit comments

Comments
 (0)