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

Side by Side Diff: chrome/renderer/render_view.cc

Issue 255042: Reverting 27711. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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/renderer/print_web_view_helper.cc ('k') | chrome/renderer/webplugin_delegate_proxy.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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/renderer/render_view.h" 5 #include "chrome/renderer/render_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 decrement_shared_popup_at_destruction_ = true; 307 decrement_shared_popup_at_destruction_ = true;
308 } else { 308 } else {
309 shared_popup_counter_ = new SharedRenderViewCounter(0); 309 shared_popup_counter_ = new SharedRenderViewCounter(0);
310 decrement_shared_popup_at_destruction_ = false; 310 decrement_shared_popup_at_destruction_ = false;
311 } 311 }
312 312
313 devtools_agent_.reset(new DevToolsAgent(routing_id, this)); 313 devtools_agent_.reset(new DevToolsAgent(routing_id, this));
314 314
315 webwidget_ = WebView::Create(this); 315 webwidget_ = WebView::Create(this);
316 webkit_preferences_.Apply(webview()); 316 webkit_preferences_.Apply(webview());
317 webview()->InitializeMainFrame(this); 317 webview()->initializeMainFrame(this);
318 318
319 OnSetRendererPrefs(renderer_prefs); 319 OnSetRendererPrefs(renderer_prefs);
320 320
321 // Don't let WebCore keep a B/F list - we have our own.
322 // We let it keep 1 entry because FrameLoader::goToItem expects an item in the
323 // backForwardList, which is used only in ASSERTs.
324 webview()->SetBackForwardListSize(1);
325
326 routing_id_ = routing_id; 321 routing_id_ = routing_id;
327 render_thread_->AddRoute(routing_id_, this); 322 render_thread_->AddRoute(routing_id_, this);
328 // Take a reference on behalf of the RenderThread. This will be balanced 323 // Take a reference on behalf of the RenderThread. This will be balanced
329 // when we receive ViewMsg_Close. 324 // when we receive ViewMsg_Close.
330 AddRef(); 325 AddRef();
331 326
332 // If this is a popup, we must wait for the CreatingNew_ACK message before 327 // If this is a popup, we must wait for the CreatingNew_ACK message before
333 // completing initialization. Otherwise, we can finish it now. 328 // completing initialization. Otherwise, we can finish it now.
334 if (opener_id == MSG_ROUTING_NONE) { 329 if (opener_id == MSG_ROUTING_NONE) {
335 did_show_ = true; 330 did_show_ = true;
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 main_frame->loadRequest(request); 731 main_frame->loadRequest(request);
737 } 732 }
738 733
739 // In case LoadRequest failed before DidCreateDataSource was called. 734 // In case LoadRequest failed before DidCreateDataSource was called.
740 pending_navigation_state_.reset(); 735 pending_navigation_state_.reset();
741 } 736 }
742 737
743 // Stop loading the current page 738 // Stop loading the current page
744 void RenderView::OnStop() { 739 void RenderView::OnStop() {
745 if (webview()) 740 if (webview())
746 webview()->StopLoading(); 741 webview()->mainFrame()->stopLoading();
747 } 742 }
748 743
749 void RenderView::OnLoadAlternateHTMLText(const std::string& html, 744 void RenderView::OnLoadAlternateHTMLText(const std::string& html,
750 bool new_navigation, 745 bool new_navigation,
751 const GURL& display_url, 746 const GURL& display_url,
752 const std::string& security_info) { 747 const std::string& security_info) {
753 if (!webview()) 748 if (!webview())
754 return; 749 return;
755 750
756 pending_navigation_state_.reset(NavigationState::CreateBrowserInitiated( 751 pending_navigation_state_.reset(NavigationState::CreateBrowserInitiated(
(...skipping 28 matching lines...) Expand all
785 WebView* view = webview(); 780 WebView* view = webview();
786 if (!view) 781 if (!view)
787 return; 782 return;
788 783
789 if (clear_selection) 784 if (clear_selection)
790 view->focusedFrame()->executeCommand(WebString::fromUTF8("Unselect")); 785 view->focusedFrame()->executeCommand(WebString::fromUTF8("Unselect"));
791 786
792 WebFrame* frame = view->mainFrame(); 787 WebFrame* frame = view->mainFrame();
793 while (frame) { 788 while (frame) {
794 frame->stopFinding(clear_selection); 789 frame->stopFinding(clear_selection);
795 frame = view->GetNextFrameAfter(frame, false); 790 frame = frame->traverseNext(false);
796 } 791 }
797 } 792 }
798 793
799 void RenderView::OnFindReplyAck() { 794 void RenderView::OnFindReplyAck() {
800 // Check if there is any queued up request waiting to be sent. 795 // Check if there is any queued up request waiting to be sent.
801 if (queued_find_reply_message_.get()) { 796 if (queued_find_reply_message_.get()) {
802 // Send the search result over to the browser process. 797 // Send the search result over to the browser process.
803 Send(queued_find_reply_message_.get()); 798 Send(queued_find_reply_message_.get());
804 queued_find_reply_message_.release(); 799 queued_find_reply_message_.release();
805 } 800 }
(...skipping 1774 matching lines...) Expand 10 before | Expand all | Expand 10 after
2580 GURL::Replacements link_doctor_params; 2575 GURL::Replacements link_doctor_params;
2581 link_doctor_params.SetQueryStr(params); 2576 link_doctor_params.SetQueryStr(params);
2582 GURL url = alternate_error_page_url_.ReplaceComponents(link_doctor_params); 2577 GURL url = alternate_error_page_url_.ReplaceComponents(link_doctor_params);
2583 return url; 2578 return url;
2584 } 2579 }
2585 2580
2586 void RenderView::OnFind(int request_id, 2581 void RenderView::OnFind(int request_id,
2587 const string16& search_text, 2582 const string16& search_text,
2588 const WebKit::WebFindOptions& options) { 2583 const WebKit::WebFindOptions& options) {
2589 WebFrame* main_frame = webview()->mainFrame(); 2584 WebFrame* main_frame = webview()->mainFrame();
2590 WebFrame* frame_after_main = webview()->GetNextFrameAfter(main_frame, true); 2585 WebFrame* frame_after_main = main_frame->traverseNext(true);
2591 WebFrame* focused_frame = webview()->focusedFrame(); 2586 WebFrame* focused_frame = webview()->focusedFrame();
2592 WebFrame* search_frame = focused_frame; // start searching focused frame. 2587 WebFrame* search_frame = focused_frame; // start searching focused frame.
2593 2588
2594 bool multi_frame = (frame_after_main != main_frame); 2589 bool multi_frame = (frame_after_main != main_frame);
2595 2590
2596 // If we have multiple frames, we don't want to wrap the search within the 2591 // If we have multiple frames, we don't want to wrap the search within the
2597 // frame, so we check here if we only have main_frame in the chain. 2592 // frame, so we check here if we only have main_frame in the chain.
2598 bool wrap_within_frame = !multi_frame; 2593 bool wrap_within_frame = !multi_frame;
2599 2594
2600 WebRect selection_rect; 2595 WebRect selection_rect;
2601 bool result = false; 2596 bool result = false;
2602 2597
2603 do { 2598 do {
2604 result = search_frame->find( 2599 result = search_frame->find(
2605 request_id, search_text, options, wrap_within_frame, &selection_rect); 2600 request_id, search_text, options, wrap_within_frame, &selection_rect);
2606 2601
2607 if (!result) { 2602 if (!result) {
2608 // don't leave text selected as you move to the next frame. 2603 // don't leave text selected as you move to the next frame.
2609 search_frame->executeCommand(WebString::fromUTF8("Unselect")); 2604 search_frame->executeCommand(WebString::fromUTF8("Unselect"));
2610 2605
2611 // Find the next frame, but skip the invisible ones. 2606 // Find the next frame, but skip the invisible ones.
2612 do { 2607 do {
2613 // What is the next frame to search? (we might be going backwards). Note 2608 // What is the next frame to search? (we might be going backwards). Note
2614 // that we specify wrap=true so that search_frame never becomes NULL. 2609 // that we specify wrap=true so that search_frame never becomes NULL.
2615 search_frame = options.forward ? 2610 search_frame = options.forward ?
2616 webview()->GetNextFrameAfter(search_frame, true) : 2611 search_frame->traverseNext(true) :
2617 webview()->GetPreviousFrameBefore(search_frame, true); 2612 search_frame->traversePrevious(true);
2618 } while (!search_frame->hasVisibleContent() && 2613 } while (!search_frame->hasVisibleContent() &&
2619 search_frame != focused_frame); 2614 search_frame != focused_frame);
2620 2615
2621 // Make sure selection doesn't affect the search operation in new frame. 2616 // Make sure selection doesn't affect the search operation in new frame.
2622 search_frame->executeCommand(WebString::fromUTF8("Unselect")); 2617 search_frame->executeCommand(WebString::fromUTF8("Unselect"));
2623 2618
2624 // If we have multiple frames and we have wrapped back around to the 2619 // If we have multiple frames and we have wrapped back around to the
2625 // focused frame, we need to search it once more allowing wrap within 2620 // focused frame, we need to search it once more allowing wrap within
2626 // the frame, otherwise it will report 'no match' if the focused frame has 2621 // the frame, otherwise it will report 'no match' if the focused frame has
2627 // reported matches, but no frames after the focused_frame contain a 2622 // reported matches, but no frames after the focused_frame contain a
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2673 // Start new scoping request. If the scoping function determines that it 2668 // Start new scoping request. If the scoping function determines that it
2674 // needs to scope, it will defer until later. 2669 // needs to scope, it will defer until later.
2675 search_frame->scopeStringMatches(request_id, 2670 search_frame->scopeStringMatches(request_id,
2676 search_text, 2671 search_text,
2677 options, 2672 options,
2678 true); // reset the tickmarks 2673 true); // reset the tickmarks
2679 } 2674 }
2680 2675
2681 // Iterate to the next frame. The frame will not necessarily scope, for 2676 // Iterate to the next frame. The frame will not necessarily scope, for
2682 // example if it is not visible. 2677 // example if it is not visible.
2683 search_frame = webview()->GetNextFrameAfter(search_frame, true); 2678 search_frame = search_frame->traverseNext(true);
2684 } while (search_frame != main_frame); 2679 } while (search_frame != main_frame);
2685 } 2680 }
2686 } 2681 }
2687 2682
2688 void RenderView::OnDeterminePageText() { 2683 void RenderView::OnDeterminePageText() {
2689 if (!is_loading_) { 2684 if (!is_loading_) {
2690 if (!webview()) 2685 if (!webview())
2691 return; 2686 return;
2692 WebFrame* main_frame = webview()->mainFrame(); 2687 WebFrame* main_frame = webview()->mainFrame();
2693 std::wstring contents; 2688 std::wstring contents;
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
3270 RenderWidget::OnResize(new_size, resizer_rect); 3265 RenderWidget::OnResize(new_size, resizer_rect);
3271 } 3266 }
3272 3267
3273 void RenderView::OnClearFocusedNode() { 3268 void RenderView::OnClearFocusedNode() {
3274 if (webview()) 3269 if (webview())
3275 webview()->clearFocusedNode(); 3270 webview()->clearFocusedNode();
3276 } 3271 }
3277 3272
3278 void RenderView::OnSetBackground(const SkBitmap& background) { 3273 void RenderView::OnSetBackground(const SkBitmap& background) {
3279 if (webview()) 3274 if (webview())
3280 webview()->SetIsTransparent(!background.empty()); 3275 webview()->setIsTransparent(!background.empty());
3281 3276
3282 SetBackground(background); 3277 SetBackground(background);
3283 } 3278 }
3284 3279
3285 void RenderView::OnSetActive(bool active) { 3280 void RenderView::OnSetActive(bool active) {
3286 if (webview()) 3281 if (webview())
3287 webview()->SetActive(active); 3282 webview()->setIsActive(active);
3288 } 3283 }
3289 3284
3290 void RenderView::SendExtensionRequest(const std::string& name, 3285 void RenderView::SendExtensionRequest(const std::string& name,
3291 const std::string& args, 3286 const std::string& args,
3292 int request_id, 3287 int request_id,
3293 bool has_callback) { 3288 bool has_callback) {
3294 Send(new ViewHostMsg_ExtensionRequest(routing_id_, name, args, request_id, 3289 Send(new ViewHostMsg_ExtensionRequest(routing_id_, name, args, request_id,
3295 has_callback)); 3290 has_callback));
3296 } 3291 }
3297 3292
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
3615 new PluginMsg_SignalModalDialogEvent(host_window_)); 3610 new PluginMsg_SignalModalDialogEvent(host_window_));
3616 3611
3617 message->EnableMessagePumping(); // Runs a nested message loop. 3612 message->EnableMessagePumping(); // Runs a nested message loop.
3618 bool rv = Send(message); 3613 bool rv = Send(message);
3619 3614
3620 PluginChannelHost::Broadcast( 3615 PluginChannelHost::Broadcast(
3621 new PluginMsg_ResetModalDialogEvent(host_window_)); 3616 new PluginMsg_ResetModalDialogEvent(host_window_));
3622 3617
3623 return rv; 3618 return rv;
3624 } 3619 }
OLDNEW
« no previous file with comments | « chrome/renderer/print_web_view_helper.cc ('k') | chrome/renderer/webplugin_delegate_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698