OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_TAB_CONTENTS_WEB_CONTENTS_H_ | 5 #ifndef CHROME_BROWSER_TAB_CONTENTS_WEB_CONTENTS_H_ |
6 #define CHROME_BROWSER_TAB_CONTENTS_WEB_CONTENTS_H_ | 6 #define CHROME_BROWSER_TAB_CONTENTS_WEB_CONTENTS_H_ |
7 | 7 |
8 #include "chrome/browser/download/save_package.h" | 8 #include "chrome/browser/download/save_package.h" |
9 #include "chrome/browser/fav_icon_helper.h" | 9 #include "chrome/browser/fav_icon_helper.h" |
10 #include "chrome/browser/printing/print_view_manager.h" | 10 #include "chrome/browser/printing/print_view_manager.h" |
11 #include "chrome/browser/renderer_host/render_view_host_delegate.h" | 11 #include "chrome/browser/renderer_host/render_view_host_delegate.h" |
12 #include "chrome/browser/tab_contents/render_view_host_manager.h" | 12 #include "chrome/browser/tab_contents/render_view_host_manager.h" |
13 #include "chrome/browser/shell_dialogs.h" | 13 #include "chrome/browser/shell_dialogs.h" |
14 #include "chrome/browser/tab_contents/tab_contents.h" | 14 #include "chrome/browser/tab_contents/tab_contents.h" |
15 #include "chrome/browser/web_app.h" | 15 #include "chrome/common/gears_api.h" |
16 | 16 |
17 class AutofillManager; | 17 class AutofillManager; |
18 class InterstitialPageDelegate; | 18 class InterstitialPageDelegate; |
19 class PasswordManager; | 19 class PasswordManager; |
20 class PluginInstaller; | 20 class PluginInstaller; |
21 class RenderViewHost; | 21 class RenderViewHost; |
22 class RenderViewHostFactory; | 22 class RenderViewHostFactory; |
23 class RenderWidgetHost; | 23 class RenderWidgetHost; |
24 class WebContentsView; | 24 class WebContentsView; |
25 | 25 |
26 namespace base { | 26 namespace base { |
27 class WaitableEvent; | 27 class WaitableEvent; |
28 } | 28 } |
29 | 29 |
30 // WebContents represents the contents of a tab that shows web pages. It embeds | 30 // WebContents represents the contents of a tab that shows web pages. It embeds |
31 // a RenderViewHost (via RenderViewHostManager) to actually display the page. | 31 // a RenderViewHost (via RenderViewHostManager) to actually display the page. |
32 class WebContents : public TabContents, | 32 class WebContents : public TabContents, |
33 public RenderViewHostDelegate, | 33 public RenderViewHostDelegate, |
34 public RenderViewHostManager::Delegate, | 34 public RenderViewHostManager::Delegate, |
35 public SelectFileDialog::Listener, | 35 public SelectFileDialog::Listener { |
36 public WebApp::Observer { | |
37 public: | 36 public: |
38 // If instance is NULL, then creates a new process for this view. Otherwise | 37 // If instance is NULL, then creates a new process for this view. Otherwise |
39 // initialize with a process already created for a different WebContents. | 38 // initialize with a process already created for a different WebContents. |
40 // This will share the process between views in the same instance. If | 39 // This will share the process between views in the same instance. If |
41 // render_view_factory is NULL, this will create RenderViewHost objects | 40 // render_view_factory is NULL, this will create RenderViewHost objects |
42 // directly. | 41 // directly. |
43 WebContents(Profile* profile, | 42 WebContents(Profile* profile, |
44 SiteInstance* instance, | 43 SiteInstance* instance, |
45 RenderViewHostFactory* render_view_factory, | 44 RenderViewHostFactory* render_view_factory, |
46 int routing_id, | 45 int routing_id, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 const std::wstring& encoding() const { return encoding_; } | 80 const std::wstring& encoding() const { return encoding_; } |
82 void set_encoding(const std::wstring& encoding) { | 81 void set_encoding(const std::wstring& encoding) { |
83 encoding_ = encoding; | 82 encoding_ = encoding; |
84 } | 83 } |
85 | 84 |
86 // TabContents (public overrides) -------------------------------------------- | 85 // TabContents (public overrides) -------------------------------------------- |
87 | 86 |
88 virtual void Destroy(); | 87 virtual void Destroy(); |
89 virtual WebContents* AsWebContents() { return this; } | 88 virtual WebContents* AsWebContents() { return this; } |
90 virtual SiteInstance* GetSiteInstance() const; | 89 virtual SiteInstance* GetSiteInstance() const; |
91 virtual SkBitmap GetFavIcon(); | |
92 virtual std::wstring GetStatusText() const; | 90 virtual std::wstring GetStatusText() const; |
93 virtual bool NavigateToPendingEntry(bool reload); | 91 virtual bool NavigateToPendingEntry(bool reload); |
94 virtual void Stop(); | 92 virtual void Stop(); |
95 virtual void Cut(); | 93 virtual void Cut(); |
96 virtual void Copy(); | 94 virtual void Copy(); |
97 virtual void Paste(); | 95 virtual void Paste(); |
98 virtual void DisassociateFromPopupCount(); | 96 virtual void DisassociateFromPopupCount(); |
99 virtual void DidBecomeSelected(); | 97 virtual void DidBecomeSelected(); |
100 virtual void WasHidden(); | 98 virtual void WasHidden(); |
101 virtual void ShowContents(); | 99 virtual void ShowContents(); |
102 virtual void HideContents(); | 100 virtual void HideContents(); |
103 virtual void SetDownloadShelfVisible(bool visible); | 101 virtual void SetDownloadShelfVisible(bool visible); |
104 virtual void PopupNotificationVisibilityChanged(bool visible); | 102 virtual void PopupNotificationVisibilityChanged(bool visible); |
105 | 103 |
106 // Retarded pass-throughs to the view. | 104 // Retarded pass-throughs to the view. |
107 // TODO(brettw) fix this, tab contents shouldn't have these methods, probably | 105 // TODO(brettw) fix this, tab contents shouldn't have these methods, probably |
108 // it should be killed altogether. | 106 // it should be killed altogether. |
109 virtual void CreateView(); | 107 virtual void CreateView(); |
110 virtual HWND GetContainerHWND() const; | 108 virtual HWND GetContainerHWND() const; |
111 virtual HWND GetContentHWND(); | 109 virtual HWND GetContentHWND(); |
112 virtual void GetContainerBounds(gfx::Rect *out) const; | 110 virtual void GetContainerBounds(gfx::Rect *out) const; |
113 | 111 |
114 // Web apps ------------------------------------------------------------------ | 112 // Web apps ------------------------------------------------------------------ |
115 | 113 |
116 // Sets the WebApp for this WebContents. | |
117 void SetWebApp(WebApp* web_app); | |
118 WebApp* web_app() { return web_app_.get(); } | |
119 | |
120 // Return whether this tab contents was created to contain an application. | |
121 bool IsWebApplication() const; | |
122 | |
123 // Tell Gears to create a shortcut for the current page. | 114 // Tell Gears to create a shortcut for the current page. |
124 void CreateShortcut(); | 115 void CreateShortcut(); |
125 | 116 |
126 // Interstitials ------------------------------------------------------------- | 117 // Interstitials ------------------------------------------------------------- |
127 | 118 |
128 // Various other systems need to know about our interstitials. | 119 // Various other systems need to know about our interstitials. |
129 bool showing_interstitial_page() const { | 120 bool showing_interstitial_page() const { |
130 return render_manager_.interstitial_page() != NULL; | 121 return render_manager_.interstitial_page() != NULL; |
131 } | 122 } |
132 | 123 |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 // changed, the delegate is notified. | 415 // changed, the delegate is notified. |
425 void UpdateStarredStateForCurrentURL(); | 416 void UpdateStarredStateForCurrentURL(); |
426 | 417 |
427 // Send the alternate error page URL to the renderer. This method is virtual | 418 // Send the alternate error page URL to the renderer. This method is virtual |
428 // so special html pages can override this (e.g., the new tab page). | 419 // so special html pages can override this (e.g., the new tab page). |
429 virtual void UpdateAlternateErrorPageURL(); | 420 virtual void UpdateAlternateErrorPageURL(); |
430 | 421 |
431 // Send webkit specific settings to the renderer. | 422 // Send webkit specific settings to the renderer. |
432 void UpdateWebPreferences(); | 423 void UpdateWebPreferences(); |
433 | 424 |
434 // Return whether the optional web application is active for the current URL. | |
435 // Call this method to check if web app properties are in effect. | |
436 // | |
437 // Note: This method should be used for presentation but not security. The app | |
438 // is always active if the containing window is a web application. | |
439 bool IsWebApplicationActive() const; | |
440 | |
441 // WebApp::Observer method. Invoked when the set of images contained in the | |
442 // web app changes. Notifies the delegate our favicon has changed. | |
443 virtual void WebAppImagesChanged(WebApp* web_app); | |
444 | |
445 // Called when the user dismisses the shortcut creation dialog. 'success' is | 425 // Called when the user dismisses the shortcut creation dialog. 'success' is |
446 // true if the shortcut was created. | 426 // true if the shortcut was created. |
447 void OnGearsCreateShortcutDone(const GearsShortcutData& shortcut_data, | 427 void OnGearsCreateShortcutDone(const GearsShortcutData& shortcut_data, |
448 bool success); | 428 bool success); |
449 | 429 |
450 // If our controller was restored and the page id is > than the site | 430 // If our controller was restored and the page id is > than the site |
451 // instance's page id, the site instances page id is updated as well as the | 431 // instance's page id, the site instances page id is updated as well as the |
452 // renderers max page id. | 432 // renderers max page id. |
453 void UpdateMaxPageIDIfNecessary(SiteInstance* site_instance, | 433 void UpdateMaxPageIDIfNecessary(SiteInstance* site_instance, |
454 RenderViewHost* rvh); | 434 RenderViewHost* rvh); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 | 539 |
560 PendingInstall pending_install_; | 540 PendingInstall pending_install_; |
561 | 541 |
562 // The last time that the download shelf was made visible. | 542 // The last time that the download shelf was made visible. |
563 base::TimeTicks last_download_shelf_show_; | 543 base::TimeTicks last_download_shelf_show_; |
564 | 544 |
565 // The current load state and the URL associated with it. | 545 // The current load state and the URL associated with it. |
566 net::LoadState load_state_; | 546 net::LoadState load_state_; |
567 std::wstring load_state_host_; | 547 std::wstring load_state_host_; |
568 | 548 |
569 // Non-null if we're displaying content for a web app. | |
570 scoped_refptr<WebApp> web_app_; | |
571 | |
572 DISALLOW_COPY_AND_ASSIGN(WebContents); | 549 DISALLOW_COPY_AND_ASSIGN(WebContents); |
573 }; | 550 }; |
574 | 551 |
575 #endif // CHROME_BROWSER_TAB_CONTENTS_WEB_CONTENTS_H_ | 552 #endif // CHROME_BROWSER_TAB_CONTENTS_WEB_CONTENTS_H_ |
OLD | NEW |