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 "chrome/browser/ui/gtk/tabs/tab_gtk.h" | 5 #include "chrome/browser/ui/gtk/tabs/tab_gtk.h" |
6 | 6 |
7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
11 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "chrome/app/chrome_command_ids.h" | 13 #include "chrome/app/chrome_command_ids.h" |
14 #include "chrome/browser/ui/gtk/accelerators_gtk.h" | 14 #include "chrome/browser/ui/gtk/accelerators_gtk.h" |
15 #include "chrome/browser/ui/gtk/gtk_input_event_box.h" | 15 #include "chrome/browser/ui/gtk/gtk_input_event_box.h" |
16 #include "chrome/browser/ui/gtk/menu_gtk.h" | 16 #include "chrome/browser/ui/gtk/menu_gtk.h" |
17 #include "chrome/browser/ui/gtk/tabs/tab_strip_menu_controller.h" | 17 #include "chrome/browser/ui/gtk/tabs/tab_strip_menu_controller.h" |
18 #include "chrome/browser/ui/tabs/tab_menu_model.h" | 18 #include "chrome/browser/ui/tabs/tab_menu_model.h" |
19 #include "chrome/browser/ui/tabs/tab_resources.h" | 19 #include "chrome/browser/ui/tabs/tab_resources.h" |
20 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
21 #include "grit/theme_resources.h" | 21 #include "grit/theme_resources.h" |
22 #include "ui/base/dragdrop/gtk_dnd_util.h" | 22 #include "ui/base/dragdrop/gtk_dnd_util.h" |
23 #include "ui/base/gtk/scoped_region.h" | 23 #include "ui/base/gtk/scoped_region.h" |
| 24 #include "ui/gfx/font_list.h" |
24 #include "ui/gfx/path.h" | 25 #include "ui/gfx/path.h" |
| 26 #include "ui/gfx/text_utils.h" |
25 | 27 |
26 using content::WebContents; | 28 using content::WebContents; |
27 | 29 |
28 namespace { | 30 namespace { |
29 | 31 |
30 // Returns the width of the title for the current font, in pixels. | 32 // Returns the width of the title for the current font, in pixels. |
31 int GetTitleWidth(gfx::Font* font, base::string16 title) { | 33 int GetTitleWidth(gfx::Font* font, base::string16 title) { |
32 DCHECK(font); | 34 DCHECK(font); |
33 if (title.empty()) | 35 if (title.empty()) |
34 return 0; | 36 return 0; |
35 | 37 |
36 return font->GetStringWidth(title); | 38 return gfx::GetStringWidth(title, gfx::FontList(*font)); |
37 } | 39 } |
38 | 40 |
39 } // namespace | 41 } // namespace |
40 | 42 |
41 class TabGtk::TabGtkObserverHelper { | 43 class TabGtk::TabGtkObserverHelper { |
42 public: | 44 public: |
43 explicit TabGtkObserverHelper(TabGtk* tab) | 45 explicit TabGtkObserverHelper(TabGtk* tab) |
44 : tab_(tab) { | 46 : tab_(tab) { |
45 base::MessageLoopForUI::current()->AddObserver(tab_); | 47 base::MessageLoopForUI::current()->AddObserver(tab_); |
46 } | 48 } |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 gdk_event_free(last_mouse_down_); | 377 gdk_event_free(last_mouse_down_); |
376 last_mouse_down_ = NULL; | 378 last_mouse_down_ = NULL; |
377 } | 379 } |
378 | 380 |
379 // Notify the drag helper that we're done with any potential drag operations. | 381 // Notify the drag helper that we're done with any potential drag operations. |
380 // Clean up the drag helper, which is re-created on the next mouse press. | 382 // Clean up the drag helper, which is re-created on the next mouse press. |
381 delegate_->EndDrag(canceled); | 383 delegate_->EndDrag(canceled); |
382 | 384 |
383 observer_.reset(); | 385 observer_.reset(); |
384 } | 386 } |
OLD | NEW |