OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/location_bar_view_gtk.h" | 5 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 #include "chrome/browser/ui/gtk/view_id_util.h" | 48 #include "chrome/browser/ui/gtk/view_id_util.h" |
49 #include "chrome/browser/ui/omnibox/location_bar_util.h" | 49 #include "chrome/browser/ui/omnibox/location_bar_util.h" |
50 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 50 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
51 #include "chrome/common/chrome_notification_types.h" | 51 #include "chrome/common/chrome_notification_types.h" |
52 #include "chrome/common/extensions/extension.h" | 52 #include "chrome/common/extensions/extension.h" |
53 #include "chrome/common/extensions/extension_action.h" | 53 #include "chrome/common/extensions/extension_action.h" |
54 #include "chrome/common/extensions/extension_resource.h" | 54 #include "chrome/common/extensions/extension_resource.h" |
55 #include "chrome/common/pref_names.h" | 55 #include "chrome/common/pref_names.h" |
56 #include "content/browser/tab_contents/tab_contents.h" | 56 #include "content/browser/tab_contents/tab_contents.h" |
57 #include "content/common/notification_service.h" | 57 #include "content/common/notification_service.h" |
58 #include "content/common/page_transition_types.h" | |
59 #include "grit/generated_resources.h" | 58 #include "grit/generated_resources.h" |
60 #include "grit/theme_resources.h" | 59 #include "grit/theme_resources.h" |
61 #include "grit/theme_resources_standard.h" | 60 #include "grit/theme_resources_standard.h" |
62 #include "net/base/net_util.h" | 61 #include "net/base/net_util.h" |
63 #include "ui/base/dragdrop/gtk_dnd_util.h" | 62 #include "ui/base/dragdrop/gtk_dnd_util.h" |
64 #include "ui/base/gtk/gtk_hig_constants.h" | 63 #include "ui/base/gtk/gtk_hig_constants.h" |
65 #include "ui/base/l10n/l10n_util.h" | 64 #include "ui/base/l10n/l10n_util.h" |
66 #include "ui/base/resource/resource_bundle.h" | 65 #include "ui/base/resource/resource_bundle.h" |
67 #include "ui/gfx/canvas_skia_paint.h" | 66 #include "ui/gfx/canvas_skia_paint.h" |
68 #include "ui/gfx/font.h" | 67 #include "ui/gfx/font.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 tab_to_search_full_label_(NULL), | 159 tab_to_search_full_label_(NULL), |
161 tab_to_search_partial_label_(NULL), | 160 tab_to_search_partial_label_(NULL), |
162 tab_to_search_hint_(NULL), | 161 tab_to_search_hint_(NULL), |
163 tab_to_search_hint_leading_label_(NULL), | 162 tab_to_search_hint_leading_label_(NULL), |
164 tab_to_search_hint_icon_(NULL), | 163 tab_to_search_hint_icon_(NULL), |
165 tab_to_search_hint_trailing_label_(NULL), | 164 tab_to_search_hint_trailing_label_(NULL), |
166 command_updater_(browser->command_updater()), | 165 command_updater_(browser->command_updater()), |
167 toolbar_model_(browser->toolbar_model()), | 166 toolbar_model_(browser->toolbar_model()), |
168 browser_(browser), | 167 browser_(browser), |
169 disposition_(CURRENT_TAB), | 168 disposition_(CURRENT_TAB), |
170 transition_(PageTransition::TYPED | PageTransition::FROM_ADDRESS_BAR), | 169 transition_(content::PageTransitionFromInt( |
| 170 content::PAGE_TRANSITION_TYPED | |
| 171 content::PAGE_TRANSITION_FROM_ADDRESS_BAR)), |
171 first_run_bubble_(this), | 172 first_run_bubble_(this), |
172 popup_window_mode_(false), | 173 popup_window_mode_(false), |
173 theme_service_(NULL), | 174 theme_service_(NULL), |
174 hbox_width_(0), | 175 hbox_width_(0), |
175 entry_box_width_(0), | 176 entry_box_width_(0), |
176 show_selected_keyword_(false), | 177 show_selected_keyword_(false), |
177 show_keyword_hint_(false) { | 178 show_keyword_hint_(false) { |
178 } | 179 } |
179 | 180 |
180 LocationBarViewGtk::~LocationBarViewGtk() { | 181 LocationBarViewGtk::~LocationBarViewGtk() { |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 // In GTK mode, we need our parent to redraw, as it draws the text entry | 457 // In GTK mode, we need our parent to redraw, as it draws the text entry |
457 // border. | 458 // border. |
458 gtk_widget_queue_draw(widget()->parent); | 459 gtk_widget_queue_draw(widget()->parent); |
459 } else { | 460 } else { |
460 gtk_widget_queue_draw(widget()); | 461 gtk_widget_queue_draw(widget()); |
461 } | 462 } |
462 } | 463 } |
463 | 464 |
464 void LocationBarViewGtk::OnAutocompleteAccept(const GURL& url, | 465 void LocationBarViewGtk::OnAutocompleteAccept(const GURL& url, |
465 WindowOpenDisposition disposition, | 466 WindowOpenDisposition disposition, |
466 PageTransition::Type transition, | 467 content::PageTransition transition, |
467 const GURL& alternate_nav_url) { | 468 const GURL& alternate_nav_url) { |
468 if (url.is_valid()) { | 469 if (url.is_valid()) { |
469 location_input_ = UTF8ToUTF16(url.spec()); | 470 location_input_ = UTF8ToUTF16(url.spec()); |
470 disposition_ = disposition; | 471 disposition_ = disposition; |
471 transition_ = transition | PageTransition::FROM_ADDRESS_BAR; | 472 transition_ = content::PageTransitionFromInt( |
| 473 transition | content::PAGE_TRANSITION_FROM_ADDRESS_BAR); |
472 | 474 |
473 if (command_updater_) { | 475 if (command_updater_) { |
474 if (!alternate_nav_url.is_valid()) { | 476 if (!alternate_nav_url.is_valid()) { |
475 command_updater_->ExecuteCommand(IDC_OPEN_CURRENT_URL); | 477 command_updater_->ExecuteCommand(IDC_OPEN_CURRENT_URL); |
476 } else { | 478 } else { |
477 AlternateNavURLFetcher* fetcher = | 479 AlternateNavURLFetcher* fetcher = |
478 new AlternateNavURLFetcher(alternate_nav_url); | 480 new AlternateNavURLFetcher(alternate_nav_url); |
479 // The AlternateNavURLFetcher will listen for the pending navigation | 481 // The AlternateNavURLFetcher will listen for the pending navigation |
480 // notification that will be issued as a result of the "open URL." It | 482 // notification that will be issued as a result of the "open URL." It |
481 // will automatically install itself into that navigation controller. | 483 // will automatically install itself into that navigation controller. |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 } | 593 } |
592 | 594 |
593 string16 LocationBarViewGtk::GetInputString() const { | 595 string16 LocationBarViewGtk::GetInputString() const { |
594 return location_input_; | 596 return location_input_; |
595 } | 597 } |
596 | 598 |
597 WindowOpenDisposition LocationBarViewGtk::GetWindowOpenDisposition() const { | 599 WindowOpenDisposition LocationBarViewGtk::GetWindowOpenDisposition() const { |
598 return disposition_; | 600 return disposition_; |
599 } | 601 } |
600 | 602 |
601 PageTransition::Type LocationBarViewGtk::GetPageTransition() const { | 603 content::PageTransition LocationBarViewGtk::GetPageTransition() const { |
602 return transition_; | 604 return transition_; |
603 } | 605 } |
604 | 606 |
605 void LocationBarViewGtk::AcceptInput() { | 607 void LocationBarViewGtk::AcceptInput() { |
606 location_entry_->model()->AcceptInput(CURRENT_TAB, false); | 608 location_entry_->model()->AcceptInput(CURRENT_TAB, false); |
607 } | 609 } |
608 | 610 |
609 void LocationBarViewGtk::FocusLocation(bool select_all) { | 611 void LocationBarViewGtk::FocusLocation(bool select_all) { |
610 location_entry_->SetFocus(); | 612 location_entry_->SetFocus(); |
611 if (select_all) | 613 if (select_all) |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1046 if (!gtk_util::WidgetBounds(sender).Contains( | 1048 if (!gtk_util::WidgetBounds(sender).Contains( |
1047 gfx::Point(event->x, event->y))) { | 1049 gfx::Point(event->x, event->y))) { |
1048 return FALSE; | 1050 return FALSE; |
1049 } | 1051 } |
1050 | 1052 |
1051 GURL url; | 1053 GURL url; |
1052 if (!gtk_util::URLFromPrimarySelection(browser_->profile(), &url)) | 1054 if (!gtk_util::URLFromPrimarySelection(browser_->profile(), &url)) |
1053 return FALSE; | 1055 return FALSE; |
1054 | 1056 |
1055 tab->OpenURL(OpenURLParams( | 1057 tab->OpenURL(OpenURLParams( |
1056 url, GURL(), CURRENT_TAB, PageTransition::TYPED)); | 1058 url, GURL(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED)); |
1057 return TRUE; | 1059 return TRUE; |
1058 } | 1060 } |
1059 | 1061 |
1060 return FALSE; | 1062 return FALSE; |
1061 } | 1063 } |
1062 | 1064 |
1063 void LocationBarViewGtk::OnIconDragData(GtkWidget* sender, | 1065 void LocationBarViewGtk::OnIconDragData(GtkWidget* sender, |
1064 GdkDragContext* context, | 1066 GdkDragContext* context, |
1065 GtkSelectionData* data, | 1067 GtkSelectionData* data, |
1066 guint info, guint time) { | 1068 guint info, guint time) { |
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1628 | 1630 |
1629 std::string badge_text = page_action_->GetBadgeText(tab_id); | 1631 std::string badge_text = page_action_->GetBadgeText(tab_id); |
1630 if (badge_text.empty()) | 1632 if (badge_text.empty()) |
1631 return FALSE; | 1633 return FALSE; |
1632 | 1634 |
1633 gfx::CanvasSkiaPaint canvas(event, false); | 1635 gfx::CanvasSkiaPaint canvas(event, false); |
1634 gfx::Rect bounding_rect(widget->allocation); | 1636 gfx::Rect bounding_rect(widget->allocation); |
1635 page_action_->PaintBadge(&canvas, bounding_rect, tab_id); | 1637 page_action_->PaintBadge(&canvas, bounding_rect, tab_id); |
1636 return FALSE; | 1638 return FALSE; |
1637 } | 1639 } |
OLD | NEW |