OLD | NEW |
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 // Implements the Chrome Extensions WebNavigation API. | 5 // Implements the Chrome Extensions WebNavigation API. |
6 | 6 |
7 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h" | 7 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h" |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 bool is_history_state_modification = | 312 bool is_history_state_modification = |
313 navigation_state_.GetNavigationCommitted(render_frame_host); | 313 navigation_state_.GetNavigationCommitted(render_frame_host); |
314 | 314 |
315 // Update the URL as it might have changed. | 315 // Update the URL as it might have changed. |
316 navigation_state_.UpdateFrame(render_frame_host, url); | 316 navigation_state_.UpdateFrame(render_frame_host, url); |
317 navigation_state_.SetNavigationCommitted(render_frame_host); | 317 navigation_state_.SetNavigationCommitted(render_frame_host); |
318 | 318 |
319 if (!navigation_state_.CanSendEvents(render_frame_host)) | 319 if (!navigation_state_.CanSendEvents(render_frame_host)) |
320 return; | 320 return; |
321 | 321 |
| 322 events::HistogramValue histogram_value = events::UNKNOWN; |
322 std::string event_name; | 323 std::string event_name; |
323 if (is_reference_fragment_navigation) { | 324 if (is_reference_fragment_navigation) { |
| 325 histogram_value = events::WEB_NAVIGATION_ON_REFERENCE_FRAGMENT_UPDATED; |
324 event_name = web_navigation::OnReferenceFragmentUpdated::kEventName; | 326 event_name = web_navigation::OnReferenceFragmentUpdated::kEventName; |
325 } else if (is_history_state_modification) { | 327 } else if (is_history_state_modification) { |
| 328 histogram_value = events::WEB_NAVIGATION_ON_HISTORY_STATE_UPDATED; |
326 event_name = web_navigation::OnHistoryStateUpdated::kEventName; | 329 event_name = web_navigation::OnHistoryStateUpdated::kEventName; |
327 } else { | 330 } else { |
328 if (navigation_state_.GetIsServerRedirected(render_frame_host)) { | 331 if (navigation_state_.GetIsServerRedirected(render_frame_host)) { |
329 transition_type = ui::PageTransitionFromInt( | 332 transition_type = ui::PageTransitionFromInt( |
330 transition_type | ui::PAGE_TRANSITION_SERVER_REDIRECT); | 333 transition_type | ui::PAGE_TRANSITION_SERVER_REDIRECT); |
331 } | 334 } |
| 335 histogram_value = events::WEB_NAVIGATION_ON_COMMITTED; |
332 event_name = web_navigation::OnCommitted::kEventName; | 336 event_name = web_navigation::OnCommitted::kEventName; |
333 } | 337 } |
334 helpers::DispatchOnCommitted(event_name, web_contents(), render_frame_host, | 338 helpers::DispatchOnCommitted( |
335 navigation_state_.GetUrl(render_frame_host), | 339 histogram_value, event_name, web_contents(), render_frame_host, |
336 transition_type); | 340 navigation_state_.GetUrl(render_frame_host), transition_type); |
337 } | 341 } |
338 | 342 |
339 void WebNavigationTabObserver::DidFailProvisionalLoad( | 343 void WebNavigationTabObserver::DidFailProvisionalLoad( |
340 content::RenderFrameHost* render_frame_host, | 344 content::RenderFrameHost* render_frame_host, |
341 const GURL& validated_url, | 345 const GURL& validated_url, |
342 int error_code, | 346 int error_code, |
343 const base::string16& error_description, | 347 const base::string16& error_description, |
344 bool was_ignored_by_handler) { | 348 bool was_ignored_by_handler) { |
345 DVLOG(2) << "DidFailProvisionalLoad(" | 349 DVLOG(2) << "DidFailProvisionalLoad(" |
346 << "render_frame_host=" << render_frame_host | 350 << "render_frame_host=" << render_frame_host |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 return g_factory.Pointer(); | 625 return g_factory.Pointer(); |
622 } | 626 } |
623 | 627 |
624 void WebNavigationAPI::OnListenerAdded(const EventListenerInfo& details) { | 628 void WebNavigationAPI::OnListenerAdded(const EventListenerInfo& details) { |
625 web_navigation_event_router_.reset(new WebNavigationEventRouter( | 629 web_navigation_event_router_.reset(new WebNavigationEventRouter( |
626 Profile::FromBrowserContext(browser_context_))); | 630 Profile::FromBrowserContext(browser_context_))); |
627 EventRouter::Get(browser_context_)->UnregisterObserver(this); | 631 EventRouter::Get(browser_context_)->UnregisterObserver(this); |
628 } | 632 } |
629 | 633 |
630 } // namespace extensions | 634 } // namespace extensions |
OLD | NEW |