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

Side by Side Diff: chrome/browser/extensions/extension_tab_util.h

Issue 245933002: Initial implementation of chrome.browser.openTab. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing. Created 6 years, 7 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
OLDNEW
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_EXTENSIONS_EXTENSION_TAB_UTIL_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_UTIL_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_UTIL_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_UTIL_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "chrome/common/extensions/api/tabs.h" 11 #include "chrome/common/extensions/api/tabs.h"
12 #include "ui/base/window_open_disposition.h" 12 #include "ui/base/window_open_disposition.h"
13 13
14 class Browser; 14 class Browser;
15 class ChromeAsyncExtensionFunction;
15 class GURL; 16 class GURL;
16 class Profile; 17 class Profile;
17 class TabStripModel; 18 class TabStripModel;
18 19
19 namespace base { 20 namespace base {
20 class DictionaryValue; 21 class DictionaryValue;
21 class ListValue; 22 class ListValue;
22 } 23 }
23 24
24 namespace content { 25 namespace content {
25 class WebContents; 26 class WebContents;
26 } 27 }
27 28
28 namespace gfx { 29 namespace gfx {
29 class Rect; 30 class Rect;
30 } 31 }
31 32
32 namespace extensions { 33 namespace extensions {
33 class Extension; 34 class Extension;
34 class WindowController; 35 class WindowController;
35 36
36 // Provides various utility functions that help manipulate tabs. 37 // Provides various utility functions that help manipulate tabs.
37 class ExtensionTabUtil { 38 class ExtensionTabUtil {
38 public: 39 public:
40 struct OpenTabParams {
41 OpenTabParams();
42 ~OpenTabParams();
43
44 bool create_browser_if_needed;
45 scoped_ptr<int> window_id;
46 scoped_ptr<int> opener_tab_id;
47 scoped_ptr<std::string> url;
48 scoped_ptr<bool> active;
49 scoped_ptr<bool> pinned;
50 scoped_ptr<int> index;
51 };
52
53 // Opens a new tab given an extension function |function| and creation
54 // parameters |params|. Returns a Tab object if successful, or NULL and
55 // optionally sets |error| if an error occurs.
56 static base::DictionaryValue* OpenTab(ChromeAsyncExtensionFunction* function,
57 const OpenTabParams& params,
58 std::string* error);
59
39 static int GetWindowId(const Browser* browser); 60 static int GetWindowId(const Browser* browser);
40 static int GetWindowIdOfTabStripModel(const TabStripModel* tab_strip_model); 61 static int GetWindowIdOfTabStripModel(const TabStripModel* tab_strip_model);
41 static int GetTabId(const content::WebContents* web_contents); 62 static int GetTabId(const content::WebContents* web_contents);
42 static std::string GetTabStatusText(bool is_loading); 63 static std::string GetTabStatusText(bool is_loading);
43 static int GetWindowIdOfTab(const content::WebContents* web_contents); 64 static int GetWindowIdOfTab(const content::WebContents* web_contents);
44 static base::ListValue* CreateTabList(const Browser* browser, 65 static base::ListValue* CreateTabList(const Browser* browser,
45 const Extension* extension); 66 const Extension* extension);
67 static Browser* GetBrowserFromWindowID(ChromeAsyncExtensionFunction* function,
68 int window_id,
69 std::string* error_message);
46 70
47 // Creates a Tab object (see chrome/common/extensions/api/tabs.json) with 71 // Creates a Tab object (see chrome/common/extensions/api/tabs.json) with
48 // information about the state of a browser tab. Depending on the 72 // information about the state of a browser tab. Depending on the
49 // permissions of the extension, the object may or may not include sensitive 73 // permissions of the extension, the object may or may not include sensitive
50 // data such as the tab's URL. 74 // data such as the tab's URL.
51 static base::DictionaryValue* CreateTabValue( 75 static base::DictionaryValue* CreateTabValue(
52 const content::WebContents* web_contents, 76 const content::WebContents* web_contents,
53 const Extension* extension) { 77 const Extension* extension) {
54 return CreateTabValue(web_contents, NULL, -1, extension); 78 return CreateTabValue(web_contents, NULL, -1, extension);
55 } 79 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 static WindowController* GetWindowControllerOfTab( 149 static WindowController* GetWindowControllerOfTab(
126 const content::WebContents* web_contents); 150 const content::WebContents* web_contents);
127 151
128 // Open the extension's options page. 152 // Open the extension's options page.
129 static void OpenOptionsPage(const Extension* extension, Browser* browser); 153 static void OpenOptionsPage(const Extension* extension, Browser* browser);
130 }; 154 };
131 155
132 } // namespace extensions 156 } // namespace extensions
133 157
134 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_UTIL_H_ 158 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_UTIL_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/tabs/tabs_api.cc ('k') | chrome/browser/extensions/extension_tab_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698