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_WEB_CONTENTS_H_ | 5 #ifndef CHROME_BROWSER_WEB_CONTENTS_H_ |
6 #define CHROME_BROWSER_WEB_CONTENTS_H_ | 6 #define CHROME_BROWSER_WEB_CONTENTS_H_ |
7 | 7 |
8 #include "base/hash_tables.h" | 8 #include "base/hash_tables.h" |
9 #include "chrome/browser/download/save_package.h" | 9 #include "chrome/browser/download/save_package.h" |
10 #include "chrome/browser/fav_icon_helper.h" | 10 #include "chrome/browser/fav_icon_helper.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 return render_manager_.current_host(); | 65 return render_manager_.current_host(); |
66 } | 66 } |
67 | 67 |
68 // The WebContentsView will never change and is guaranteed non-NULL. | 68 // The WebContentsView will never change and is guaranteed non-NULL. |
69 WebContentsView* view() const { | 69 WebContentsView* view() const { |
70 return view_.get(); | 70 return view_.get(); |
71 } | 71 } |
72 | 72 |
73 bool is_starred() const { return is_starred_; } | 73 bool is_starred() const { return is_starred_; } |
74 | 74 |
| 75 const std::wstring& encoding() const { return encoding_; } |
| 76 void set_encoding(const std::wstring& encoding) { |
| 77 encoding_ = encoding; |
| 78 } |
| 79 |
75 // TabContents (public overrides) -------------------------------------------- | 80 // TabContents (public overrides) -------------------------------------------- |
76 | 81 |
77 virtual void Destroy(); | 82 virtual void Destroy(); |
78 virtual WebContents* AsWebContents() { return this; } | 83 virtual WebContents* AsWebContents() { return this; } |
79 virtual SiteInstance* GetSiteInstance() const; | 84 virtual SiteInstance* GetSiteInstance() const; |
80 virtual SkBitmap GetFavIcon(); | 85 virtual SkBitmap GetFavIcon(); |
81 virtual std::wstring GetStatusText() const; | 86 virtual std::wstring GetStatusText() const; |
82 virtual bool NavigateToPendingEntry(bool reload); | 87 virtual bool NavigateToPendingEntry(bool reload); |
83 virtual void Stop(); | 88 virtual void Stop(); |
84 virtual void Cut(); | 89 virtual void Cut(); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 // Returns true if the active NavigationEntry's page_id equals page_id. | 186 // Returns true if the active NavigationEntry's page_id equals page_id. |
182 bool IsActiveEntry(int32 page_id); | 187 bool IsActiveEntry(int32 page_id); |
183 | 188 |
184 const std::string& contents_mime_type() const { | 189 const std::string& contents_mime_type() const { |
185 return contents_mime_type_; | 190 return contents_mime_type_; |
186 } | 191 } |
187 | 192 |
188 // Returns true if this WebContents will notify about disconnection. | 193 // Returns true if this WebContents will notify about disconnection. |
189 bool notify_disconnection() const { return notify_disconnection_; } | 194 bool notify_disconnection() const { return notify_disconnection_; } |
190 | 195 |
| 196 // Override the encoding and reload the page by sending down |
| 197 // ViewMsg_SetPageEncoding to the renderer. |UpdateEncoding| is kinda |
| 198 // the opposite of this, by which 'browser' is notified of |
| 199 // the encoding of the current tab from 'renderer' (determined by |
| 200 // auto-detect, http header, meta, bom detection, etc). |
| 201 void override_encoding(const std::wstring& encoding) { |
| 202 set_encoding(encoding); |
| 203 render_view_host()->SetPageEncoding(encoding); |
| 204 } |
| 205 |
191 protected: | 206 protected: |
192 // Should be deleted via CloseContents. | 207 // Should be deleted via CloseContents. |
193 virtual ~WebContents(); | 208 virtual ~WebContents(); |
194 | 209 |
195 RenderWidgetHostView* render_widget_host_view() const { | 210 RenderWidgetHostView* render_widget_host_view() const { |
196 return render_manager_.current_view(); | 211 return render_manager_.current_view(); |
197 } | 212 } |
198 | 213 |
199 // TabContents (private overrides) ------------------------------------------- | 214 // TabContents (private overrides) ------------------------------------------- |
200 | 215 |
(...skipping 11 matching lines...) Expand all Loading... |
212 const ViewHostMsg_FrameNavigate_Params& params); | 227 const ViewHostMsg_FrameNavigate_Params& params); |
213 virtual void UpdateState(RenderViewHost* render_view_host, | 228 virtual void UpdateState(RenderViewHost* render_view_host, |
214 int32 page_id, | 229 int32 page_id, |
215 const GURL& url, | 230 const GURL& url, |
216 const std::wstring& title, | 231 const std::wstring& title, |
217 const std::string& state); | 232 const std::string& state); |
218 virtual void UpdateTitle(RenderViewHost* render_view_host, | 233 virtual void UpdateTitle(RenderViewHost* render_view_host, |
219 int32 page_id, | 234 int32 page_id, |
220 const std::wstring& title); | 235 const std::wstring& title); |
221 virtual void UpdateEncoding(RenderViewHost* render_view_host, | 236 virtual void UpdateEncoding(RenderViewHost* render_view_host, |
222 const std::wstring& encoding_name); | 237 const std::wstring& encoding); |
223 virtual void UpdateTargetURL(int32 page_id, const GURL& url); | 238 virtual void UpdateTargetURL(int32 page_id, const GURL& url); |
224 virtual void UpdateThumbnail(const GURL& url, | 239 virtual void UpdateThumbnail(const GURL& url, |
225 const SkBitmap& bitmap, | 240 const SkBitmap& bitmap, |
226 const ThumbnailScore& score); | 241 const ThumbnailScore& score); |
227 virtual void Close(RenderViewHost* render_view_host); | 242 virtual void Close(RenderViewHost* render_view_host); |
228 virtual void RequestMove(const gfx::Rect& new_bounds); | 243 virtual void RequestMove(const gfx::Rect& new_bounds); |
229 virtual void DidStartLoading(RenderViewHost* render_view_host, int32 page_id); | 244 virtual void DidStartLoading(RenderViewHost* render_view_host, int32 page_id); |
230 virtual void DidStopLoading(RenderViewHost* render_view_host, int32 page_id); | 245 virtual void DidStopLoading(RenderViewHost* render_view_host, int32 page_id); |
231 virtual void DidStartProvisionalLoadForFrame(RenderViewHost* render_view_host, | 246 virtual void DidStartProvisionalLoadForFrame(RenderViewHost* render_view_host, |
232 bool is_main_frame, | 247 bool is_main_frame, |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 struct PendingInstall { | 370 struct PendingInstall { |
356 int32 page_id; | 371 int32 page_id; |
357 SkBitmap icon; | 372 SkBitmap icon; |
358 std::wstring title; | 373 std::wstring title; |
359 GURL url; | 374 GURL url; |
360 // This object receives the GearsCreateShortcutCallback and routes the | 375 // This object receives the GearsCreateShortcutCallback and routes the |
361 // message back to the WebContents, if we haven't been deleted. | 376 // message back to the WebContents, if we haven't been deleted. |
362 GearsCreateShortcutCallbackFunctor* callback_functor; | 377 GearsCreateShortcutCallbackFunctor* callback_functor; |
363 }; | 378 }; |
364 | 379 |
| 380 |
365 // NotificationObserver ------------------------------------------------------ | 381 // NotificationObserver ------------------------------------------------------ |
366 | 382 |
367 virtual void Observe(NotificationType type, | 383 virtual void Observe(NotificationType type, |
368 const NotificationSource& source, | 384 const NotificationSource& source, |
369 const NotificationDetails& details); | 385 const NotificationDetails& details); |
370 | 386 |
371 // Navigation helpers -------------------------------------------------------- | 387 // Navigation helpers -------------------------------------------------------- |
372 // | 388 // |
373 // These functions are helpers for Navigate() and DidNavigate(). | 389 // These functions are helpers for Navigate() and DidNavigate(). |
374 | 390 |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 TimeTicks last_javascript_message_dismissal_; | 530 TimeTicks last_javascript_message_dismissal_; |
515 | 531 |
516 // True if the user has decided to block future javascript messages. This is | 532 // True if the user has decided to block future javascript messages. This is |
517 // reset on navigations to false on navigations. | 533 // reset on navigations to false on navigations. |
518 bool suppress_javascript_messages_; | 534 bool suppress_javascript_messages_; |
519 | 535 |
520 // When a navigation occurs, we record its contents MIME type. It can be | 536 // When a navigation occurs, we record its contents MIME type. It can be |
521 // used to check whether we can do something for some special contents. | 537 // used to check whether we can do something for some special contents. |
522 std::string contents_mime_type_; | 538 std::string contents_mime_type_; |
523 | 539 |
| 540 // Character encoding. TODO(jungshik) : convert to std::string |
| 541 std::wstring encoding_; |
| 542 |
524 PendingInstall pending_install_; | 543 PendingInstall pending_install_; |
525 | 544 |
526 // The last time that the download shelf was made visible. | 545 // The last time that the download shelf was made visible. |
527 TimeTicks last_download_shelf_show_; | 546 TimeTicks last_download_shelf_show_; |
528 | 547 |
529 // The current load state and the URL associated with it. | 548 // The current load state and the URL associated with it. |
530 net::LoadState load_state_; | 549 net::LoadState load_state_; |
531 std::wstring load_state_host_; | 550 std::wstring load_state_host_; |
532 | 551 |
533 // Non-null if we're displaying content for a web app. | 552 // Non-null if we're displaying content for a web app. |
534 scoped_refptr<WebApp> web_app_; | 553 scoped_refptr<WebApp> web_app_; |
535 | 554 |
536 DISALLOW_COPY_AND_ASSIGN(WebContents); | 555 DISALLOW_COPY_AND_ASSIGN(WebContents); |
537 }; | 556 }; |
538 | 557 |
539 #endif // CHROME_BROWSER_WEB_CONTENTS_H_ | 558 #endif // CHROME_BROWSER_WEB_CONTENTS_H_ |
OLD | NEW |