Commit 43cc782f authored by avi's avatar avi Committed by Commit bot

Remove NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED.

BUG=170921
TEST=everything still works

Review URL: https://codereview.chromium.org/1242953004

Cr-Commit-Position: refs/heads/master@{#339739}
parent da5e1028
...@@ -60,7 +60,7 @@ WebAuthFlow::~WebAuthFlow() { ...@@ -60,7 +60,7 @@ WebAuthFlow::~WebAuthFlow() {
// Stop listening to notifications first since some of the code // Stop listening to notifications first since some of the code
// below may generate notifications. // below may generate notifications.
registrar_.RemoveAll(); registrar_.RemoveAll();
WebContentsObserver::Observe(NULL); WebContentsObserver::Observe(nullptr);
if (!app_window_key_.empty()) { if (!app_window_key_.empty()) {
AppWindowRegistry::Get(profile_)->RemoveObserver(this); AppWindowRegistry::Get(profile_)->RemoveObserver(this);
...@@ -73,7 +73,7 @@ WebAuthFlow::~WebAuthFlow() { ...@@ -73,7 +73,7 @@ WebAuthFlow::~WebAuthFlow() {
void WebAuthFlow::Start() { void WebAuthFlow::Start() {
AppWindowRegistry::Get(profile_)->AddObserver(this); AppWindowRegistry::Get(profile_)->AddObserver(this);
// Attach a random ID string to the window so we can recoginize it // Attach a random ID string to the window so we can recognize it
// in OnAppWindowAdded. // in OnAppWindowAdded.
std::string random_bytes; std::string random_bytes;
crypto::RandBytes(base::WriteInto(&random_bytes, 33), 32); crypto::RandBytes(base::WriteInto(&random_bytes, 33), 32);
...@@ -129,6 +129,7 @@ void WebAuthFlow::OnAppWindowRemoved(AppWindow* app_window) { ...@@ -129,6 +129,7 @@ void WebAuthFlow::OnAppWindowRemoved(AppWindow* app_window) {
app_window->extension_id() == extension_misc::kIdentityApiUiAppId) { app_window->extension_id() == extension_misc::kIdentityApiUiAppId) {
app_window_ = NULL; app_window_ = NULL;
registrar_.RemoveAll(); registrar_.RemoveAll();
WebContentsObserver::Observe(nullptr);
if (delegate_) if (delegate_)
delegate_->OnAuthFlowFailure(WebAuthFlow::WINDOW_CLOSED); delegate_->OnAuthFlowFailure(WebAuthFlow::WINDOW_CLOSED);
...@@ -168,39 +169,9 @@ void WebAuthFlow::Observe(int type, ...@@ -168,39 +169,9 @@ void WebAuthFlow::Observe(int type,
WebContentsObserver::Observe(web_contents); WebContentsObserver::Observe(web_contents);
registrar_.RemoveAll(); registrar_.RemoveAll();
registrar_.Add(this,
content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT,
content::Source<WebContents>(web_contents));
registrar_.Add(this,
content::NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED,
content::Source<WebContents>(web_contents));
}
} else {
// embedded_window_created_
switch (type) {
case content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT: {
ResourceRedirectDetails* redirect_details =
content::Details<ResourceRedirectDetails>(details).ptr();
if (redirect_details != NULL)
BeforeUrlLoaded(redirect_details->new_url);
break;
}
case content::NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED: {
std::pair<content::NavigationEntry*, bool>* title =
content::Details<std::pair<content::NavigationEntry*, bool> >(
details).ptr();
if (title->first) {
delegate_->OnAuthFlowTitleChange(
base::UTF16ToUTF8(title->first->GetTitle()));
}
break;
}
default:
NOTREACHED()
<< "Got a notification that we did not register for: " << type;
break;
} }
} else { // embedded_window_created_
NOTREACHED() << "Got a notification that we did not register for: " << type;
} }
} }
...@@ -234,6 +205,17 @@ void WebAuthFlow::DidFailProvisionalLoad( ...@@ -234,6 +205,17 @@ void WebAuthFlow::DidFailProvisionalLoad(
delegate_->OnAuthFlowFailure(LOAD_FAILED); delegate_->OnAuthFlowFailure(LOAD_FAILED);
} }
void WebAuthFlow::DidGetRedirectForResourceRequest(
content::RenderFrameHost* render_frame_host,
const content::ResourceRedirectDetails& details) {
BeforeUrlLoaded(details.new_url);
}
void WebAuthFlow::TitleWasSet(content::NavigationEntry* entry,
bool explicit_set) {
delegate_->OnAuthFlowTitleChange(base::UTF16ToUTF8(entry->GetTitle()));
}
void WebAuthFlow::DidStopLoading() { void WebAuthFlow::DidStopLoading() {
AfterUrlLoaded(); AfterUrlLoaded();
} }
......
...@@ -116,6 +116,10 @@ class WebAuthFlow : public content::NotificationObserver, ...@@ -116,6 +116,10 @@ class WebAuthFlow : public content::NotificationObserver,
int error_code, int error_code,
const base::string16& error_description, const base::string16& error_description,
bool was_ignored_by_handler) override; bool was_ignored_by_handler) override;
void DidGetRedirectForResourceRequest(
content::RenderFrameHost* render_frame_host,
const content::ResourceRedirectDetails& details) override;
void TitleWasSet(content::NavigationEntry* entry, bool explicit_set) override;
void BeforeUrlLoaded(const GURL& url); void BeforeUrlLoaded(const GURL& url);
void AfterUrlLoaded(); void AfterUrlLoaded();
......
...@@ -3477,14 +3477,6 @@ bool WebContentsImpl::UpdateTitleForEntry(NavigationEntryImpl* entry, ...@@ -3477,14 +3477,6 @@ bool WebContentsImpl::UpdateTitleForEntry(NavigationEntryImpl* entry,
FOR_EACH_OBSERVER(WebContentsObserver, observers_, FOR_EACH_OBSERVER(WebContentsObserver, observers_,
TitleWasSet(entry, explicit_set)); TitleWasSet(entry, explicit_set));
// TODO(avi): Remove. http://crbug.com/170921
std::pair<NavigationEntry*, bool> details =
std::make_pair(entry, explicit_set);
NotificationService::current()->Notify(
NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED,
Source<WebContents>(this),
Details<std::pair<NavigationEntry*, bool> >(&details));
return true; return true;
} }
......
...@@ -121,12 +121,6 @@ enum NotificationType { ...@@ -121,12 +121,6 @@ enum NotificationType {
// WebContentsObserver::WebContentsDestroyed() // WebContentsObserver::WebContentsDestroyed()
NOTIFICATION_WEB_CONTENTS_DISCONNECTED, NOTIFICATION_WEB_CONTENTS_DISCONNECTED,
// This notification is sent after WebContents' title is updated. The source
// is a Source<WebContents> with a pointer to the WebContents. The details
// is a std::pair<NavigationEntry*, bool> that contains more information.
// DEPRECATED: Use WebContentsObserver::TitleWasSet()
NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED,
// This notification is sent when a WebContents is being destroyed. Any // This notification is sent when a WebContents is being destroyed. Any
// object holding a reference to a WebContents can listen to that // object holding a reference to a WebContents can listen to that
// notification to properly reset the reference. The source is a // notification to properly reset the reference. The source is a
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment