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

Side by Side Diff: chrome/browser/ui/views/find_bar_view.cc

Issue 6675005: Integrate the new input method API for Views into Chromium. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Windows build. Created 9 years, 8 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/ui/views/find_bar_view.h ('k') | chrome/browser/ui/views/frame/browser_view.cc » ('j') | 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) 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/views/find_bar_view.h" 5 #include "chrome/browser/ui/views/find_bar_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 81
82 // The default number of average characters that the text box will be. This 82 // The default number of average characters that the text box will be. This
83 // number brings the width on a "regular fonts" system to about 300px. 83 // number brings the width on a "regular fonts" system to about 300px.
84 static const int kDefaultCharWidth = 43; 84 static const int kDefaultCharWidth = 43;
85 85
86 //////////////////////////////////////////////////////////////////////////////// 86 ////////////////////////////////////////////////////////////////////////////////
87 // FindBarView, public: 87 // FindBarView, public:
88 88
89 FindBarView::FindBarView(FindBarHost* host) 89 FindBarView::FindBarView(FindBarHost* host)
90 : DropdownBarView(host), 90 : DropdownBarView(host),
91 #if defined(OS_LINUX)
92 ignore_contents_changed_(false),
93 #endif
94 find_text_(NULL), 91 find_text_(NULL),
95 match_count_text_(NULL), 92 match_count_text_(NULL),
96 focus_forwarder_view_(NULL), 93 focus_forwarder_view_(NULL),
97 find_previous_button_(NULL), 94 find_previous_button_(NULL),
98 find_next_button_(NULL), 95 find_next_button_(NULL),
99 close_button_(NULL) { 96 close_button_(NULL) {
100 SetID(VIEW_ID_FIND_IN_PAGE); 97 SetID(VIEW_ID_FIND_IN_PAGE);
101 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 98 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
102 99
103 find_text_ = new SearchTextfieldView(); 100 find_text_ = new SearchTextfieldView();
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 // Background images for the Find edit box. 169 // Background images for the Find edit box.
173 kBackground = rb.GetBitmapNamed(IDR_FIND_BOX_BACKGROUND); 170 kBackground = rb.GetBitmapNamed(IDR_FIND_BOX_BACKGROUND);
174 kBackground_left = rb.GetBitmapNamed(IDR_FIND_BOX_BACKGROUND_LEFT); 171 kBackground_left = rb.GetBitmapNamed(IDR_FIND_BOX_BACKGROUND_LEFT);
175 } 172 }
176 } 173 }
177 174
178 FindBarView::~FindBarView() { 175 FindBarView::~FindBarView() {
179 } 176 }
180 177
181 void FindBarView::SetFindText(const string16& find_text) { 178 void FindBarView::SetFindText(const string16& find_text) {
182 #if defined(OS_LINUX)
183 ignore_contents_changed_ = true;
184 #endif
185 find_text_->SetText(find_text); 179 find_text_->SetText(find_text);
186 #if defined(OS_LINUX)
187 ignore_contents_changed_ = false;
188 #endif
189 } 180 }
190 181
191 string16 FindBarView::GetFindText() const { 182 string16 FindBarView::GetFindText() const {
192 return find_text_->text(); 183 return find_text_->text();
193 } 184 }
194 185
195 string16 FindBarView::GetFindSelectedText() const { 186 string16 FindBarView::GetFindSelectedText() const {
196 return find_text_->GetSelectedText(); 187 return find_text_->GetSelectedText();
197 } 188 }
198 189
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 NOTREACHED() << L"Unknown button"; 453 NOTREACHED() << L"Unknown button";
463 break; 454 break;
464 } 455 }
465 } 456 }
466 457
467 //////////////////////////////////////////////////////////////////////////////// 458 ////////////////////////////////////////////////////////////////////////////////
468 // FindBarView, views::TextfieldController implementation: 459 // FindBarView, views::TextfieldController implementation:
469 460
470 void FindBarView::ContentsChanged(views::Textfield* sender, 461 void FindBarView::ContentsChanged(views::Textfield* sender,
471 const string16& new_contents) { 462 const string16& new_contents) {
472 #if defined(OS_LINUX)
473 // On gtk setting the text in the find view causes a notification.
474 if (ignore_contents_changed_)
475 return;
476 #endif
477
478 FindBarController* controller = find_bar_host()->GetFindBarController(); 463 FindBarController* controller = find_bar_host()->GetFindBarController();
479 DCHECK(controller); 464 DCHECK(controller);
480 // We must guard against a NULL tab_contents, which can happen if the text 465 // We must guard against a NULL tab_contents, which can happen if the text
481 // in the Find box is changed right after the tab is destroyed. Otherwise, it 466 // in the Find box is changed right after the tab is destroyed. Otherwise, it
482 // can lead to crashes, as exposed by automation testing in issue 8048. 467 // can lead to crashes, as exposed by automation testing in issue 8048.
483 if (!controller->tab_contents()) 468 if (!controller->tab_contents())
484 return; 469 return;
485 FindTabHelper* find_tab_helper = 470 FindTabHelper* find_tab_helper =
486 controller->tab_contents()->find_tab_helper(); 471 controller->tab_contents()->find_tab_helper();
487 472
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 555
571 void FindBarView::OnThemeChanged() { 556 void FindBarView::OnThemeChanged() {
572 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 557 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
573 if (GetThemeProvider()) { 558 if (GetThemeProvider()) {
574 close_button_->SetBackground( 559 close_button_->SetBackground(
575 GetThemeProvider()->GetColor(ThemeService::COLOR_TAB_TEXT), 560 GetThemeProvider()->GetColor(ThemeService::COLOR_TAB_TEXT),
576 rb.GetBitmapNamed(IDR_CLOSE_BAR), 561 rb.GetBitmapNamed(IDR_CLOSE_BAR),
577 rb.GetBitmapNamed(IDR_CLOSE_BAR_MASK)); 562 rb.GetBitmapNamed(IDR_CLOSE_BAR_MASK));
578 } 563 }
579 } 564 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/find_bar_view.h ('k') | chrome/browser/ui/views/frame/browser_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698