OLD | NEW |
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 CONTENT_SHELL_SHELL_H_ | 5 #ifndef CONTENT_SHELL_SHELL_H_ |
6 #define CONTENT_SHELL_SHELL_H_ | 6 #define CONTENT_SHELL_SHELL_H_ |
7 | 7 |
8 #pragma once | 8 #pragma once |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/string_piece.h" | 14 #include "base/string_piece.h" |
15 #include "content/public/browser/web_contents_delegate.h" | 15 #include "content/public/browser/web_contents_delegate.h" |
| 16 #include "content/public/browser/web_contents_observer.h" |
16 #include "ui/gfx/native_widget_types.h" | 17 #include "ui/gfx/native_widget_types.h" |
17 | 18 |
18 #if defined(OS_LINUX) | 19 #if defined(OS_LINUX) |
19 #include <gtk/gtk.h> | 20 #include <gtk/gtk.h> |
20 #include "ui/base/gtk/gtk_signal.h" | 21 #include "ui/base/gtk/gtk_signal.h" |
21 | 22 |
22 typedef struct _GtkToolItem GtkToolItem; | 23 typedef struct _GtkToolItem GtkToolItem; |
23 #endif | 24 #endif |
24 | 25 |
25 class GURL; | 26 class GURL; |
26 class TabContents; | 27 class TabContents; |
27 | 28 |
28 namespace content { | 29 namespace content { |
29 class BrowserContext; | 30 class BrowserContext; |
30 class SiteInstance; | 31 class SiteInstance; |
31 | 32 |
32 // This represents one window of the Content Shell, i.e. all the UI including | 33 // This represents one window of the Content Shell, i.e. all the UI including |
33 // buttons and url bar, as well as the web content area. | 34 // buttons and url bar, as well as the web content area. |
34 class Shell : public WebContentsDelegate { | 35 class Shell : public WebContentsDelegate, |
| 36 public WebContentsObserver { |
35 public: | 37 public: |
36 virtual ~Shell(); | 38 virtual ~Shell(); |
37 | 39 |
38 void LoadURL(const GURL& url); | 40 void LoadURL(const GURL& url); |
39 void GoBackOrForward(int offset); | 41 void GoBackOrForward(int offset); |
40 void Reload(); | 42 void Reload(); |
41 void Stop(); | 43 void Stop(); |
42 void UpdateNavigationControls(); | 44 void UpdateNavigationControls(); |
43 | 45 |
44 // Do one time initialization at application startup. | 46 // Do one time initialization at application startup. |
(...skipping 19 matching lines...) Expand all Loading... |
64 void URLEntered(std::string url_string); | 66 void URLEntered(std::string url_string); |
65 #endif | 67 #endif |
66 | 68 |
67 private: | 69 private: |
68 enum UIControl { | 70 enum UIControl { |
69 BACK_BUTTON, | 71 BACK_BUTTON, |
70 FORWARD_BUTTON, | 72 FORWARD_BUTTON, |
71 STOP_BUTTON | 73 STOP_BUTTON |
72 }; | 74 }; |
73 | 75 |
74 Shell(); | 76 explicit Shell(TabContents* tab_contents); |
75 | 77 |
76 // Helper to create a new Shell given a newly created TabContents. | 78 // Helper to create a new Shell given a newly created TabContents. |
77 static Shell* CreateShell(TabContents* tab_contents); | 79 static Shell* CreateShell(TabContents* tab_contents); |
78 | 80 |
79 // All the methods that begin with Platform need to be implemented by the | 81 // All the methods that begin with Platform need to be implemented by the |
80 // platform specific Shell implementation. | 82 // platform specific Shell implementation. |
81 // Called from the destructor to let each platform do any necessary cleanup. | 83 // Called from the destructor to let each platform do any necessary cleanup. |
82 void PlatformCleanUp(); | 84 void PlatformCleanUp(); |
83 // Creates the main window GUI. | 85 // Creates the main window GUI. |
84 void PlatformCreateWindow(int width, int height); | 86 void PlatformCreateWindow(int width, int height); |
(...skipping 15 matching lines...) Expand all Loading... |
100 // content::WebContentsDelegate | 102 // content::WebContentsDelegate |
101 virtual void LoadingStateChanged(WebContents* source) OVERRIDE; | 103 virtual void LoadingStateChanged(WebContents* source) OVERRIDE; |
102 virtual void WebContentsCreated(WebContents* source_contents, | 104 virtual void WebContentsCreated(WebContents* source_contents, |
103 int64 source_frame_id, | 105 int64 source_frame_id, |
104 const GURL& target_url, | 106 const GURL& target_url, |
105 WebContents* new_contents) OVERRIDE; | 107 WebContents* new_contents) OVERRIDE; |
106 virtual void DidNavigateMainFramePostCommit(WebContents* tab) OVERRIDE; | 108 virtual void DidNavigateMainFramePostCommit(WebContents* tab) OVERRIDE; |
107 virtual void UpdatePreferredSize(WebContents* source, | 109 virtual void UpdatePreferredSize(WebContents* source, |
108 const gfx::Size& pref_size) OVERRIDE; | 110 const gfx::Size& pref_size) OVERRIDE; |
109 | 111 |
| 112 // content::WebContentsObserver |
| 113 virtual void DidFinishLoad(int64 frame_id, |
| 114 const GURL& validated_url, |
| 115 bool is_main_frame) OVERRIDE; |
| 116 |
110 #if defined(OS_WIN) | 117 #if defined(OS_WIN) |
111 static ATOM RegisterWindowClass(); | 118 static ATOM RegisterWindowClass(); |
112 static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); | 119 static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); |
113 static LRESULT CALLBACK EditWndProc(HWND, UINT, WPARAM, LPARAM); | 120 static LRESULT CALLBACK EditWndProc(HWND, UINT, WPARAM, LPARAM); |
114 #elif defined(OS_LINUX) | 121 #elif defined(OS_LINUX) |
115 CHROMEGTK_CALLBACK_0(Shell, void, OnBackButtonClicked); | 122 CHROMEGTK_CALLBACK_0(Shell, void, OnBackButtonClicked); |
116 CHROMEGTK_CALLBACK_0(Shell, void, OnForwardButtonClicked); | 123 CHROMEGTK_CALLBACK_0(Shell, void, OnForwardButtonClicked); |
117 CHROMEGTK_CALLBACK_0(Shell, void, OnReloadButtonClicked); | 124 CHROMEGTK_CALLBACK_0(Shell, void, OnReloadButtonClicked); |
118 CHROMEGTK_CALLBACK_0(Shell, void, OnStopButtonClicked); | 125 CHROMEGTK_CALLBACK_0(Shell, void, OnStopButtonClicked); |
119 CHROMEGTK_CALLBACK_0(Shell, void, OnURLEntryActivate); | 126 CHROMEGTK_CALLBACK_0(Shell, void, OnURLEntryActivate); |
(...skipping 29 matching lines...) Expand all Loading... |
149 #endif | 156 #endif |
150 | 157 |
151 // A container of all the open windows. We use a vector so we can keep track | 158 // A container of all the open windows. We use a vector so we can keep track |
152 // of ordering. | 159 // of ordering. |
153 static std::vector<Shell*> windows_; | 160 static std::vector<Shell*> windows_; |
154 }; | 161 }; |
155 | 162 |
156 } // namespace content | 163 } // namespace content |
157 | 164 |
158 #endif // CONTENT_SHELL_SHELL_H_ | 165 #endif // CONTENT_SHELL_SHELL_H_ |
OLD | NEW |