send_tab_to_self_infobar_delegate.cc 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Copyright 2019 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "components/send_tab_to_self/send_tab_to_self_infobar_delegate.h"
  5. #include "base/memory/ptr_util.h"
  6. #include "base/strings/utf_string_conversions.h"
  7. #include "components/send_tab_to_self/send_tab_to_self_entry.h"
  8. #include "content/public/browser/web_contents.h"
  9. #include "url/gurl.h"
  10. namespace send_tab_to_self {
  11. // static
  12. std::unique_ptr<SendTabToSelfInfoBarDelegate>
  13. SendTabToSelfInfoBarDelegate::Create(content::WebContents* web_contents,
  14. const SendTabToSelfEntry* entry) {
  15. return base::WrapUnique(
  16. new SendTabToSelfInfoBarDelegate(web_contents, entry));
  17. }
  18. SendTabToSelfInfoBarDelegate::~SendTabToSelfInfoBarDelegate() {}
  19. std::u16string SendTabToSelfInfoBarDelegate::GetInfobarMessage() const {
  20. // TODO(crbug.com/944602): Define real string.
  21. NOTIMPLEMENTED();
  22. return u"Open";
  23. }
  24. void SendTabToSelfInfoBarDelegate::OpenTab() {
  25. content::OpenURLParams open_url_params(
  26. entry_->GetURL(), content::Referrer(),
  27. WindowOpenDisposition::NEW_FOREGROUND_TAB,
  28. ui::PageTransition::PAGE_TRANSITION_LINK,
  29. false /* is_renderer_initiated */);
  30. web_contents_->OpenURL(open_url_params);
  31. // TODO(crbug.com/944602): Update the model to reflect that an infobar is
  32. // shown.
  33. }
  34. void SendTabToSelfInfoBarDelegate::InfoBarDismissed() {
  35. NOTIMPLEMENTED();
  36. }
  37. infobars::InfoBarDelegate::InfoBarIdentifier
  38. SendTabToSelfInfoBarDelegate::GetIdentifier() const {
  39. return SEND_TAB_TO_SELF_INFOBAR_DELEGATE;
  40. }
  41. SendTabToSelfInfoBarDelegate::SendTabToSelfInfoBarDelegate(
  42. content::WebContents* web_contents,
  43. const SendTabToSelfEntry* entry) {
  44. web_contents_ = web_contents;
  45. entry_ = entry;
  46. }
  47. } // namespace send_tab_to_self