Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: chrome/browser/web_contents.cc

Issue 4088: Move a bunch of stuff out of WebContents. I removed a bunch of render view ho... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/web_contents.h ('k') | chrome/browser/web_drop_target.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/web_contents.h" 5 #include "chrome/browser/web_contents.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/file_version_info.h" 8 #include "base/file_version_info.h"
9 #include "chrome/app/locales/locale_settings.h" 9 #include "chrome/app/locales/locale_settings.h"
10 #include "chrome/browser/bookmarks/bookmark_model.h" 10 #include "chrome/browser/bookmarks/bookmark_model.h"
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 275
276 void WebContents::SizeContents(const gfx::Size& size) { 276 void WebContents::SizeContents(const gfx::Size& size) {
277 if (view()) 277 if (view())
278 view()->SetSize(size); 278 view()->SetSize(size);
279 if (find_in_page_controller_.get()) 279 if (find_in_page_controller_.get())
280 find_in_page_controller_->RespondToResize(size); 280 find_in_page_controller_->RespondToResize(size);
281 RepositionSupressedPopupsToFit(size); 281 RepositionSupressedPopupsToFit(size);
282 } 282 }
283 283
284 void WebContents::FirePageBeforeUnload() { 284 void WebContents::FirePageBeforeUnload() {
285 render_view_host()->FirePageBeforeUnload(); 285 render_view_host()->FirePageBeforeUnload();
huanr 2008/09/25 18:01:39 what is the reason to keep this function in WebCon
286 } 286 }
287 287
288 void WebContents::FirePageUnload() {
289 render_view_host()->FirePageUnload();
290 }
291
292 void WebContents::Destroy() { 288 void WebContents::Destroy() {
293 // Tell the notification service we no longer want notifications. 289 // Tell the notification service we no longer want notifications.
294 NotificationService::current()-> 290 NotificationService::current()->
295 RemoveObserver(this, NOTIFY_URLS_STARRED, 291 RemoveObserver(this, NOTIFY_URLS_STARRED,
296 NotificationService::AllSources()); 292 NotificationService::AllSources());
297 NotificationService::current()-> 293 NotificationService::current()->
298 RemoveObserver(this, NOTIFY_BOOKMARK_MODEL_LOADED, 294 RemoveObserver(this, NOTIFY_BOOKMARK_MODEL_LOADED,
299 NotificationService::AllSources()); 295 NotificationService::AllSources());
300 296
301 // Destroy the print manager right now since a Print command may be pending. 297 // Destroy the print manager right now since a Print command may be pending.
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 find_in_page_controller_->DidBecomeUnselected(); 673 find_in_page_controller_->DidBecomeUnselected();
678 674
679 TabContents::WasHidden(); 675 TabContents::WasHidden();
680 } 676 }
681 677
682 void WebContents::StartFinding(int request_id, 678 void WebContents::StartFinding(int request_id,
683 const std::wstring& search_string, 679 const std::wstring& search_string,
684 bool forward, 680 bool forward,
685 bool match_case, 681 bool match_case,
686 bool find_next) { 682 bool find_next) {
687 if (search_string.empty())
688 return;
689 render_view_host()->StartFinding(request_id, search_string, forward, 683 render_view_host()->StartFinding(request_id, search_string, forward,
690 match_case, find_next); 684 match_case, find_next);
691 } 685 }
692 686
693 void WebContents::StopFinding(bool clear_selection) { 687 void WebContents::StopFinding(bool clear_selection) {
694 render_view_host()->StopFinding(clear_selection); 688 render_view_host()->StopFinding(clear_selection);
695 } 689 }
696 690
697 void WebContents::OpenFindInPageWindow(const Browser& browser) { 691 void WebContents::OpenFindInPageWindow(const Browser& browser) {
698 if (!find_in_page_controller_.get()) { 692 if (!find_in_page_controller_.get()) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 if (IsFindWindowFullyVisible() && 733 if (IsFindWindowFullyVisible() &&
740 ::IsWindow(find_wnd) && 734 ::IsWindow(find_wnd) &&
741 ::GetWindowRect(find_wnd, &window_rect)) { 735 ::GetWindowRect(find_wnd, &window_rect)) {
742 *x = window_rect.TopLeft().x; 736 *x = window_rect.TopLeft().x;
743 *y = window_rect.TopLeft().y; 737 *y = window_rect.TopLeft().y;
744 return true; 738 return true;
745 } 739 }
746 740
747 return false; 741 return false;
748 } 742 }
749
750 void WebContents::AlterTextSize(text_zoom::TextSize size) {
751 render_view_host()->AlterTextSize(size);
752 // TODO(creis): should this be propagated to other and future RVHs?
753 }
754
755 void WebContents::SetPageEncoding(const std::wstring& encoding_name) {
756 render_view_host()->SetPageEncoding(encoding_name);
757 // TODO(creis): should this be propagated to other and future RVHs?
758 }
759
760 void WebContents::CopyImageAt(int x, int y) {
761 render_view_host()->CopyImageAt(x, y);
762 }
763
764 void WebContents::InspectElementAt(int x, int y) {
765 render_view_host()->InspectElementAt(x, y);
766 }
767
768 void WebContents::ShowJavaScriptConsole() {
769 render_view_host()->ShowJavaScriptConsole();
770 }
771
772 void WebContents::AllowDomAutomationBindings() {
773 render_view_host()->AllowDomAutomationBindings();
774 // TODO(creis): should this be propagated to other and future RVHs?
775 }
776
777 void WebContents::OnJavaScriptMessageBoxClosed(IPC::Message* reply_msg, 743 void WebContents::OnJavaScriptMessageBoxClosed(IPC::Message* reply_msg,
778 bool success, 744 bool success,
779 const std::wstring& prompt) { 745 const std::wstring& prompt) {
780 last_javascript_message_dismissal_ = TimeTicks::Now(); 746 last_javascript_message_dismissal_ = TimeTicks::Now();
781 render_manager_.OnJavaScriptMessageBoxClosed(reply_msg, success, prompt); 747 render_manager_.OnJavaScriptMessageBoxClosed(reply_msg, success, prompt);
782 } 748 }
783 749
784 // Generic NotificationObserver callback. 750 // Generic NotificationObserver callback.
785 void WebContents::Observe(NotificationType type, 751 void WebContents::Observe(NotificationType type,
786 const NotificationSource& source, 752 const NotificationSource& source,
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 if (!notify_disconnection_) 808 if (!notify_disconnection_)
843 return; 809 return;
844 810
845 notify_disconnection_ = false; 811 notify_disconnection_ = false;
846 NotificationService::current()-> 812 NotificationService::current()->
847 Notify(NOTIFY_WEB_CONTENTS_DISCONNECTED, 813 Notify(NOTIFY_WEB_CONTENTS_DISCONNECTED,
848 Source<WebContents>(this), 814 Source<WebContents>(this),
849 NotificationService::NoDetails()); 815 NotificationService::NoDetails());
850 } 816 }
851 817
852 void WebContents::SetSuppressJavascriptMessageBoxes(
853 bool suppress_javascript_messages) {
854 suppress_javascript_messages_ = suppress_javascript_messages;
855 }
856
857 void WebContents::UpdateHistoryForNavigation(const GURL& display_url, 818 void WebContents::UpdateHistoryForNavigation(const GURL& display_url,
858 const ViewHostMsg_FrameNavigate_Params& params) { 819 const ViewHostMsg_FrameNavigate_Params& params) {
859 if (profile()->IsOffTheRecord()) 820 if (profile()->IsOffTheRecord())
860 return; 821 return;
861 822
862 // Add to history service. 823 // Add to history service.
863 HistoryService* hs = profile()->GetHistoryService(Profile::IMPLICIT_ACCESS); 824 HistoryService* hs = profile()->GetHistoryService(Profile::IMPLICIT_ACCESS);
864 if (hs) { 825 if (hs) {
865 if (PageTransition::IsMainFrame(params.transition) && 826 if (PageTransition::IsMainFrame(params.transition) &&
866 display_url != params.url) { 827 display_url != params.url) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 892
932 InfoBarView* WebContents::GetInfoBarView() { 893 InfoBarView* WebContents::GetInfoBarView() {
933 if (info_bar_view_.get() == NULL) { 894 if (info_bar_view_.get() == NULL) {
934 info_bar_view_.reset(new InfoBarView(this)); 895 info_bar_view_.reset(new InfoBarView(this));
935 // The WebContents owns the info-bar. 896 // The WebContents owns the info-bar.
936 info_bar_view_->SetParentOwned(false); 897 info_bar_view_->SetParentOwned(false);
937 } 898 }
938 return info_bar_view_.get(); 899 return info_bar_view_.get();
939 } 900 }
940 901
941 void WebContents::ExecuteJavascriptInWebFrame(
942 const std::wstring& frame_xpath, const std::wstring& jscript) {
943 render_view_host()->ExecuteJavascriptInWebFrame(frame_xpath, jscript);
944 }
945
946 void WebContents::AddMessageToConsole(
947 const std::wstring& frame_xpath, const std::wstring& msg,
948 ConsoleMessageLevel level) {
949 render_view_host()->AddMessageToConsole(frame_xpath, msg, level);
950 }
951
952 void WebContents::Undo() {
953 render_view_host()->Undo();
954 }
955
956 void WebContents::Redo() {
957 render_view_host()->Redo();
958 }
959
960 void WebContents::Replace(const std::wstring& text) {
961 render_view_host()->Replace(text);
962 }
963
964 void WebContents::AddToDictionary(const std::wstring& word) {
965 render_view_host()->AddToDictionary(word);
966 }
967
968 void WebContents::Delete() {
969 render_view_host()->Delete();
970 }
971
972 void WebContents::SelectAll() {
973 render_view_host()->SelectAll();
974 }
975
976 void WebContents::StartFileUpload(const std::wstring& file_path,
977 const std::wstring& form,
978 const std::wstring& file,
979 const std::wstring& submit,
980 const std::wstring& other_values) {
981 render_view_host()->UploadFile(file_path, form, file, submit, other_values);
982 }
983
984 void WebContents::SetWebApp(WebApp* web_app) { 902 void WebContents::SetWebApp(WebApp* web_app) {
985 if (web_app_.get()) { 903 if (web_app_.get()) {
986 web_app_->RemoveObserver(this); 904 web_app_->RemoveObserver(this);
987 web_app_->SetWebContents(NULL); 905 web_app_->SetWebContents(NULL);
988 } 906 }
989 907
990 web_app_ = web_app; 908 web_app_ = web_app;
991 if (web_app) { 909 if (web_app) {
992 web_app->AddObserver(this); 910 web_app->AddObserver(this);
993 web_app_->SetWebContents(this); 911 web_app_->SetWebContents(this);
(...skipping 21 matching lines...) Expand all
1015 } 933 }
1016 DCHECK(!pending_install_.icon.isNull()) << "Menu item should be disabled."; 934 DCHECK(!pending_install_.icon.isNull()) << "Menu item should be disabled.";
1017 if (pending_install_.title.empty()) 935 if (pending_install_.title.empty())
1018 pending_install_.title = UTF8ToWide(GetURL().spec()); 936 pending_install_.title = UTF8ToWide(GetURL().spec());
1019 937
1020 // Request the application info. When done OnDidGetApplicationInfo is invoked 938 // Request the application info. When done OnDidGetApplicationInfo is invoked
1021 // and we'll create the shortcut. 939 // and we'll create the shortcut.
1022 render_view_host()->GetApplicationInfo(pending_install_.page_id); 940 render_view_host()->GetApplicationInfo(pending_install_.page_id);
1023 } 941 }
1024 942
1025 void WebContents::FillForm(const FormData& form) {
1026 render_view_host()->FillForm(form);
1027 }
1028
1029 void WebContents::FillPasswordForm(
1030 const PasswordFormDomManager::FillData& form_data) {
1031 render_view_host()->FillPasswordForm(form_data);
1032 }
1033
1034 void WebContents::DragTargetDragEnter(const WebDropData& drop_data,
1035 const gfx::Point& client_pt, const gfx::Point& screen_pt) {
1036 render_view_host()->DragTargetDragEnter(drop_data, client_pt, screen_pt);
1037 }
1038
1039 void WebContents::DragTargetDragOver(
1040 const gfx::Point& client_pt, const gfx::Point& screen_pt) {
1041 render_view_host()->DragTargetDragOver(client_pt, screen_pt);
1042 }
1043
1044 void WebContents::DragTargetDragLeave() {
1045 render_view_host()->DragTargetDragLeave();
1046 }
1047
1048 void WebContents::DragTargetDrop(
1049 const gfx::Point& client_pt, const gfx::Point& screen_pt) {
1050 render_view_host()->DragTargetDrop(client_pt, screen_pt);
1051 }
1052
1053 PasswordManager* WebContents::GetPasswordManager() { 943 PasswordManager* WebContents::GetPasswordManager() {
1054 if (password_manager_.get() == NULL) 944 if (password_manager_.get() == NULL)
1055 password_manager_.reset(new PasswordManager(this)); 945 password_manager_.reset(new PasswordManager(this));
1056 return password_manager_.get(); 946 return password_manager_.get();
1057 } 947 }
1058 948
1059 PluginInstaller* WebContents::GetPluginInstaller() { 949 PluginInstaller* WebContents::GetPluginInstaller() {
1060 if (plugin_installer_.get() == NULL) 950 if (plugin_installer_.get() == NULL)
1061 plugin_installer_.reset(new PluginInstaller(this)); 951 plugin_installer_.reset(new PluginInstaller(this));
1062 return plugin_installer_.get(); 952 return plugin_installer_.get();
1063 } 953 }
1064 954
1065 bool WebContents::IsActiveEntry(int32 page_id) { 955 bool WebContents::IsActiveEntry(int32 page_id) {
1066 NavigationEntry* active_entry = controller()->GetActiveEntry(); 956 NavigationEntry* active_entry = controller()->GetActiveEntry();
1067 return (active_entry != NULL && 957 return (active_entry != NULL &&
1068 active_entry->site_instance() == GetSiteInstance() && 958 active_entry->site_instance() == GetSiteInstance() &&
1069 active_entry->page_id() == page_id); 959 active_entry->page_id() == page_id);
1070 } 960 }
1071 961
1072 /////////////////////////////////////////////////////////////////////////////// 962 ///////////////////////////////////////////////////////////////////////////////
1073 // RenderViewHostDelegate implementation: 963 // RenderViewHostDelegate implementation:
1074 964
1075 RenderViewHostDelegate::FindInPage* WebContents::GetFindInPageDelegate() { 965 RenderViewHostDelegate::FindInPage* WebContents::GetFindInPageDelegate() const {
1076 // The find in page controller implements this interface for us. Our return 966 // The find in page controller implements this interface for us. Our return
1077 // value can be NULL, so it's fine if the find in controller doesn't exist. 967 // value can be NULL, so it's fine if the find in controller doesn't exist.
1078 return find_in_page_controller_.get(); 968 return find_in_page_controller_.get();
1079 } 969 }
1080 970
971 RenderViewHostDelegate::Save* WebContents::GetSaveDelegate() const {
972 return save_package_.get(); // May be NULL, but we can return NULL.
973 }
974
1081 Profile* WebContents::GetProfile() const { 975 Profile* WebContents::GetProfile() const {
1082 return profile(); 976 return profile();
1083 } 977 }
1084 978
1085 void WebContents::CreateView(int route_id, HANDLE modal_dialog_event) { 979 void WebContents::CreateView(int route_id, HANDLE modal_dialog_event) {
1086 WebContents* new_view = new WebContents(profile(), 980 WebContents* new_view = new WebContents(profile(),
1087 GetSiteInstance(), 981 GetSiteInstance(),
1088 render_view_factory_, 982 render_view_factory_,
1089 route_id, 983 route_id,
1090 modal_dialog_event); 984 modal_dialog_event);
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after
1781 1675
1782 void WebContents::ProcessExternalHostMessage(const std::string& receiver, 1676 void WebContents::ProcessExternalHostMessage(const std::string& receiver,
1783 const std::string& message) { 1677 const std::string& message) {
1784 if (delegate()) 1678 if (delegate())
1785 delegate()->ForwardMessageToExternalHost(receiver, message); 1679 delegate()->ForwardMessageToExternalHost(receiver, message);
1786 } 1680 }
1787 1681
1788 void WebContents::GoToEntryAtOffset(int offset) { 1682 void WebContents::GoToEntryAtOffset(int offset) {
1789 if (!controller()) 1683 if (!controller())
1790 return; 1684 return;
1791
1792 controller()->GoToOffset(offset); 1685 controller()->GoToOffset(offset);
1793 } 1686 }
1794 1687
1795 void WebContents::GetHistoryListCount(int* back_list_count, 1688 void WebContents::GetHistoryListCount(int* back_list_count,
1796 int* forward_list_count) { 1689 int* forward_list_count) {
1797 *back_list_count = 0; 1690 *back_list_count = 0;
1798 *forward_list_count = 0; 1691 *forward_list_count = 0;
1799 1692
1800 if (controller()) { 1693 if (controller()) {
1801 int current_index = controller()->GetLastCommittedEntryIndex(); 1694 int current_index = controller()->GetLastCommittedEntryIndex();
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
2415 return l10n_util::GetString(IDS_LOAD_STATE_SENDING_REQUEST); 2308 return l10n_util::GetString(IDS_LOAD_STATE_SENDING_REQUEST);
2416 case net::LOAD_STATE_WAITING_FOR_RESPONSE: 2309 case net::LOAD_STATE_WAITING_FOR_RESPONSE:
2417 return l10n_util::GetStringF(IDS_LOAD_STATE_WAITING_FOR_RESPONSE, 2310 return l10n_util::GetStringF(IDS_LOAD_STATE_WAITING_FOR_RESPONSE,
2418 load_state_host_); 2311 load_state_host_);
2419 // Ignore net::LOAD_STATE_READING_RESPONSE and net::LOAD_STATE_IDLE 2312 // Ignore net::LOAD_STATE_READING_RESPONSE and net::LOAD_STATE_IDLE
2420 } 2313 }
2421 2314
2422 return std::wstring(); 2315 return std::wstring();
2423 } 2316 }
2424 2317
2425 // Called by PluginInstaller to start installation of missing plugin.
2426 void WebContents::InstallMissingPlugin() {
2427 render_view_host()->InstallMissingPlugin();
2428 }
2429
2430 void WebContents::GetAllSavableResourceLinksForCurrentPage(
2431 const GURL& page_url) {
2432 render_view_host()->GetAllSavableResourceLinksForCurrentPage(
2433 page_url);
2434 }
2435
2436 void WebContents::OnReceivedSavableResourceLinksForCurrentPage(
2437 const std::vector<GURL>& resources_list,
2438 const std::vector<GURL>& referrers_list,
2439 const std::vector<GURL>& frames_list) {
2440 SavePackage* save_package = get_save_package();
2441 if (save_package) {
2442 save_package->ProcessCurrentPageAllSavableResourceLinks(resources_list,
2443 referrers_list,
2444 frames_list);
2445 }
2446 }
2447
2448 void WebContents::GetSerializedHtmlDataForCurrentPageWithLocalLinks(
2449 const std::vector<std::wstring>& links,
2450 const std::vector<std::wstring>& local_paths,
2451 const std::wstring& local_directory_name) {
2452 render_view_host()->GetSerializedHtmlDataForCurrentPageWithLocalLinks(
2453 links, local_paths, local_directory_name);
2454 }
2455
2456
2457 void WebContents::OnReceivedSerializedHtmlData(const GURL& frame_url,
2458 const std::string& data,
2459 int32 status) {
2460 SavePackage* save_package = get_save_package();
2461 if (save_package)
2462 save_package->ProcessSerializedHtmlData(frame_url,
2463 data,
2464 status);
2465 }
2466
2467 bool WebContents::CanBlur() const { 2318 bool WebContents::CanBlur() const {
2468 return delegate() ? delegate()->CanBlur() : true; 2319 return delegate() ? delegate()->CanBlur() : true;
2469 } 2320 }
2470 2321
2471 void WebContents::RendererUnresponsive(RenderViewHost* rvh) { 2322 void WebContents::RendererUnresponsive(RenderViewHost* rvh) {
2472 if (render_view_host() && render_view_host()->IsRenderViewLive()) 2323 if (render_view_host() && render_view_host()->IsRenderViewLive())
2473 HungRendererWarning::ShowForWebContents(this); 2324 HungRendererWarning::ShowForWebContents(this);
2474 } 2325 }
2475 2326
2476 void WebContents::RendererResponsive(RenderViewHost* render_view_host) { 2327 void WebContents::RendererResponsive(RenderViewHost* render_view_host) {
(...skipping 15 matching lines...) Expand all
2492 } 2343 }
2493 2344
2494 BOOL WebContents::EnumPluginWindowsCallback(HWND window, LPARAM) { 2345 BOOL WebContents::EnumPluginWindowsCallback(HWND window, LPARAM) {
2495 if (WebPluginDelegateImpl::IsPluginDelegateWindow(window)) { 2346 if (WebPluginDelegateImpl::IsPluginDelegateWindow(window)) {
2496 ::ShowWindow(window, SW_HIDE); 2347 ::ShowWindow(window, SW_HIDE);
2497 SetParent(window, NULL); 2348 SetParent(window, NULL);
2498 } 2349 }
2499 2350
2500 return TRUE; 2351 return TRUE;
2501 } 2352 }
OLDNEW
« no previous file with comments | « chrome/browser/web_contents.h ('k') | chrome/browser/web_drop_target.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698