summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbeng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-19 22:17:22 +0000
committerbeng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-19 22:17:22 +0000
commitad28cd4163bce913bc8b21c9a4a3eb8b02602852 (patch)
treea8f664d2ce4781650d3600bfc5a824b2455b4a8b
parentfa783618bd2c77e3461e300edcad7c9dea26685a (diff)
downloadchromium_src-ad28cd4163bce913bc8b21c9a4a3eb8b02602852.zip
chromium_src-ad28cd4163bce913bc8b21c9a4a3eb8b02602852.tar.gz
chromium_src-ad28cd4163bce913bc8b21c9a4a3eb8b02602852.tar.bz2
Replace usage of DOMView with usage of views::WebView.
BUG=none TEST=none Review URL: https://chromiumcodereview.appspot.com/10115047 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133069 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/enrollment_dialog_view.cc36
-rw-r--r--chrome/browser/chromeos/login/captive_portal_view.cc36
-rw-r--r--chrome/browser/chromeos/login/captive_portal_view.h8
-rw-r--r--chrome/browser/chromeos/login/lock_window.h8
-rw-r--r--chrome/browser/chromeos/login/lock_window_aura.cc2
-rw-r--r--chrome/browser/chromeos/login/lock_window_aura.h2
-rw-r--r--chrome/browser/chromeos/login/webui_login_view.cc18
-rw-r--r--chrome/browser/chromeos/login/webui_login_view.h8
-rw-r--r--chrome/browser/chromeos/login/webui_screen_locker.cc3
-rw-r--r--chrome/browser/tab_render_watcher_browsertest.cc16
-rw-r--r--chrome/browser/ui/virtual_keyboard/virtual_keyboard_manager.cc36
-rw-r--r--ui/views/controls/webview/webview.cc24
-rw-r--r--ui/views/controls/webview/webview.h18
13 files changed, 121 insertions, 94 deletions
diff --git a/chrome/browser/chromeos/enrollment_dialog_view.cc b/chrome/browser/chromeos/enrollment_dialog_view.cc
index 868f08d..28eb087 100644
--- a/chrome/browser/chromeos/enrollment_dialog_view.cc
+++ b/chrome/browser/chromeos/enrollment_dialog_view.cc
@@ -8,12 +8,12 @@
#include "chrome/browser/chromeos/cros/network_library.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/themes/theme_service.h"
-#include "chrome/browser/ui/views/dom_view.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/views/border.h"
#include "ui/views/controls/label.h"
+#include "ui/views/controls/webview/webview.h"
#include "ui/views/layout/grid_layout.h"
#include "ui/views/layout/layout_constants.h"
#include "ui/views/widget/widget.h"
@@ -33,8 +33,8 @@ namespace {
const int kDefaultWidth = 640;
const int kDefaultHeight = 480;
-// Border around the DOMView
-const int kDOMBorderWidth = 1;
+// Border around the WebView
+const int kWebViewBorderSize = 1;
// TODO(gspencer): Move this into ui/views/layout, perhaps just adding insets
// to FillLayout.
@@ -198,23 +198,23 @@ void EnrollmentDialogView::InitDialog() {
label->SetMultiLine(true);
label->SetAllowCharacterBreak(true);
- // In order to get a border that shows around the DOMView, we need to embed it
+ // In order to get a border that shows around the WebView, we need to embed it
// into another view because it hosts a native window that fills the view.
- View* dom_border_view = new View();
- dom_border_view->SetLayoutManager(
- new BorderLayout(gfx::Insets(kDOMBorderWidth,
- kDOMBorderWidth,
- kDOMBorderWidth,
- kDOMBorderWidth)));
+ View* web_view_border_view = new View();
+ web_view_border_view->SetLayoutManager(
+ new BorderLayout(gfx::Insets(kWebViewBorderSize,
+ kWebViewBorderSize,
+ kWebViewBorderSize,
+ kWebViewBorderSize)));
SkColor frame_color = ThemeService::GetDefaultColor(
ThemeService::COLOR_FRAME);
- Border* border = views::Border::CreateSolidBorder(kDOMBorderWidth,
+ Border* border = views::Border::CreateSolidBorder(kWebViewBorderSize,
frame_color);
- dom_border_view->set_border(border);
- DOMView* dom_view = new DOMView();
- dom_view->Init(ProfileManager::GetLastUsedProfile(), NULL);
- dom_border_view->AddChildView(dom_view);
- dom_view->SetVisible(true);
+ web_view_border_view->set_border(border);
+ views::WebView* web_view =
+ new views::WebView(ProfileManager::GetLastUsedProfile());
+ web_view_border_view->AddChildView(web_view);
+ web_view->SetVisible(true);
GridLayout* grid_layout = GridLayout::CreatePanel(this);
SetLayoutManager(grid_layout);
@@ -242,10 +242,10 @@ void EnrollmentDialogView::InitDialog() {
grid_layout->AddView(label);
grid_layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing);
grid_layout->StartRow(100.0f, 0);
- grid_layout->AddView(dom_border_view);
+ grid_layout->AddView(web_view_border_view);
grid_layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing);
grid_layout->Layout(this);
- dom_view->LoadURL(target_uri_);
+ web_view->LoadInitialURL(target_uri_);
}
} // namespace chromeos
diff --git a/chrome/browser/chromeos/login/captive_portal_view.cc b/chrome/browser/chromeos/login/captive_portal_view.cc
index cb4f6f2..1d9de73 100644
--- a/chrome/browser/chromeos/login/captive_portal_view.cc
+++ b/chrome/browser/chromeos/login/captive_portal_view.cc
@@ -30,6 +30,7 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/theme_provider.h"
#include "ui/views/background.h"
+#include "ui/views/controls/webview/webview.h"
#include "ui/views/layout/grid_layout.h"
#include "ui/views/layout/layout_constants.h"
#include "ui/views/view.h"
@@ -44,7 +45,7 @@ const char kCaptivePortalStartURL[] = "http://client3.google.com/generate_204";
const int kLocationBarHeight = 35;
// Margin between screen edge and CaptivePortalView border.
const int kExternalMargin = 50;
-// Margin between DomView and CaptivePortalView border.
+// Margin between WebView and CaptivePortalView border.
const int kInnerMargin = 2;
class ToolbarRowView : public views::View {
@@ -125,7 +126,7 @@ CaptivePortalView::CaptivePortalView(Profile* profile,
forward_(NULL),
reload_(NULL),
location_bar_(NULL),
- dom_view_(NULL),
+ web_view_(NULL),
bubble_model_delegate_(new StubBubbleModelDelegate) {
command_updater_.reset(new CommandUpdater(this));
command_updater_->UpdateCommandEnabled(IDC_BACK, true);
@@ -136,20 +137,19 @@ CaptivePortalView::CaptivePortalView(Profile* profile,
}
CaptivePortalView::~CaptivePortalView() {
- if (dom_view_container_.get()) {
- // DomView can't be deleted immediately, because it could be on the stack.
- dom_view_->dom_contents()->web_contents()->SetDelegate(NULL);
+ if (web_view_container_.get()) {
+ // WebView can't be deleted immediately, because it could be on the stack.
+ web_view_->web_contents()->SetDelegate(NULL);
MessageLoop::current()->DeleteSoon(
- FROM_HERE, dom_view_container_.release());
+ FROM_HERE, web_view_container_.release());
}
}
void CaptivePortalView::StartLoad() {
- dom_view_container_.reset(new DOMView);
- dom_view_ = dom_view_container_.get();
- dom_view_->Init(profile_, NULL);
- dom_view_->dom_contents()->web_contents()->SetDelegate(this);
- dom_view_->LoadURL(GURL(kCaptivePortalStartURL));
+ web_view_container_.reset(new views::WebView(profile_));
+ web_view_ = web_view_container_.get();
+ web_view_->GetWebContents()->SetDelegate(this);
+ web_view_->LoadInitialURL(GURL(kCaptivePortalStartURL));
}
void CaptivePortalView::Init() {
@@ -219,11 +219,11 @@ void CaptivePortalView::Init() {
layout->AddPaddingRow(0, kInnerMargin);
layout->StartRow(1, 1);
- layout->AddView(dom_view_container_.release());
+ layout->AddView(web_view_container_.release());
layout->AddPaddingRow(0, kInnerMargin);
location_bar_->Init();
- UpdateReload(dom_view_->dom_contents()->web_contents()->IsLoading(), true);
+ UpdateReload(web_view_->web_contents()->IsLoading(), true);
Layout();
}
@@ -255,7 +255,7 @@ views::View* CaptivePortalView::GetContentsView() {
}
views::View* CaptivePortalView::GetInitiallyFocusedView() {
- return dom_view_;
+ return web_view_;
}
bool CaptivePortalView::ShouldShowWindowTitle() const {
@@ -298,7 +298,7 @@ void CaptivePortalView::LoadingStateChanged(WebContents* source) {
}
TabContentsWrapper* CaptivePortalView::GetTabContentsWrapper() const {
- return dom_view_->dom_contents();
+ return NULL;
}
InstantController* CaptivePortalView::GetInstant() {
@@ -344,13 +344,13 @@ void CaptivePortalView::OnInputInProgress(bool in_progress) {
}
content::WebContents* CaptivePortalView::GetActiveWebContents() const {
- return dom_view_->dom_contents()->web_contents();
+ return web_view_->web_contents();
}
void CaptivePortalView::ExecuteCommandWithDisposition(
int id,
WindowOpenDisposition) {
- WebContents* web_contents = dom_view_->dom_contents()->web_contents();
+ WebContents* web_contents = web_view_->web_contents();
switch (id) {
case IDC_BACK:
if (web_contents->GetController().CanGoBack()) {
@@ -414,7 +414,7 @@ void CaptivePortalView::LoadImages() {
void CaptivePortalView::UpdateButtons() {
const content::NavigationController& navigation_controller =
- dom_view_->dom_contents()->web_contents()->GetController();
+ web_view_->web_contents()->GetController();
back_->SetEnabled(navigation_controller.CanGoBack());
forward_->SetEnabled(navigation_controller.CanGoForward());
}
diff --git a/chrome/browser/chromeos/login/captive_portal_view.h b/chrome/browser/chromeos/login/captive_portal_view.h
index a7b7f36..f744c6b 100644
--- a/chrome/browser/chromeos/login/captive_portal_view.h
+++ b/chrome/browser/chromeos/login/captive_portal_view.h
@@ -10,7 +10,6 @@
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/command_updater.h"
#include "chrome/browser/ui/toolbar/toolbar_model_delegate.h"
-#include "chrome/browser/ui/views/dom_view.h"
#include "chrome/browser/ui/views/location_bar/location_bar_view.h"
#include "content/public/browser/web_contents_delegate.h"
#include "ui/gfx/size.h"
@@ -23,6 +22,7 @@ class ReloadButton;
class ToolbarModel;
namespace views {
+class WebView;
class Widget;
}
@@ -112,10 +112,10 @@ class CaptivePortalView : public views::ButtonListener,
views::ImageButton* forward_;
ReloadButton* reload_;
LocationBarView* location_bar_;
- DOMView* dom_view_;
+ views::WebView* web_view_;
- // Contains |dom_view_| while it isn't owned by the view.
- scoped_ptr<DOMView> dom_view_container_;
+ // Contains |web_view_| while it isn't owned by the view.
+ scoped_ptr<views::WebView> web_view_container_;
scoped_ptr<StubBubbleModelDelegate> bubble_model_delegate_;
diff --git a/chrome/browser/chromeos/login/lock_window.h b/chrome/browser/chromeos/login/lock_window.h
index 0f4189b..b2ee55d 100644
--- a/chrome/browser/chromeos/login/lock_window.h
+++ b/chrome/browser/chromeos/login/lock_window.h
@@ -8,8 +8,6 @@
#include "base/basictypes.h"
-class DOMView;
-
namespace views {
class Widget;
}
@@ -31,9 +29,9 @@ class LockWindow {
LockWindow();
- // Attempt to grab inputs on |dom_view|, the actual view displaying the lock
- // screen DOM.
- virtual void Grab(DOMView* dom_view) = 0;
+ // Attempt to grab inputs on the webview, the actual view displaying the lock
+ // screen WebView.
+ virtual void Grab() = 0;
// Returns the actual widget for the lock window.
virtual views::Widget* GetWidget() = 0;
diff --git a/chrome/browser/chromeos/login/lock_window_aura.cc b/chrome/browser/chromeos/login/lock_window_aura.cc
index d334926..05da9c3 100644
--- a/chrome/browser/chromeos/login/lock_window_aura.cc
+++ b/chrome/browser/chromeos/login/lock_window_aura.cc
@@ -18,7 +18,7 @@ LockWindow* LockWindow::Create() {
////////////////////////////////////////////////////////////////////////////////
// LockWindow implementation:
-void LockWindowAura::Grab(DOMView* dom_view) {
+void LockWindowAura::Grab() {
// We already have grab from the lock screen container, just call the ready
// callback immediately.
if (observer_)
diff --git a/chrome/browser/chromeos/login/lock_window_aura.h b/chrome/browser/chromeos/login/lock_window_aura.h
index 4478dcf..9117aca 100644
--- a/chrome/browser/chromeos/login/lock_window_aura.h
+++ b/chrome/browser/chromeos/login/lock_window_aura.h
@@ -16,7 +16,7 @@ class LockWindowAura : public views::Widget,
public LockWindow {
public:
// LockWindow implementation:
- virtual void Grab(DOMView* dom_view) OVERRIDE;
+ virtual void Grab() OVERRIDE;
virtual views::Widget* GetWidget() OVERRIDE;
private:
diff --git a/chrome/browser/chromeos/login/webui_login_view.cc b/chrome/browser/chromeos/login/webui_login_view.cc
index 78ba39b..7fa2a75b 100644
--- a/chrome/browser/chromeos/login/webui_login_view.cc
+++ b/chrome/browser/chromeos/login/webui_login_view.cc
@@ -17,7 +17,6 @@
#include "chrome/browser/chromeos/login/webui_login_display.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/views/ash/chrome_shell_delegate.h"
-#include "chrome/browser/ui/views/dom_view.h"
#include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/render_messages.h"
@@ -29,6 +28,7 @@
#include "content/public/browser/web_ui.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/size.h"
+#include "ui/views/controls/webview/webview.h"
#include "ui/views/widget/widget.h"
#if defined(USE_VIRTUAL_KEYBOARD)
@@ -157,12 +157,10 @@ WebUILoginView::~WebUILoginView() {
void WebUILoginView::Init(views::Widget* login_window) {
login_window_ = login_window;
- webui_login_ = new DOMView();
+ webui_login_ = new views::WebView(ProfileManager::GetDefaultProfile());
AddChildView(webui_login_);
- webui_login_->Init(ProfileManager::GetDefaultProfile(), NULL);
- webui_login_->SetVisible(true);
- WebContents* web_contents = webui_login_->dom_contents()->web_contents();
+ WebContents* web_contents = webui_login_->GetWebContents();
web_contents->SetDelegate(this);
tab_watcher_.reset(new TabRenderWatcher(web_contents, this));
@@ -202,12 +200,12 @@ void WebUILoginView::UpdateWindowType() {
}
void WebUILoginView::LoadURL(const GURL & url) {
- webui_login_->LoadURL(url);
+ webui_login_->LoadInitialURL(url);
webui_login_->RequestFocus();
}
content::WebUI* WebUILoginView::GetWebUI() {
- return webui_login_->dom_contents()->web_contents()->GetWebUI();
+ return webui_login_->web_contents()->GetWebUI();
}
void WebUILoginView::OpenProxySettings() {
@@ -243,8 +241,7 @@ void WebUILoginView::ChildPreferredSizeChanged(View* child) {
void WebUILoginView::AboutToRequestFocusFromTabTraversal(bool reverse) {
// Return the focus to the web contents.
- webui_login_->dom_contents()->web_contents()->
- FocusThroughTabTraversal(reverse);
+ webui_login_->web_contents()->FocusThroughTabTraversal(reverse);
GetWidget()->Activate();
}
@@ -325,8 +322,7 @@ bool WebUILoginView::TakeFocus(bool reverse) {
void WebUILoginView::ReturnFocus(bool reverse) {
// Return the focus to the web contents.
- webui_login_->dom_contents()->web_contents()->
- FocusThroughTabTraversal(reverse);
+ webui_login_->web_contents()->FocusThroughTabTraversal(reverse);
GetWidget()->Activate();
}
diff --git a/chrome/browser/chromeos/login/webui_login_view.h b/chrome/browser/chromeos/login/webui_login_view.h
index 9745f3b..4067cb1 100644
--- a/chrome/browser/chromeos/login/webui_login_view.h
+++ b/chrome/browser/chromeos/login/webui_login_view.h
@@ -18,7 +18,6 @@
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"
-class DOMView;
class GURL;
namespace content {
@@ -27,13 +26,14 @@ class WebUI;
namespace views {
class View;
+class WebView;
class Widget;
}
namespace chromeos {
// View used to render a WebUI supporting Widget. This widget is used for the
-// WebUI based start up and lock screens. It contains a DOMView.
+// WebUI based start up and lock screens. It contains a WebView.
class WebUILoginView : public views::WidgetDelegateView,
public content::WebContentsDelegate,
public content::NotificationObserver,
@@ -94,8 +94,8 @@ class WebUILoginView : public views::WidgetDelegateView,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
- // DOMView for rendering a webpage as a webui login.
- DOMView* webui_login_;
+ // WebView for rendering a webpage as a webui login.
+ views::WebView* webui_login_;
private:
// Map type for the accelerator-to-identifier map.
diff --git a/chrome/browser/chromeos/login/webui_screen_locker.cc b/chrome/browser/chromeos/login/webui_screen_locker.cc
index 9f8e7c2..08f6b3d 100644
--- a/chrome/browser/chromeos/login/webui_screen_locker.cc
+++ b/chrome/browser/chromeos/login/webui_screen_locker.cc
@@ -13,7 +13,6 @@
#include "chrome/browser/chromeos/login/screen_locker.h"
#include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/chromeos/login/webui_login_display.h"
-#include "chrome/browser/ui/views/dom_view.h"
#include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/url_constants.h"
@@ -55,7 +54,7 @@ void WebUIScreenLocker::LockScreen(bool unlock_on_input) {
lock_window_->Show();
OnWindowCreated();
LoadURL(GURL(kLoginURL));
- lock_window->Grab(webui_login_);
+ lock_window->Grab();
// User list consisting of a single logged-in user.
UserList users(1, &chromeos::UserManager::Get()->GetLoggedInUser());
diff --git a/chrome/browser/tab_render_watcher_browsertest.cc b/chrome/browser/tab_render_watcher_browsertest.cc
index 8d84e5d..d488b12 100644
--- a/chrome/browser/tab_render_watcher_browsertest.cc
+++ b/chrome/browser/tab_render_watcher_browsertest.cc
@@ -5,10 +5,11 @@
#include "base/message_loop.h"
#include "chrome/browser/tab_render_watcher.h"
#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/views/dom_view.h"
+#include "chrome/browser/profiles/profile.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/views/controls/webview/webview.h"
#include "ui/views/widget/widget.h"
namespace {
@@ -59,19 +60,18 @@ class TabRenderWatcherTest : public InProcessBrowserTest,
// Migrated from HtmlDialogBrowserTest.TestStateTransition, which times out
// about 5~10% of runs. See crbug.com/86059.
IN_PROC_BROWSER_TEST_F(TabRenderWatcherTest, DISABLED_TestStateTransition) {
- DOMView* dom_view = new DOMView;
- dom_view->Init(browser()->profile(), NULL);
- CreateWindowForContents(dom_view);
- dom_view->GetWidget()->Show();
+ views::WebView* webview = new views::WebView(browser()->profile());
+ CreateWindowForContents(webview);
+ webview->GetWidget()->Show();
scoped_ptr<TabRenderWatcher> watcher(
- new TabRenderWatcher(dom_view->dom_contents()->web_contents(), this));
+ new TabRenderWatcher(webview->GetWebContents(), this));
EXPECT_FALSE(host_created_);
EXPECT_FALSE(main_frame_loaded_);
EXPECT_FALSE(main_frame_rendered_);
- dom_view->LoadURL(GURL(chrome::kChromeUIChromeURLsURL));
+ webview->LoadInitialURL(GURL(chrome::kChromeUIChromeURLsURL));
EXPECT_TRUE(host_created_);
// OnTabMainFrameLoaded() will Quit().
@@ -82,5 +82,5 @@ IN_PROC_BROWSER_TEST_F(TabRenderWatcherTest, DISABLED_TestStateTransition) {
MessageLoopForUI::current()->Run();
EXPECT_TRUE(main_frame_rendered_);
- dom_view->GetWidget()->Close();
+ webview->GetWidget()->Close();
}
diff --git a/chrome/browser/ui/virtual_keyboard/virtual_keyboard_manager.cc b/chrome/browser/ui/virtual_keyboard/virtual_keyboard_manager.cc
index 19dca65..762ec9b 100644
--- a/chrome/browser/ui/virtual_keyboard/virtual_keyboard_manager.cc
+++ b/chrome/browser/ui/virtual_keyboard/virtual_keyboard_manager.cc
@@ -28,6 +28,7 @@
#include "ui/base/ime/text_input_type.h"
#include "ui/gfx/compositor/layer.h"
#include "ui/gfx/screen.h"
+#include "ui/views/controls/webview/webview.h"
#include "ui/views/ime/text_input_type_tracker.h"
#include "ui/views/widget/widget.h"
@@ -152,8 +153,8 @@ class KeyboardWidget
GURL keyboard_url_;
- // The DOM view to host the keyboard.
- DOMView* dom_view_;
+ // The WebView to host the keyboard.
+ views::WebView* webview_;
ExtensionFunctionDispatcher extension_dispatcher_;
@@ -171,7 +172,7 @@ class KeyboardWidget
KeyboardWidget::KeyboardWidget()
: views::Widget::Widget(),
keyboard_url_(chrome::kChromeUIKeyboardURL),
- dom_view_(new DOMView),
+ webview_(new DOMView(ProfileManager::GetDefaultProfile()))),
ALLOW_THIS_IN_INITIALIZER_LIST(
extension_dispatcher_(ProfileManager::GetDefaultProfile(), this)),
target_(NULL),
@@ -189,16 +190,14 @@ KeyboardWidget::KeyboardWidget()
Init(params);
// Setup the DOM view to host the keyboard.
- Profile* profile = ProfileManager::GetDefaultProfile();
- dom_view_->Init(profile,
- content::SiteInstance::CreateForURL(profile, keyboard_url_));
- dom_view_->LoadURL(keyboard_url_);
- dom_view_->SetVisible(true);
- SetContentsView(dom_view_);
+ webview_->CreateWebContentsWithSiteInstance(
+ content::SiteInstance::CreateForURL(webview_->browser_context(),
+ keyboard_url_));
+ webview_->LoadInitialURL(keyboard_url_);
+ SetContentsView(webview_);
// Setup observer so the events from the keyboard can be handled.
- content::WebContentsObserver::Observe(
- dom_view_->dom_contents()->web_contents());
+ content::WebContentsObserver::Observe(webview_->web_contents());
// Initialize the animation.
animation_.reset(new ui::SlideAnimation(this));
@@ -343,14 +342,14 @@ bool KeyboardWidget::OnMessageReceived(const IPC::Message& message) {
void KeyboardWidget::RenderViewGone(base::TerminationStatus status) {
if (status != base::TERMINATION_STATUS_NORMAL_TERMINATION) {
// Reload the keyboard if it crashes.
- dom_view_->LoadURL(keyboard_url_);
- dom_view_->SchedulePaint();
+ webview_->LoadInitialURL(keyboard_url_);
+ webview_->SchedulePaint();
}
}
void KeyboardWidget::OnRequest(const ExtensionHostMsg_Request_Params& request) {
extension_dispatcher_.Dispatch(request,
- dom_view_->dom_contents()->web_contents()->GetRenderViewHost());
+ webview_->web_contents()->GetRenderViewHost());
}
void KeyboardWidget::TextInputTypeChanged(ui::TextInputType type,
@@ -400,9 +399,7 @@ void KeyboardWidget::TextInputTypeChanged(ui::TextInputType type,
std::string json_args;
base::JSONWriter::Write(&args, &json_args);
- Profile* profile =
- Profile::FromBrowserContext(
- dom_view_->dom_contents()->web_contents()->GetBrowserContext());
+ Profile* profile = Profile::FromBrowserContext(webview_->browser_context());
profile->GetExtensionEventRouter()->DispatchEventToRenderers(
kOnTextInputTypeChanged, json_args, NULL, GURL());
@@ -420,8 +417,7 @@ Browser* KeyboardWidget::GetBrowser() {
}
content::WebContents* KeyboardWidget::GetAssociatedWebContents() const {
- return dom_view_->dom_contents() ?
- dom_view_->dom_contents()->web_contents() : NULL;
+ return webview_->web_contents();
}
#if defined(OS_CHROMEOS)
@@ -430,7 +426,7 @@ void KeyboardWidget::VirtualKeyboardChanged(
const chromeos::input_method::VirtualKeyboard& virtual_keyboard,
const std::string& virtual_keyboard_layout) {
const GURL& url = virtual_keyboard.GetURLForLayout(virtual_keyboard_layout);
- dom_view_->LoadURL(url);
+ webview_->LoadInitialURL(url);
VLOG(1) << "VirtualKeyboardChanged: Switched to " << url.spec();
}
#endif
diff --git a/ui/views/controls/webview/webview.cc b/ui/views/controls/webview/webview.cc
index 136db8a..f1b9e3a 100644
--- a/ui/views/controls/webview/webview.cc
+++ b/ui/views/controls/webview/webview.cc
@@ -5,6 +5,7 @@
#include "ui/views/controls/webview/webview.h"
#include "content/public/browser/browser_context.h"
+#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/notification_source.h"
@@ -19,6 +20,10 @@
namespace views {
+// static
+const char WebView::kViewClassName[] =
+ "ui/views/WebView";
+
////////////////////////////////////////////////////////////////////////////////
// WebView, public:
@@ -33,9 +38,15 @@ WebView::~WebView() {
}
content::WebContents* WebView::GetWebContents() {
+ CreateWebContentsWithSiteInstance(NULL);
+ return web_contents_;
+}
+
+void WebView::CreateWebContentsWithSiteInstance(
+ content::SiteInstance* site_instance) {
if (!web_contents_) {
wc_owner_.reset(content::WebContents::Create(browser_context_,
- NULL,
+ site_instance,
MSG_ROUTING_NONE,
NULL,
NULL));
@@ -43,7 +54,6 @@ content::WebContents* WebView::GetWebContents() {
web_contents_->SetDelegate(this);
AttachWebContents();
}
- return web_contents_;
}
void WebView::SetWebContents(content::WebContents* web_contents) {
@@ -55,6 +65,12 @@ void WebView::SetWebContents(content::WebContents* web_contents) {
AttachWebContents();
}
+void WebView::LoadInitialURL(const GURL& url) {
+ GetWebContents()->GetController().LoadURL(
+ url, content::Referrer(), content::PAGE_TRANSITION_START_PAGE,
+ std::string());
+}
+
void WebView::SetFastResize(bool fast_resize) {
wcv_holder_->set_fast_resize(fast_resize);
}
@@ -68,6 +84,10 @@ void WebView::OnWebContentsFocused(content::WebContents* web_contents) {
////////////////////////////////////////////////////////////////////////////////
// WebView, View overrides:
+std::string WebView::GetClassName() const {
+ return kViewClassName;
+}
+
void WebView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
wcv_holder_->SetSize(bounds().size());
}
diff --git a/ui/views/controls/webview/webview.h b/ui/views/controls/webview/webview.h
index 23c4748..f519c0e 100644
--- a/ui/views/controls/webview/webview.h
+++ b/ui/views/controls/webview/webview.h
@@ -21,6 +21,8 @@ class VIEWS_EXPORT WebView : public View,
public content::NotificationObserver,
public content::WebContentsDelegate {
public:
+ static const char kViewClassName[];
+
explicit WebView(content::BrowserContext* browser_context);
virtual ~WebView();
@@ -28,12 +30,25 @@ class VIEWS_EXPORT WebView : public View,
// WebView owns this implicitly created WebContents.
content::WebContents* GetWebContents();
+ // Creates a WebContents if none is yet assocaited with this WebView, with the
+ // specified site instance. The WebView owns this WebContents.
+ void CreateWebContentsWithSiteInstance(content::SiteInstance* site_instance);
+
// WebView does not assume ownership of WebContents set via this method, only
// those it implicitly creates via GetWebContents() above.
void SetWebContents(content::WebContents* web_contents);
content::WebContents* web_contents() { return web_contents_; }
+ content::BrowserContext* browser_context() { return browser_context_; }
+
+ // Loads the initial URL to display in the attached WebContents. Creates the
+ // WebContents if none is attached yet. Note that this is intended as a
+ // convenience for loading the initial URL, and so URLs are navigated with
+ // PAGE_TRANSITION_START_PAGE, so this is not intended as a general purpose
+ // navigation method - use WebContents' API directly.
+ void LoadInitialURL(const GURL& url);
+
// Controls how the attached WebContents is resized.
// false = WebContents' views' bounds are updated continuously as the
// WebView's bounds change (default).
@@ -49,6 +64,9 @@ class VIEWS_EXPORT WebView : public View,
// forward this notification.
void OnWebContentsFocused(content::WebContents* web_contents);
+ // Overridden from View:
+ virtual std::string GetClassName() const OVERRIDE;
+
private:
// Overridden from View:
virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE;