| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/views/location_bar/location_bar_view.h" | 5 #include "chrome/browser/views/location_bar/location_bar_view.h" |
| 6 | 6 |
| 7 #if defined(OS_LINUX) | 7 #if defined(OS_LINUX) |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 delegate_(delegate), | 92 delegate_(delegate), |
| 93 disposition_(CURRENT_TAB), | 93 disposition_(CURRENT_TAB), |
| 94 location_icon_view_(NULL), | 94 location_icon_view_(NULL), |
| 95 ev_bubble_view_(NULL), | 95 ev_bubble_view_(NULL), |
| 96 location_entry_view_(NULL), | 96 location_entry_view_(NULL), |
| 97 selected_keyword_view_(NULL), | 97 selected_keyword_view_(NULL), |
| 98 keyword_hint_view_(NULL), | 98 keyword_hint_view_(NULL), |
| 99 star_view_(NULL), | 99 star_view_(NULL), |
| 100 mode_(mode), | 100 mode_(mode), |
| 101 show_focus_rect_(false), | 101 show_focus_rect_(false), |
| 102 ALLOW_THIS_IN_INITIALIZER_LIST(first_run_bubble_(this)) { | 102 bubble_type_(FirstRun::MINIMALBUBBLE), |
| 103 template_url_model_(NULL) { |
| 103 DCHECK(profile_); | 104 DCHECK(profile_); |
| 104 SetID(VIEW_ID_LOCATION_BAR); | 105 SetID(VIEW_ID_LOCATION_BAR); |
| 105 SetFocusable(true); | 106 SetFocusable(true); |
| 106 | 107 |
| 107 if (mode_ == NORMAL) | 108 if (mode_ == NORMAL) |
| 108 painter_.reset(new views::HorizontalPainter(kNormalModeBackgroundImages)); | 109 painter_.reset(new views::HorizontalPainter(kNormalModeBackgroundImages)); |
| 109 } | 110 } |
| 110 | 111 |
| 111 LocationBarView::~LocationBarView() { | 112 LocationBarView::~LocationBarView() { |
| 113 if (template_url_model_) |
| 114 template_url_model_->RemoveObserver(this); |
| 112 } | 115 } |
| 113 | 116 |
| 114 void LocationBarView::Init() { | 117 void LocationBarView::Init() { |
| 115 if (mode_ == POPUP) { | 118 if (mode_ == POPUP) { |
| 116 font_ = ResourceBundle::GetSharedInstance().GetFont( | 119 font_ = ResourceBundle::GetSharedInstance().GetFont( |
| 117 ResourceBundle::BaseFont); | 120 ResourceBundle::BaseFont); |
| 118 } else { | 121 } else { |
| 119 // Use a larger version of the system font. | 122 // Use a larger version of the system font. |
| 120 font_ = font_.DeriveFont(3); | 123 font_ = font_.DeriveFont(3); |
| 121 } | 124 } |
| (...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 939 bool LocationBarView::CanStartDrag(View* sender, | 942 bool LocationBarView::CanStartDrag(View* sender, |
| 940 const gfx::Point& press_pt, | 943 const gfx::Point& press_pt, |
| 941 const gfx::Point& p) { | 944 const gfx::Point& p) { |
| 942 return true; | 945 return true; |
| 943 } | 946 } |
| 944 | 947 |
| 945 //////////////////////////////////////////////////////////////////////////////// | 948 //////////////////////////////////////////////////////////////////////////////// |
| 946 // LocationBarView, LocationBar implementation: | 949 // LocationBarView, LocationBar implementation: |
| 947 | 950 |
| 948 void LocationBarView::ShowFirstRunBubble(FirstRun::BubbleType bubble_type) { | 951 void LocationBarView::ShowFirstRunBubble(FirstRun::BubbleType bubble_type) { |
| 949 // We wait 30 milliseconds to open. It allows less flicker. | 952 // Wait until search engines have loaded to show the first run bubble. |
| 950 Task* task = first_run_bubble_.NewRunnableMethod( | 953 if (!profile_->GetTemplateURLModel()->loaded()) { |
| 951 &LocationBarView::ShowFirstRunBubbleInternal, bubble_type); | 954 bubble_type_ = bubble_type; |
| 952 MessageLoop::current()->PostDelayedTask(FROM_HERE, task, 30); | 955 template_url_model_ = profile_->GetTemplateURLModel(); |
| 956 template_url_model_->AddObserver(this); |
| 957 template_url_model_->Load(); |
| 958 return; |
| 959 } |
| 960 ShowFirstRunBubbleInternal(bubble_type); |
| 953 } | 961 } |
| 954 | 962 |
| 955 std::wstring LocationBarView::GetInputString() const { | 963 std::wstring LocationBarView::GetInputString() const { |
| 956 return location_input_; | 964 return location_input_; |
| 957 } | 965 } |
| 958 | 966 |
| 959 WindowOpenDisposition LocationBarView::GetWindowOpenDisposition() const { | 967 WindowOpenDisposition LocationBarView::GetWindowOpenDisposition() const { |
| 960 return disposition_; | 968 return disposition_; |
| 961 } | 969 } |
| 962 | 970 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1028 page_action_views_[i]->image_view()->ExecuteAction(kLeftMouseButton, | 1036 page_action_views_[i]->image_view()->ExecuteAction(kLeftMouseButton, |
| 1029 false); // inspect_with_devtools | 1037 false); // inspect_with_devtools |
| 1030 return; | 1038 return; |
| 1031 } | 1039 } |
| 1032 ++current; | 1040 ++current; |
| 1033 } | 1041 } |
| 1034 } | 1042 } |
| 1035 | 1043 |
| 1036 NOTREACHED(); | 1044 NOTREACHED(); |
| 1037 } | 1045 } |
| 1046 |
| 1047 void LocationBarView::OnTemplateURLModelChanged() { |
| 1048 template_url_model_->RemoveObserver(this); |
| 1049 template_url_model_ = NULL; |
| 1050 ShowFirstRunBubble(bubble_type_); |
| 1051 } |
| 1052 |
| OLD | NEW |