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

Side by Side Diff: chrome/browser/ui/find_bar/find_bar_controller.cc

Issue 8983012: Get rid of content::NavigationController in cc file and use "using" instead. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 11 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
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/find_bar/find_bar_controller.h" 5 #include "chrome/browser/ui/find_bar/find_bar_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
11 #include "chrome/browser/ui/find_bar/find_bar.h" 11 #include "chrome/browser/ui/find_bar/find_bar.h"
12 #include "chrome/browser/ui/find_bar/find_bar_state.h" 12 #include "chrome/browser/ui/find_bar/find_bar_state.h"
13 #include "chrome/browser/ui/find_bar/find_tab_helper.h" 13 #include "chrome/browser/ui/find_bar/find_tab_helper.h"
14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
15 #include "chrome/common/chrome_notification_types.h" 15 #include "chrome/common/chrome_notification_types.h"
16 #include "content/browser/tab_contents/tab_contents.h" 16 #include "content/browser/tab_contents/tab_contents.h"
17 #include "content/public/browser/navigation_details.h" 17 #include "content/public/browser/navigation_details.h"
18 #include "content/public/browser/navigation_entry.h" 18 #include "content/public/browser/navigation_entry.h"
19 #include "content/public/browser/notification_details.h" 19 #include "content/public/browser/notification_details.h"
20 #include "content/public/browser/notification_source.h" 20 #include "content/public/browser/notification_source.h"
21 #include "ui/gfx/rect.h" 21 #include "ui/gfx/rect.h"
22 22
23 using content::NavigationController;
23 using content::WebContents; 24 using content::WebContents;
24 25
25 // The minimum space between the FindInPage window and the search result. 26 // The minimum space between the FindInPage window and the search result.
26 static const int kMinFindWndDistanceFromSelection = 5; 27 static const int kMinFindWndDistanceFromSelection = 5;
27 28
28 FindBarController::FindBarController(FindBar* find_bar) 29 FindBarController::FindBarController(FindBar* find_bar)
29 : find_bar_(find_bar), 30 : find_bar_(find_bar),
30 tab_contents_(NULL), 31 tab_contents_(NULL),
31 last_reported_matchcount_(0) { 32 last_reported_matchcount_(0) {
32 } 33 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 88
88 if (!tab_contents_) 89 if (!tab_contents_)
89 return; 90 return;
90 91
91 registrar_.Add(this, 92 registrar_.Add(this,
92 chrome::NOTIFICATION_FIND_RESULT_AVAILABLE, 93 chrome::NOTIFICATION_FIND_RESULT_AVAILABLE,
93 content::Source<WebContents>(tab_contents_->tab_contents())); 94 content::Source<WebContents>(tab_contents_->tab_contents()));
94 registrar_.Add( 95 registrar_.Add(
95 this, 96 this,
96 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 97 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
97 content::Source<content::NavigationController>( 98 content::Source<NavigationController>(
98 &tab_contents_->web_contents()->GetController())); 99 &tab_contents_->web_contents()->GetController()));
99 100
100 MaybeSetPrepopulateText(); 101 MaybeSetPrepopulateText();
101 102
102 if (tab_contents_->find_tab_helper()->find_ui_active()) { 103 if (tab_contents_->find_tab_helper()->find_ui_active()) {
103 // A tab with a visible find bar just got selected and we need to show the 104 // A tab with a visible find bar just got selected and we need to show the
104 // find bar but without animation since it was already animated into its 105 // find bar but without animation since it was already animated into its
105 // visible state. We also want to reset the window location so that 106 // visible state. We also want to reset the window location so that
106 // we don't surprise the user by popping up to the left for no apparent 107 // we don't surprise the user by popping up to the left for no apparent
107 // reason. 108 // reason.
(...skipping 18 matching lines...) Expand all
126 UpdateFindBarForCurrentResult(); 127 UpdateFindBarForCurrentResult();
127 if (find_tab_helper->find_result().final_update() && 128 if (find_tab_helper->find_result().final_update() &&
128 find_tab_helper->find_result().number_of_matches() == 0) { 129 find_tab_helper->find_result().number_of_matches() == 0) {
129 const string16& last_search = find_tab_helper->previous_find_text(); 130 const string16& last_search = find_tab_helper->previous_find_text();
130 const string16& current_search = find_tab_helper->find_text(); 131 const string16& current_search = find_tab_helper->find_text();
131 if (last_search.find(current_search) != 0) 132 if (last_search.find(current_search) != 0)
132 find_bar_->AudibleAlert(); 133 find_bar_->AudibleAlert();
133 } 134 }
134 } 135 }
135 } else if (type == content::NOTIFICATION_NAV_ENTRY_COMMITTED) { 136 } else if (type == content::NOTIFICATION_NAV_ENTRY_COMMITTED) {
136 content::NavigationController* source_controller = 137 NavigationController* source_controller =
137 content::Source<content::NavigationController>(source).ptr(); 138 content::Source<NavigationController>(source).ptr();
138 if (source_controller == &tab_contents_->web_contents()->GetController()) { 139 if (source_controller == &tab_contents_->web_contents()->GetController()) {
139 content::LoadCommittedDetails* commit_details = 140 content::LoadCommittedDetails* commit_details =
140 content::Details<content::LoadCommittedDetails>(details).ptr(); 141 content::Details<content::LoadCommittedDetails>(details).ptr();
141 content::PageTransition transition_type = 142 content::PageTransition transition_type =
142 commit_details->entry->GetTransitionType(); 143 commit_details->entry->GetTransitionType();
143 // We hide the FindInPage window when the user navigates away, except on 144 // We hide the FindInPage window when the user navigates away, except on
144 // reload. 145 // reload.
145 if (find_bar_->IsFindBarVisible()) { 146 if (find_bar_->IsFindBarVisible()) {
146 if (content::PageTransitionStripQualifier(transition_type) != 147 if (content::PageTransitionStripQualifier(transition_type) !=
147 content::PAGE_TRANSITION_RELOAD) { 148 content::PAGE_TRANSITION_RELOAD) {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 // shown it is showing the right state for this tab. We update the find text 238 // shown it is showing the right state for this tab. We update the find text
238 // _first_ since the FindBarView checks its emptiness to see if it should 239 // _first_ since the FindBarView checks its emptiness to see if it should
239 // clear the result count display when there's nothing in the box. 240 // clear the result count display when there's nothing in the box.
240 find_bar_->SetFindText(find_string); 241 find_bar_->SetFindText(find_string);
241 #else 242 #else
242 // Having a per-tab find_string is not compatible with OS X's find pasteboard, 243 // Having a per-tab find_string is not compatible with OS X's find pasteboard,
243 // so we always have the same find text in all find bars. This is done through 244 // so we always have the same find text in all find bars. This is done through
244 // the find pasteboard mechanism, so don't set the text here. 245 // the find pasteboard mechanism, so don't set the text here.
245 #endif 246 #endif
246 } 247 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698