| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extensions/extension_page_actions_module.h" | 5 #include "chrome/browser/extensions/extension_page_actions_module.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "chrome/browser/extensions/extension_page_actions_module_constants.h" | 10 #include "chrome/browser/extensions/extension_page_actions_module_constants.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 TabContentsWrapper* contents = NULL; | 73 TabContentsWrapper* contents = NULL; |
| 74 bool result = ExtensionTabUtil::GetTabById( | 74 bool result = ExtensionTabUtil::GetTabById( |
| 75 tab_id, profile(), include_incognito(), NULL, NULL, &contents, NULL); | 75 tab_id, profile(), include_incognito(), NULL, NULL, &contents, NULL); |
| 76 if (!result || !contents) { | 76 if (!result || !contents) { |
| 77 error_ = ExtensionErrorUtils::FormatErrorMessage( | 77 error_ = ExtensionErrorUtils::FormatErrorMessage( |
| 78 kNoTabError, base::IntToString(tab_id)); | 78 kNoTabError, base::IntToString(tab_id)); |
| 79 return false; | 79 return false; |
| 80 } | 80 } |
| 81 | 81 |
| 82 // Make sure the URL hasn't changed. | 82 // Make sure the URL hasn't changed. |
| 83 NavigationEntry* entry = contents->controller().GetActiveEntry(); | 83 NavigationEntry* entry = |
| 84 contents->tab_contents()->controller().GetActiveEntry(); |
| 84 if (!entry || url != entry->url().spec()) { | 85 if (!entry || url != entry->url().spec()) { |
| 85 error_ = ExtensionErrorUtils::FormatErrorMessage(kUrlNotActiveError, url); | 86 error_ = ExtensionErrorUtils::FormatErrorMessage(kUrlNotActiveError, url); |
| 86 return false; | 87 return false; |
| 87 } | 88 } |
| 88 | 89 |
| 89 // Set visibility and broadcast notifications that the UI should be updated. | 90 // Set visibility and broadcast notifications that the UI should be updated. |
| 90 page_action->SetIsVisible(tab_id, enable); | 91 page_action->SetIsVisible(tab_id, enable); |
| 91 page_action->SetTitle(tab_id, title); | 92 page_action->SetTitle(tab_id, title); |
| 92 page_action->SetIconIndex(tab_id, icon_id); | 93 page_action->SetIconIndex(tab_id, icon_id); |
| 93 contents->extension_tab_helper()->PageActionStateChanged(); | 94 contents->extension_tab_helper()->PageActionStateChanged(); |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 if (!InitCommon(tab_id)) | 284 if (!InitCommon(tab_id)) |
| 284 return false; | 285 return false; |
| 285 | 286 |
| 286 std::string text; | 287 std::string text; |
| 287 EXTENSION_FUNCTION_VALIDATE(args->GetString("text", &text)); | 288 EXTENSION_FUNCTION_VALIDATE(args->GetString("text", &text)); |
| 288 | 289 |
| 289 page_action_->SetBadgeText(tab_id, text); | 290 page_action_->SetBadgeText(tab_id, text); |
| 290 contents_->extension_tab_helper()->PageActionStateChanged(); | 291 contents_->extension_tab_helper()->PageActionStateChanged(); |
| 291 return true; | 292 return true; |
| 292 } | 293 } |
| OLD | NEW |