OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/shell/shell.h" | 5 #include "content/shell/shell.h" |
6 | 6 |
7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/string_piece.h" | 11 #include "base/string_piece.h" |
12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
13 #include "content/public/browser/browser_context.h" | 13 #include "content/public/browser/browser_context.h" |
14 #include "content/public/browser/native_web_keyboard_event.h" | 14 #include "content/public/browser/native_web_keyboard_event.h" |
15 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
16 #include "content/public/browser/web_contents_view.h" | 16 #include "content/public/browser/web_contents_view.h" |
17 #include "content/public/common/renderer_preferences.h" | 17 #include "content/public/common/renderer_preferences.h" |
18 #include "content/shell/shell_browser_context.h" | 18 #include "content/shell/shell_browser_context.h" |
19 #include "content/shell/shell_content_browser_client.h" | 19 #include "content/shell/shell_content_browser_client.h" |
20 #include "third_party/skia/include/core/SkColor.h" | |
21 | 20 |
22 namespace content { | 21 namespace content { |
23 | 22 |
24 namespace { | 23 namespace { |
25 | 24 |
26 // Callback for Debug > Show web inspector... menu item. | 25 // Callback for Debug > Show web inspector... menu item. |
27 gboolean ShowWebInspectorActivated(GtkWidget* widget, Shell* shell) { | 26 gboolean ShowWebInspectorActivated(GtkWidget* widget, Shell* shell) { |
28 shell->ShowDevTools(); | 27 shell->ShowDevTools(); |
29 return FALSE; // Don't stop this message. | 28 return FALSE; // Don't stop this message. |
30 } | 29 } |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 | 182 |
184 gtk_container_add(GTK_CONTAINER(window_), vbox_); | 183 gtk_container_add(GTK_CONTAINER(window_), vbox_); |
185 gtk_widget_show_all(GTK_WIDGET(window_)); | 184 gtk_widget_show_all(GTK_WIDGET(window_)); |
186 | 185 |
187 SizeTo(width, height); | 186 SizeTo(width, height); |
188 } | 187 } |
189 | 188 |
190 void Shell::PlatformSetContents() { | 189 void Shell::PlatformSetContents() { |
191 WebContentsView* content_view = web_contents_->GetView(); | 190 WebContentsView* content_view = web_contents_->GetView(); |
192 gtk_container_add(GTK_CONTAINER(vbox_), content_view->GetNativeView()); | 191 gtk_container_add(GTK_CONTAINER(vbox_), content_view->GetNativeView()); |
193 | |
194 // As an additional requirement on Linux, we must set the colors for the | |
195 // render widgets in webkit. | |
196 content::RendererPreferences* prefs = | |
197 web_contents_->GetMutableRendererPrefs(); | |
198 prefs->focus_ring_color = SkColorSetARGB(255, 229, 151, 0); | |
199 prefs->thumb_active_color = SkColorSetRGB(244, 244, 244); | |
200 prefs->thumb_inactive_color = SkColorSetRGB(234, 234, 234); | |
201 prefs->track_color = SkColorSetRGB(211, 211, 211); | |
202 | |
203 prefs->active_selection_bg_color = SkColorSetRGB(30, 144, 255); | |
204 prefs->active_selection_fg_color = SK_ColorWHITE; | |
205 prefs->inactive_selection_bg_color = SkColorSetRGB(200, 200, 200); | |
206 prefs->inactive_selection_fg_color = SkColorSetRGB(50, 50, 50); | |
207 } | 192 } |
208 | 193 |
209 void Shell::SizeTo(int width, int height) { | 194 void Shell::SizeTo(int width, int height) { |
210 content_width_ = width; | 195 content_width_ = width; |
211 content_height_ = height; | 196 content_height_ = height; |
212 if (web_contents_.get()) { | 197 if (web_contents_.get()) { |
213 gtk_widget_set_size_request(web_contents_->GetNativeView(), width, height); | 198 gtk_widget_set_size_request(web_contents_->GetNativeView(), width, height); |
214 } | 199 } |
215 } | 200 } |
216 | 201 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 gtk_widget_grab_focus(GTK_WIDGET(url_edit_view_)); | 267 gtk_widget_grab_focus(GTK_WIDGET(url_edit_view_)); |
283 return TRUE; | 268 return TRUE; |
284 } | 269 } |
285 | 270 |
286 void Shell::PlatformSetTitle(const string16& title) { | 271 void Shell::PlatformSetTitle(const string16& title) { |
287 std::string title_utf8 = UTF16ToUTF8(title); | 272 std::string title_utf8 = UTF16ToUTF8(title); |
288 gtk_window_set_title(GTK_WINDOW(window_), title_utf8.c_str()); | 273 gtk_window_set_title(GTK_WINDOW(window_), title_utf8.c_str()); |
289 } | 274 } |
290 | 275 |
291 } // namespace content | 276 } // namespace content |
OLD | NEW |