| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/browser/ui/test/test_confirm_bubble_model.h" | 5 #include "chrome/browser/ui/test/test_confirm_bubble_model.h" |
| 6 | 6 |
| 7 #include "base/strings/string16.h" | 7 #include "base/strings/string16.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "grit/theme_resources.h" | |
| 10 #include "ui/base/resource/resource_bundle.h" | |
| 11 | 9 |
| 12 TestConfirmBubbleModel::TestConfirmBubbleModel(bool* model_deleted, | 10 TestConfirmBubbleModel::TestConfirmBubbleModel(bool* model_deleted, |
| 13 bool* accept_clicked, | 11 bool* accept_clicked, |
| 14 bool* cancel_clicked, | 12 bool* cancel_clicked, |
| 15 bool* link_clicked) | 13 bool* link_clicked) |
| 16 : model_deleted_(model_deleted), | 14 : model_deleted_(model_deleted), |
| 17 accept_clicked_(accept_clicked), | 15 accept_clicked_(accept_clicked), |
| 18 cancel_clicked_(cancel_clicked), | 16 cancel_clicked_(cancel_clicked), |
| 19 link_clicked_(link_clicked) { | 17 link_clicked_(link_clicked) { |
| 20 } | 18 } |
| 21 | 19 |
| 22 TestConfirmBubbleModel::~TestConfirmBubbleModel() { | 20 TestConfirmBubbleModel::~TestConfirmBubbleModel() { |
| 23 if (model_deleted_) | 21 if (model_deleted_) |
| 24 *model_deleted_ = true; | 22 *model_deleted_ = true; |
| 25 } | 23 } |
| 26 | 24 |
| 27 base::string16 TestConfirmBubbleModel::GetTitle() const { | 25 base::string16 TestConfirmBubbleModel::GetTitle() const { |
| 28 return base::ASCIIToUTF16("Test"); | 26 return base::ASCIIToUTF16("Test"); |
| 29 } | 27 } |
| 30 | 28 |
| 31 base::string16 TestConfirmBubbleModel::GetMessageText() const { | 29 base::string16 TestConfirmBubbleModel::GetMessageText() const { |
| 32 return base::ASCIIToUTF16("Test Message"); | 30 return base::ASCIIToUTF16("Test Message"); |
| 33 } | 31 } |
| 34 | 32 |
| 35 gfx::Image* TestConfirmBubbleModel::GetIcon() const { | |
| 36 // Return an arbitrary non-empty image. | |
| 37 return &ui::ResourceBundle::GetSharedInstance().GetImageNamed( | |
| 38 IDR_PRODUCT_LOGO_16); | |
| 39 } | |
| 40 | |
| 41 int TestConfirmBubbleModel::GetButtons() const { | 33 int TestConfirmBubbleModel::GetButtons() const { |
| 42 return BUTTON_OK | BUTTON_CANCEL; | 34 return BUTTON_OK | BUTTON_CANCEL; |
| 43 } | 35 } |
| 44 | 36 |
| 45 base::string16 TestConfirmBubbleModel::GetButtonLabel( | 37 base::string16 TestConfirmBubbleModel::GetButtonLabel( |
| 46 BubbleButton button) const { | 38 BubbleButton button) const { |
| 47 return button == BUTTON_OK ? base::ASCIIToUTF16("OK") | 39 return button == BUTTON_OK ? base::ASCIIToUTF16("OK") |
| 48 : base::ASCIIToUTF16("Cancel"); | 40 : base::ASCIIToUTF16("Cancel"); |
| 49 } | 41 } |
| 50 | 42 |
| 51 void TestConfirmBubbleModel::Accept() { | 43 void TestConfirmBubbleModel::Accept() { |
| 52 if (accept_clicked_) | 44 if (accept_clicked_) |
| 53 *accept_clicked_ = true; | 45 *accept_clicked_ = true; |
| 54 } | 46 } |
| 55 | 47 |
| 56 void TestConfirmBubbleModel::Cancel() { | 48 void TestConfirmBubbleModel::Cancel() { |
| 57 if (cancel_clicked_) | 49 if (cancel_clicked_) |
| 58 *cancel_clicked_ = true; | 50 *cancel_clicked_ = true; |
| 59 } | 51 } |
| 60 | 52 |
| 61 base::string16 TestConfirmBubbleModel::GetLinkText() const { | 53 base::string16 TestConfirmBubbleModel::GetLinkText() const { |
| 62 return base::ASCIIToUTF16("Link"); | 54 return base::ASCIIToUTF16("Link"); |
| 63 } | 55 } |
| 64 | 56 |
| 65 void TestConfirmBubbleModel::LinkClicked() { | 57 void TestConfirmBubbleModel::LinkClicked() { |
| 66 if (link_clicked_) | 58 if (link_clicked_) |
| 67 *link_clicked_ = true; | 59 *link_clicked_ = true; |
| 68 } | 60 } |
| OLD | NEW |