OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_UI_FIND_BAR_FIND_BAR_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_FIND_BAR_FIND_BAR_CONTROLLER_H_ |
6 #define CHROME_BROWSER_UI_FIND_BAR_FIND_BAR_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_FIND_BAR_FIND_BAR_CONTROLLER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "content/public/browser/notification_observer.h" | 10 #include "content/public/browser/notification_observer.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 // An enum listing the possible actions to take on a find-in-page results in | 34 // An enum listing the possible actions to take on a find-in-page results in |
35 // the Find box when ending the find session. | 35 // the Find box when ending the find session. |
36 enum ResultAction { | 36 enum ResultAction { |
37 kClearResultsInFindBox, // Clear search string, ordinal and match count. | 37 kClearResultsInFindBox, // Clear search string, ordinal and match count. |
38 kKeepResultsInFindBox, // Leave the results untouched. | 38 kKeepResultsInFindBox, // Leave the results untouched. |
39 }; | 39 }; |
40 | 40 |
41 // FindBar takes ownership of |find_bar_view|. | 41 // FindBar takes ownership of |find_bar_view|. |
42 explicit FindBarController(FindBar* find_bar); | 42 explicit FindBarController(FindBar* find_bar); |
43 | 43 |
44 virtual ~FindBarController(); | 44 ~FindBarController() override; |
45 | 45 |
46 // Shows the find bar. Any previous search string will again be visible. | 46 // Shows the find bar. Any previous search string will again be visible. |
47 void Show(); | 47 void Show(); |
48 | 48 |
49 // Ends the current session. |selection_action| specifies what to do with the | 49 // Ends the current session. |selection_action| specifies what to do with the |
50 // selection on the page created by the find operation. |results_action| | 50 // selection on the page created by the find operation. |results_action| |
51 // specifies what to do with the contents of the Find box (after ending). | 51 // specifies what to do with the contents of the Find box (after ending). |
52 void EndFindSession(SelectionAction selection_action, | 52 void EndFindSession(SelectionAction selection_action, |
53 ResultAction results_action); | 53 ResultAction results_action); |
54 | 54 |
55 // Accessor for the attached WebContents. | 55 // Accessor for the attached WebContents. |
56 content::WebContents* web_contents() const { return web_contents_; } | 56 content::WebContents* web_contents() const { return web_contents_; } |
57 | 57 |
58 // Changes the WebContents that this FindBar is attached to. This | 58 // Changes the WebContents that this FindBar is attached to. This |
59 // occurs when the user switches tabs in the Browser window. |contents| can be | 59 // occurs when the user switches tabs in the Browser window. |contents| can be |
60 // NULL. | 60 // NULL. |
61 void ChangeWebContents(content::WebContents* contents); | 61 void ChangeWebContents(content::WebContents* contents); |
62 | 62 |
63 // Overridden from content::NotificationObserver: | 63 // Overridden from content::NotificationObserver: |
64 virtual void Observe(int type, | 64 void Observe(int type, |
65 const content::NotificationSource& source, | 65 const content::NotificationSource& source, |
66 const content::NotificationDetails& details) override; | 66 const content::NotificationDetails& details) override; |
67 | 67 |
68 FindBar* find_bar() const { return find_bar_.get(); } | 68 FindBar* find_bar() const { return find_bar_.get(); } |
69 | 69 |
70 // Reposition |view_location| such that it avoids |avoid_overlapping_rect|, | 70 // Reposition |view_location| such that it avoids |avoid_overlapping_rect|, |
71 // and return the new location. | 71 // and return the new location. |
72 static gfx::Rect GetLocationForFindbarView( | 72 static gfx::Rect GetLocationForFindbarView( |
73 gfx::Rect view_location, | 73 gfx::Rect view_location, |
74 const gfx::Rect& dialog_bounds, | 74 const gfx::Rect& dialog_bounds, |
75 const gfx::Rect& avoid_overlapping_rect); | 75 const gfx::Rect& avoid_overlapping_rect); |
76 | 76 |
(...skipping 18 matching lines...) Expand all Loading... |
95 content::WebContents* web_contents_; | 95 content::WebContents* web_contents_; |
96 | 96 |
97 // The last match count we reported to the user. This is used by | 97 // The last match count we reported to the user. This is used by |
98 // UpdateFindBarForCurrentResult to avoid flickering. | 98 // UpdateFindBarForCurrentResult to avoid flickering. |
99 int last_reported_matchcount_; | 99 int last_reported_matchcount_; |
100 | 100 |
101 DISALLOW_COPY_AND_ASSIGN(FindBarController); | 101 DISALLOW_COPY_AND_ASSIGN(FindBarController); |
102 }; | 102 }; |
103 | 103 |
104 #endif // CHROME_BROWSER_UI_FIND_BAR_FIND_BAR_CONTROLLER_H_ | 104 #endif // CHROME_BROWSER_UI_FIND_BAR_FIND_BAR_CONTROLLER_H_ |
OLD | NEW |