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

Side by Side Diff: chrome/browser/views/location_bar/location_bar_view.cc

Issue 3025009: Revert 53198 - Some first run fixes:... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 5 months 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
« no previous file with comments | « chrome/browser/views/location_bar/location_bar_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 bubble_type_(FirstRun::MINIMALBUBBLE) { 102 ALLOW_THIS_IN_INITIALIZER_LIST(first_run_bubble_(this)) {
103 DCHECK(profile_); 103 DCHECK(profile_);
104 SetID(VIEW_ID_LOCATION_BAR); 104 SetID(VIEW_ID_LOCATION_BAR);
105 SetFocusable(true); 105 SetFocusable(true);
106 106
107 if (mode_ == NORMAL) 107 if (mode_ == NORMAL)
108 painter_.reset(new views::HorizontalPainter(kNormalModeBackgroundImages)); 108 painter_.reset(new views::HorizontalPainter(kNormalModeBackgroundImages));
109 } 109 }
110 110
111 LocationBarView::~LocationBarView() { 111 LocationBarView::~LocationBarView() {
112 // This is in case we're destroyed before the model loads. This is safe
113 // if we're not a registered observer.
114 if (profile_->GetTemplateURLModel())
115 profile_->GetTemplateURLModel()->RemoveObserver(this);
116 } 112 }
117 113
118 void LocationBarView::Init() { 114 void LocationBarView::Init() {
119 if (mode_ == POPUP) { 115 if (mode_ == POPUP) {
120 font_ = ResourceBundle::GetSharedInstance().GetFont( 116 font_ = ResourceBundle::GetSharedInstance().GetFont(
121 ResourceBundle::BaseFont); 117 ResourceBundle::BaseFont);
122 } else { 118 } else {
123 // Use a larger version of the system font. 119 // Use a larger version of the system font.
124 font_ = font_.DeriveFont(3); 120 font_ = font_.DeriveFont(3);
125 } 121 }
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 bool LocationBarView::CanStartDrag(View* sender, 939 bool LocationBarView::CanStartDrag(View* sender,
944 const gfx::Point& press_pt, 940 const gfx::Point& press_pt,
945 const gfx::Point& p) { 941 const gfx::Point& p) {
946 return true; 942 return true;
947 } 943 }
948 944
949 //////////////////////////////////////////////////////////////////////////////// 945 ////////////////////////////////////////////////////////////////////////////////
950 // LocationBarView, LocationBar implementation: 946 // LocationBarView, LocationBar implementation:
951 947
952 void LocationBarView::ShowFirstRunBubble(FirstRun::BubbleType bubble_type) { 948 void LocationBarView::ShowFirstRunBubble(FirstRun::BubbleType bubble_type) {
953 // Wait until search engines have loaded to show the first run bubble. 949 // We wait 30 milliseconds to open. It allows less flicker.
954 if (!profile_->GetTemplateURLModel()->loaded()) { 950 Task* task = first_run_bubble_.NewRunnableMethod(
955 bubble_type_ = bubble_type; 951 &LocationBarView::ShowFirstRunBubbleInternal, bubble_type);
956 profile_->GetTemplateURLModel()->AddObserver(this); 952 MessageLoop::current()->PostDelayedTask(FROM_HERE, task, 30);
957 profile_->GetTemplateURLModel()->Load();
958 return;
959 }
960 ShowFirstRunBubbleInternal(bubble_type);
961 } 953 }
962 954
963 std::wstring LocationBarView::GetInputString() const { 955 std::wstring LocationBarView::GetInputString() const {
964 return location_input_; 956 return location_input_;
965 } 957 }
966 958
967 WindowOpenDisposition LocationBarView::GetWindowOpenDisposition() const { 959 WindowOpenDisposition LocationBarView::GetWindowOpenDisposition() const {
968 return disposition_; 960 return disposition_;
969 } 961 }
970 962
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 page_action_views_[i]->image_view()->ExecuteAction(kLeftMouseButton, 1028 page_action_views_[i]->image_view()->ExecuteAction(kLeftMouseButton,
1037 false); // inspect_with_devtools 1029 false); // inspect_with_devtools
1038 return; 1030 return;
1039 } 1031 }
1040 ++current; 1032 ++current;
1041 } 1033 }
1042 } 1034 }
1043 1035
1044 NOTREACHED(); 1036 NOTREACHED();
1045 } 1037 }
1046
1047 void LocationBarView::OnTemplateURLModelChanged() {
1048 if (profile_->GetTemplateURLModel())
1049 profile_->GetTemplateURLModel()->RemoveObserver(this);
1050 ShowFirstRunBubble(bubble_type_);
1051 }
1052
OLDNEW
« no previous file with comments | « chrome/browser/views/location_bar/location_bar_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698