| 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::PAGE_TRANSITION_TYPED | |
| 170 content::PAGE_TRANSITION_FROM_ADDRESS_BAR), |
| 171 first_run_bubble_(this), | 171 first_run_bubble_(this), |
| 172 popup_window_mode_(false), | 172 popup_window_mode_(false), |
| 173 theme_service_(NULL), | 173 theme_service_(NULL), |
| 174 hbox_width_(0), | 174 hbox_width_(0), |
| 175 entry_box_width_(0), | 175 entry_box_width_(0), |
| 176 show_selected_keyword_(false), | 176 show_selected_keyword_(false), |
| 177 show_keyword_hint_(false) { | 177 show_keyword_hint_(false) { |
| 178 } | 178 } |
| 179 | 179 |
| 180 LocationBarViewGtk::~LocationBarViewGtk() { | 180 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 | 456 // In GTK mode, we need our parent to redraw, as it draws the text entry |
| 457 // border. | 457 // border. |
| 458 gtk_widget_queue_draw(widget()->parent); | 458 gtk_widget_queue_draw(widget()->parent); |
| 459 } else { | 459 } else { |
| 460 gtk_widget_queue_draw(widget()); | 460 gtk_widget_queue_draw(widget()); |
| 461 } | 461 } |
| 462 } | 462 } |
| 463 | 463 |
| 464 void LocationBarViewGtk::OnAutocompleteAccept(const GURL& url, | 464 void LocationBarViewGtk::OnAutocompleteAccept(const GURL& url, |
| 465 WindowOpenDisposition disposition, | 465 WindowOpenDisposition disposition, |
| 466 PageTransition::Type transition, | 466 content::PageTransition transition, |
| 467 const GURL& alternate_nav_url) { | 467 const GURL& alternate_nav_url) { |
| 468 if (url.is_valid()) { | 468 if (url.is_valid()) { |
| 469 location_input_ = UTF8ToUTF16(url.spec()); | 469 location_input_ = UTF8ToUTF16(url.spec()); |
| 470 disposition_ = disposition; | 470 disposition_ = disposition; |
| 471 transition_ = transition | PageTransition::FROM_ADDRESS_BAR; | 471 transition_ = transition | content::PAGE_TRANSITION_FROM_ADDRESS_BAR; |
| 472 | 472 |
| 473 if (command_updater_) { | 473 if (command_updater_) { |
| 474 if (!alternate_nav_url.is_valid()) { | 474 if (!alternate_nav_url.is_valid()) { |
| 475 command_updater_->ExecuteCommand(IDC_OPEN_CURRENT_URL); | 475 command_updater_->ExecuteCommand(IDC_OPEN_CURRENT_URL); |
| 476 } else { | 476 } else { |
| 477 AlternateNavURLFetcher* fetcher = | 477 AlternateNavURLFetcher* fetcher = |
| 478 new AlternateNavURLFetcher(alternate_nav_url); | 478 new AlternateNavURLFetcher(alternate_nav_url); |
| 479 // The AlternateNavURLFetcher will listen for the pending navigation | 479 // The AlternateNavURLFetcher will listen for the pending navigation |
| 480 // notification that will be issued as a result of the "open URL." It | 480 // notification that will be issued as a result of the "open URL." It |
| 481 // will automatically install itself into that navigation controller. | 481 // will automatically install itself into that navigation controller. |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 } | 591 } |
| 592 | 592 |
| 593 string16 LocationBarViewGtk::GetInputString() const { | 593 string16 LocationBarViewGtk::GetInputString() const { |
| 594 return location_input_; | 594 return location_input_; |
| 595 } | 595 } |
| 596 | 596 |
| 597 WindowOpenDisposition LocationBarViewGtk::GetWindowOpenDisposition() const { | 597 WindowOpenDisposition LocationBarViewGtk::GetWindowOpenDisposition() const { |
| 598 return disposition_; | 598 return disposition_; |
| 599 } | 599 } |
| 600 | 600 |
| 601 PageTransition::Type LocationBarViewGtk::GetPageTransition() const { | 601 content::PageTransition LocationBarViewGtk::GetPageTransition() const { |
| 602 return transition_; | 602 return transition_; |
| 603 } | 603 } |
| 604 | 604 |
| 605 void LocationBarViewGtk::AcceptInput() { | 605 void LocationBarViewGtk::AcceptInput() { |
| 606 location_entry_->model()->AcceptInput(CURRENT_TAB, false); | 606 location_entry_->model()->AcceptInput(CURRENT_TAB, false); |
| 607 } | 607 } |
| 608 | 608 |
| 609 void LocationBarViewGtk::FocusLocation(bool select_all) { | 609 void LocationBarViewGtk::FocusLocation(bool select_all) { |
| 610 location_entry_->SetFocus(); | 610 location_entry_->SetFocus(); |
| 611 if (select_all) | 611 if (select_all) |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1046 if (!gtk_util::WidgetBounds(sender).Contains( | 1046 if (!gtk_util::WidgetBounds(sender).Contains( |
| 1047 gfx::Point(event->x, event->y))) { | 1047 gfx::Point(event->x, event->y))) { |
| 1048 return FALSE; | 1048 return FALSE; |
| 1049 } | 1049 } |
| 1050 | 1050 |
| 1051 GURL url; | 1051 GURL url; |
| 1052 if (!gtk_util::URLFromPrimarySelection(browser_->profile(), &url)) | 1052 if (!gtk_util::URLFromPrimarySelection(browser_->profile(), &url)) |
| 1053 return FALSE; | 1053 return FALSE; |
| 1054 | 1054 |
| 1055 tab->OpenURL(OpenURLParams( | 1055 tab->OpenURL(OpenURLParams( |
| 1056 url, GURL(), CURRENT_TAB, PageTransition::TYPED)); | 1056 url, GURL(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED)); |
| 1057 return TRUE; | 1057 return TRUE; |
| 1058 } | 1058 } |
| 1059 | 1059 |
| 1060 return FALSE; | 1060 return FALSE; |
| 1061 } | 1061 } |
| 1062 | 1062 |
| 1063 void LocationBarViewGtk::OnIconDragData(GtkWidget* sender, | 1063 void LocationBarViewGtk::OnIconDragData(GtkWidget* sender, |
| 1064 GdkDragContext* context, | 1064 GdkDragContext* context, |
| 1065 GtkSelectionData* data, | 1065 GtkSelectionData* data, |
| 1066 guint info, guint time) { | 1066 guint info, guint time) { |
| (...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1628 | 1628 |
| 1629 std::string badge_text = page_action_->GetBadgeText(tab_id); | 1629 std::string badge_text = page_action_->GetBadgeText(tab_id); |
| 1630 if (badge_text.empty()) | 1630 if (badge_text.empty()) |
| 1631 return FALSE; | 1631 return FALSE; |
| 1632 | 1632 |
| 1633 gfx::CanvasSkiaPaint canvas(event, false); | 1633 gfx::CanvasSkiaPaint canvas(event, false); |
| 1634 gfx::Rect bounding_rect(widget->allocation); | 1634 gfx::Rect bounding_rect(widget->allocation); |
| 1635 page_action_->PaintBadge(&canvas, bounding_rect, tab_id); | 1635 page_action_->PaintBadge(&canvas, bounding_rect, tab_id); |
| 1636 return FALSE; | 1636 return FALSE; |
| 1637 } | 1637 } |
| OLD | NEW |