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

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

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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
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 "content/browser/tab_contents/navigation_details.h" 16 #include "content/browser/tab_contents/navigation_details.h"
16 #include "content/browser/tab_contents/navigation_entry.h" 17 #include "content/browser/tab_contents/navigation_entry.h"
17 #include "content/common/notification_details.h" 18 #include "content/common/notification_details.h"
18 #include "content/common/notification_source.h" 19 #include "content/common/notification_source.h"
19 #include "ui/gfx/rect.h" 20 #include "ui/gfx/rect.h"
20 21
21 // The minimum space between the FindInPage window and the search result. 22 // The minimum space between the FindInPage window and the search result.
22 static const int kMinFindWndDistanceFromSelection = 5; 23 static const int kMinFindWndDistanceFromSelection = 5;
23 24
24 FindBarController::FindBarController(FindBar* find_bar) 25 FindBarController::FindBarController(FindBar* find_bar)
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // Hide any visible find window from the previous tab if NULL |tab_contents| 78 // Hide any visible find window from the previous tab if NULL |tab_contents|
78 // is passed in or if the find UI is not active in the new tab. 79 // is passed in or if the find UI is not active in the new tab.
79 if (find_bar_->IsFindBarVisible() && 80 if (find_bar_->IsFindBarVisible() &&
80 (!tab_contents_ || !tab_contents_->find_tab_helper()->find_ui_active())) { 81 (!tab_contents_ || !tab_contents_->find_tab_helper()->find_ui_active())) {
81 find_bar_->Hide(false); 82 find_bar_->Hide(false);
82 } 83 }
83 84
84 if (!tab_contents_) 85 if (!tab_contents_)
85 return; 86 return;
86 87
87 registrar_.Add(this, NotificationType::FIND_RESULT_AVAILABLE, 88 registrar_.Add(this, chrome::NOTIFICATION_FIND_RESULT_AVAILABLE,
88 Source<TabContents>(tab_contents_->tab_contents())); 89 Source<TabContents>(tab_contents_->tab_contents()));
89 registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED, 90 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
90 Source<NavigationController>(&tab_contents_->controller())); 91 Source<NavigationController>(&tab_contents_->controller()));
91 92
92 MaybeSetPrepopulateText(); 93 MaybeSetPrepopulateText();
93 94
94 if (tab_contents_->find_tab_helper()->find_ui_active()) { 95 if (tab_contents_->find_tab_helper()->find_ui_active()) {
95 // A tab with a visible find bar just got selected and we need to show the 96 // A tab with a visible find bar just got selected and we need to show the
96 // find bar but without animation since it was already animated into its 97 // find bar but without animation since it was already animated into its
97 // visible state. We also want to reset the window location so that 98 // visible state. We also want to reset the window location so that
98 // we don't surprise the user by popping up to the left for no apparent 99 // we don't surprise the user by popping up to the left for no apparent
99 // reason. 100 // reason.
100 find_bar_->Show(false); 101 find_bar_->Show(false);
101 } 102 }
102 103
103 UpdateFindBarForCurrentResult(); 104 UpdateFindBarForCurrentResult();
104 } 105 }
105 106
106 //////////////////////////////////////////////////////////////////////////////// 107 ////////////////////////////////////////////////////////////////////////////////
107 // FindBarHost, NotificationObserver implementation: 108 // FindBarHost, NotificationObserver implementation:
108 109
109 void FindBarController::Observe(NotificationType type, 110 void FindBarController::Observe(int type,
110 const NotificationSource& source, 111 const NotificationSource& source,
111 const NotificationDetails& details) { 112 const NotificationDetails& details) {
112 FindTabHelper* find_tab_helper = tab_contents_->find_tab_helper(); 113 FindTabHelper* find_tab_helper = tab_contents_->find_tab_helper();
113 if (type == NotificationType::FIND_RESULT_AVAILABLE) { 114 if (type == chrome::NOTIFICATION_FIND_RESULT_AVAILABLE) {
114 // Don't update for notifications from TabContentses other than the one we 115 // Don't update for notifications from TabContentses other than the one we
115 // are actively tracking. 116 // are actively tracking.
116 if (Source<TabContents>(source).ptr() == tab_contents_->tab_contents()) { 117 if (Source<TabContents>(source).ptr() == tab_contents_->tab_contents()) {
117 UpdateFindBarForCurrentResult(); 118 UpdateFindBarForCurrentResult();
118 if (find_tab_helper->find_result().final_update() && 119 if (find_tab_helper->find_result().final_update() &&
119 find_tab_helper->find_result().number_of_matches() == 0) { 120 find_tab_helper->find_result().number_of_matches() == 0) {
120 const string16& last_search = find_tab_helper->previous_find_text(); 121 const string16& last_search = find_tab_helper->previous_find_text();
121 const string16& current_search = find_tab_helper->find_text(); 122 const string16& current_search = find_tab_helper->find_text();
122 if (last_search.find(current_search) != 0) 123 if (last_search.find(current_search) != 0)
123 find_bar_->AudibleAlert(); 124 find_bar_->AudibleAlert();
124 } 125 }
125 } 126 }
126 } else if (type == NotificationType::NAV_ENTRY_COMMITTED) { 127 } else if (type == content::NOTIFICATION_NAV_ENTRY_COMMITTED) {
127 NavigationController* source_controller = 128 NavigationController* source_controller =
128 Source<NavigationController>(source).ptr(); 129 Source<NavigationController>(source).ptr();
129 if (source_controller == &tab_contents_->controller()) { 130 if (source_controller == &tab_contents_->controller()) {
130 content::LoadCommittedDetails* commit_details = 131 content::LoadCommittedDetails* commit_details =
131 Details<content::LoadCommittedDetails>(details).ptr(); 132 Details<content::LoadCommittedDetails>(details).ptr();
132 PageTransition::Type transition_type = 133 PageTransition::Type transition_type =
133 commit_details->entry->transition_type(); 134 commit_details->entry->transition_type();
134 // We hide the FindInPage window when the user navigates away, except on 135 // We hide the FindInPage window when the user navigates away, except on
135 // reload. 136 // reload.
136 if (find_bar_->IsFindBarVisible()) { 137 if (find_bar_->IsFindBarVisible()) {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 // shown it is showing the right state for this tab. We update the find text 229 // shown it is showing the right state for this tab. We update the find text
229 // _first_ since the FindBarView checks its emptiness to see if it should 230 // _first_ since the FindBarView checks its emptiness to see if it should
230 // clear the result count display when there's nothing in the box. 231 // clear the result count display when there's nothing in the box.
231 find_bar_->SetFindText(find_string); 232 find_bar_->SetFindText(find_string);
232 #else 233 #else
233 // Having a per-tab find_string is not compatible with OS X's find pasteboard, 234 // Having a per-tab find_string is not compatible with OS X's find pasteboard,
234 // so we always have the same find text in all find bars. This is done through 235 // so we always have the same find text in all find bars. This is done through
235 // the find pasteboard mechanism, so don't set the text here. 236 // the find pasteboard mechanism, so don't set the text here.
236 #endif 237 #endif
237 } 238 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/find_bar/find_bar_controller.h ('k') | chrome/browser/ui/find_bar/find_tab_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698