diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-26 06:09:06 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-26 06:09:06 +0000 |
commit | f3615f0a53ed81a0146c3ff2816ac8432b779cbf (patch) | |
tree | cb1565c101fc9c425c8d6848e9bbd4ea62d00078 | |
parent | c9e49a0ce0b7e7d0cc4c447f1c81161d28dbfe07 (diff) | |
download | chromium_src-f3615f0a53ed81a0146c3ff2816ac8432b779cbf.zip chromium_src-f3615f0a53ed81a0146c3ff2816ac8432b779cbf.tar.gz chromium_src-f3615f0a53ed81a0146c3ff2816ac8432b779cbf.tar.bz2 |
Remove WebContents methods that duplicate WebContentsView methods.
Review URL: https://codereview.chromium.org/12334073
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@184598 0039d316-1c4b-4281-b951-d872f2087c98
94 files changed, 368 insertions, 281 deletions
diff --git a/android_webview/native/aw_web_contents_view_delegate.cc b/android_webview/native/aw_web_contents_view_delegate.cc index 160cf99..849fd5c 100644 --- a/android_webview/native/aw_web_contents_view_delegate.cc +++ b/android_webview/native/aw_web_contents_view_delegate.cc @@ -7,6 +7,7 @@ #include "android_webview/native/aw_contents.h" #include "content/public/browser/android/content_view_core.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "content/public/common/context_menu_params.h" namespace android_webview { @@ -43,7 +44,7 @@ void AwWebContentsViewDelegate::ShowContextMenu( // Display paste pop-up only when selection is empty and editable. if (params.is_editable && params.selection_text.empty()) { content::ContentViewCore* content_view_core = - web_contents_->GetContentNativeView(); + web_contents_->GetView()->GetContentNativeView(); if (content_view_core) { content_view_core->ShowPastePopup(params.selection_start.x(), params.selection_start.y()); diff --git a/chrome/browser/autofill/autofill_external_delegate.cc b/chrome/browser/autofill/autofill_external_delegate.cc index 507f08e..6d60412 100644 --- a/chrome/browser/autofill/autofill_external_delegate.cc +++ b/chrome/browser/autofill/autofill_external_delegate.cc @@ -160,7 +160,7 @@ void AutofillExternalDelegate::EnsurePopupForElement( const gfx::RectF& element_bounds) { // Convert element_bounds to be in screen space. gfx::Rect client_area; - web_contents_->GetContainerBounds(&client_area); + web_contents_->GetView()->GetContainerBounds(&client_area); gfx::RectF element_bounds_in_screen_space = element_bounds + client_area.OffsetFromOrigin(); diff --git a/chrome/browser/automation/automation_provider_win.cc b/chrome/browser/automation/automation_provider_win.cc index eaed51e..358ad6f 100644 --- a/chrome/browser/automation/automation_provider_win.cc +++ b/chrome/browser/automation/automation_provider_win.cc @@ -24,6 +24,7 @@ #include "content/public/browser/navigation_controller.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "content/public/common/page_zoom.h" #include "ui/base/keycodes/keyboard_codes.h" #include "ui/views/focus/accelerator_handler.h" @@ -63,7 +64,7 @@ void AutomationProvider::CreateExternalTab( SessionTabHelper::FromWebContents(web_contents); *tab_handle = external_tab_container->GetTabHandle(); *tab_container_window = external_tab_container->GetExternalTabNativeView(); - *tab_window = web_contents->GetNativeView(); + *tab_window = web_contents->GetView()->GetNativeView(); *session_id = session_tab_helper->session_id().id(); } else { external_tab_container->Uninitialize(); @@ -118,7 +119,7 @@ ExternalTabContainer* AutomationProvider::GetExternalTabForHandle(int handle) { if (tab_tracker_->ContainsHandle(handle)) { NavigationController* tab = tab_tracker_->GetResource(handle); return ExternalTabContainer::GetContainerForTab( - tab->GetWebContents()->GetNativeView()); + tab->GetWebContents()->GetView()->GetNativeView()); } return NULL; @@ -191,7 +192,7 @@ void AutomationProvider::ConnectExternalTab( SessionTabHelper::FromWebContents(web_contents); *tab_handle = external_tab_container->GetTabHandle(); *tab_container_window = external_tab_container->GetExternalTabNativeView(); - *tab_window = web_contents->GetNativeView(); + *tab_window = web_contents->GetView()->GetNativeView(); *session_id = session_tab_helper->session_id().id(); } else { external_tab_container->Uninitialize(); diff --git a/chrome/browser/chromeos/login/webui_login_display_host.cc b/chrome/browser/chromeos/login/webui_login_display_host.cc index 20a67e8..56a961e 100644 --- a/chrome/browser/chromeos/login/webui_login_display_host.cc +++ b/chrome/browser/chromeos/login/webui_login_display_host.cc @@ -26,6 +26,7 @@ #include "chrome/common/chrome_switches.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "content/public/browser/web_ui.h" #include "ui/aura/env.h" #include "ui/aura/root_window.h" @@ -322,7 +323,7 @@ void WebUILoginDisplayHost::ShowWebUI() { } LOG(INFO) << "Login WebUI >> Show already initialized UI"; login_window_->Show(); - login_view_->GetWebContents()->Focus(); + login_view_->GetWebContents()->GetView()->Focus(); login_view_->SetStatusAreaVisible(status_area_saved_visibility_); login_view_->OnPostponedShow(); // We should reset this flag to allow changing of status area visibility. diff --git a/chrome/browser/chromeos/login/webui_login_view.cc b/chrome/browser/chromeos/login/webui_login_view.cc index 36f6714..918a620 100644 --- a/chrome/browser/chromeos/login/webui_login_view.cc +++ b/chrome/browser/chromeos/login/webui_login_view.cc @@ -33,6 +33,7 @@ #include "content/public/browser/render_view_host_observer.h" #include "content/public/browser/render_widget_host_view.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "content/public/browser/web_ui.h" #include "ui/aura/env.h" #include "ui/gfx/rect.h" @@ -276,7 +277,7 @@ void WebUILoginView::AboutToRequestFocusFromTabTraversal(bool reverse) { // Return the focus to the web contents. webui_login_->web_contents()->FocusThroughTabTraversal(reverse); GetWidget()->Activate(); - webui_login_->web_contents()->Focus(); + webui_login_->web_contents()->GetView()->Focus(); } void WebUILoginView::Observe(int type, diff --git a/chrome/browser/devtools/devtools_window.cc b/chrome/browser/devtools/devtools_window.cc index 94d73c9..b313155 100644 --- a/chrome/browser/devtools/devtools_window.cc +++ b/chrome/browser/devtools/devtools_window.cc @@ -409,7 +409,8 @@ void DevToolsWindow::CreateDevToolsBrowser() { } chrome::HostDesktopType host_desktop_type = - chrome::GetHostDesktopTypeForNativeView(web_contents_->GetNativeView()); + chrome::GetHostDesktopTypeForNativeView( + web_contents_->GetView()->GetNativeView()); browser_ = new Browser(Browser::CreateParams::CreateForDevTools( profile_, host_desktop_type)); diff --git a/chrome/browser/download/download_file_picker.cc b/chrome/browser/download/download_file_picker.cc index 5b908e8..29a1573 100644 --- a/chrome/browser/download/download_file_picker.cc +++ b/chrome/browser/download/download_file_picker.cc @@ -11,6 +11,7 @@ #include "content/public/browser/download_item.h" #include "content/public/browser/download_manager.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" @@ -82,7 +83,8 @@ void DownloadFilePicker::Init( file_type_info.include_all_files = true; file_type_info.support_drive = true; gfx::NativeWindow owning_window = web_contents ? - platform_util::GetTopLevel(web_contents->GetNativeView()) : NULL; + platform_util::GetTopLevel(web_contents->GetView()->GetNativeView()) : + NULL; select_file_dialog_->SelectFile( ui::SelectFileDialog::SELECT_SAVEAS_FILE, diff --git a/chrome/browser/download/download_shelf.cc b/chrome/browser/download/download_shelf.cc index 843a662..659bf6f 100644 --- a/chrome/browser/download/download_shelf.cc +++ b/chrome/browser/download/download_shelf.cc @@ -17,6 +17,7 @@ #include "content/public/browser/download_item.h" #include "content/public/browser/download_manager.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "ui/base/animation/animation.h" using content::DownloadItem; @@ -124,7 +125,7 @@ void DownloadShelf::ShowDownload(DownloadItem* download) { browser()->tab_strip_model()->GetActiveWebContents(); if (DownloadItemModel(download).ShouldShowDownloadStartedAnimation() && shelf_tab && - platform_util::IsVisible(shelf_tab->GetNativeView()) && + platform_util::IsVisible(shelf_tab->GetView()->GetNativeView()) && ui::Animation::ShouldRenderRichAnimation()) { DownloadStartedAnimation::Show(shelf_tab); } diff --git a/chrome/browser/download/save_package_file_picker.cc b/chrome/browser/download/save_package_file_picker.cc index 6ed710e..7844cfc 100644 --- a/chrome/browser/download/save_package_file_picker.cc +++ b/chrome/browser/download/save_package_file_picker.cc @@ -20,6 +20,7 @@ #include "content/public/browser/render_process_host.h" #include "content/public/browser/save_page_type.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" @@ -159,15 +160,15 @@ SavePackageFilePicker::SavePackageFilePicker( if (g_should_prompt_for_filename) { select_file_dialog_ = ui::SelectFileDialog::Create( this, new ChromeSelectFilePolicy(web_contents)); - select_file_dialog_->SelectFile(ui::SelectFileDialog::SELECT_SAVEAS_FILE, - string16(), - suggested_path, - &file_type_info, - file_type_index, - default_extension, - platform_util::GetTopLevel( - web_contents->GetNativeView()), - NULL); + select_file_dialog_->SelectFile( + ui::SelectFileDialog::SELECT_SAVEAS_FILE, + string16(), + suggested_path, + &file_type_info, + file_type_index, + default_extension, + platform_util::GetTopLevel(web_contents->GetView()->GetNativeView()), + NULL); } else { // Just use 'suggested_path' instead of opening the dialog prompt. // Go through FileSelected() for consistency. diff --git a/chrome/browser/download/save_package_file_picker_chromeos.cc b/chrome/browser/download/save_package_file_picker_chromeos.cc index 0ab4692..f9f8ab1 100644 --- a/chrome/browser/download/save_package_file_picker_chromeos.cc +++ b/chrome/browser/download/save_package_file_picker_chromeos.cc @@ -15,6 +15,7 @@ #include "chrome/browser/ui/chrome_select_file_policy.h" #include "content/public/browser/download_item.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "ui/shell_dialogs/selected_file_info.h" namespace { @@ -53,15 +54,15 @@ SavePackageFilePickerChromeOS::SavePackageFilePickerChromeOS( this, new ChromeSelectFilePolicy(web_contents)); ui::SelectFileDialog::FileTypeInfo file_types; file_types.support_drive = true; - select_file_dialog_->SelectFile(ui::SelectFileDialog::SELECT_SAVEAS_FILE, - string16(), - suggested_path.ReplaceExtension("mhtml"), - &file_types, - 0, - "mhtml", - platform_util::GetTopLevel( - web_contents->GetNativeView()), - NULL); + select_file_dialog_->SelectFile( + ui::SelectFileDialog::SELECT_SAVEAS_FILE, + string16(), + suggested_path.ReplaceExtension("mhtml"), + &file_types, + 0, + "mhtml", + platform_util::GetTopLevel(web_contents->GetView()->GetNativeView()), + NULL); } else { FileSelected(suggested_path.ReplaceExtension("mhtml"), 0, NULL); } diff --git a/chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_api.cc b/chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_api.cc index 4224050..71ad989 100644 --- a/chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_api.cc +++ b/chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_api.cc @@ -26,6 +26,7 @@ #include "chrome/common/pref_names.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "content/public/browser/web_ui.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" @@ -404,7 +405,7 @@ bool BookmarkManagerPrivateStartDragFunction::RunImpl() { dispatcher()->delegate()->GetAssociatedWebContents(); CHECK(web_contents); bookmark_utils::DragBookmarks(profile(), nodes, - web_contents->GetNativeView()); + web_contents->GetView()->GetNativeView()); return true; } else { diff --git a/chrome/browser/extensions/api/developer_private/entry_picker.cc b/chrome/browser/extensions/api/developer_private/entry_picker.cc index 2cd6bdf..c2b3d78 100644 --- a/chrome/browser/extensions/api/developer_private/entry_picker.cc +++ b/chrome/browser/extensions/api/developer_private/entry_picker.cc @@ -14,6 +14,7 @@ #include "chrome/browser/ui/chrome_select_file_policy.h" #include "chrome/browser/ui/extensions/shell_window.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "ui/shell_dialogs/select_file_dialog.h" namespace { @@ -39,7 +40,8 @@ EntryPicker::EntryPicker(EntryPickerClient* client, this, new ChromeSelectFilePolicy(web_contents)); gfx::NativeWindow owning_window = web_contents ? - platform_util::GetTopLevel(web_contents->GetNativeView()) : NULL; + platform_util::GetTopLevel(web_contents->GetView()->GetNativeView()) : + NULL; if (g_skip_picker_for_test) { if (g_path_to_be_picked_for_test) { diff --git a/chrome/browser/extensions/api/downloads/downloads_api.cc b/chrome/browser/extensions/api/downloads/downloads_api.cc index df50565..8545f7d 100644 --- a/chrome/browser/extensions/api/downloads/downloads_api.cc +++ b/chrome/browser/extensions/api/downloads/downloads_api.cc @@ -52,6 +52,7 @@ #include "content/public/browser/resource_context.h" #include "content/public/browser/resource_dispatcher_host.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "net/base/load_flags.h" #include "net/http/http_util.h" #include "net/url_request/url_request.h" @@ -971,7 +972,7 @@ bool DownloadsDragFunction::RunImpl() { RecordApiFunctions(DOWNLOADS_FUNCTION_DRAG); gfx::Image* icon = g_browser_process->icon_manager()->LookupIcon( download_item->GetUserVerifiedFilePath(), IconLoader::NORMAL); - gfx::NativeView view = web_contents->GetNativeView(); + gfx::NativeView view = web_contents->GetView()->GetNativeView(); { // Enable nested tasks during DnD, while |DragDownload()| blocks. MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); diff --git a/chrome/browser/extensions/api/file_system/file_system_api.cc b/chrome/browser/extensions/api/file_system/file_system_api.cc index 5435410..42d51c3 100644 --- a/chrome/browser/extensions/api/file_system/file_system_api.cc +++ b/chrome/browser/extensions/api/file_system/file_system_api.cc @@ -22,6 +22,7 @@ #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "grit/generated_resources.h" #include "net/base/mime_util.h" #include "ui/base/l10n/l10n_util.h" @@ -390,7 +391,8 @@ class FileSystemChooseEntryFunction::FilePicker select_file_dialog_ = ui::SelectFileDialog::Create( this, new ChromeSelectFilePolicy(web_contents)); gfx::NativeWindow owning_window = web_contents ? - platform_util::GetTopLevel(web_contents->GetNativeView()) : NULL; + platform_util::GetTopLevel(web_contents->GetView()->GetNativeView()) : + NULL; if (g_skip_picker_for_test) { if (g_path_to_be_picked_for_test) { diff --git a/chrome/browser/instant/instant_controller.cc b/chrome/browser/instant/instant_controller.cc index 70e0a60..17bdbb0 100644 --- a/chrome/browser/instant/instant_controller.cc +++ b/chrome/browser/instant/instant_controller.cc @@ -30,6 +30,7 @@ #include "content/public/browser/notification_service.h" #include "content/public/browser/render_widget_host_view.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "net/base/escape.h" #include "third_party/icu/public/common/unicode/normalizer2.h" @@ -140,7 +141,7 @@ bool IsViewInContents(gfx::NativeView view, content::WebContents* contents) { if (!view || !rwhv) return false; - gfx::NativeView tab_view = contents->GetNativeView(); + gfx::NativeView tab_view = contents->GetView()->GetNativeView(); if (view == rwhv->GetNativeView() || view == tab_view) return true; @@ -581,7 +582,7 @@ bool InstantController::CommitIfPossible(InstantCommitType type) { last_suggestion_.behavior == INSTANT_COMPLETE_NEVER)) { EnsureSearchTermsAreSet(instant_tab_->contents(), last_omnibox_text_); instant_tab_->Submit(last_omnibox_text_); - instant_tab_->contents()->Focus(); + instant_tab_->contents()->GetView()->Focus(); return true; } return false; @@ -1101,7 +1102,7 @@ void InstantController::StopCapturingKeyStrokes( return; DCHECK(IsContentsFrom(instant_tab(), contents)); - contents->Focus(); + contents->GetView()->Focus(); } void InstantController::NavigateToURL(const content::WebContents* contents, diff --git a/chrome/browser/managed_mode/managed_mode_navigation_observer.cc b/chrome/browser/managed_mode/managed_mode_navigation_observer.cc index 9579482..0949b3a 100644 --- a/chrome/browser/managed_mode/managed_mode_navigation_observer.cc +++ b/chrome/browser/managed_mode/managed_mode_navigation_observer.cc @@ -32,6 +32,7 @@ #include "content/public/browser/render_view_host.h" #include "content/public/browser/user_metrics.h" #include "content/public/browser/web_contents_delegate.h" +#include "content/public/browser/web_contents_view.h" #include "content/public/common/frame_navigate_params.h" #include "grit/generated_resources.h" #include "grit/locale_settings.h" @@ -91,7 +92,8 @@ void GoBackToSafety(content::WebContents* web_contents) { // If we can't go back (because we opened a new tab), try to close the tab. // If this is the last tab on this desktop, open a new window. chrome::HostDesktopType host_desktop_type = - chrome::GetHostDesktopTypeForNativeView(web_contents->GetNativeView()); + chrome::GetHostDesktopTypeForNativeView( + web_contents->GetView()->GetNativeView()); const BrowserList* browser_list = BrowserList::GetInstance(host_desktop_type); if (browser_list->size() == 1) { Browser* browser = browser_list->get(0); diff --git a/chrome/browser/printing/print_preview_dialog_controller.cc b/chrome/browser/printing/print_preview_dialog_controller.cc index 0f5fbfc..67184f4 100644 --- a/chrome/browser/printing/print_preview_dialog_controller.cc +++ b/chrome/browser/printing/print_preview_dialog_controller.cc @@ -40,6 +40,7 @@ #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_delegate.h" +#include "content/public/browser/web_contents_view.h" #include "ui/web_dialogs/web_dialog_delegate.h" #include "ui/web_dialogs/web_dialog_web_contents_delegate.h" #include "webkit/plugins/webplugininfo.h" @@ -127,7 +128,7 @@ void PrintPreviewTabDelegate::GetDialogSize(gfx::Size* size) const { const gfx::Size kMinDialogSize(800, 480); const int kBorder = 50; gfx::Rect rect; - initiator_tab_->GetContainerBounds(&rect); + initiator_tab_->GetView()->GetContainerBounds(&rect); size->set_width(std::max(rect.width(), kMinDialogSize.width()) - kBorder); size->set_height(std::max(rect.height(), kMinDialogSize.height()) - kBorder); @@ -305,10 +306,6 @@ void PrintPreviewDialogController::EraseInitiatorTabInfo( preview_tab_map_[preview_tab] = NULL; } -bool PrintPreviewDialogController::is_creating_print_preview_dialog() const { - return is_creating_print_preview_dialog_; -} - PrintPreviewDialogController::~PrintPreviewDialogController() {} void PrintPreviewDialogController::OnRendererProcessClosed( @@ -434,6 +431,9 @@ WebContents* PrintPreviewDialogController::CreatePrintPreviewTab( AddObservers(initiator_tab); AddObservers(preview_tab); + if (!print_preview_tab_created_callback_.is_null()) + print_preview_tab_created_callback_.Run(); + return preview_tab; } diff --git a/chrome/browser/printing/print_preview_dialog_controller.h b/chrome/browser/printing/print_preview_dialog_controller.h index 0b9691a..6dc1a3e 100644 --- a/chrome/browser/printing/print_preview_dialog_controller.h +++ b/chrome/browser/printing/print_preview_dialog_controller.h @@ -7,6 +7,7 @@ #include <map> +#include "base/callback.h" #include "base/memory/ref_counted.h" #include "chrome/browser/sessions/session_id.h" #include "content/public/browser/notification_observer.h" @@ -76,7 +77,14 @@ class PrintPreviewDialogController // Erase the initiator tab info associated with |preview_tab|. void EraseInitiatorTabInfo(content::WebContents* preview_tab); - bool is_creating_print_preview_dialog() const; + bool is_creating_print_preview_dialog() const { + return is_creating_print_preview_dialog_; + } + + void set_print_preview_tab_created_callback_for_testing( + const base::Closure& callback) { + print_preview_tab_created_callback_ = callback; + } private: friend class base::RefCounted<PrintPreviewDialogController>; @@ -132,6 +140,8 @@ class PrintPreviewDialogController // print preview dialog. bool is_creating_print_preview_dialog_; + base::Closure print_preview_tab_created_callback_; + DISALLOW_COPY_AND_ASSIGN(PrintPreviewDialogController); }; diff --git a/chrome/browser/speech/speech_recognition_bubble.cc b/chrome/browser/speech/speech_recognition_bubble.cc index b0dd4aa..1144e9c 100644 --- a/chrome/browser/speech/speech_recognition_bubble.cc +++ b/chrome/browser/speech/speech_recognition_bubble.cc @@ -8,6 +8,7 @@ #include "base/lazy_instance.h" #include "base/message_loop.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" #include "ui/base/resource/resource_bundle.h" @@ -140,7 +141,8 @@ SpeechRecognitionBubbleBase::SpeechRecognitionBubbleBase( display_mode_(DISPLAY_MODE_RECORDING), web_contents_(web_contents), scale_factor_(ui::SCALE_FACTOR_NONE) { - gfx::NativeView view = web_contents_ ? web_contents_->GetNativeView() : NULL; + gfx::NativeView view = + web_contents_ ? web_contents_->GetView()->GetNativeView() : NULL; gfx::Screen* screen = gfx::Screen::GetScreenFor(view); gfx::Display display = screen->GetDisplayNearestWindow(view); scale_factor_ = ui::GetScaleFactorFromScale( diff --git a/chrome/browser/ui/android/tab_contents/chrome_web_contents_view_delegate_android.cc b/chrome/browser/ui/android/tab_contents/chrome_web_contents_view_delegate_android.cc index 32c739d..9012dd8 100644 --- a/chrome/browser/ui/android/tab_contents/chrome_web_contents_view_delegate_android.cc +++ b/chrome/browser/ui/android/tab_contents/chrome_web_contents_view_delegate_android.cc @@ -8,6 +8,7 @@ #include "chrome/browser/android/tab_android.h" #include "content/public/browser/android/content_view_core.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "content/public/browser/web_contents_view_delegate.h" #include "content/public/common/context_menu_params.h" @@ -33,7 +34,7 @@ void ChromeWebContentsViewDelegateAndroid::ShowContextMenu( // Display paste pop-up only when selection is empty and editable. if (params.is_editable && params.selection_text.empty()) { content::ContentViewCore* content_view_core = - web_contents_->GetContentNativeView(); + web_contents_->GetView()->GetContentNativeView(); if (content_view_core) { content_view_core->ShowPastePopup(params.selection_start.x(), params.selection_start.y()); diff --git a/chrome/browser/ui/ash/chrome_shell_delegate_chromeos.cc b/chrome/browser/ui/ash/chrome_shell_delegate_chromeos.cc index a01f383..d39da0e 100644 --- a/chrome/browser/ui/ash/chrome_shell_delegate_chromeos.cc +++ b/chrome/browser/ui/ash/chrome_shell_delegate_chromeos.cc @@ -44,6 +44,7 @@ #include "chromeos/dbus/session_manager_client.h" #include "content/public/browser/user_metrics.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" @@ -122,7 +123,7 @@ void ChromeShellDelegate::OpenCrosh() { false)); browser->window()->Show(); browser->window()->Activate(); - page->Focus(); + page->GetView()->Focus(); } void ChromeShellDelegate::OpenMobileSetup(const std::string& service_path) { diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index 928bc00..e57f286 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -916,7 +916,7 @@ void Browser::UpdateUIForNavigationInTab(WebContents* contents, ScheduleUIUpdate(contents, content::INVALIDATE_TYPE_URL); if (contents_is_selected) - contents->Focus(); + contents->GetView()->Focus(); } /////////////////////////////////////////////////////////////////////////////// @@ -1658,7 +1658,7 @@ void Browser::SetWebContentsBlocked(content::WebContents* web_contents, } tab_strip_model_->SetTabBlocked(index, blocked); if (!blocked && tab_strip_model_->GetActiveWebContents() == web_contents) - web_contents->Focus(); + web_contents->GetView()->Focus(); } bool Browser::GetDialogTopCenter(gfx::Point* point) { diff --git a/chrome/browser/ui/browser_commands.cc b/chrome/browser/ui/browser_commands.cc index f023344..c093b83 100644 --- a/chrome/browser/ui/browser_commands.cc +++ b/chrome/browser/ui/browser_commands.cc @@ -168,7 +168,7 @@ void ReloadInternal(Browser* browser, WebContents* web_contents = GetOrCloneTabForDisposition(browser, disposition); web_contents->UserGestureDone(); if (!web_contents->FocusLocationBarByDefault()) - web_contents->Focus(); + web_contents->GetView()->Focus(); if (ignore_cache) web_contents->GetController().ReloadIgnoringCache(true); else diff --git a/chrome/browser/ui/browser_navigator.cc b/chrome/browser/ui/browser_navigator.cc index 41c3095..3e01d3c 100644 --- a/chrome/browser/ui/browser_navigator.cc +++ b/chrome/browser/ui/browser_navigator.cc @@ -576,7 +576,7 @@ void Navigate(NavigateParams* params) { (params->disposition == NEW_FOREGROUND_TAB || params->disposition == NEW_WINDOW) && (params->tabstrip_add_types & TabStripModel::ADD_INHERIT_OPENER)) - params->source_contents->Focus(); + params->source_contents->GetView()->Focus(); if (params->source_contents == params->target_contents || (swapped_in_instant && params->disposition == CURRENT_TAB)) { diff --git a/chrome/browser/ui/cocoa/browser_window_cocoa.mm b/chrome/browser/ui/cocoa/browser_window_cocoa.mm index 15fbdea..fe0670f 100644 --- a/chrome/browser/ui/cocoa/browser_window_cocoa.mm +++ b/chrome/browser/ui/cocoa/browser_window_cocoa.mm @@ -51,6 +51,7 @@ #include "content/public/browser/notification_details.h" #include "content/public/browser/notification_source.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "content/public/common/password_form.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" @@ -91,7 +92,7 @@ namespace { NSPoint GetPointForBubble(content::WebContents* web_contents, int x_offset, int y_offset) { - NSView* view = web_contents->GetNativeView(); + NSView* view = web_contents->GetView()->GetNativeView(); NSRect bounds = [view bounds]; NSPoint point; point.x = NSMinX(bounds) + x_offset; diff --git a/chrome/browser/ui/cocoa/constrained_web_dialog_delegate_mac.mm b/chrome/browser/ui/cocoa/constrained_web_dialog_delegate_mac.mm index ffb11c2..eaac62a 100644 --- a/chrome/browser/ui/cocoa/constrained_web_dialog_delegate_mac.mm +++ b/chrome/browser/ui/cocoa/constrained_web_dialog_delegate_mac.mm @@ -11,6 +11,7 @@ #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_window.h" #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "ui/gfx/size.h" #include "ui/web_dialogs/web_dialog_delegate.h" #include "ui/web_dialogs/web_dialog_ui.h" @@ -113,8 +114,9 @@ ConstrainedWebDialogDelegateViewMac::ConstrainedWebDialogDelegateViewMac( window_.reset( [[ConstrainedWindowCustomWindow alloc] initWithContentRect:frame]); - [GetWebContents()->GetNativeView() setFrame:frame]; - [[window_ contentView] addSubview:GetWebContents()->GetNativeView()]; + [GetWebContents()->GetView()->GetNativeView() setFrame:frame]; + [[window_ contentView] + addSubview:GetWebContents()->GetView()->GetNativeView()]; scoped_nsobject<CustomConstrainedWindowSheet> sheet( [[CustomConstrainedWindowSheet alloc] diff --git a/chrome/browser/ui/cocoa/constrained_window/constrained_window_mac_browsertest.mm b/chrome/browser/ui/cocoa/constrained_window/constrained_window_mac_browsertest.mm index dea4878..51cfcbb 100644 --- a/chrome/browser/ui/cocoa/constrained_window/constrained_window_mac_browsertest.mm +++ b/chrome/browser/ui/cocoa/constrained_window/constrained_window_mac_browsertest.mm @@ -15,6 +15,7 @@ #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/test/base/in_process_browser_test.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "googleurl/src/gurl.h" #include "testing/gmock/include/gmock/gmock.h" @@ -100,7 +101,7 @@ IN_PROC_BROWSER_TEST_F(ConstrainedWindowMacTest, ShowInUninitializedTab) { content::WebContents* tab2 = browser()->tab_strip_model()->GetWebContentsAt(2); ASSERT_TRUE(tab2); - EXPECT_FALSE([tab2->GetNativeView() superview]); + EXPECT_FALSE([tab2->GetView()->GetNativeView() superview]); // Show dialog and verify that it's not visible yet. NiceMock<ConstrainedWindowDelegateMock> delegate; @@ -109,7 +110,7 @@ IN_PROC_BROWSER_TEST_F(ConstrainedWindowMacTest, ShowInUninitializedTab) { // Activate the tab and verify that the constrained window is shown. browser()->tab_strip_model()->ActivateTabAt(2, true); - EXPECT_TRUE([tab2->GetNativeView() superview]); + EXPECT_TRUE([tab2->GetView()->GetNativeView() superview]); EXPECT_TRUE([sheet_window_ isVisible]); EXPECT_EQ(1.0, [sheet_window_ alphaValue]); diff --git a/chrome/browser/ui/cocoa/dev_tools_controller.mm b/chrome/browser/ui/cocoa/dev_tools_controller.mm index c07b5a3..7622e14 100644 --- a/chrome/browser/ui/cocoa/dev_tools_controller.mm +++ b/chrome/browser/ui/cocoa/dev_tools_controller.mm @@ -15,6 +15,7 @@ #import "chrome/browser/ui/cocoa/view_id_util.h" #include "chrome/common/pref_names.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" using content::WebContents; @@ -142,7 +143,7 @@ using content::WebContents; // |devToolsView| is a TabContentsViewCocoa object, whose ViewID was // set to VIEW_ID_TAB_CONTAINER initially, so we need to change it to // VIEW_ID_DEV_TOOLS_DOCKED here. - NSView* devToolsView = devToolsContents->GetNativeView(); + NSView* devToolsView = devToolsContents->GetView()->GetNativeView(); view_id_util::SetID(devToolsView, VIEW_ID_DEV_TOOLS_DOCKED); [devToolsView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; @@ -198,7 +199,8 @@ using content::WebContents; } - (void)updateDevToolsViewFrame { - NSView* devToolsView = devToolsWindow_->web_contents()->GetNativeView(); + NSView* devToolsView = + devToolsWindow_->web_contents()->GetView()->GetNativeView(); NSRect devToolsRect = [[devToolsView superview] bounds]; if (devToolsWindow_->dock_side() == DEVTOOLS_DOCK_SIDE_RIGHT) devToolsRect.size.height -= [splitView_ topContentOffset]; diff --git a/chrome/browser/ui/cocoa/download/download_started_animation_mac.mm b/chrome/browser/ui/cocoa/download/download_started_animation_mac.mm index 901a7559..ef203ae 100644 --- a/chrome/browser/ui/cocoa/download/download_started_animation_mac.mm +++ b/chrome/browser/ui/cocoa/download/download_started_animation_mac.mm @@ -19,6 +19,7 @@ #include "content/public/browser/notification_source.h" #include "content/public/browser/notification_types.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "grit/theme_resources.h" #import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h" #include "third_party/skia/include/utils/mac/SkCGUtils.h" @@ -105,7 +106,7 @@ class DownloadAnimationWebObserver : public content::NotificationObserver { // the bottom of the tab, assuming there is enough room. If there isn't // enough, don't show the animation and let the shelf speak for itself. gfx::Rect bounds; - webContents->GetContainerBounds(&bounds); + webContents->GetView()->GetContainerBounds(&bounds); imageWidth_ = [image size].width; CGFloat imageHeight = [image size].height; @@ -115,7 +116,7 @@ class DownloadAnimationWebObserver : public content::NotificationObserver { return nil; } - NSView* tabContentsView = webContents->GetNativeView(); + NSView* tabContentsView = webContents->GetView()->GetNativeView(); NSWindow* parentWindow = [tabContentsView window]; if (!parentWindow) { // The tab is no longer frontmost. diff --git a/chrome/browser/ui/cocoa/extensions/native_app_window_cocoa.mm b/chrome/browser/ui/cocoa/extensions/native_app_window_cocoa.mm index 6363216..8d13987 100644 --- a/chrome/browser/ui/cocoa/extensions/native_app_window_cocoa.mm +++ b/chrome/browser/ui/cocoa/extensions/native_app_window_cocoa.mm @@ -654,7 +654,7 @@ bool NativeAppWindowCocoa::IsAlwaysOnTop() const { } void NativeAppWindowCocoa::RenderViewHostChanged() { - web_contents()->Focus(); + web_contents()->GetView()->Focus(); } gfx::Insets NativeAppWindowCocoa::GetFrameInsets() const { diff --git a/chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.mm b/chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.mm index ece8b8d..6d1f6f7 100644 --- a/chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.mm +++ b/chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.mm @@ -312,7 +312,7 @@ const float kRightEdgeOffset = 25; if (!(focusTracker_.get() && [focusTracker_ restoreFocusInWindow:[findBarView_ window]])) { // Fall back to giving focus to the tab contents. - findBarBridge_->GetFindBarController()->web_contents()->Focus(); + findBarBridge_->GetFindBarController()->web_contents()->GetView()->Focus(); } focusTracker_.reset(nil); } diff --git a/chrome/browser/ui/cocoa/infobars/extension_infobar_controller.mm b/chrome/browser/ui/cocoa/infobars/extension_infobar_controller.mm index 1073c3d..caed8d1 100644 --- a/chrome/browser/ui/cocoa/infobars/extension_infobar_controller.mm +++ b/chrome/browser/ui/cocoa/infobars/extension_infobar_controller.mm @@ -20,6 +20,7 @@ #include "chrome/common/extensions/extension_icon_set.h" #include "chrome/common/extensions/extension_resource.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "grit/theme_resources.h" #include "skia/ext/skia_utils_mac.h" #include "ui/base/resource/resource_bundle.h" @@ -272,7 +273,8 @@ class InfobarBridge : public ExtensionInfoBarDelegate::DelegateObserver { InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(InfoBarService* owner) { NSWindow* window = - [(NSView*)owner->GetWebContents()->GetContentNativeView() window]; + [(NSView*)owner->GetWebContents()->GetView()->GetContentNativeView() + window]; ExtensionInfoBarController* controller = [[ExtensionInfoBarController alloc] initWithDelegate:this owner:owner diff --git a/chrome/browser/ui/cocoa/notifications/balloon_view_host_mac.mm b/chrome/browser/ui/cocoa/notifications/balloon_view_host_mac.mm index b7748cc..a130345 100644 --- a/chrome/browser/ui/cocoa/notifications/balloon_view_host_mac.mm +++ b/chrome/browser/ui/cocoa/notifications/balloon_view_host_mac.mm @@ -30,5 +30,5 @@ void BalloonViewHost::UpdateActualSize(const gfx::Size& new_size) { } gfx::NativeView BalloonViewHost::native_view() const { - return web_contents_->GetContentNativeView(); + return web_contents_->GetView()->GetContentNativeView(); } diff --git a/chrome/browser/ui/cocoa/tab_contents/chrome_web_contents_view_delegate_mac.mm b/chrome/browser/ui/cocoa/tab_contents/chrome_web_contents_view_delegate_mac.mm index c0cc6ce..858108f 100644 --- a/chrome/browser/ui/cocoa/tab_contents/chrome_web_contents_view_delegate_mac.mm +++ b/chrome/browser/ui/cocoa/tab_contents/chrome_web_contents_view_delegate_mac.mm @@ -10,6 +10,7 @@ #include "chrome/browser/ui/tab_contents/chrome_web_contents_view_delegate.h" #include "content/public/browser/render_widget_host_view.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" ChromeWebContentsViewDelegateMac::ChromeWebContentsViewDelegateMac( content::WebContents* web_contents) @@ -47,10 +48,10 @@ void ChromeWebContentsViewDelegateMac::ShowContextMenu( if (widget_view && widget_view->IsShowingContextMenu()) return; - context_menu_.reset( - new RenderViewContextMenuMac(web_contents_, - params, - web_contents_->GetContentNativeView())); + context_menu_.reset(new RenderViewContextMenuMac( + web_contents_, + params, + web_contents_->GetView()->GetContentNativeView())); context_menu_->Init(); } diff --git a/chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller.mm b/chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller.mm index c5fba22..7cae329 100644 --- a/chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller.mm +++ b/chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller.mm @@ -70,7 +70,7 @@ // Remove any old preview contents before showing the new one. if (previewContents_) { - [previewContents_->GetNativeView() removeFromSuperview]; + [previewContents_->GetView()->GetNativeView() removeFromSuperview]; previewContents_->WasHidden(); } @@ -83,7 +83,7 @@ if (previewContents_) { [[[self view] window] disableScreenUpdatesUntilFlush]; previewContents_->GetView()->SetAllowOverlappingViews(true); - [[self view] addSubview:previewContents_->GetNativeView()]; + [[self view] addSubview:previewContents_->GetView()->GetNativeView()]; } if (drawDropShadow_) { @@ -106,7 +106,7 @@ - (void)onActivateTabWithContents:(content::WebContents*)contents { if (previewContents_ == contents) { if (previewContents_) { - [previewContents_->GetNativeView() removeFromSuperview]; + [previewContents_->GetView()->GetNativeView() removeFromSuperview]; previewContents_ = NULL; } [self setPreview:NULL @@ -151,7 +151,7 @@ NSRect previewFrame = bounds; previewFrame.size.height = [self previewHeightInPixels]; previewFrame.origin.y = NSMaxY(bounds) - NSHeight(previewFrame); - [previewContents_->GetNativeView() setFrame:previewFrame]; + [previewContents_->GetView()->GetNativeView() setFrame:previewFrame]; if (dropShadowView_) { NSRect dropShadowFrame = bounds; diff --git a/chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller_browsertest.mm b/chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller_browsertest.mm index 9063d75..7273d96 100644 --- a/chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller_browsertest.mm +++ b/chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller_browsertest.mm @@ -13,6 +13,7 @@ #include "chrome/browser/ui/cocoa/tab_contents/preview_drop_shadow_view.h" #include "chrome/test/base/in_process_browser_test.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #import "testing/gtest_mac.h" class PreviewableContentsControllerTest : public InProcessBrowserTest { @@ -43,7 +44,7 @@ class PreviewableContentsControllerTest : public InProcessBrowserTest { InstantSizeUnits units) { NSRect container_bounds = [[controller_ view] bounds]; NSRect preview_frame = - [web_contents_->GetNativeView() frame]; + [web_contents_->GetView()->GetNativeView() frame]; EXPECT_EQ(NSMinX(container_bounds), NSMinX(preview_frame)); EXPECT_EQ(NSWidth(container_bounds), NSWidth(preview_frame)); @@ -73,7 +74,7 @@ IN_PROC_BROWSER_TEST_F(PreviewableContentsControllerTest, SizePerecent) { InstantSizeUnits units = INSTANT_SIZE_PERCENT; instant_model_.SetPreviewState(mode, expected_height, units); - EXPECT_NSEQ([web_contents_->GetNativeView() superview], + EXPECT_NSEQ([web_contents_->GetView()->GetNativeView() superview], [controller_ view]); VerifyPreviewFrame(expected_height, units); @@ -90,7 +91,7 @@ IN_PROC_BROWSER_TEST_F(PreviewableContentsControllerTest, SizePixels) { InstantSizeUnits units = INSTANT_SIZE_PIXELS; instant_model_.SetPreviewState(mode, expected_height, units); - EXPECT_NSEQ([web_contents_->GetNativeView() superview], + EXPECT_NSEQ([web_contents_->GetView()->GetNativeView() superview], [controller_ view]); VerifyPreviewFrame(expected_height, units); diff --git a/chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.mm b/chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.mm index d4a7f3f..1622bb6 100644 --- a/chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.mm +++ b/chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.mm @@ -40,8 +40,10 @@ using content::WebContents; - (void)ensureContentsSizeDoesNotChange { NSView* contentsContainer = [self view]; NSArray* subviews = [contentsContainer subviews]; - if ([subviews count] > 0) - [contents_->GetNativeView() setAutoresizingMask:NSViewNotSizable]; + if ([subviews count] > 0) { + [contents_->GetView()->GetNativeView() + setAutoresizingMask:NSViewNotSizable]; + } } // Call when the tab view is properly sized and the render widget host view @@ -51,7 +53,7 @@ using content::WebContents; return; NSView* contentsContainer = [self view]; NSArray* subviews = [contentsContainer subviews]; - NSView* contentsNativeView = contents_->GetNativeView(); + NSView* contentsNativeView = contents_->GetView()->GetNativeView(); [contentsNativeView setFrame:[contentsContainer frame]]; if ([subviews count] == 0) { [contentsContainer addSubview:contentsNativeView]; diff --git a/chrome/browser/ui/cocoa/tabpose_window.mm b/chrome/browser/ui/cocoa/tabpose_window.mm index 2d1f3ec..c9a9318 100644 --- a/chrome/browser/ui/cocoa/tabpose_window.mm +++ b/chrome/browser/ui/cocoa/tabpose_window.mm @@ -32,6 +32,7 @@ #include "content/public/browser/render_view_host.h" #include "content/public/browser/render_widget_host_view.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "grit/theme_resources.h" #include "grit/ui_resources.h" #include "skia/ext/skia_utils_mac.h" @@ -213,7 +214,7 @@ void ThumbnailLoader::LoadThumbnail() { // Medium term, we want to show thumbs of the actual info bar views, which // means I need to create InfoBarControllers here. - NSWindow* window = [contents_->GetNativeView() window]; + NSWindow* window = [contents_->GetView()->GetNativeView() window]; NSWindowController* windowController = [window windowController]; if ([windowController isKindOfClass:[BrowserWindowController class]]) { BrowserWindowController* bwc = diff --git a/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm b/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm index 2b31288..1f0c0cb 100644 --- a/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm +++ b/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm @@ -2237,5 +2237,5 @@ NSView* GetSheetParentViewForWebContents(WebContents* web_contents) { // // Changing it? Do not forget to modify // -[TabStripController swapInTabAtIndex:] too. - return [web_contents->GetNativeView() superview]; + return [web_contents->GetView()->GetNativeView() superview]; } diff --git a/chrome/browser/ui/cocoa/web_dialog_window_controller.mm b/chrome/browser/ui/cocoa/web_dialog_window_controller.mm index 3181020..eee1c68 100644 --- a/chrome/browser/ui/cocoa/web_dialog_window_controller.mm +++ b/chrome/browser/ui/cocoa/web_dialog_window_controller.mm @@ -13,6 +13,7 @@ #include "chrome/browser/ui/webui/chrome_web_contents_handler.h" #include "content/public/browser/native_web_keyboard_event.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "content/public/browser/web_ui_message_handler.h" #include "ui/base/keycodes/keyboard_codes.h" #include "ui/gfx/size.h" @@ -342,7 +343,7 @@ void WebDialogWindowDelegateBridge::HandleKeyboardEvent( - (void)loadDialogContents { webContents_.reset(WebContents::Create( WebContents::CreateParams(delegate_->browser_context()))); - [[self window] setContentView:webContents_->GetNativeView()]; + [[self window] setContentView:webContents_->GetView()->GetNativeView()]; webContents_->SetDelegate(delegate_.get()); // This must be done before loading the page; see the comments in diff --git a/chrome/browser/ui/gtk/browser_window_gtk.cc b/chrome/browser/ui/gtk/browser_window_gtk.cc index 88eb4b5..b268fba 100644 --- a/chrome/browser/ui/gtk/browser_window_gtk.cc +++ b/chrome/browser/ui/gtk/browser_window_gtk.cc @@ -1139,7 +1139,7 @@ bool BrowserWindowGtk::GetConstrainedWindowTopY(int* top_y) { void BrowserWindowGtk::ShowAvatarBubble(WebContents* web_contents, const gfx::Rect& rect) { - GtkWidget* widget = web_contents->GetContentNativeView(); + GtkWidget* widget = web_contents->GetView()->GetContentNativeView(); new AvatarMenuBubbleGtk(browser_.get(), widget, BubbleGtk::ANCHOR_TOP_LEFT, &rect); } @@ -1155,7 +1155,7 @@ void BrowserWindowGtk::ShowPasswordGenerationBubble( autofill::PasswordGenerator* password_generator) { WebContents* web_contents = browser_->tab_strip_model()->GetActiveWebContents(); - if (!web_contents || !web_contents->GetContentNativeView()) { + if (!web_contents || !web_contents->GetView()->GetContentNativeView()) { return; } @@ -1979,8 +1979,10 @@ gboolean BrowserWindowGtk::OnKeyPress(GtkWidget* widget, GdkEventKey* event) { WebContents* current_web_contents = browser()->tab_strip_model()->GetActiveWebContents(); // The current tab might not have a render view if it crashed. - if (!current_web_contents || !current_web_contents->GetContentNativeView() || - !gtk_widget_is_focus(current_web_contents->GetContentNativeView())) { + if (!current_web_contents || + !current_web_contents->GetView()->GetContentNativeView() || + !gtk_widget_is_focus( + current_web_contents->GetView()->GetContentNativeView())) { int command_id = GetCustomCommandId(event); if (command_id == -1) command_id = GetPreHandleCommandId(event); diff --git a/chrome/browser/ui/gtk/constrained_web_dialog_delegate_gtk.cc b/chrome/browser/ui/gtk/constrained_web_dialog_delegate_gtk.cc index 56b8073..590b6d0 100644 --- a/chrome/browser/ui/gtk/constrained_web_dialog_delegate_gtk.cc +++ b/chrome/browser/ui/gtk/constrained_web_dialog_delegate_gtk.cc @@ -83,7 +83,7 @@ class ConstrainedWebDialogDelegateViewGtk return GetWebContents()->GetView()->GetNativeView(); } virtual GtkWidget* GetFocusWidget() OVERRIDE { - return GetWebContents()->GetContentNativeView(); + return GetWebContents()->GetView()->GetContentNativeView(); } virtual void DeleteDelegate() OVERRIDE { if (!impl_->closed_via_webui()) diff --git a/chrome/browser/ui/gtk/download/download_started_animation_gtk.cc b/chrome/browser/ui/gtk/download/download_started_animation_gtk.cc index caca11b..8358a24 100644 --- a/chrome/browser/ui/gtk/download/download_started_animation_gtk.cc +++ b/chrome/browser/ui/gtk/download/download_started_animation_gtk.cc @@ -15,6 +15,7 @@ #include "content/public/browser/notification_source.h" #include "content/public/browser/notification_types.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "grit/theme_resources.h" #include "ui/base/animation/linear_animation.h" #include "ui/base/resource/resource_bundle.h" @@ -101,7 +102,7 @@ DownloadStartedAnimationGtk::DownloadStartedAnimationGtk( // If we're too small to show the download image, then don't bother - // the shelf will be enough. - web_contents_->GetContainerBounds(&web_contents_bounds_); + web_contents_->GetView()->GetContainerBounds(&web_contents_bounds_); if (web_contents_bounds_.height() < height_) return; diff --git a/chrome/browser/ui/gtk/extensions/native_app_window_gtk.cc b/chrome/browser/ui/gtk/extensions/native_app_window_gtk.cc index 07947e6..52d01f0 100644 --- a/chrome/browser/ui/gtk/extensions/native_app_window_gtk.cc +++ b/chrome/browser/ui/gtk/extensions/native_app_window_gtk.cc @@ -234,7 +234,7 @@ bool NativeAppWindowGtk::IsAlwaysOnTop() const { } void NativeAppWindowGtk::RenderViewHostChanged() { - web_contents()->Focus(); + web_contents()->GetView()->Focus(); } gfx::Insets NativeAppWindowGtk::GetFrameInsets() const { diff --git a/chrome/browser/ui/gtk/find_bar_gtk.cc b/chrome/browser/ui/gtk/find_bar_gtk.cc index 582ede6..0010d17 100644 --- a/chrome/browser/ui/gtk/find_bar_gtk.cc +++ b/chrome/browser/ui/gtk/find_bar_gtk.cc @@ -37,6 +37,7 @@ #include "content/public/browser/notification_source.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" #include "grit/ui_resources.h" @@ -465,7 +466,7 @@ void FindBarGtk::RestoreSavedFocus() { if (focus_store_.widget()) gtk_widget_grab_focus(focus_store_.widget()); else - find_bar_controller_->web_contents()->Focus(); + find_bar_controller_->web_contents()->GetView()->Focus(); } FindBarTesting* FindBarGtk::GetFindBarTesting() { diff --git a/chrome/browser/ui/gtk/gtk_window_util.cc b/chrome/browser/ui/gtk/gtk_window_util.cc index 529496e..b2ca591 100644 --- a/chrome/browser/ui/gtk/gtk_window_util.cc +++ b/chrome/browser/ui/gtk/gtk_window_util.cc @@ -8,6 +8,7 @@ #include "chrome/browser/ui/base_window.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" using content::RenderWidgetHost; using content::WebContents; @@ -36,7 +37,8 @@ void DoCutCopyPaste(GtkWindow* window, if (widget == NULL) return; // Do nothing if no focused widget. - if (web_contents && widget == web_contents->GetContentNativeView()) { + if (web_contents && + widget == web_contents->GetView()->GetContentNativeView()) { (web_contents->GetRenderViewHost()->*method)(); } else { guint id; diff --git a/chrome/browser/ui/gtk/notifications/balloon_view_host_gtk.cc b/chrome/browser/ui/gtk/notifications/balloon_view_host_gtk.cc index 7f31844..dba6a1b 100644 --- a/chrome/browser/ui/gtk/notifications/balloon_view_host_gtk.cc +++ b/chrome/browser/ui/gtk/notifications/balloon_view_host_gtk.cc @@ -10,6 +10,7 @@ #include "content/public/browser/render_view_host.h" #include "content/public/browser/render_widget_host_view.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" BalloonViewHost::BalloonViewHost(Balloon* balloon) : BalloonHost(balloon) { @@ -32,5 +33,5 @@ void BalloonViewHost::UpdateActualSize(const gfx::Size& new_size) { } gfx::NativeView BalloonViewHost::native_view() const { - return web_contents_->GetNativeView(); + return web_contents_->GetView()->GetNativeView(); } diff --git a/chrome/browser/ui/gtk/panels/panel_gtk.cc b/chrome/browser/ui/gtk/panels/panel_gtk.cc index 5423a77..3b93576 100644 --- a/chrome/browser/ui/gtk/panels/panel_gtk.cc +++ b/chrome/browser/ui/gtk/panels/panel_gtk.cc @@ -29,6 +29,7 @@ #include "content/public/browser/native_web_keyboard_event.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "grit/theme_resources.h" #include "grit/ui_resources.h" #include "ui/base/accelerators/platform_accelerator_gtk.h" @@ -941,7 +942,7 @@ void PanelGtk::PanelExpansionStateChanging( void PanelGtk::AttachWebContents(content::WebContents* contents) { if (!contents) return; - gfx::NativeView widget = contents->GetNativeView(); + gfx::NativeView widget = contents->GetView()->GetNativeView(); if (widget) { gtk_container_add(GTK_CONTAINER(contents_expanded_), widget); gtk_widget_show(widget); @@ -950,7 +951,7 @@ void PanelGtk::AttachWebContents(content::WebContents* contents) { } void PanelGtk::DetachWebContents(content::WebContents* contents) { - gfx::NativeView widget = contents->GetNativeView(); + gfx::NativeView widget = contents->GetView()->GetNativeView(); if (widget) { GtkWidget* parent = gtk_widget_get_parent(widget); if (parent) { diff --git a/chrome/browser/ui/gtk/password_generation_bubble_gtk.cc b/chrome/browser/ui/gtk/password_generation_bubble_gtk.cc index 393b43b..ef4c065 100644 --- a/chrome/browser/ui/gtk/password_generation_bubble_gtk.cc +++ b/chrome/browser/ui/gtk/password_generation_bubble_gtk.cc @@ -18,6 +18,7 @@ #include "chrome/common/url_constants.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" #include "ui/base/gtk/gtk_hig_constants.h" @@ -88,7 +89,7 @@ PasswordGenerationBubbleGtk::PasswordGenerationBubbleGtk( GtkThemeService* theme_service = GtkThemeService::GetFrom( Profile::FromBrowserContext(web_contents->GetBrowserContext())); - bubble_ = BubbleGtk::Show(web_contents->GetContentNativeView(), + bubble_ = BubbleGtk::Show(web_contents->GetView()->GetContentNativeView(), &anchor_rect, content, BubbleGtk::ANCHOR_TOP_LEFT, diff --git a/chrome/browser/ui/gtk/speech_recognition_bubble_gtk.cc b/chrome/browser/ui/gtk/speech_recognition_bubble_gtk.cc index faac3a1..903b555 100644 --- a/chrome/browser/ui/gtk/speech_recognition_bubble_gtk.cc +++ b/chrome/browser/ui/gtk/speech_recognition_bubble_gtk.cc @@ -18,6 +18,7 @@ #include "content/public/browser/resource_context.h" #include "content/public/browser/speech_recognition_manager.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" #include "ui/base/gtk/gtk_hig_constants.h" @@ -176,9 +177,9 @@ void SpeechRecognitionBubbleGtk::Show() { gtk_container_add(GTK_CONTAINER(content), vbox); GtkThemeService* theme_provider = GtkThemeService::GetFrom(profile); - GtkWidget* reference_widget = GetWebContents()->GetNativeView(); + GtkWidget* reference_widget = GetWebContents()->GetView()->GetNativeView(); gfx::Rect container_rect; - GetWebContents()->GetContainerBounds(&container_rect); + GetWebContents()->GetView()->GetContainerBounds(&container_rect); gfx::Rect target_rect(element_rect_.right() - kBubbleTargetOffsetX, element_rect_.bottom(), 1, 1); diff --git a/chrome/browser/ui/gtk/tab_contents_container_gtk.cc b/chrome/browser/ui/gtk/tab_contents_container_gtk.cc index 3dacd5e..a8b5c5c 100644 --- a/chrome/browser/ui/gtk/tab_contents_container_gtk.cc +++ b/chrome/browser/ui/gtk/tab_contents_container_gtk.cc @@ -12,6 +12,7 @@ #include "content/public/browser/notification_source.h" #include "content/public/browser/render_widget_host_view.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "ui/base/gtk/gtk_expanded_container.h" #include "ui/base/gtk/gtk_floating_container.h" #include "ui/gfx/native_widget_types.h" @@ -80,7 +81,7 @@ void TabContentsContainerGtk::SetTab(content::WebContents* tab) { // Make sure that the tab is below the find bar. Sometimes the content // native view will be null. - GtkWidget* widget = tab_->GetContentNativeView(); + GtkWidget* widget = tab_->GetView()->GetContentNativeView(); if (widget) { GdkWindow* content_gdk_window = gtk_widget_get_window(widget); if (content_gdk_window) @@ -95,7 +96,7 @@ void TabContentsContainerGtk::SetPreview(content::WebContents* preview) { if (preview_) { HideTab(preview_); - GtkWidget* preview_widget = preview_->GetNativeView(); + GtkWidget* preview_widget = preview_->GetView()->GetNativeView(); if (preview_widget) gtk_container_remove(GTK_CONTAINER(expanded_), preview_widget); } @@ -107,7 +108,7 @@ void TabContentsContainerGtk::SetPreview(content::WebContents* preview) { } void TabContentsContainerGtk::PackTab(content::WebContents* tab) { - gfx::NativeView widget = tab->GetNativeView(); + gfx::NativeView widget = tab->GetView()->GetNativeView(); if (widget) { if (gtk_widget_get_parent(widget) != expanded_) gtk_container_add(GTK_CONTAINER(expanded_), widget); @@ -120,7 +121,7 @@ void TabContentsContainerGtk::PackTab(content::WebContents* tab) { } void TabContentsContainerGtk::HideTab(content::WebContents* tab) { - gfx::NativeView widget = tab->GetNativeView(); + gfx::NativeView widget = tab->GetView()->GetNativeView(); if (widget) gtk_widget_hide(widget); @@ -130,7 +131,7 @@ void TabContentsContainerGtk::HideTab(content::WebContents* tab) { } void TabContentsContainerGtk::DetachTab(content::WebContents* tab) { - gfx::NativeView widget = tab->GetNativeView(); + gfx::NativeView widget = tab->GetView()->GetNativeView(); // It is possible to detach an unrealized, unparented WebContents if you // slow things down enough in valgrind. Might happen in the real world, too. @@ -169,7 +170,7 @@ void TabContentsContainerGtk::WebContentsDestroyed( gboolean TabContentsContainerGtk::OnFocus(GtkWidget* widget, GtkDirectionType focus) { if (preview_) { - gtk_widget_child_focus(tab_->GetContentNativeView(), focus); + gtk_widget_child_focus(tab_->GetView()->GetContentNativeView(), focus); return TRUE; } diff --git a/chrome/browser/ui/gtk/tabs/dragged_tab_controller_gtk.cc b/chrome/browser/ui/gtk/tabs/dragged_tab_controller_gtk.cc index fa697d1..aca50c6 100644 --- a/chrome/browser/ui/gtk/tabs/dragged_tab_controller_gtk.cc +++ b/chrome/browser/ui/gtk/tabs/dragged_tab_controller_gtk.cc @@ -21,6 +21,7 @@ #include "chrome/common/chrome_notification_types.h" #include "content/public/browser/notification_source.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "ui/base/gtk/gtk_screen_util.h" #include "ui/gfx/screen.h" @@ -786,7 +787,7 @@ void DraggedTabControllerGtk::ResetDelegates() { void DraggedTabControllerGtk::EnsureDraggedView() { if (!dragged_view_.get()) { gfx::Rect rect; - drag_data_->GetSourceWebContents()->GetContainerBounds(&rect); + drag_data_->GetSourceWebContents()->GetView()->GetContainerBounds(&rect); dragged_view_.reset(new DraggedViewGtk(drag_data_.get(), mouse_offset_, rect.size())); } diff --git a/chrome/browser/ui/views/color_chooser_aura.cc b/chrome/browser/ui/views/color_chooser_aura.cc index 080534d..37b9163 100644 --- a/chrome/browser/ui/views/color_chooser_aura.cc +++ b/chrome/browser/ui/views/color_chooser_aura.cc @@ -4,6 +4,7 @@ #include "content/public/browser/color_chooser.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "ui/views/color_chooser/color_chooser_listener.h" #include "ui/views/color_chooser/color_chooser_view.h" #include "ui/views/widget/widget.h" @@ -49,7 +50,8 @@ ColorChooserAura::ColorChooserAura(int identifier, tab_(tab) { DCHECK(tab_); view_ = new views::ColorChooserView(this, initial_color); - widget_ = views::Widget::CreateWindowWithContext(view_, tab->GetNativeView()); + widget_ = views::Widget::CreateWindowWithContext( + view_, tab->GetView()->GetNativeView()); widget_->SetAlwaysOnTop(true); widget_->Show(); } diff --git a/chrome/browser/ui/views/constrained_window_views.cc b/chrome/browser/ui/views/constrained_window_views.cc index 540fa47..0b21d96 100644 --- a/chrome/browser/ui/views/constrained_window_views.cc +++ b/chrome/browser/ui/views/constrained_window_views.cc @@ -622,7 +622,7 @@ ConstrainedWindowViews* ConstrainedWindowViews::Create( WebContentsModalDialogManager* manager = WebContentsModalDialogManager::FromWebContents(web_contents); ConstrainedWindowViews* dialog = new ConstrainedWindowViews( - web_contents->GetNativeView(), + web_contents->GetView()->GetNativeView(), web_contents->GetBrowserContext()->IsOffTheRecord(), widget_delegate); manager->AddDialog(dialog->GetNativeView()); diff --git a/chrome/browser/ui/views/download/download_started_animation_views.cc b/chrome/browser/ui/views/download/download_started_animation_views.cc index 8280ba2..5b67f38 100644 --- a/chrome/browser/ui/views/download/download_started_animation_views.cc +++ b/chrome/browser/ui/views/download/download_started_animation_views.cc @@ -10,6 +10,7 @@ #include "content/public/browser/notification_source.h" #include "content/public/browser/notification_types.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "grit/theme_resources.h" #include "ui/base/animation/linear_animation.h" #include "ui/base/resource/resource_bundle.h" @@ -90,7 +91,7 @@ DownloadStartedAnimationWin::DownloadStartedAnimationWin( // If we're too small to show the download image, then don't bother - // the shelf will be enough. - web_contents_->GetContainerBounds(&web_contents_bounds_); + web_contents_->GetView()->GetContainerBounds(&web_contents_bounds_); if (web_contents_bounds_.height() < kDownloadImage->height()) return; @@ -110,7 +111,7 @@ DownloadStartedAnimationWin::DownloadStartedAnimationWin( views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); params.transparent = true; params.accept_events = false; - params.parent = web_contents_->GetNativeView(); + params.parent = web_contents_->GetView()->GetNativeView(); popup_->Init(params); popup_->SetOpacity(0x00); popup_->SetContentsView(this); diff --git a/chrome/browser/ui/views/dropdown_bar_host_win.cc b/chrome/browser/ui/views/dropdown_bar_host_win.cc index f636a78..04bb65d 100644 --- a/chrome/browser/ui/views/dropdown_bar_host_win.cc +++ b/chrome/browser/ui/views/dropdown_bar_host_win.cc @@ -19,7 +19,7 @@ using content::WebContents; NativeWebKeyboardEvent DropdownBarHost::GetKeyboardEvent( const WebContents* contents, const ui::KeyEvent& key_event) { - HWND hwnd = contents->GetContentNativeView(); + HWND hwnd = contents->GetView()->GetContentNativeView(); WORD key = WindowsKeyCodeForKeyboardCode(key_event.key_code()); MSG msg = { hwnd, key_event.native_event().message, key, 0 }; diff --git a/chrome/browser/ui/views/extensions/extension_dialog.cc b/chrome/browser/ui/views/extensions/extension_dialog.cc index 5571cbb..d8b74ae 100644 --- a/chrome/browser/ui/views/extensions/extension_dialog.cc +++ b/chrome/browser/ui/views/extensions/extension_dialog.cc @@ -16,6 +16,7 @@ #include "content/public/browser/render_view_host.h" #include "content/public/browser/render_widget_host_view.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "googleurl/src/gurl.h" #include "ui/gfx/screen.h" #include "ui/views/background.h" @@ -109,7 +110,7 @@ ExtensionDialog* ExtensionDialog::ShowInternal( host->view()->SetVisible(true); // Ensure the DOM JavaScript can respond immediately to keyboard shortcuts. - host->host_contents()->Focus(); + host->host_contents()->GetView()->Focus(); return dialog; } diff --git a/chrome/browser/ui/views/extensions/extension_popup.cc b/chrome/browser/ui/views/extensions/extension_popup.cc index c5eca55..259d714 100644 --- a/chrome/browser/ui/views/extensions/extension_popup.cc +++ b/chrome/browser/ui/views/extensions/extension_popup.cc @@ -18,6 +18,7 @@ #include "content/public/browser/notification_source.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "ui/gfx/insets.h" #include "ui/views/layout/fill_layout.h" #include "ui/views/widget/widget.h" @@ -210,7 +211,7 @@ void ExtensionPopup::ShowBubble() { host()->view()->RequestFocus(); // Focus on the host contents when the bubble is first shown. - host()->host_contents()->Focus(); + host()->host_contents()->GetView()->Focus(); // Listen for widget focus changes after showing (used for non-aura win). views::WidgetFocusManager::GetInstance()->AddFocusChangeListener(this); diff --git a/chrome/browser/ui/views/extensions/native_app_window_views.cc b/chrome/browser/ui/views/extensions/native_app_window_views.cc index e03fb9b..a0e30a4 100644 --- a/chrome/browser/ui/views/extensions/native_app_window_views.cc +++ b/chrome/browser/ui/views/extensions/native_app_window_views.cc @@ -327,7 +327,8 @@ void NativeAppWindowViews::OnViewWasResized() { path.lineTo(0, height - radius - 1); path.close(); } - SetWindowRgn(web_contents()->GetNativeView(), path.CreateNativeRegion(), 1); + SetWindowRgn(web_contents()->GetView()->GetNativeView(), + path.CreateNativeRegion(), 1); SkRegion* rgn = new SkRegion; if (!window_->IsFullscreen()) { diff --git a/chrome/browser/ui/views/external_protocol_dialog.cc b/chrome/browser/ui/views/external_protocol_dialog.cc index 2112377..86944c5 100644 --- a/chrome/browser/ui/views/external_protocol_dialog.cc +++ b/chrome/browser/ui/views/external_protocol_dialog.cc @@ -13,6 +13,7 @@ #include "chrome/browser/external_protocol/external_protocol_handler.h" #include "chrome/browser/tab_contents/tab_util.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" @@ -155,7 +156,8 @@ ExternalProtocolDialog::ExternalProtocolDialog(WebContents* web_contents, HWND root_hwnd; if (web_contents_) { - root_hwnd = GetAncestor(web_contents_->GetContentNativeView(), GA_ROOT); + root_hwnd = GetAncestor(web_contents_->GetView()->GetContentNativeView(), + GA_ROOT); } else { // Dialog is top level if we don't have a web_contents associated with us. root_hwnd = NULL; diff --git a/chrome/browser/ui/views/external_tab_container_win.cc b/chrome/browser/ui/views/external_tab_container_win.cc index 6bb6ece..bc5d9ce 100644 --- a/chrome/browser/ui/views/external_tab_container_win.cc +++ b/chrome/browser/ui/views/external_tab_container_win.cc @@ -51,6 +51,7 @@ #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "content/public/common/bindings_policy.h" #include "content/public/common/frame_navigate_params.h" #include "content/public/common/page_transition_types.h" @@ -250,7 +251,7 @@ bool ExternalTabContainerWin::Init(Profile* profile, if (parent) SetParent(GetNativeView(), parent); - ::ShowWindow(existing_contents->GetNativeView(), SW_SHOWNA); + ::ShowWindow(existing_contents->GetView()->GetNativeView(), SW_SHOWNA); LoadAccelerators(); SetupExternalTabView(); @@ -398,7 +399,7 @@ void ExternalTabContainerWin::FocusThroughTabTraversal( bool restore_focus_to_view) { DCHECK(web_contents_.get()); if (web_contents_.get()) - web_contents_->Focus(); + web_contents_->GetView()->Focus(); // The web_contents_ member can get destroyed in the context of the call to // WebContentsViewViews::Focus() above. This method eventually calls SetFocus diff --git a/chrome/browser/ui/views/find_bar_host.cc b/chrome/browser/ui/views/find_bar_host.cc index 7a00bcb..d85110a 100644 --- a/chrome/browser/ui/views/find_bar_host.cc +++ b/chrome/browser/ui/views/find_bar_host.cc @@ -159,7 +159,7 @@ bool FindBarHost::IsFindBarVisible() { void FindBarHost::RestoreSavedFocus() { if (focus_tracker() == NULL) { // TODO(brettw): Focus() should be on WebContentsView. - find_bar_controller_->web_contents()->Focus(); + find_bar_controller_->web_contents()->GetView()->Focus(); } else { focus_tracker()->FocusLastFocusedExternalView(); } diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc index 21b3383..5e5ec9c 100644 --- a/chrome/browser/ui/views/frame/browser_view.cc +++ b/chrome/browser/ui/views/frame/browser_view.cc @@ -2578,7 +2578,7 @@ void BrowserView::DoCutCopyPaste(void (content::RenderWidgetHost::*method)(), bool BrowserView::DoCutCopyPasteForWebContents( WebContents* contents, void (content::RenderWidgetHost::*method)()) { - gfx::NativeView native_view = contents->GetContentNativeView(); + gfx::NativeView native_view = contents->GetView()->GetContentNativeView(); if (!native_view) return false; #if defined(USE_AURA) diff --git a/chrome/browser/ui/views/hung_renderer_view.cc b/chrome/browser/ui/views/hung_renderer_view.cc index b54f77e..af2ab49 100644 --- a/chrome/browser/ui/views/hung_renderer_view.cc +++ b/chrome/browser/ui/views/hung_renderer_view.cc @@ -22,6 +22,7 @@ #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "content/public/common/result_codes.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" @@ -206,7 +207,7 @@ HungRendererDialogView* HungRendererDialogView::GetInstance() { // static bool HungRendererDialogView::IsFrameActive(WebContents* contents) { gfx::NativeView frame_view = - platform_util::GetTopLevel(contents->GetNativeView()); + platform_util::GetTopLevel(contents->GetView()->GetNativeView()); return platform_util::IsWindowActive(frame_view); } @@ -244,7 +245,7 @@ void HungRendererDialogView::ShowForWebContents(WebContents* contents) { gfx::Rect bounds = GetDisplayBounds(contents); gfx::NativeView frame_view = - platform_util::GetTopLevel(contents->GetNativeView()); + platform_util::GetTopLevel(contents->GetView()->GetNativeView()); views::Widget* insert_after = views::Widget::GetWidgetForNativeView(frame_view); @@ -410,9 +411,10 @@ void HungRendererDialogView::Init() { gfx::Rect HungRendererDialogView::GetDisplayBounds( WebContents* contents) { #if defined(USE_AURA) - gfx::Rect contents_bounds(contents->GetNativeView()->GetBoundsInRootWindow()); + gfx::Rect contents_bounds( + contents->GetView()->GetNativeView()->GetBoundsInRootWindow()); #elif defined(OS_WIN) - HWND contents_hwnd = contents->GetNativeView(); + HWND contents_hwnd = contents->GetView()->GetNativeView(); RECT contents_bounds_rect; GetWindowRect(contents_hwnd, &contents_bounds_rect); gfx::Rect contents_bounds(contents_bounds_rect); diff --git a/chrome/browser/ui/views/speech_recognition_bubble_views.cc b/chrome/browser/ui/views/speech_recognition_bubble_views.cc index 0ee10ca..9477320 100644 --- a/chrome/browser/ui/views/speech_recognition_bubble_views.cc +++ b/chrome/browser/ui/views/speech_recognition_bubble_views.cc @@ -126,7 +126,7 @@ void SpeechRecognitionBubbleView::OnWidgetActivationChanged( gfx::Rect SpeechRecognitionBubbleView::GetAnchorRect() { gfx::Rect container_rect; - web_contents_->GetContainerBounds(&container_rect); + web_contents_->GetView()->GetContainerBounds(&container_rect); gfx::Rect anchor(element_rect_); anchor.Offset(container_rect.OffsetFromOrigin()); if (!container_rect.Intersects(anchor)) diff --git a/chrome/browser/ui/views/tabs/tab_drag_controller.cc b/chrome/browser/ui/views/tabs/tab_drag_controller.cc index 273c63f..25a0b71 100644 --- a/chrome/browser/ui/views/tabs/tab_drag_controller.cc +++ b/chrome/browser/ui/views/tabs/tab_drag_controller.cc @@ -32,6 +32,7 @@ #include "content/public/browser/notification_types.h" #include "content/public/browser/user_metrics.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "grit/theme_resources.h" #include "ui/base/animation/animation.h" #include "ui/base/animation/animation_delegate.h" @@ -1849,11 +1850,11 @@ void TabDragController::CreateDraggedView( // Set up the photo booth to start capturing the contents of the dragged // WebContents. - NativeViewPhotobooth* photobooth = - NativeViewPhotobooth::Create(source_dragged_contents()->GetNativeView()); + NativeViewPhotobooth* photobooth = NativeViewPhotobooth::Create( + source_dragged_contents()->GetView()->GetNativeView()); gfx::Rect content_bounds; - source_dragged_contents()->GetContainerBounds(&content_bounds); + source_dragged_contents()->GetView()->GetContainerBounds(&content_bounds); std::vector<views::View*> renderers; for (size_t i = 0; i < drag_data_.size(); ++i) { diff --git a/chrome/browser/ui/webui/downloads_dom_handler.cc b/chrome/browser/ui/webui/downloads_dom_handler.cc index 209a9ab..da4bc31 100644 --- a/chrome/browser/ui/webui/downloads_dom_handler.cc +++ b/chrome/browser/ui/webui/downloads_dom_handler.cc @@ -39,6 +39,7 @@ #include "content/public/browser/user_metrics.h" #include "content/public/browser/url_data_source.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "content/public/browser/web_ui.h" #include "grit/generated_resources.h" #include "net/base/net_util.h" @@ -344,7 +345,7 @@ void DownloadsDOMHandler::HandleDrag(const base::ListValue* args) { return; gfx::Image* icon = g_browser_process->icon_manager()->LookupIcon( file->GetTargetFilePath(), IconLoader::NORMAL); - gfx::NativeView view = web_contents->GetNativeView(); + gfx::NativeView view = web_contents->GetView()->GetNativeView(); { // Enable nested tasks during DnD, while |DragDownload()| blocks. MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); diff --git a/chrome/browser/ui/webui/ntp/foreign_session_handler.cc b/chrome/browser/ui/webui/ntp/foreign_session_handler.cc index 2436cb5..7436e44 100644 --- a/chrome/browser/ui/webui/ntp/foreign_session_handler.cc +++ b/chrome/browser/ui/webui/ntp/foreign_session_handler.cc @@ -33,6 +33,7 @@ #include "content/public/browser/notification_source.h" #include "content/public/browser/url_data_source.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "content/public/browser/web_ui.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" @@ -112,7 +113,7 @@ void ForeignSessionHandler::OpenForeignSessionWindows( iter_begin + 1; chrome::HostDesktopType host_desktop_type = chrome::GetHostDesktopTypeForNativeView( - web_ui->GetWebContents()->GetNativeView()); + web_ui->GetWebContents()->GetView()->GetNativeView()); SessionRestore::RestoreForeignSessionWindows( Profile::FromWebUI(web_ui), host_desktop_type, iter_begin, iter_end); } diff --git a/chrome/browser/ui/webui/ntp/recently_closed_tabs_handler.cc b/chrome/browser/ui/webui/ntp/recently_closed_tabs_handler.cc index fdc30a1..da133de 100644 --- a/chrome/browser/ui/webui/ntp/recently_closed_tabs_handler.cc +++ b/chrome/browser/ui/webui/ntp/recently_closed_tabs_handler.cc @@ -14,6 +14,7 @@ #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" #include "chrome/common/url_constants.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "content/public/browser/web_ui.h" #include "ui/webui/web_ui_util.h" @@ -106,7 +107,7 @@ void RecentlyClosedTabsHandler::HandleReopenTab(const ListValue* args) { return; chrome::HostDesktopType host_desktop_type = chrome::GetHostDesktopTypeForNativeView( - web_ui()->GetWebContents()->GetNativeView()); + web_ui()->GetWebContents()->GetView()->GetNativeView()); WindowOpenDisposition disposition = webui::GetDispositionFromClick(args, 2); tab_restore_service_->RestoreEntryById(delegate, static_cast<int>(session_to_restore), diff --git a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc index 88d3ef4..2a875ef 100644 --- a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc +++ b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc @@ -505,7 +505,7 @@ void PrintPreviewHandler::PrintToPdf() { } else if (!select_file_dialog_ || !select_file_dialog_->IsRunning( platform_util::GetTopLevel( - preview_web_contents()->GetNativeView()))) { + preview_web_contents()->GetView()->GetNativeView()))) { PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>( web_ui()->GetController()); // Pre-populating select file dialog with print job title. @@ -582,8 +582,8 @@ void PrintPreviewHandler::OnSigninComplete( } void PrintPreviewHandler::HandleSignin(const ListValue* /*args*/) { - gfx::NativeWindow modal_parent = - platform_util::GetTopLevel(preview_web_contents()->GetNativeView()); + gfx::NativeWindow modal_parent = platform_util::GetTopLevel( + preview_web_contents()->GetView()->GetNativeView()); print_dialog_cloud::CreateCloudPrintSigninDialog( preview_web_contents()->GetBrowserContext(), modal_parent, @@ -597,8 +597,8 @@ void PrintPreviewHandler::PrintWithCloudPrintDialog( // instead of the print preview dialog. ReportStats(); - gfx::NativeWindow modal_parent = - platform_util::GetTopLevel(preview_web_contents()->GetNativeView()); + gfx::NativeWindow modal_parent = platform_util::GetTopLevel( + preview_web_contents()->GetView()->GetNativeView()); print_dialog_cloud::CreatePrintDialogForBytes( preview_web_contents()->GetBrowserContext(), modal_parent, @@ -877,7 +877,8 @@ void PrintPreviewHandler::SelectFile(const base::FilePath& default_filename) { &file_type_info, 0, FILE_PATH_LITERAL(""), - platform_util::GetTopLevel(preview_web_contents()->GetNativeView()), + platform_util::GetTopLevel( + preview_web_contents()->GetView()->GetNativeView()), NULL); } diff --git a/chrome/browser/ui/webui/print_preview/print_preview_ui_interactive_browsertest.cc b/chrome/browser/ui/webui/print_preview/print_preview_ui_interactive_browsertest.cc new file mode 100644 index 0000000..c7fb081 --- /dev/null +++ b/chrome/browser/ui/webui/print_preview/print_preview_ui_interactive_browsertest.cc @@ -0,0 +1,105 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/command_line.h" +#include "chrome/browser/printing/print_preview_dialog_controller.h" +#include "chrome/browser/printing/print_view_manager.h" +#include "chrome/browser/ui/browser.h" +#include "chrome/browser/ui/tabs/tab_strip_model.h" +#include "chrome/browser/ui/web_contents_modal_dialog_manager.h" +#include "chrome/browser/ui/webui/print_preview/print_preview_ui.h" +#include "chrome/common/chrome_switches.h" +#include "chrome/test/base/in_process_browser_test.h" +#include "content/public/browser/render_widget_host_view.h" +#include "content/public/test/test_utils.h" + +namespace { + +bool IsShowingWebContentsModalDialog(content::WebContents* tab) { + WebContentsModalDialogManager* web_contents_modal_dialog_manager = + WebContentsModalDialogManager::FromWebContents(tab); + return web_contents_modal_dialog_manager->IsShowingDialog(); +} + +class PrintPreviewTest : public InProcessBrowserTest { + public: + PrintPreviewTest() {} + +#if !defined(GOOGLE_CHROME_BUILD) + virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { + command_line->AppendSwitch(switches::kEnablePrintPreview); + } +#endif +}; + +class WebContentsDestroyedWatcher : public content::WebContentsObserver { + public: + WebContentsDestroyedWatcher(content::WebContents* web_contents, + const base::Closure& callback) + : content::WebContentsObserver(web_contents), + callback_(callback) {} + + virtual void WebContentsDestroyed(content::WebContents* web_contents) { + callback_.Run(); + } + + private: + base::Closure callback_; +}; + +#if defined(OS_MACOSX) // TODO(jam): track down. +#define MAYBE_InitiatorTabGetsFocusOnPrintPreviewDialogClose \ + DISABLED_InitiatorTabGetsFocusOnPrintPreviewDialogClose +#else +#define MAYBE_InitiatorTabGetsFocusOnPrintPreviewDialogClose \ + InitiatorTabGetsFocusOnPrintPreviewDialogClose +#endif + +IN_PROC_BROWSER_TEST_F(PrintPreviewTest, + MAYBE_InitiatorTabGetsFocusOnPrintPreviewDialogClose) { + content::WebContents* initiator_tab = + browser()->tab_strip_model()->GetActiveWebContents(); + + printing::PrintPreviewDialogController* controller = + printing::PrintPreviewDialogController::GetInstance(); + ASSERT_TRUE(controller); + + printing::PrintViewManager* print_view_manager = + printing::PrintViewManager::FromWebContents(initiator_tab); + print_view_manager->PrintPreviewNow(false); + + // Don't call GetOrCreatePreviewDialog since that would create the dialog now. + // The problem with doing so is that if we close it right away (which this + // test does), then when the IPC comes back from the renderer in the normal + // printing workflow that would cause the dialog to get created again (and it + // would be dispatched, racily, in the second nested message loop below). + scoped_refptr<content::MessageLoopRunner> dialog_runner = + new content::MessageLoopRunner; + controller->set_print_preview_tab_created_callback_for_testing( + dialog_runner->QuitClosure()); + dialog_runner->Run(); + + content::WebContents* preview_dialog = + controller->GetPrintPreviewForContents(initiator_tab); + + EXPECT_NE(initiator_tab, preview_dialog); + EXPECT_TRUE(IsShowingWebContentsModalDialog(initiator_tab)); + EXPECT_FALSE(initiator_tab->GetRenderWidgetHostView()->HasFocus()); + + PrintPreviewUI* preview_ui = static_cast<PrintPreviewUI*>( + preview_dialog->GetWebUI()->GetController()); + ASSERT_TRUE(preview_ui != NULL); + + scoped_refptr<content::MessageLoopRunner> runner = + new content::MessageLoopRunner; + WebContentsDestroyedWatcher watcher(preview_dialog, runner->QuitClosure()); + + preview_ui->OnPrintPreviewDialogClosed(); + + runner->Run(); + + EXPECT_FALSE(IsShowingWebContentsModalDialog(initiator_tab)); + EXPECT_TRUE(initiator_tab->GetRenderWidgetHostView()->HasFocus()); +} +} // namespace diff --git a/chrome/browser/ui/webui/print_preview/print_preview_ui_unittest.cc b/chrome/browser/ui/webui/print_preview/print_preview_ui_unittest.cc index b85f9fc..15b6eb2 100644 --- a/chrome/browser/ui/webui/print_preview/print_preview_ui_unittest.cc +++ b/chrome/browser/ui/webui/print_preview/print_preview_ui_unittest.cc @@ -19,12 +19,10 @@ #include "content/public/browser/plugin_service.h" #include "content/public/browser/site_instance.h" #include "content/public/browser/web_contents.h" -#include "content/public/test/web_contents_tester.h" #include "printing/print_job_constants.h" #include "webkit/plugins/npapi/mock_plugin_list.h" using content::WebContents; -using content::WebContentsTester; namespace { @@ -239,40 +237,3 @@ TEST_F(PrintPreviewUIUnitTest, GetCurrentPrintPreviewStatus) { &cancel); EXPECT_FALSE(cancel); } - -TEST_F(PrintPreviewUIUnitTest, InitiatorTabGetsFocusOnPrintPreviewDialogClose) { - EXPECT_EQ(1, browser()->tab_strip_model()->count()); - WebContents* initiator_tab = - WebContentsTester::CreateTestWebContentsCountFocus(profile(), NULL); - WebContentsTester* initiator_tester = WebContentsTester::For(initiator_tab); - chrome::AddWebContents(browser(), NULL, initiator_tab, - NEW_FOREGROUND_TAB, gfx::Rect(), false, NULL); - EXPECT_EQ(2, browser()->tab_strip_model()->count()); - EXPECT_EQ(0, initiator_tester->GetNumberOfFocusCalls()); - - printing::PrintPreviewDialogController* controller = - printing::PrintPreviewDialogController::GetInstance(); - ASSERT_TRUE(controller); - - printing::PrintViewManager* print_view_manager = - printing::PrintViewManager::FromWebContents(initiator_tab); - print_view_manager->PrintPreviewNow(false); - WebContents* preview_dialog = - controller->GetOrCreatePreviewDialog(initiator_tab); - - EXPECT_NE(initiator_tab, preview_dialog); - EXPECT_EQ(2, browser()->tab_strip_model()->count()); - EXPECT_TRUE(IsShowingWebContentsModalDialog(initiator_tab)); - EXPECT_EQ(0, initiator_tester->GetNumberOfFocusCalls()); - - PrintPreviewUI* preview_ui = static_cast<PrintPreviewUI*>( - preview_dialog->GetWebUI()->GetController()); - ASSERT_TRUE(preview_ui != NULL); - - preview_ui->OnPrintPreviewDialogClosed(); - message_loop()->RunUntilIdle(); - - EXPECT_EQ(2, browser()->tab_strip_model()->count()); - EXPECT_FALSE(IsShowingWebContentsModalDialog(initiator_tab)); - EXPECT_EQ(1, initiator_tester->GetNumberOfFocusCalls()); -} diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index bcb2294..99176a8 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -240,6 +240,7 @@ 'browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc', 'browser/ui/views/tabs/tab_drag_controller_interactive_uitest.h', 'browser/ui/views/tabs/tab_drag_controller_interactive_uitest_win.cc', + 'browser/ui/webui/print_preview/print_preview_ui_interactive_browsertest.cc', 'test/base/chrome_test_launcher.cc', 'test/base/interactive_test_utils.cc', 'test/base/interactive_test_utils.h', diff --git a/chrome/test/gpu/gpu_pixel_browsertest.cc b/chrome/test/gpu/gpu_pixel_browsertest.cc index 0fae72c..71d9478 100644 --- a/chrome/test/gpu/gpu_pixel_browsertest.cc +++ b/chrome/test/gpu/gpu_pixel_browsertest.cc @@ -21,6 +21,7 @@ #include "chrome/test/base/ui_test_utils.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "content/public/common/content_paths.h" #include "content/public/common/content_switches.h" #include "content/public/test/browser_test_utils.h" @@ -392,8 +393,8 @@ class GpuPixelBrowserTest : public InProcessBrowserTest { gfx::Rect root_bounds = browser()->window()->GetBounds(); gfx::Rect tab_contents_bounds; - browser()->tab_strip_model()->GetActiveWebContents()->GetContainerBounds( - &tab_contents_bounds); + browser()->tab_strip_model()->GetActiveWebContents()->GetView()-> + GetContainerBounds(&tab_contents_bounds); gfx::Rect snapshot_bounds(tab_contents_bounds.x() - root_bounds.x(), tab_contents_bounds.y() - root_bounds.y(), diff --git a/chrome/test/perf/rendering/throughput_tests.cc b/chrome/test/perf/rendering/throughput_tests.cc index e7c25aa..f9bfefe 100644 --- a/chrome/test/perf/rendering/throughput_tests.cc +++ b/chrome/test/perf/rendering/throughput_tests.cc @@ -26,6 +26,7 @@ #include "chrome/test/perf/browser_perf_test.h" #include "chrome/test/perf/perf_test.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "content/public/common/content_switches.h" #include "content/public/test/browser_test_utils.h" #include "content/public/test/test_utils.h" @@ -220,8 +221,8 @@ class ThroughputTest : public BrowserPerfTest { gfx::Rect root_bounds = browser()->window()->GetBounds(); gfx::Rect tab_contents_bounds; - browser()->tab_strip_model()->GetActiveWebContents()->GetContainerBounds( - &tab_contents_bounds); + browser()->tab_strip_model()->GetActiveWebContents()->GetView()-> + GetContainerBounds(&tab_contents_bounds); gfx::Rect snapshot_bounds(tab_contents_bounds.x() - root_bounds.x(), tab_contents_bounds.y() - root_bounds.y(), diff --git a/components/web_contents_delegate_android/color_chooser_android.cc b/components/web_contents_delegate_android/color_chooser_android.cc index 6e4c298f..b0f53d5 100644 --- a/components/web_contents_delegate_android/color_chooser_android.cc +++ b/components/web_contents_delegate_android/color_chooser_android.cc @@ -6,6 +6,7 @@ #include "content/public/browser/android/content_view_core.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "jni/ColorChooserAndroid_jni.h" namespace content { @@ -25,7 +26,8 @@ ColorChooserAndroid::ColorChooserAndroid(int identifier, : ColorChooser::ColorChooser(identifier), content::WebContentsObserver(tab) { JNIEnv* env = AttachCurrentThread(); - content::ContentViewCore* content_view_core = tab->GetContentNativeView(); + content::ContentViewCore* content_view_core = + tab->GetView()->GetContentNativeView(); DCHECK(content_view_core); j_color_chooser_.Reset(Java_ColorChooserAndroid_createColorChooserAndroid( diff --git a/content/browser/android/download_controller_android_impl.cc b/content/browser/android/download_controller_android_impl.cc index f1a3699..386d6a0 100644 --- a/content/browser/android/download_controller_android_impl.cc +++ b/content/browser/android/download_controller_android_impl.cc @@ -18,6 +18,7 @@ #include "content/browser/web_contents/web_contents_impl.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/global_request_id.h" +#include "content/public/browser/web_contents_view.h" #include "jni/DownloadController_jni.h" #include "net/cookies/cookie_options.h" #include "net/cookies/cookie_store.h" @@ -311,7 +312,7 @@ ScopedJavaLocalRef<jobject> if (!web_contents) return ScopedJavaLocalRef<jobject>(); - ContentViewCore* view_core = web_contents->GetContentNativeView(); + ContentViewCore* view_core = web_contents->GetView()->GetContentNativeView(); return view_core ? view_core->GetJavaObject() : ScopedJavaLocalRef<jobject>(); } diff --git a/content/browser/web_contents/web_contents_drag_win.cc b/content/browser/web_contents/web_contents_drag_win.cc index cb83dcd..0b7fac4 100644 --- a/content/browser/web_contents/web_contents_drag_win.cc +++ b/content/browser/web_contents/web_contents_drag_win.cc @@ -24,6 +24,7 @@ #include "content/public/browser/browser_thread.h" #include "content/public/browser/content_browser_client.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "content/public/browser/web_drag_dest_delegate.h" #include "net/base/net_util.h" #include "third_party/skia/include/core/SkBitmap.h" @@ -348,7 +349,7 @@ bool WebContentsDragWin::DoDragging(const WebDropData& drop_data, // Use a local variable to keep track of the contents view window handle. // It might not be safe to access the instance after DoDragDrop returns // because the window could be disposed in the nested message loop. - HWND native_window = web_contents_->GetNativeView(); + HWND native_window = web_contents_->GetView()->GetNativeView(); // We need to enable recursive tasks on the message loop so we can get // updates while in the system DoDragDrop loop. diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc index f4b6aa4..e8e55a7 100644 --- a/content/browser/web_contents/web_contents_impl.cc +++ b/content/browser/web_contents/web_contents_impl.cc @@ -344,7 +344,7 @@ WebContentsImpl::~WebContentsImpl() { #if defined(OS_WIN) && !defined(USE_AURA) // If we still have a window handle, destroy it. GetNativeView can return // NULL if this contents was part of a window that closed. - if (GetNativeView()) { + if (view_->GetNativeView()) { RenderViewHost* host = GetRenderViewHost(); if (host && host->GetView()) RenderWidgetHostViewPort::FromRWHV(host->GetView())->WillWmDestroy(); @@ -1186,22 +1186,6 @@ WebContents* WebContentsImpl::Clone() { return tc; } -gfx::NativeView WebContentsImpl::GetContentNativeView() const { - return view_->GetContentNativeView(); -} - -gfx::NativeView WebContentsImpl::GetNativeView() const { - return view_->GetNativeView(); -} - -void WebContentsImpl::GetContainerBounds(gfx::Rect* out) const { - view_->GetContainerBounds(out); -} - -void WebContentsImpl::Focus() { - view_->Focus(); -} - void WebContentsImpl::Observe(int type, const NotificationSource& source, const NotificationDetails& details) { @@ -2385,7 +2369,7 @@ void WebContentsImpl::OnFindMatchRectsReply( void WebContentsImpl::OnOpenDateTimeDialog( const ViewHostMsg_DateTimeDialogValue_Params& value) { date_time_chooser_->ShowDialog( - GetContentNativeView(), GetRenderViewHost(), value.dialog_type, + view_->GetContentNativeView(), GetRenderViewHost(), value.dialog_type, value.year, value.month, value.day, value.hour, value.minute, value.second); } @@ -2787,7 +2771,7 @@ void WebContentsImpl::RenderViewReady(RenderViewHost* rvh) { // window). if (was_crashed && !FocusLocationBarByDefault() && (!delegate_ || delegate_->ShouldFocusPageAfterCrash())) { - Focus(); + view_->Focus(); } FOR_EACH_OBSERVER(WebContentsObserver, observers_, RenderViewReady()); diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h index 9e8124f..a1e01b7 100644 --- a/content/browser/web_contents/web_contents_impl.h +++ b/content/browser/web_contents/web_contents_impl.h @@ -232,10 +232,6 @@ class CONTENT_EXPORT WebContentsImpl virtual bool NeedToFireBeforeUnload() OVERRIDE; virtual void Stop() OVERRIDE; virtual WebContents* Clone() OVERRIDE; - virtual gfx::NativeView GetContentNativeView() const OVERRIDE; - virtual gfx::NativeView GetNativeView() const OVERRIDE; - virtual void GetContainerBounds(gfx::Rect* out) const OVERRIDE; - virtual void Focus() OVERRIDE; virtual void FocusThroughTabTraversal(bool reverse) OVERRIDE; virtual bool ShowingInterstitialPage() const OVERRIDE; virtual InterstitialPage* GetInterstitialPage() const OVERRIDE; diff --git a/content/browser/web_contents/web_contents_view_aura_browsertest.cc b/content/browser/web_contents/web_contents_view_aura_browsertest.cc index b029296..3a278f3 100644 --- a/content/browser/web_contents/web_contents_view_aura_browsertest.cc +++ b/content/browser/web_contents/web_contents_view_aura_browsertest.cc @@ -13,6 +13,7 @@ #include "content/browser/web_contents/navigation_controller_impl.h" #include "content/browser/web_contents/navigation_entry_impl.h" #include "content/browser/web_contents/web_contents_impl.h" +#include "content/public/browser/web_contents_view.h" #include "content/public/common/content_switches.h" #include "content/public/test/browser_test_utils.h" #include "content/public/test/test_utils.h" @@ -84,7 +85,8 @@ class WebContentsViewAuraTest : public ContentBrowserTest { ASSERT_TRUE(test_server()->Start()); GURL test_url(test_server()->GetURL(url)); NavigateToURL(shell(), test_url); - aura::Window* content = shell()->web_contents()->GetContentNativeView(); + aura::Window* content = + shell()->web_contents()->GetView()->GetContentNativeView(); content->GetRootWindow()->SetHostSize(gfx::Size(800, 600)); } @@ -116,7 +118,7 @@ class WebContentsViewAuraTest : public ContentBrowserTest { EXPECT_TRUE(controller.CanGoBack()); EXPECT_FALSE(controller.CanGoForward()); - aura::Window* content = web_contents->GetContentNativeView(); + aura::Window* content = web_contents->GetView()->GetContentNativeView(); gfx::Rect bounds = content->GetBoundsInRootWindow(); aura::test::EventGenerator generator(content->GetRootWindow(), content); @@ -219,7 +221,7 @@ IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest, web_contents->GetController().GoBack(); EXPECT_EQ(1, GetCurrentIndex()); - aura::Window* content = web_contents->GetContentNativeView(); + aura::Window* content = web_contents->GetView()->GetContentNativeView(); aura::RootWindow* root_window = content->GetRootWindow(); gfx::Rect bounds = content->GetBoundsInRootWindow(); @@ -321,7 +323,7 @@ IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest, // index 3 to index 2, and index 3 should have a screenshot. string16 expected_title = ASCIIToUTF16("Title: #2"); content::TitleWatcher title_watcher(web_contents, expected_title); - aura::Window* content = web_contents->GetContentNativeView(); + aura::Window* content = web_contents->GetView()->GetContentNativeView(); gfx::Rect bounds = content->GetBoundsInRootWindow(); aura::test::EventGenerator generator(content->GetRootWindow(), content); generator.GestureScrollSequence( diff --git a/content/public/browser/web_contents.h b/content/public/browser/web_contents.h index 1a26c89..e5e8440 100644 --- a/content/public/browser/web_contents.h +++ b/content/public/browser/web_contents.h @@ -272,22 +272,6 @@ class WebContents : public PageNavigator, virtual WebContents* Clone() = 0; // Views and focus ----------------------------------------------------------- - // TODO(brettw): Most of these should be removed and the caller should call - // the view directly. - - // Returns the actual window that is focused when this WebContents is shown. - virtual gfx::NativeView GetContentNativeView() const = 0; - - // Returns the NativeView associated with this WebContents. Outside of - // automation in the context of the UI, this is required to be implemented. - virtual gfx::NativeView GetNativeView() const = 0; - - // Returns the bounds of this WebContents in the screen coordinate system. - virtual void GetContainerBounds(gfx::Rect* out) const = 0; - - // Makes the tab the focused window. - virtual void Focus() = 0; - // Focuses the first (last if |reverse| is true) element in the page. // Invoked when this tab is getting the focus through tab traversal (|reverse| // is true when using Shift-Tab). diff --git a/content/public/test/web_contents_tester.cc b/content/public/test/web_contents_tester.cc index 3b2ed55..4435d9ff 100644 --- a/content/public/test/web_contents_tester.cc +++ b/content/public/test/web_contents_tester.cc @@ -13,24 +13,6 @@ namespace { // The two subclasses here are instantiated via the deprecated // CreateWebContentsFor... factories below. -class TestWebContentsCountFocus : public TestWebContents { - public: - explicit TestWebContentsCountFocus(BrowserContext* browser_context) - : TestWebContents(browser_context), focus_called_(0) { - } - - virtual int GetNumberOfFocusCalls() OVERRIDE { - return focus_called_; - } - - virtual void Focus() OVERRIDE { - focus_called_++; - } - - private: - int focus_called_; -}; - class TestWebContentsCountSetFocusToLocationBar : public TestWebContents { public: explicit TestWebContentsCountSetFocusToLocationBar( @@ -73,14 +55,4 @@ WebContents* WebContentsTester::CreateTestWebContentsCountSetFocusToLocationBar( return web_contents; } -// static -WebContents* WebContentsTester::CreateTestWebContentsCountFocus( - BrowserContext* browser_context, - SiteInstance* instance) { - TestWebContentsCountFocus* web_contents = - new TestWebContentsCountFocus(browser_context); - web_contents->Init(WebContents::CreateParams(browser_context, instance)); - return web_contents; -} - } // namespace content diff --git a/content/public/test/web_contents_tester.h b/content/public/test/web_contents_tester.h index 5c4a37c..5978d0b 100644 --- a/content/public/test/web_contents_tester.h +++ b/content/public/test/web_contents_tester.h @@ -65,12 +65,6 @@ class WebContentsTester { BrowserContext* browser_context, SiteInstance* instance); - // Deprecated. Creates a WebContents enabled for testing, that - // counts the number of times Focus is called. - static WebContents* CreateTestWebContentsCountFocus( - BrowserContext* browser_context, - SiteInstance* instance); - // Simulates the appropriate RenderView (pending if any, current otherwise) // sending a navigate notification for the NavigationController pending entry. virtual void CommitPendingNavigation() = 0; diff --git a/content/shell/shell.cc b/content/shell/shell.cc index fe65fc1..0a92aff 100644 --- a/content/shell/shell.cc +++ b/content/shell/shell.cc @@ -156,22 +156,22 @@ void Shell::LoadURLForFrame(const GURL& url, const std::string& frame_name) { PAGE_TRANSITION_TYPED | PAGE_TRANSITION_FROM_ADDRESS_BAR); params.frame_name = frame_name; web_contents_->GetController().LoadURLWithParams(params); - web_contents_->Focus(); + web_contents_->GetView()->Focus(); } void Shell::GoBackOrForward(int offset) { web_contents_->GetController().GoToOffset(offset); - web_contents_->Focus(); + web_contents_->GetView()->Focus(); } void Shell::Reload() { web_contents_->GetController().Reload(false); - web_contents_->Focus(); + web_contents_->GetView()->Focus(); } void Shell::Stop() { web_contents_->Stop(); - web_contents_->Focus(); + web_contents_->GetView()->Focus(); } void Shell::UpdateNavigationControls() { @@ -201,7 +201,7 @@ void Shell::CloseDevTools() { gfx::NativeView Shell::GetContentView() { if (!web_contents_.get()) return NULL; - return web_contents_->GetNativeView(); + return web_contents_->GetView()->GetNativeView(); } WebContents* Shell::OpenURLFromTab(WebContents* source, diff --git a/content/shell/shell_aura.cc b/content/shell/shell_aura.cc index 2297587..f78c9e1 100644 --- a/content/shell/shell_aura.cc +++ b/content/shell/shell_aura.cc @@ -7,6 +7,7 @@ #include "base/command_line.h" #include "base/utf_string_conversions.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "ui/aura/env.h" #include "ui/aura/root_window.h" #include "ui/aura/window.h" @@ -87,7 +88,7 @@ class ShellWindowDelegateView : public WidgetDelegateView, contents_view_->SetLayoutManager(new FillLayout()); web_view_ = new WebView(web_contents->GetBrowserContext()); web_view_->SetWebContents(web_contents); - web_contents->Focus(); + web_contents->GetView()->Focus(); contents_view_->AddChildView(web_view_); Layout(); } diff --git a/content/shell/shell_devtools_frontend.cc b/content/shell/shell_devtools_frontend.cc index d6aaeeb..9149680 100644 --- a/content/shell/shell_devtools_frontend.cc +++ b/content/shell/shell_devtools_frontend.cc @@ -9,6 +9,7 @@ #include "content/public/browser/devtools_http_handler.h" #include "content/public/browser/devtools_manager.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "content/public/common/content_client.h" #include "content/shell/shell.h" #include "content/shell/shell_browser_context.h" @@ -65,7 +66,7 @@ ShellDevToolsFrontend* ShellDevToolsFrontend::Show( } void ShellDevToolsFrontend::Focus() { - web_contents()->Focus(); + web_contents()->GetView()->Focus(); } void ShellDevToolsFrontend::Close() { diff --git a/content/shell/shell_download_manager_delegate.cc b/content/shell/shell_download_manager_delegate.cc index 0771754..55c36df 100644 --- a/content/shell/shell_download_manager_delegate.cc +++ b/content/shell/shell_download_manager_delegate.cc @@ -135,7 +135,7 @@ void ShellDownloadManagerDelegate::ChooseDownloadPath( OPENFILENAME save_as; ZeroMemory(&save_as, sizeof(save_as)); save_as.lStructSize = sizeof(OPENFILENAME); - save_as.hwndOwner = item->GetWebContents()->GetNativeView(); + save_as.hwndOwner = item->GetWebContents()->GetView()->GetNativeView(); save_as.lpstrFile = file_name; save_as.nMaxFile = arraysize(file_name); diff --git a/content/shell/shell_gtk.cc b/content/shell/shell_gtk.cc index de41e66..8d024ce 100644 --- a/content/shell/shell_gtk.cc +++ b/content/shell/shell_gtk.cc @@ -209,8 +209,10 @@ void Shell::PlatformSetContents() { void Shell::SizeTo(int width, int height) { content_width_ = width; content_height_ = height; - if (web_contents_.get()) - gtk_widget_set_size_request(web_contents_->GetNativeView(), width, height); + if (web_contents_.get()) { + gtk_widget_set_size_request(web_contents_->GetView()->GetNativeView(), + width, height); + } } void Shell::PlatformResizeSubViews() { diff --git a/content/shell/shell_web_contents_view_delegate_gtk.cc b/content/shell/shell_web_contents_view_delegate_gtk.cc index ce354ef..cd72e03 100644 --- a/content/shell/shell_web_contents_view_delegate_gtk.cc +++ b/content/shell/shell_web_contents_view_delegate_gtk.cc @@ -196,17 +196,17 @@ gboolean ShellWebContentsViewDelegate::OnNativeViewFocusEvent( void ShellWebContentsViewDelegate::OnBackMenuActivated(GtkWidget* widget) { web_contents_->GetController().GoToOffset(-1); - web_contents_->Focus(); + web_contents_->GetView()->Focus(); } void ShellWebContentsViewDelegate::OnForwardMenuActivated(GtkWidget* widget) { web_contents_->GetController().GoToOffset(1); - web_contents_->Focus(); + web_contents_->GetView()->Focus(); } void ShellWebContentsViewDelegate::OnReloadMenuActivated(GtkWidget* widget) { web_contents_->GetController().Reload(false); - web_contents_->Focus(); + web_contents_->GetView()->Focus(); } void ShellWebContentsViewDelegate::OnOpenURLMenuActivated(GtkWidget* widget) { diff --git a/content/shell/shell_web_contents_view_delegate_mac.mm b/content/shell/shell_web_contents_view_delegate_mac.mm index 7143e16..2460595 100644 --- a/content/shell/shell_web_contents_view_delegate_mac.mm +++ b/content/shell/shell_web_contents_view_delegate_mac.mm @@ -201,7 +201,7 @@ void ShellWebContentsViewDelegate::ShowContextMenu( YES, delegate); - NSView* parent_view = web_contents_->GetContentNativeView(); + NSView* parent_view = web_contents_->GetView()->GetContentNativeView(); NSEvent* currentEvent = [NSApp currentEvent]; NSWindow* window = [parent_view window]; NSPoint position = [window mouseLocationOutsideOfEventStream]; @@ -248,15 +248,15 @@ void ShellWebContentsViewDelegate::ActionPerformed(int tag) { } case ShellContextMenuItemBackTag: web_contents_->GetController().GoToOffset(-1); - web_contents_->Focus(); + web_contents_->GetView()->Focus(); break; case ShellContextMenuItemForwardTag: web_contents_->GetController().GoToOffset(1); - web_contents_->Focus(); + web_contents_->GetView()->Focus(); break; case ShellContextMenuItemReloadTag: { web_contents_->GetController().Reload(false); - web_contents_->Focus(); + web_contents_->GetView()->Focus(); break; } case ShellContextMenuItemInspectTag: { diff --git a/content/shell/shell_web_contents_view_delegate_win.cc b/content/shell/shell_web_contents_view_delegate_win.cc index 071b1af..df400f7 100644 --- a/content/shell/shell_web_contents_view_delegate_win.cc +++ b/content/shell/shell_web_contents_view_delegate_win.cc @@ -216,15 +216,15 @@ void ShellWebContentsViewDelegate::MenuItemSelected(int selection) { } case ShellContextMenuItemBackId: web_contents_->GetController().GoToOffset(-1); - web_contents_->Focus(); + web_contents_->GetView()->Focus(); break; case ShellContextMenuItemForwardId: web_contents_->GetController().GoToOffset(1); - web_contents_->Focus(); + web_contents_->GetView()->Focus(); break; case ShellContextMenuItemReloadId: web_contents_->GetController().Reload(false); - web_contents_->Focus(); + web_contents_->GetView()->Focus(); break; case ShellContextMenuItemInspectId: { ShellDevToolsFrontend::Show(web_contents_); diff --git a/ui/views/controls/webview/webview.cc b/ui/views/controls/webview/webview.cc index 0edd781..54a74ad 100644 --- a/ui/views/controls/webview/webview.cc +++ b/ui/views/controls/webview/webview.cc @@ -13,6 +13,7 @@ #include "content/public/browser/render_view_host.h" #include "content/public/browser/render_widget_host_view.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "ipc/ipc_message.h" #include "ui/base/accessibility/accessibility_types.h" #include "ui/base/accessibility/accessible_view_state.h" @@ -121,7 +122,7 @@ bool WebView::IsFocusable() const { void WebView::OnFocus() { if (web_contents_) - web_contents_->Focus(); + web_contents_->GetView()->Focus(); } void WebView::AboutToRequestFocusFromTabTraversal(bool reverse) { @@ -187,19 +188,19 @@ void WebView::AttachWebContents() { // Prevents attachment if the WebView isn't already in a Widget, or it's // already attached. if (!GetWidget() || !web_contents_ || - wcv_holder_->native_view() == web_contents_->GetNativeView()) { + wcv_holder_->native_view() == web_contents_->GetView()->GetNativeView()) { return; } if (web_contents_) { - wcv_holder_->Attach(web_contents_->GetNativeView()); + wcv_holder_->Attach(web_contents_->GetView()->GetNativeView()); // The WebContentsView will not be focused automatically when it is // attached, so we need to pass on focus to it if the FocusManager thinks // the WebView is focused. Note that not every Widget has a focus manager. FocusManager* focus_manager = GetFocusManager(); if (focus_manager && focus_manager->GetFocusedView() == this) - web_contents_->Focus(); + web_contents_->GetView()->Focus(); registrar_.Add( this, @@ -224,7 +225,7 @@ void WebView::DetachWebContents() { // // Moving this out of here would also mean we wouldn't be potentially // calling member functions on a half-destroyed WebContents. - ShowWindow(web_contents_->GetNativeView(), SW_HIDE); + ShowWindow(web_contents_->GetView()->GetNativeView(), SW_HIDE); #endif } registrar_.RemoveAll(); @@ -233,7 +234,7 @@ void WebView::DetachWebContents() { void WebView::RenderViewHostChanged(content::RenderViewHost* old_host, content::RenderViewHost* new_host) { if (GetFocusManager()->GetFocusedView() == this) - web_contents_->Focus(); + web_contents_->GetView()->Focus(); } void WebView::WebContentsDestroyed(content::WebContents* web_contents) { diff --git a/ui/views/examples/webview_example.cc b/ui/views/examples/webview_example.cc index feae6b9..5a2d89d 100644 --- a/ui/views/examples/webview_example.cc +++ b/ui/views/examples/webview_example.cc @@ -6,6 +6,7 @@ #include "content/public/browser/browser_context.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "ui/views/controls/webview/webview.h" #include "ui/views/layout/fill_layout.h" @@ -27,7 +28,7 @@ void WebViewExample::CreateExampleView(View* container) { container->AddChildView(webview_); webview_->LoadInitialURL(GURL("http://www.google.com/")); - webview_->web_contents()->Focus(); + webview_->web_contents()->GetView()->Focus(); } } // namespace examples |