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/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 : profile_(profile) {} | 397 : profile_(profile) {} |
398 | 398 |
399 WebNavigationEventRouter::~WebNavigationEventRouter() {} | 399 WebNavigationEventRouter::~WebNavigationEventRouter() {} |
400 | 400 |
401 void WebNavigationEventRouter::Init() { | 401 void WebNavigationEventRouter::Init() { |
402 if (registrar_.IsEmpty()) { | 402 if (registrar_.IsEmpty()) { |
403 registrar_.Add(this, | 403 registrar_.Add(this, |
404 chrome::NOTIFICATION_RETARGETING, | 404 chrome::NOTIFICATION_RETARGETING, |
405 content::NotificationService::AllSources()); | 405 content::NotificationService::AllSources()); |
406 registrar_.Add(this, | 406 registrar_.Add(this, |
407 content::NOTIFICATION_TAB_ADDED, | 407 chrome::NOTIFICATION_TAB_ADDED, |
408 content::NotificationService::AllSources()); | 408 content::NotificationService::AllSources()); |
409 registrar_.Add(this, | 409 registrar_.Add(this, |
410 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 410 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
411 content::NotificationService::AllSources()); | 411 content::NotificationService::AllSources()); |
412 } | 412 } |
413 } | 413 } |
414 | 414 |
415 void WebNavigationEventRouter::Observe( | 415 void WebNavigationEventRouter::Observe( |
416 int type, | 416 int type, |
417 const content::NotificationSource& source, | 417 const content::NotificationSource& source, |
418 const content::NotificationDetails& details) { | 418 const content::NotificationDetails& details) { |
419 switch (type) { | 419 switch (type) { |
420 case chrome::NOTIFICATION_RETARGETING: { | 420 case chrome::NOTIFICATION_RETARGETING: { |
421 Profile* profile = content::Source<Profile>(source).ptr(); | 421 Profile* profile = content::Source<Profile>(source).ptr(); |
422 if (profile->GetOriginalProfile() == profile_) { | 422 if (profile->GetOriginalProfile() == profile_) { |
423 Retargeting( | 423 Retargeting( |
424 content::Details<const RetargetingDetails>(details).ptr()); | 424 content::Details<const RetargetingDetails>(details).ptr()); |
425 } | 425 } |
426 break; | 426 break; |
427 } | 427 } |
428 | 428 |
429 case content::NOTIFICATION_TAB_ADDED: | 429 case chrome::NOTIFICATION_TAB_ADDED: |
430 TabAdded(content::Details<WebContents>(details).ptr()); | 430 TabAdded(content::Details<WebContents>(details).ptr()); |
431 break; | 431 break; |
432 | 432 |
433 case content::NOTIFICATION_WEB_CONTENTS_DESTROYED: | 433 case content::NOTIFICATION_WEB_CONTENTS_DESTROYED: |
434 TabDestroyed(content::Source<WebContents>(source).ptr()); | 434 TabDestroyed(content::Source<WebContents>(source).ptr()); |
435 break; | 435 break; |
436 | 436 |
437 default: | 437 default: |
438 NOTREACHED(); | 438 NOTREACHED(); |
439 } | 439 } |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 frameDict->SetBoolean( | 801 frameDict->SetBoolean( |
802 keys::kErrorOccurredKey, | 802 keys::kErrorOccurredKey, |
803 navigation_state.GetErrorOccurredInFrame(*frame)); | 803 navigation_state.GetErrorOccurredInFrame(*frame)); |
804 resultList->Append(frameDict); | 804 resultList->Append(frameDict); |
805 } | 805 } |
806 result_.reset(resultList); | 806 result_.reset(resultList); |
807 return true; | 807 return true; |
808 } | 808 } |
809 | 809 |
810 } // namespace extensions | 810 } // namespace extensions |
OLD | NEW |