OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_UI_BROWSER_FINDER_H_ | |
6 #define CHROME_BROWSER_UI_BROWSER_FINDER_H_ | |
7 #pragma once | |
8 | |
9 #include "chrome/browser/ui/browser.h" | |
10 #include "ui/gfx/native_widget_types.h" | |
11 | |
12 class Profile; | |
13 | |
14 namespace contents { | |
15 class NavigationController; | |
16 class WebContents; | |
17 } | |
18 | |
19 // Collection of functions to find Browsers based on various criteria. | |
20 | |
21 namespace browser { | |
22 | |
23 // Retrieve the last active tabbed browser with a profile matching |profile|. | |
24 // If |match_original_profiles| is true, matching is done based on the | |
25 // original profile, eg profile->GetOriginalProfile() == | |
26 // browser->profile()->GetOriginalProfile(). This has the effect of matching | |
27 // against both non-incognito and incognito profiles. If | |
28 // |match_original_profiles| is false, only an exact match may be returned. | |
29 Browser* FindTabbedBrowser(Profile* profile, bool match_original_profiles); | |
30 | |
31 // Returns the first tabbed browser matching |profile|. If there is no tabbed | |
32 // browser a new one is created and returned. If a new browser is created it is | |
33 // not made visible. | |
34 Browser* FindOrCreateTabbedBrowser(Profile* profile); | |
35 | |
36 // Find an existing browser window with any type. See comment above for | |
37 // additional information. | |
38 Browser* FindAnyBrowser(Profile* profile, bool match_original_profiles); | |
39 | |
40 // Find an existing browser window that can provide the specified type (this | |
41 // uses Browser::CanSupportsWindowFeature, not | |
42 // Browser::SupportsWindowFeature). This searches in the order of last | |
43 // activation. Only browsers that have been active can be returned. Returns | |
44 // NULL if no such browser currently exists. | |
45 Browser* FindBrowserWithFeature(Profile* profile, | |
46 Browser::WindowFeature feature); | |
47 | |
48 // Find an existing browser window with the provided profile. Searches in the | |
49 // order of last activation. Only browsers that have been active can be | |
50 // returned. Returns NULL if no such browser currently exists. | |
51 Browser* FindBrowserWithProfile(Profile* profile); | |
52 | |
53 // Find an existing browser with the provided ID. Returns NULL if no such | |
54 // browser currently exists. | |
55 Browser* FindBrowserWithID(SessionID::id_type desired_id); | |
56 | |
57 // Find the browser represented by |window| or NULL if not found. | |
58 Browser* FindBrowserWithWindow(gfx::NativeWindow window); | |
59 | |
60 // Find the browser containing |web_contents| or NULL if none is found. | |
61 // |web_contents| must not be NULL. | |
62 Browser* FindBrowserWithWebContents(content::WebContents* web_contents); | |
63 | |
64 // Returns the Browser which contains the tab with the given | |
65 // NavigationController, also filling in |index| (if valid) with the tab's index | |
66 // in the tab strip. Returns NULL if not found. This call is O(N) in the | |
67 // number of tabs. | |
68 Browser* FindBrowserForController( | |
69 const content::NavigationController* controller, | |
70 int* index); | |
71 | |
72 // Identical in behavior to BrowserList::GetLastActive(), except that the most | |
achuithb
2012/05/16 18:22:16
nit: update comment
sky
2012/05/16 20:54:16
This comment is correct. I didn't move BrowserList
| |
73 // recently open browser owned by |profile| is returned. If none exist, returns | |
74 // NULL. WARNING: see warnings in BrowserList::GetLastActive(). | |
75 Browser* FindLastActiveWithProfile(Profile* profile); | |
76 | |
77 // Returns the number of browsers with the Profile |profile|. | |
78 size_t GetBrowserCount(Profile* profile); | |
79 | |
80 // Returns the number of tabbed browsers with the Profile |profile|. | |
81 size_t GetTabbedBrowserCount(Profile* profile); | |
82 | |
83 } // namespace browser | |
84 | |
85 #endif // CHROME_BROWSER_UI_BROWSER_FINDER_H_ | |
OLD | NEW |