summaryrefslogtreecommitdiffstats
path: root/content/shell
diff options
context:
space:
mode:
authoravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-26 21:29:32 +0000
committeravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-26 21:29:32 +0000
commit0b659b3aa968760adac676083477cadaaf3c7433 (patch)
tree9c0c0ad3b2d309772829460911893daa06279a5f /content/shell
parent2b195f45f0a6e08ae2b694bf74dbfd409443f35b (diff)
downloadchromium_src-0b659b3aa968760adac676083477cadaaf3c7433.zip
chromium_src-0b659b3aa968760adac676083477cadaaf3c7433.tar.gz
chromium_src-0b659b3aa968760adac676083477cadaaf3c7433.tar.bz2
Content shell: Use only public API.
BUG=119869 TEST=none Review URL: https://chromiumcodereview.appspot.com/9834092 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@129010 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/shell')
-rw-r--r--content/shell/DEPS5
-rw-r--r--content/shell/shell.cc61
-rw-r--r--content/shell/shell.h16
-rw-r--r--content/shell/shell_browser_context.cc4
-rw-r--r--content/shell/shell_browser_main_parts.cc5
-rw-r--r--content/shell/shell_content_browser_client.cc10
-rw-r--r--content/shell/shell_download_manager_delegate.cc3
-rw-r--r--content/shell/shell_gtk.cc14
-rw-r--r--content/shell/shell_mac.mm4
-rw-r--r--content/shell/shell_render_view_host_observer.cc2
-rw-r--r--content/shell/shell_win.cc6
11 files changed, 59 insertions, 71 deletions
diff --git a/content/shell/DEPS b/content/shell/DEPS
index 12c7728..ce20828 100644
--- a/content/shell/DEPS
+++ b/content/shell/DEPS
@@ -1,7 +1,10 @@
include_rules = [
- "+content",
"+v8/include",
+ # The content_shell is the canonical sample embedder, so it only uses
+ # content's public API.
+ "+content/public",
+
# The content_shell is an embedder so it must work with resource bundles.
"+ui/base/resource",
diff --git a/content/shell/shell.cc b/content/shell/shell.cc
index c2d5329..49097bc 100644
--- a/content/shell/shell.cc
+++ b/content/shell/shell.cc
@@ -8,9 +8,9 @@
#include "base/message_loop.h"
#include "base/path_service.h"
#include "base/string_util.h"
-#include "content/browser/renderer_host/render_view_host_impl.h"
-#include "content/browser/tab_contents/navigation_controller_impl.h"
-#include "content/browser/tab_contents/tab_contents.h"
+#include "content/public/browser/navigation_controller.h"
+#include "content/public/browser/render_view_host.h"
+#include "content/public/browser/web_contents.h"
#include "content/shell/shell_messages.h"
#include "content/shell/shell_switches.h"
#include "ui/gfx/size.h"
@@ -23,8 +23,8 @@ namespace content {
std::vector<Shell*> Shell::windows_;
-Shell::Shell(TabContents* tab_contents)
- : WebContentsObserver(tab_contents),
+Shell::Shell(WebContents* web_contents)
+ : WebContentsObserver(web_contents),
wait_until_done_(false),
window_(NULL),
url_edit_view_(NULL)
@@ -46,12 +46,12 @@ Shell::~Shell() {
}
}
-Shell* Shell::CreateShell(TabContents* tab_contents) {
- Shell* shell = new Shell(tab_contents);
+Shell* Shell::CreateShell(WebContents* web_contents) {
+ Shell* shell = new Shell(web_contents);
shell->PlatformCreateWindow(kTestWindowWidth, kTestWindowHeight);
- shell->tab_contents_.reset(tab_contents);
- tab_contents->SetDelegate(shell);
+ shell->web_contents_.reset(web_contents);
+ web_contents->SetDelegate(shell);
shell->PlatformSetContents();
@@ -61,8 +61,8 @@ Shell* Shell::CreateShell(TabContents* tab_contents) {
Shell* Shell::FromRenderViewHost(RenderViewHost* rvh) {
for (size_t i = 0; i < windows_.size(); ++i) {
- if (windows_[i]->tab_contents() &&
- windows_[i]->tab_contents()->GetRenderViewHost() == rvh) {
+ if (windows_[i]->web_contents() &&
+ windows_[i]->web_contents()->GetRenderViewHost() == rvh) {
return windows_[i];
}
}
@@ -73,56 +73,56 @@ Shell* Shell::CreateNewWindow(content::BrowserContext* browser_context,
const GURL& url,
SiteInstance* site_instance,
int routing_id,
- TabContents* base_tab_contents) {
- TabContents* tab_contents = new TabContents(
+ WebContents* base_web_contents) {
+ WebContents* web_contents = WebContents::Create(
browser_context,
site_instance,
routing_id,
- base_tab_contents,
+ base_web_contents,
NULL);
- Shell* shell = CreateShell(tab_contents);
+ Shell* shell = CreateShell(web_contents);
if (!url.is_empty())
shell->LoadURL(url);
return shell;
}
void Shell::LoadURL(const GURL& url) {
- tab_contents_->GetController().LoadURL(
+ web_contents_->GetController().LoadURL(
url,
content::Referrer(),
content::PAGE_TRANSITION_TYPED,
std::string());
- tab_contents_->Focus();
+ web_contents_->Focus();
}
void Shell::GoBackOrForward(int offset) {
- tab_contents_->GetController().GoToOffset(offset);
- tab_contents_->Focus();
+ web_contents_->GetController().GoToOffset(offset);
+ web_contents_->Focus();
}
void Shell::Reload() {
- tab_contents_->GetController().Reload(false);
- tab_contents_->Focus();
+ web_contents_->GetController().Reload(false);
+ web_contents_->Focus();
}
void Shell::Stop() {
- tab_contents_->Stop();
- tab_contents_->Focus();
+ web_contents_->Stop();
+ web_contents_->Focus();
}
void Shell::UpdateNavigationControls() {
- int current_index = tab_contents_->GetController().GetCurrentEntryIndex();
- int max_index = tab_contents_->GetController().GetEntryCount() - 1;
+ int current_index = web_contents_->GetController().GetCurrentEntryIndex();
+ int max_index = web_contents_->GetController().GetEntryCount() - 1;
PlatformEnableUIControl(BACK_BUTTON, current_index > 0);
PlatformEnableUIControl(FORWARD_BUTTON, current_index < max_index);
- PlatformEnableUIControl(STOP_BUTTON, tab_contents_->IsLoading());
+ PlatformEnableUIControl(STOP_BUTTON, web_contents_->IsLoading());
}
gfx::NativeView Shell::GetContentView() {
- if (!tab_contents_.get())
+ if (!web_contents_.get())
return NULL;
- return tab_contents_->GetNativeView();
+ return web_contents_->GetNativeView();
}
void Shell::LoadingStateChanged(WebContents* source) {
@@ -134,7 +134,7 @@ void Shell::WebContentsCreated(WebContents* source_contents,
int64 source_frame_id,
const GURL& target_url,
WebContents* new_contents) {
- CreateShell(static_cast<TabContents*>(new_contents));
+ CreateShell(new_contents);
}
void Shell::DidNavigateMainFramePostCommit(WebContents* tab) {
@@ -148,8 +148,7 @@ void Shell::DidFinishLoad(int64 frame_id,
return;
if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree))
return;
- RenderViewHostImpl* render_view_host =
- static_cast<RenderViewHostImpl*>(tab_contents_->GetRenderViewHost());
+ RenderViewHost* render_view_host = web_contents_->GetRenderViewHost();
render_view_host->Send(
new ShellViewMsg_CaptureTextDump(render_view_host->GetRoutingID(),
false));
diff --git a/content/shell/shell.h b/content/shell/shell.h
index 3f1d436..07221da 100644
--- a/content/shell/shell.h
+++ b/content/shell/shell.h
@@ -24,7 +24,7 @@ typedef struct _GtkToolItem GtkToolItem;
#endif
class GURL;
-class TabContents;
+class WebContents;
namespace content {
class BrowserContext;
@@ -53,7 +53,7 @@ class Shell : public WebContentsDelegate,
const GURL& url,
SiteInstance* site_instance,
int routing_id,
- TabContents* base_tab_contents);
+ WebContents* base_web_contents);
// Returns the Shell object corresponding to the given RenderViewHost.
static Shell* FromRenderViewHost(RenderViewHost* rvh);
@@ -61,7 +61,7 @@ class Shell : public WebContentsDelegate,
// Closes all windows and exits.
static void PlatformExit();
- TabContents* tab_contents() const { return tab_contents_.get(); }
+ WebContents* web_contents() const { return web_contents_.get(); }
// layoutTestController related methods.
void set_wait_until_done() { wait_until_done_ = true; }
@@ -79,10 +79,10 @@ class Shell : public WebContentsDelegate,
STOP_BUTTON
};
- explicit Shell(TabContents* tab_contents);
+ explicit Shell(WebContents* web_contents);
- // Helper to create a new Shell given a newly created TabContents.
- static Shell* CreateShell(TabContents* tab_contents);
+ // Helper to create a new Shell given a newly created WebContents.
+ static Shell* CreateShell(WebContents* web_contents);
// All the methods that begin with Platform need to be implemented by the
// platform specific Shell implementation.
@@ -90,7 +90,7 @@ class Shell : public WebContentsDelegate,
void PlatformCleanUp();
// Creates the main window GUI.
void PlatformCreateWindow(int width, int height);
- // Links the TabContents into the newly created window.
+ // Links the WebContents into the newly created window.
void PlatformSetContents();
// Resize the content area and GUI.
void PlatformResizeSubViews();
@@ -139,7 +139,7 @@ class Shell : public WebContentsDelegate,
GObject*, guint, GdkModifierType);
#endif
- scoped_ptr<TabContents> tab_contents_;
+ scoped_ptr<WebContents> web_contents_;
// layoutTestController related variables.
bool wait_until_done_;
diff --git a/content/shell/shell_browser_context.cc b/content/shell/shell_browser_context.cc
index 4cd7dae..ae3526f 100644
--- a/content/shell/shell_browser_context.cc
+++ b/content/shell/shell_browser_context.cc
@@ -10,7 +10,7 @@
#include "base/logging.h"
#include "base/path_service.h"
#include "base/threading/thread.h"
-#include "content/browser/download/download_manager_impl.h"
+#include "content/public/browser/download_manager.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/geolocation_permission_context.h"
#include "content/public/browser/speech_recognition_preferences.h"
@@ -129,7 +129,7 @@ bool ShellBrowserContext::IsOffTheRecord() const {
DownloadManager* ShellBrowserContext::GetDownloadManager() {
if (!download_manager_.get()) {
download_manager_delegate_ = new ShellDownloadManagerDelegate();
- download_manager_ = new DownloadManagerImpl(download_manager_delegate_,
+ download_manager_ = DownloadManager::Create(download_manager_delegate_,
NULL);
download_manager_delegate_->SetDownloadManager(download_manager_.get());
download_manager_->Init(this);
diff --git a/content/shell/shell_browser_main_parts.cc b/content/shell/shell_browser_main_parts.cc
index d9beba8..272b944 100644
--- a/content/shell/shell_browser_main_parts.cc
+++ b/content/shell/shell_browser_main_parts.cc
@@ -10,16 +10,13 @@
#include "base/string_number_conversions.h"
#include "base/threading/thread.h"
#include "base/threading/thread_restrictions.h"
-#include "content/browser/browser_process_sub_thread.h"
-#include "content/browser/download/download_file_manager.h"
-#include "content/browser/download/save_file_manager.h"
-#include "content/browser/plugin_service_impl.h"
#include "content/public/common/content_switches.h"
#include "content/shell/shell.h"
#include "content/shell/shell_browser_context.h"
#include "content/shell/shell_content_browser_client.h"
#include "content/shell/shell_devtools_delegate.h"
#include "content/shell/shell_switches.h"
+#include "googleurl/src/gurl.h"
#include "net/base/net_module.h"
#include "ui/base/clipboard/clipboard.h"
diff --git a/content/shell/shell_content_browser_client.cc b/content/shell/shell_content_browser_client.cc
index 901c572..632a5d7 100644
--- a/content/shell/shell_content_browser_client.cc
+++ b/content/shell/shell_content_browser_client.cc
@@ -14,16 +14,6 @@
#include "googleurl/src/gurl.h"
#include "third_party/skia/include/core/SkBitmap.h"
-#if defined(OS_WIN)
-#include "content/browser/tab_contents/tab_contents.h"
-#include "content/browser/tab_contents/tab_contents_view_win.h"
-#include "content/common/view_messages.h"
-#elif defined(OS_LINUX)
-#include "content/browser/tab_contents/tab_contents_view_gtk.h"
-#elif defined(OS_MACOSX)
-#include "content/browser/tab_contents/web_contents_view_mac.h"
-#endif
-
namespace content {
ShellContentBrowserClient::ShellContentBrowserClient()
diff --git a/content/shell/shell_download_manager_delegate.cc b/content/shell/shell_download_manager_delegate.cc
index b611868..2f6e95c 100644
--- a/content/shell/shell_download_manager_delegate.cc
+++ b/content/shell/shell_download_manager_delegate.cc
@@ -14,11 +14,10 @@
#include "base/logging.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
-#include "content/browser/download/download_state_info.h"
-#include "content/browser/tab_contents/tab_contents.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/download_manager.h"
+#include "content/public/browser/web_contents.h"
#include "net/base/net_util.h"
namespace content {
diff --git a/content/shell/shell_gtk.cc b/content/shell/shell_gtk.cc
index 4c383ba..5854091 100644
--- a/content/shell/shell_gtk.cc
+++ b/content/shell/shell_gtk.cc
@@ -12,8 +12,9 @@
#include "base/string_piece.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/native_web_keyboard_event.h"
-#include "content/browser/tab_contents/tab_contents.h"
-#include "content/browser/tab_contents/tab_contents_view_gtk.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/browser/web_contents_view.h"
+#include "content/public/common/renderer_preferences.h"
#include "third_party/skia/include/core/SkColor.h"
namespace content {
@@ -147,14 +148,13 @@ void Shell::PlatformCreateWindow(int width, int height) {
}
void Shell::PlatformSetContents() {
- TabContentsViewGtk* content_view =
- static_cast<TabContentsViewGtk*>(tab_contents_->GetView());
+ WebContentsView* content_view = web_contents_->GetView();
gtk_container_add(GTK_CONTAINER(vbox_), content_view->GetNativeView());
// As an additional requirement on Linux, we must set the colors for the
// render widgets in webkit.
content::RendererPreferences* prefs =
- tab_contents_->GetMutableRendererPrefs();
+ web_contents_->GetMutableRendererPrefs();
prefs->focus_ring_color = SkColorSetARGB(255, 229, 151, 0);
prefs->thumb_active_color = SkColorSetRGB(244, 244, 244);
prefs->thumb_inactive_color = SkColorSetRGB(234, 234, 234);
@@ -169,8 +169,8 @@ void Shell::PlatformSetContents() {
void Shell::SizeTo(int width, int height) {
content_width_ = width;
content_height_ = height;
- if (tab_contents_.get()) {
- gtk_widget_set_size_request(tab_contents_->GetNativeView(), width, height);
+ if (web_contents_.get()) {
+ gtk_widget_set_size_request(web_contents_->GetNativeView(), width, height);
}
}
diff --git a/content/shell/shell_mac.mm b/content/shell/shell_mac.mm
index ca31969..74b6a12 100644
--- a/content/shell/shell_mac.mm
+++ b/content/shell/shell_mac.mm
@@ -11,7 +11,7 @@
#import "base/memory/scoped_nsobject.h"
#include "base/string_piece.h"
#include "base/sys_string_conversions.h"
-#include "content/browser/tab_contents/tab_contents.h"
+#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
#include "content/shell/resource.h"
#include "googleurl/src/gurl.h"
@@ -199,7 +199,7 @@ void Shell::PlatformCreateWindow(int width, int height) {
}
void Shell::PlatformSetContents() {
- NSView* web_view = tab_contents_->GetView()->GetNativeView();
+ NSView* web_view = web_contents_->GetView()->GetNativeView();
NSView* content = [window_ contentView];
[content addSubview:web_view];
diff --git a/content/shell/shell_render_view_host_observer.cc b/content/shell/shell_render_view_host_observer.cc
index da57f87..c3529a0 100644
--- a/content/shell/shell_render_view_host_observer.cc
+++ b/content/shell/shell_render_view_host_observer.cc
@@ -7,7 +7,7 @@
#include <iostream>
#include "base/message_loop.h"
-#include "content/browser/renderer_host/render_view_host_impl.h"
+#include "content/public/browser/render_view_host.h"
#include "content/shell/shell.h"
#include "content/shell/shell_messages.h"
diff --git a/content/shell/shell_win.cc b/content/shell/shell_win.cc
index 47419ee..20fe1a0 100644
--- a/content/shell/shell_win.cc
+++ b/content/shell/shell_win.cc
@@ -11,7 +11,7 @@
#include "base/string_piece.h"
#include "base/utf_string_conversions.h"
#include "base/win/resource_util.h"
-#include "content/browser/tab_contents/tab_contents.h"
+#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
#include "content/shell/resource.h"
#include "googleurl/src/gurl.h"
@@ -148,7 +148,7 @@ void Shell::PlatformCreateWindow(int width, int height) {
}
void Shell::PlatformSetContents() {
- SetParent(tab_contents_->GetView()->GetNativeView(), window_);
+ SetParent(web_contents_->GetView()->GetNativeView(), window_);
}
void Shell::SizeTo(int width, int height) {
@@ -210,7 +210,7 @@ LRESULT CALLBACK Shell::WndProc(HWND hwnd, UINT message, WPARAM wParam,
switch (id) {
case IDM_NEW_WINDOW:
CreateNewWindow(
- shell->tab_contents()->GetBrowserContext(),
+ shell->web_contents()->GetBrowserContext(),
GURL(), NULL, MSG_ROUTING_NONE, NULL);
break;
case IDM_CLOSE_WINDOW: