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

Side by Side Diff: content/browser/tab_contents/tab_contents.h

Issue 6693054: Get rid of extensions dependency from content\browser. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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
« no previous file with comments | « content/browser/site_instance_unittest.cc ('k') | content/browser/tab_contents/tab_contents.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef CONTENT_BROWSER_TAB_CONTENTS_TAB_CONTENTS_H_ 5 #ifndef CONTENT_BROWSER_TAB_CONTENTS_TAB_CONTENTS_H_
6 #define CONTENT_BROWSER_TAB_CONTENTS_TAB_CONTENTS_H_ 6 #define CONTENT_BROWSER_TAB_CONTENTS_TAB_CONTENTS_H_
7 #pragma once 7 #pragma once
8 8
9 #include <deque> 9 #include <deque>
10 #include <map> 10 #include <map>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/basictypes.h" 14 #include "base/basictypes.h"
15 #include "base/gtest_prod_util.h" 15 #include "base/gtest_prod_util.h"
16 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
17 #include "base/string16.h" 17 #include "base/string16.h"
18 #include "chrome/browser/download/save_package.h" 18 #include "chrome/browser/download/save_package.h"
19 #include "chrome/browser/extensions/image_loading_tracker.h"
20 #include "chrome/browser/favicon_helper.h" 19 #include "chrome/browser/favicon_helper.h"
21 #include "chrome/browser/prefs/pref_change_registrar.h" 20 #include "chrome/browser/prefs/pref_change_registrar.h"
22 #include "chrome/browser/tab_contents/tab_specific_content_settings.h" 21 #include "chrome/browser/tab_contents/tab_specific_content_settings.h"
23 #include "chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h" 22 #include "chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h"
24 #include "chrome/common/instant_types.h" 23 #include "chrome/common/instant_types.h"
25 #include "chrome/common/translate_errors.h" 24 #include "chrome/common/translate_errors.h"
26 #include "chrome/common/web_apps.h" 25 #include "chrome/common/web_apps.h"
27 #include "content/browser/renderer_host/render_view_host_delegate.h" 26 #include "content/browser/renderer_host/render_view_host_delegate.h"
28 #include "content/browser/tab_contents/constrained_window.h" 27 #include "content/browser/tab_contents/constrained_window.h"
29 #include "content/browser/tab_contents/language_state.h" 28 #include "content/browser/tab_contents/language_state.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 struct ViewHostMsg_FrameNavigate_Params; 84 struct ViewHostMsg_FrameNavigate_Params;
86 struct WebPreferences; 85 struct WebPreferences;
87 86
88 // Describes what goes in the main content area of a tab. TabContents is 87 // Describes what goes in the main content area of a tab. TabContents is
89 // the only type of TabContents, and these should be merged together. 88 // the only type of TabContents, and these should be merged together.
90 class TabContents : public PageNavigator, 89 class TabContents : public PageNavigator,
91 public NotificationObserver, 90 public NotificationObserver,
92 public RenderViewHostDelegate, 91 public RenderViewHostDelegate,
93 public RenderViewHostManager::Delegate, 92 public RenderViewHostManager::Delegate,
94 public JavaScriptAppModalDialogDelegate, 93 public JavaScriptAppModalDialogDelegate,
95 public ImageLoadingTracker::Observer,
96 public TabSpecificContentSettings::Delegate, 94 public TabSpecificContentSettings::Delegate,
97 public net::NetworkChangeNotifier::OnlineStateObserver { 95 public net::NetworkChangeNotifier::OnlineStateObserver {
98 public: 96 public:
99 // Flags passed to the TabContentsDelegate.NavigationStateChanged to tell it 97 // Flags passed to the TabContentsDelegate.NavigationStateChanged to tell it
100 // what has changed. Combine them to update more than one thing. 98 // what has changed. Combine them to update more than one thing.
101 enum InvalidateTypes { 99 enum InvalidateTypes {
102 INVALIDATE_URL = 1 << 0, // The URL has changed. 100 INVALIDATE_URL = 1 << 0, // The URL has changed.
103 INVALIDATE_TAB = 1 << 1, // The favicon, app icon, or crashed 101 INVALIDATE_TAB = 1 << 1, // The favicon, app icon, or crashed
104 // state changed. 102 // state changed.
105 INVALIDATE_LOAD = 1 << 2, // The loading state has changed. 103 INVALIDATE_LOAD = 1 << 2, // The loading state has changed.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 // The TabContentsView will never change and is guaranteed non-NULL. 170 // The TabContentsView will never change and is guaranteed non-NULL.
173 TabContentsView* view() const { 171 TabContentsView* view() const {
174 return view_.get(); 172 return view_.get();
175 } 173 }
176 174
177 // Returns the FaviconHelper of this TabContents. 175 // Returns the FaviconHelper of this TabContents.
178 FaviconHelper& favicon_helper() { 176 FaviconHelper& favicon_helper() {
179 return *favicon_helper_.get(); 177 return *favicon_helper_.get();
180 } 178 }
181 179
182 // App extensions ------------------------------------------------------------
183
184 // Sets the extension denoting this as an app. If |extension| is non-null this
185 // tab becomes an app-tab. TabContents does not listen for unload events for
186 // the extension. It's up to consumers of TabContents to do that.
187 //
188 // NOTE: this should only be manipulated before the tab is added to a browser.
189 // TODO(sky): resolve if this is the right way to identify an app tab. If it
190 // is, than this should be passed in the constructor.
191 void SetExtensionApp(const Extension* extension);
192
193 // Convenience for setting the app extension by id. This does nothing if
194 // |extension_app_id| is empty, or an extension can't be found given the
195 // specified id.
196 void SetExtensionAppById(const std::string& extension_app_id);
197
198 const Extension* extension_app() const { return extension_app_; }
199 bool is_app() const { return extension_app_ != NULL; }
200
201 // If an app extension has been explicitly set for this TabContents its icon
202 // is returned.
203 //
204 // NOTE: the returned icon is larger than 16x16 (its size is
205 // Extension::EXTENSION_ICON_SMALLISH).
206 SkBitmap* GetExtensionAppIcon();
207
208 // Tab navigation state ------------------------------------------------------ 180 // Tab navigation state ------------------------------------------------------
209 181
210 // Returns the current navigation properties, which if a navigation is 182 // Returns the current navigation properties, which if a navigation is
211 // pending may be provisional (e.g., the navigation could result in a 183 // pending may be provisional (e.g., the navigation could result in a
212 // download, in which case the URL would revert to what it was previously). 184 // download, in which case the URL would revert to what it was previously).
213 virtual const GURL& GetURL() const; 185 virtual const GURL& GetURL() const;
214 virtual const string16& GetTitle() const; 186 virtual const string16& GetTitle() const;
215 187
216 // The max PageID of any page that this TabContents has loaded. PageIDs 188 // The max PageID of any page that this TabContents has loaded. PageIDs
217 // increase with each new page that is loaded by a tab. If this is a 189 // increase with each new page that is loaded by a tab. If this is a
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 // also notify the delegate when the flag is changed. 268 // also notify the delegate when the flag is changed.
297 bool is_crashed() const { 269 bool is_crashed() const {
298 return (crashed_status_ == base::TERMINATION_STATUS_PROCESS_CRASHED || 270 return (crashed_status_ == base::TERMINATION_STATUS_PROCESS_CRASHED ||
299 crashed_status_ == base::TERMINATION_STATUS_ABNORMAL_TERMINATION || 271 crashed_status_ == base::TERMINATION_STATUS_ABNORMAL_TERMINATION ||
300 crashed_status_ == base::TERMINATION_STATUS_PROCESS_WAS_KILLED); 272 crashed_status_ == base::TERMINATION_STATUS_PROCESS_WAS_KILLED);
301 } 273 }
302 base::TerminationStatus crashed_status() const { return crashed_status_; } 274 base::TerminationStatus crashed_status() const { return crashed_status_; }
303 int crashed_error_code() const { return crashed_error_code_; } 275 int crashed_error_code() const { return crashed_error_code_; }
304 void SetIsCrashed(base::TerminationStatus status, int error_code); 276 void SetIsCrashed(base::TerminationStatus status, int error_code);
305 277
306 // Call this after updating a page action to notify clients about the changes.
307 void PageActionStateChanged();
308
309 // Whether the tab is in the process of being destroyed. 278 // Whether the tab is in the process of being destroyed.
310 // Added as a tentative work-around for focus related bug #4633. This allows 279 // Added as a tentative work-around for focus related bug #4633. This allows
311 // us not to store focus when a tab is being closed. 280 // us not to store focus when a tab is being closed.
312 bool is_being_destroyed() const { return is_being_destroyed_; } 281 bool is_being_destroyed() const { return is_being_destroyed_; }
313 282
314 // Convenience method for notifying the delegate of a navigation state 283 // Convenience method for notifying the delegate of a navigation state
315 // change. See TabContentsDelegate. 284 // change. See TabContentsDelegate.
316 void NotifyNavigationStateChanged(unsigned changed_flags); 285 void NotifyNavigationStateChanged(unsigned changed_flags);
317 286
318 // Invoked when the tab contents becomes selected. If you override, be sure 287 // Invoked when the tab contents becomes selected. If you override, be sure
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 // InitWithExistingID. 941 // InitWithExistingID.
973 virtual bool CreateRenderViewForRenderManager( 942 virtual bool CreateRenderViewForRenderManager(
974 RenderViewHost* render_view_host); 943 RenderViewHost* render_view_host);
975 944
976 // NotificationObserver ------------------------------------------------------ 945 // NotificationObserver ------------------------------------------------------
977 946
978 virtual void Observe(NotificationType type, 947 virtual void Observe(NotificationType type,
979 const NotificationSource& source, 948 const NotificationSource& source,
980 const NotificationDetails& details); 949 const NotificationDetails& details);
981 950
982 // App extensions related methods:
983
984 // Returns the first extension whose extent contains |url|.
985 const Extension* GetExtensionContaining(const GURL& url);
986
987 // Resets app_icon_ and if |extension| is non-null creates a new
988 // ImageLoadingTracker to load the extension's image.
989 void UpdateExtensionAppIcon(const Extension* extension);
990
991 // ImageLoadingTracker::Observer.
992 virtual void OnImageLoaded(SkBitmap* image, const ExtensionResource& resource,
993 int index);
994
995 // NetworkChangeNotifier::OnlineStateObserver: 951 // NetworkChangeNotifier::OnlineStateObserver:
996 virtual void OnOnlineStateChanged(bool online); 952 virtual void OnOnlineStateChanged(bool online);
997 953
998 // Adds the given window to the list of child windows. The window will notify 954 // Adds the given window to the list of child windows. The window will notify
999 // via WillClose() when it is being destroyed. 955 // via WillClose() when it is being destroyed.
1000 void AddConstrainedDialog(ConstrainedWindow* window); 956 void AddConstrainedDialog(ConstrainedWindow* window);
1001 957
1002 // Data for core operation --------------------------------------------------- 958 // Data for core operation ---------------------------------------------------
1003 959
1004 // Delegate for notifying our owner about stuff. Not owned by us. 960 // Delegate for notifying our owner about stuff. Not owned by us.
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 bool dont_notify_render_view_; 1065 bool dont_notify_render_view_;
1110 1066
1111 // True if this is a secure page which displayed insecure content. 1067 // True if this is a secure page which displayed insecure content.
1112 bool displayed_insecure_content_; 1068 bool displayed_insecure_content_;
1113 1069
1114 // Data for shelves and stuff ------------------------------------------------ 1070 // Data for shelves and stuff ------------------------------------------------
1115 1071
1116 // Delegates for InfoBars associated with this TabContents. 1072 // Delegates for InfoBars associated with this TabContents.
1117 std::vector<InfoBarDelegate*> infobar_delegates_; 1073 std::vector<InfoBarDelegate*> infobar_delegates_;
1118 1074
1119 // Data for app extensions ---------------------------------------------------
1120
1121 // If non-null this tab is an app tab and this is the extension the tab was
1122 // created for.
1123 const Extension* extension_app_;
1124
1125 // Icon for extension_app_ (if non-null) or extension_for_current_page_.
1126 SkBitmap extension_app_icon_;
1127
1128 // Used for loading extension_app_icon_.
1129 scoped_ptr<ImageLoadingTracker> extension_app_image_loader_;
1130
1131 // Data for misc internal state ---------------------------------------------- 1075 // Data for misc internal state ----------------------------------------------
1132 1076
1133 // See capturing_contents() above. 1077 // See capturing_contents() above.
1134 bool capturing_contents_; 1078 bool capturing_contents_;
1135 1079
1136 // See getter above. 1080 // See getter above.
1137 bool is_being_destroyed_; 1081 bool is_being_destroyed_;
1138 1082
1139 // Indicates whether we should notify about disconnection of this 1083 // Indicates whether we should notify about disconnection of this
1140 // TabContents. This is used to ensure disconnection notifications only 1084 // TabContents. This is used to ensure disconnection notifications only
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 ObserverList<TabContentsObserver> observers_; 1147 ObserverList<TabContentsObserver> observers_;
1204 1148
1205 // Content restrictions, used to disable print/copy etc based on content's 1149 // Content restrictions, used to disable print/copy etc based on content's
1206 // (full-page plugins for now only) permissions. 1150 // (full-page plugins for now only) permissions.
1207 int content_restrictions_; 1151 int content_restrictions_;
1208 1152
1209 DISALLOW_COPY_AND_ASSIGN(TabContents); 1153 DISALLOW_COPY_AND_ASSIGN(TabContents);
1210 }; 1154 };
1211 1155
1212 #endif // CONTENT_BROWSER_TAB_CONTENTS_TAB_CONTENTS_H_ 1156 #endif // CONTENT_BROWSER_TAB_CONTENTS_TAB_CONTENTS_H_
OLDNEW
« no previous file with comments | « content/browser/site_instance_unittest.cc ('k') | content/browser/tab_contents/tab_contents.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698