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

Side by Side Diff: content/browser/browser_plugin/browser_plugin_guest.cc

Issue 11027065: Browser plugin: Implement titleChanged event. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix comment and Windows compile. Created 8 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/browser_plugin/browser_plugin_guest.h" 5 #include "content/browser/browser_plugin/browser_plugin_guest.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "content/browser/browser_plugin/browser_plugin_guest_helper.h" 10 #include "content/browser/browser_plugin/browser_plugin_guest_helper.h"
11 #include "content/browser/browser_plugin/browser_plugin_host_factory.h" 11 #include "content/browser/browser_plugin/browser_plugin_host_factory.h"
12 #include "content/browser/renderer_host/render_view_host_impl.h" 12 #include "content/browser/renderer_host/render_view_host_impl.h"
13 #include "content/browser/renderer_host/render_widget_host_impl.h" 13 #include "content/browser/renderer_host/render_widget_host_impl.h"
14 #include "content/browser/web_contents/web_contents_impl.h" 14 #include "content/browser/web_contents/web_contents_impl.h"
15 #include "content/common/browser_plugin_messages.h" 15 #include "content/common/browser_plugin_messages.h"
16 #include "content/common/view_messages.h" 16 #include "content/common/view_messages.h"
17 #include "content/public/browser/navigation_entry.h"
17 #include "content/public/browser/notification_service.h" 18 #include "content/public/browser/notification_service.h"
18 #include "content/public/browser/notification_types.h" 19 #include "content/public/browser/notification_types.h"
19 #include "content/public/browser/render_process_host.h" 20 #include "content/public/browser/render_process_host.h"
20 #include "content/public/browser/render_widget_host_view.h" 21 #include "content/public/browser/render_widget_host_view.h"
21 #include "content/public/browser/resource_request_details.h" 22 #include "content/public/browser/resource_request_details.h"
22 #include "content/public/browser/user_metrics.h" 23 #include "content/public/browser/user_metrics.h"
23 #include "content/public/common/result_codes.h" 24 #include "content/public/common/result_codes.h"
24 #include "content/browser/browser_plugin/browser_plugin_host_factory.h" 25 #include "content/browser/browser_plugin/browser_plugin_host_factory.h"
25 #include "net/base/net_errors.h" 26 #include "net/base/net_errors.h"
26 #include "ui/surface/transport_dib.h" 27 #include "ui/surface/transport_dib.h"
(...skipping 21 matching lines...) Expand all
48 pending_update_counter_(0), 49 pending_update_counter_(0),
49 guest_hang_timeout_( 50 guest_hang_timeout_(
50 base::TimeDelta::FromMilliseconds(kGuestHangTimeoutMs)) { 51 base::TimeDelta::FromMilliseconds(kGuestHangTimeoutMs)) {
51 DCHECK(web_contents); 52 DCHECK(web_contents);
52 // |render_view_host| manages the ownership of this BrowserPluginGuestHelper. 53 // |render_view_host| manages the ownership of this BrowserPluginGuestHelper.
53 new BrowserPluginGuestHelper(this, render_view_host); 54 new BrowserPluginGuestHelper(this, render_view_host);
54 55
55 notification_registrar_.Add( 56 notification_registrar_.Add(
56 this, content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT, 57 this, content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT,
57 content::Source<content::WebContents>(web_contents)); 58 content::Source<content::WebContents>(web_contents));
59 notification_registrar_.Add(
60 this, content::NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED,
61 content::Source<content::WebContents>(web_contents));
58 } 62 }
59 63
60 BrowserPluginGuest::~BrowserPluginGuest() { 64 BrowserPluginGuest::~BrowserPluginGuest() {
61 } 65 }
62 66
63 // static 67 // static
64 BrowserPluginGuest* BrowserPluginGuest::Create( 68 BrowserPluginGuest* BrowserPluginGuest::Create(
65 int instance_id, 69 int instance_id,
66 WebContentsImpl* web_contents, 70 WebContentsImpl* web_contents,
67 content::RenderViewHost* render_view_host) { 71 content::RenderViewHost* render_view_host) {
(...skipping 14 matching lines...) Expand all
82 DCHECK_EQ(Source<WebContents>(source).ptr(), web_contents()); 86 DCHECK_EQ(Source<WebContents>(source).ptr(), web_contents());
83 ResourceRedirectDetails* resource_redirect_details = 87 ResourceRedirectDetails* resource_redirect_details =
84 Details<ResourceRedirectDetails>(details).ptr(); 88 Details<ResourceRedirectDetails>(details).ptr();
85 bool is_top_level = 89 bool is_top_level =
86 resource_redirect_details->resource_type == ResourceType::MAIN_FRAME; 90 resource_redirect_details->resource_type == ResourceType::MAIN_FRAME;
87 LoadRedirect(resource_redirect_details->url, 91 LoadRedirect(resource_redirect_details->url,
88 resource_redirect_details->new_url, 92 resource_redirect_details->new_url,
89 is_top_level); 93 is_top_level);
90 break; 94 break;
91 } 95 }
96 case NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED: {
97 DCHECK_EQ(Source<WebContents>(source).ptr(), web_contents());
98 std::pair<NavigationEntry*, bool>* title =
99 Details<std::pair<NavigationEntry*, bool> >(details).ptr();
100 if (title->first) {
101 string16 title_text = title->first->GetTitle();
102 TitleChanged(title_text);
103 }
104 break;
105 }
92 default: 106 default:
93 NOTREACHED() << "Unexpected notification sent."; 107 NOTREACHED() << "Unexpected notification sent.";
94 break; 108 break;
95 } 109 }
96 } 110 }
97 111
98 bool BrowserPluginGuest::ViewTakeFocus(bool reverse) { 112 bool BrowserPluginGuest::ViewTakeFocus(bool reverse) {
99 SendMessageToEmbedder( 113 SendMessageToEmbedder(
100 new BrowserPluginMsg_AdvanceFocus(instance_id(), reverse)); 114 new BrowserPluginMsg_AdvanceFocus(instance_id(), reverse));
101 return true; 115 return true;
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 374
361 void BrowserPluginGuest::LoadRedirect( 375 void BrowserPluginGuest::LoadRedirect(
362 const GURL& old_url, 376 const GURL& old_url,
363 const GURL& new_url, 377 const GURL& new_url,
364 bool is_top_level) { 378 bool is_top_level) {
365 SendMessageToEmbedder( 379 SendMessageToEmbedder(
366 new BrowserPluginMsg_LoadRedirect( 380 new BrowserPluginMsg_LoadRedirect(
367 instance_id(), old_url, new_url, is_top_level)); 381 instance_id(), old_url, new_url, is_top_level));
368 } 382 }
369 383
384 void BrowserPluginGuest::TitleChanged(const string16& title) {
385 SendMessageToEmbedder(
386 new BrowserPluginMsg_TitleChanged(instance_id(), title));
387 }
388
370 void BrowserPluginGuest::DidCommitProvisionalLoadForFrame( 389 void BrowserPluginGuest::DidCommitProvisionalLoadForFrame(
371 int64 frame_id, 390 int64 frame_id,
372 bool is_main_frame, 391 bool is_main_frame,
373 const GURL& url, 392 const GURL& url,
374 PageTransition transition_type, 393 PageTransition transition_type,
375 RenderViewHost* render_view_host) { 394 RenderViewHost* render_view_host) {
376 // Inform its embedder of the updated URL. 395 // Inform its embedder of the updated URL.
377 if (is_main_frame) { 396 if (is_main_frame) {
378 SendMessageToEmbedder( 397 SendMessageToEmbedder(
379 new BrowserPluginMsg_DidNavigate( 398 new BrowserPluginMsg_DidNavigate(
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 break; 432 break;
414 } 433 }
415 } 434 }
416 435
417 void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) { 436 void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) {
418 DCHECK(embedder_render_process_host()); 437 DCHECK(embedder_render_process_host());
419 embedder_render_process_host()->Send(msg); 438 embedder_render_process_host()->Send(msg);
420 } 439 }
421 440
422 } // namespace content 441 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698