[Extensions] Make extension message bubble factory platform-abstract
[chromium-blink-merge.git] / chrome / browser / ui / browser_finder.h
blob8c1c76843408dae19289863a7e76b85ea538ee10
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.
5 #ifndef CHROME_BROWSER_UI_BROWSER_FINDER_H_
6 #define CHROME_BROWSER_UI_BROWSER_FINDER_H_
8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/host_desktop.h"
10 #include "ui/gfx/native_widget_types.h"
12 class Profile;
14 namespace contents {
15 class WebContents;
18 // Collection of functions to find Browsers based on various criteria.
20 namespace chrome {
22 // If you want to find the last active tabbed browser and create a new browser
23 // if there are no tabbed browsers, use ScopedTabbedBrowserDisplayer.
25 // Retrieve the last active tabbed browser with a profile matching |profile|.
26 // If |match_original_profiles| is true, matching is done based on the
27 // original profile, eg profile->GetOriginalProfile() ==
28 // browser->profile()->GetOriginalProfile(). This has the effect of matching
29 // against both non-incognito and incognito profiles. If
30 // |match_original_profiles| is false, only an exact match may be returned.
31 // |type| refers to the host desktop the returned browser should belong to.
32 Browser* FindTabbedBrowser(Profile* profile,
33 bool match_original_profiles,
34 HostDesktopType type);
36 // Finds an existing browser window of any kind.
37 // |type| refers to the host desktop the returned browser should belong to.
38 Browser* FindAnyBrowser(Profile* profile,
39 bool match_original_profiles,
40 HostDesktopType type);
42 // Find an existing browser window with the provided profile and hosted in the
43 // given desktop. Searches in the order of last activation. Only browsers that
44 // have been active can be returned. Returns NULL if no such browser currently
45 // exists.
46 Browser* FindBrowserWithProfile(Profile* profile, HostDesktopType type);
48 // Find an existing browser with the provided ID. Returns NULL if no such
49 // browser currently exists.
50 Browser* FindBrowserWithID(SessionID::id_type desired_id);
52 // Find the browser represented by |window| or NULL if not found.
53 Browser* FindBrowserWithWindow(gfx::NativeWindow window);
55 // Find the browser containing |web_contents| or NULL if none is found.
56 // |web_contents| must not be NULL.
57 Browser* FindBrowserWithWebContents(const content::WebContents* web_contents);
59 // Returns the Browser object owned by |profile| on the given desktop type
60 // whose window was most recently active. If no such Browsers exist, returns
61 // NULL.
63 // WARNING: this is NULL until a browser becomes active. If during startup
64 // a browser does not become active (perhaps the user launches Chrome, then
65 // clicks on another app before the first browser window appears) then this
66 // returns NULL.
67 // WARNING #2: this will always be NULL in unit tests run on the bots.
68 Browser* FindLastActiveWithProfile(Profile* profile, HostDesktopType type);
70 // Returns the Browser object on the given desktop type whose window was most
71 // recently active. If no such Browsers exist, returns NULL.
73 // WARNING: this is NULL until a browser becomes active. If during startup
74 // a browser does not become active (perhaps the user launches Chrome, then
75 // clicks on another app before the first browser window appears) then this
76 // returns NULL.
77 // WARNING #2: this will always be NULL in unit tests run on the bots.
78 Browser* FindLastActiveWithHostDesktopType(HostDesktopType type);
80 // Returns the number of browsers across all profiles and desktops.
81 size_t GetTotalBrowserCount();
83 // Returns the number of browsers with the Profile |profile| accross all
84 // desktops.
85 size_t GetTotalBrowserCountForProfile(Profile* profile);
87 // Returns the number of browsers with the Profile |profile| on the desktop
88 // defined by |type|.
89 size_t GetBrowserCount(Profile* profile, HostDesktopType type);
91 // Returns the number of tabbed browsers with the Profile |profile| on the
92 // desktop defined by |type|.
93 size_t GetTabbedBrowserCount(Profile* profile, HostDesktopType type);
95 } // namespace chrome
97 #endif // CHROME_BROWSER_UI_BROWSER_FINDER_H_