Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(370)

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_gtk.cc

Issue 102593002: Convert string16 to base::string16 in content. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/browser/renderer_host/render_widget_host_view_gtk.h" 5 #include "content/browser/renderer_host/render_widget_host_view_gtk.h"
6 6
7 #include <cairo/cairo.h> 7 #include <cairo/cairo.h>
8 #include <gdk/gdk.h> 8 #include <gdk/gdk.h>
9 #include <gdk/gdkkeysyms.h> 9 #include <gdk/gdkkeysyms.h>
10 #include <gdk/gdkx.h> 10 #include <gdk/gdkx.h>
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 // See http://crbug.com/11847 for details. 922 // See http://crbug.com/11847 for details.
923 gtk_widget_destroy(view_.get()); 923 gtk_widget_destroy(view_.get());
924 } 924 }
925 925
926 // The RenderWidgetHost's destruction led here, so don't call it. 926 // The RenderWidgetHost's destruction led here, so don't call it.
927 host_ = NULL; 927 host_ = NULL;
928 928
929 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); 929 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this);
930 } 930 }
931 931
932 void RenderWidgetHostViewGtk::SetTooltipText(const string16& tooltip_text) { 932 void RenderWidgetHostViewGtk::SetTooltipText(
933 const base::string16& tooltip_text) {
933 // Maximum number of characters we allow in a tooltip. 934 // Maximum number of characters we allow in a tooltip.
934 const int kMaxTooltipLength = 8 << 10; 935 const int kMaxTooltipLength = 8 << 10;
935 // Clamp the tooltip length to kMaxTooltipLength so that we don't 936 // Clamp the tooltip length to kMaxTooltipLength so that we don't
936 // accidentally DOS the user with a mega tooltip (since GTK doesn't do 937 // accidentally DOS the user with a mega tooltip (since GTK doesn't do
937 // this itself). 938 // this itself).
938 // I filed https://bugzilla.gnome.org/show_bug.cgi?id=604641 upstream. 939 // I filed https://bugzilla.gnome.org/show_bug.cgi?id=604641 upstream.
939 const string16 clamped_tooltip = 940 const base::string16 clamped_tooltip =
940 gfx::TruncateString(tooltip_text, kMaxTooltipLength); 941 gfx::TruncateString(tooltip_text, kMaxTooltipLength);
941 942
942 if (clamped_tooltip.empty()) { 943 if (clamped_tooltip.empty()) {
943 gtk_widget_set_has_tooltip(view_.get(), FALSE); 944 gtk_widget_set_has_tooltip(view_.get(), FALSE);
944 } else { 945 } else {
945 gtk_widget_set_tooltip_text(view_.get(), 946 gtk_widget_set_tooltip_text(view_.get(),
946 UTF16ToUTF8(clamped_tooltip).c_str()); 947 UTF16ToUTF8(clamped_tooltip).c_str());
947 } 948 }
948 } 949 }
949 950
950 void RenderWidgetHostViewGtk::SelectionChanged(const string16& text, 951 void RenderWidgetHostViewGtk::SelectionChanged(const base::string16& text,
951 size_t offset, 952 size_t offset,
952 const gfx::Range& range) { 953 const gfx::Range& range) {
953 RenderWidgetHostViewBase::SelectionChanged(text, offset, range); 954 RenderWidgetHostViewBase::SelectionChanged(text, offset, range);
954 955
955 if (text.empty() || range.is_empty()) 956 if (text.empty() || range.is_empty())
956 return; 957 return;
957 size_t pos = range.GetMin() - offset; 958 size_t pos = range.GetMin() - offset;
958 size_t n = range.length(); 959 size_t n = range.length();
959 960
960 DCHECK(pos + n <= text.length()) << "The text can not fully cover range."; 961 DCHECK(pos + n <= text.length()) << "The text can not fully cover range.";
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
1340 GDK_CURRENT_TIME); 1341 GDK_CURRENT_TIME);
1341 1342
1342 if (grab_status != GDK_GRAB_SUCCESS) { 1343 if (grab_status != GDK_GRAB_SUCCESS) {
1343 LOG(WARNING) << "Failed to grab pointer for LockMouse. " 1344 LOG(WARNING) << "Failed to grab pointer for LockMouse. "
1344 << "gdk_pointer_grab returned: " << grab_status; 1345 << "gdk_pointer_grab returned: " << grab_status;
1345 mouse_locked_ = false; 1346 mouse_locked_ = false;
1346 return false; 1347 return false;
1347 } 1348 }
1348 1349
1349 // Clear the tooltip window. 1350 // Clear the tooltip window.
1350 SetTooltipText(string16()); 1351 SetTooltipText(base::string16());
1351 1352
1352 // Ensure that the widget center location will be relevant for this mouse 1353 // Ensure that the widget center location will be relevant for this mouse
1353 // lock session. It is updated whenever the window geometry moves 1354 // lock session. It is updated whenever the window geometry moves
1354 // but may be out of date due to switching tabs. 1355 // but may be out of date due to switching tabs.
1355 MarkCachedWidgetCenterStale(); 1356 MarkCachedWidgetCenterStale();
1356 1357
1357 return true; 1358 return true;
1358 } 1359 }
1359 1360
1360 void RenderWidgetHostViewGtk::UnlockMouse() { 1361 void RenderWidgetHostViewGtk::UnlockMouse() {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1404 DCHECK(offset <= selection_text_.length()); 1405 DCHECK(offset <= selection_text_.length());
1405 1406
1406 if (offset == selection_text_.length()) { 1407 if (offset == selection_text_.length()) {
1407 *text = UTF16ToUTF8(selection_text_); 1408 *text = UTF16ToUTF8(selection_text_);
1408 *cursor_index = text->length(); 1409 *cursor_index = text->length();
1409 return true; 1410 return true;
1410 } 1411 }
1411 1412
1412 *text = base::UTF16ToUTF8AndAdjustOffset( 1413 *text = base::UTF16ToUTF8AndAdjustOffset(
1413 base::StringPiece16(selection_text_), &offset); 1414 base::StringPiece16(selection_text_), &offset);
1414 if (offset == string16::npos) { 1415 if (offset == base::string16::npos) {
1415 NOTREACHED() << "Invalid offset in UTF16 string."; 1416 NOTREACHED() << "Invalid offset in UTF16 string.";
1416 return false; 1417 return false;
1417 } 1418 }
1418 *cursor_index = offset; 1419 *cursor_index = offset;
1419 return true; 1420 return true;
1420 } 1421 }
1421 1422
1422 void RenderWidgetHostViewGtk::set_last_mouse_down(GdkEventButton* event) { 1423 void RenderWidgetHostViewGtk::set_last_mouse_down(GdkEventButton* event) {
1423 GdkEventButton* temp = NULL; 1424 GdkEventButton* temp = NULL;
1424 if (event) { 1425 if (event) {
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1591 gfx::PluginWindowHandle id) { 1592 gfx::PluginWindowHandle id) {
1592 plugin_container_manager_.CreatePluginContainer(id); 1593 plugin_container_manager_.CreatePluginContainer(id);
1593 } 1594 }
1594 1595
1595 void RenderWidgetHostViewGtk::OnDestroyPluginContainer( 1596 void RenderWidgetHostViewGtk::OnDestroyPluginContainer(
1596 gfx::PluginWindowHandle id) { 1597 gfx::PluginWindowHandle id) {
1597 plugin_container_manager_.DestroyPluginContainer(id); 1598 plugin_container_manager_.DestroyPluginContainer(id);
1598 } 1599 }
1599 1600
1600 } // namespace content 1601 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698