Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(192)

Side by Side Diff: chrome/browser/extensions/extension_tabs_module.cc

Issue 273048: Allow extensions to pin tabs:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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_tabs_module.h" 5 #include "chrome/browser/extensions/extension_tabs_module.h"
6 6
7 #include "app/gfx/codec/jpeg_codec.h" 7 #include "app/gfx/codec/jpeg_codec.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "chrome/browser/browser.h" 9 #include "chrome/browser/browser.h"
10 #include "chrome/browser/browser_list.h" 10 #include "chrome/browser/browser_list.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 108
109 DictionaryValue* result = new DictionaryValue(); 109 DictionaryValue* result = new DictionaryValue();
110 result->SetInteger(keys::kIdKey, ExtensionTabUtil::GetTabId(contents)); 110 result->SetInteger(keys::kIdKey, ExtensionTabUtil::GetTabId(contents));
111 result->SetInteger(keys::kIndexKey, tab_index); 111 result->SetInteger(keys::kIndexKey, tab_index);
112 result->SetInteger(keys::kWindowIdKey, 112 result->SetInteger(keys::kWindowIdKey,
113 ExtensionTabUtil::GetWindowIdOfTab(contents)); 113 ExtensionTabUtil::GetWindowIdOfTab(contents));
114 result->SetString(keys::kUrlKey, contents->GetURL().spec()); 114 result->SetString(keys::kUrlKey, contents->GetURL().spec());
115 result->SetString(keys::kStatusKey, GetTabStatusText(status)); 115 result->SetString(keys::kStatusKey, GetTabStatusText(status));
116 result->SetBoolean(keys::kSelectedKey, 116 result->SetBoolean(keys::kSelectedKey,
117 tab_strip && tab_index == tab_strip->selected_index()); 117 tab_strip && tab_index == tab_strip->selected_index());
118 result->SetBoolean(keys::kPinnedKey,
119 tab_strip && tab_strip->IsTabPinned(tab_index));
118 120
119 if (status != TAB_LOADING) { 121 if (status != TAB_LOADING) {
120 result->SetString(keys::kTitleKey, UTF16ToWide(contents->GetTitle())); 122 result->SetString(keys::kTitleKey, UTF16ToWide(contents->GetTitle()));
121 123
122 NavigationEntry* entry = contents->controller().GetActiveEntry(); 124 NavigationEntry* entry = contents->controller().GetActiveEntry();
123 if (entry) { 125 if (entry) {
124 if (entry->favicon().is_valid()) 126 if (entry->favicon().is_valid())
125 result->SetString(keys::kFavIconUrlKey, entry->favicon().url().spec()); 127 result->SetString(keys::kFavIconUrlKey, entry->favicon().url().spec());
126 } 128 }
127 } 129 }
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 index = -1; 517 index = -1;
516 } 518 }
517 if (index > tab_strip->count()) { 519 if (index > tab_strip->count()) {
518 index = tab_strip->count(); 520 index = tab_strip->count();
519 } 521 }
520 522
521 TabContents* contents = browser->AddTabWithURL(*(url.get()), GURL(), 523 TabContents* contents = browser->AddTabWithURL(*(url.get()), GURL(),
522 PageTransition::LINK, selected, index, true, NULL); 524 PageTransition::LINK, selected, index, true, NULL);
523 index = tab_strip->GetIndexOfTabContents(contents); 525 index = tab_strip->GetIndexOfTabContents(contents);
524 526
527 if (args->HasKey(keys::kPinnedKey)) {
528 bool pinned = false;
529 EXTENSION_FUNCTION_VALIDATE(args->GetBoolean(keys::kPinnedKey,
530 &pinned));
531 tab_strip->SetTabPinned(index, pinned);
Aaron Boodman 2010/10/14 18:04:17 This part of the code has changed since you wrote
532 }
533
525 // Return data about the newly created tab. 534 // Return data about the newly created tab.
526 if (has_callback()) 535 if (has_callback())
527 result_.reset(ExtensionTabUtil::CreateTabValue(contents, tab_strip, index)); 536 result_.reset(ExtensionTabUtil::CreateTabValue(contents, tab_strip, index));
528 537
529 return true; 538 return true;
530 } 539 }
531 540
532 bool GetTabFunction::RunImpl() { 541 bool GetTabFunction::RunImpl() {
533 int tab_id; 542 int tab_id;
534 EXTENSION_FUNCTION_VALIDATE(args_->GetAsInteger(&tab_id)); 543 EXTENSION_FUNCTION_VALIDATE(args_->GetAsInteger(&tab_id));
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 if (update_props->HasKey(keys::kSelectedKey)) { 620 if (update_props->HasKey(keys::kSelectedKey)) {
612 EXTENSION_FUNCTION_VALIDATE(update_props->GetBoolean( 621 EXTENSION_FUNCTION_VALIDATE(update_props->GetBoolean(
613 keys::kSelectedKey, 622 keys::kSelectedKey,
614 &selected)); 623 &selected));
615 if (selected && tab_strip->selected_index() != tab_index) { 624 if (selected && tab_strip->selected_index() != tab_index) {
616 tab_strip->SelectTabContentsAt(tab_index, false); 625 tab_strip->SelectTabContentsAt(tab_index, false);
617 DCHECK_EQ(contents, tab_strip->GetSelectedTabContents()); 626 DCHECK_EQ(contents, tab_strip->GetSelectedTabContents());
618 } 627 }
619 } 628 }
620 629
630 if (update_props->HasKey(keys::kPinnedKey)) {
631 bool pinned = false;
632 EXTENSION_FUNCTION_VALIDATE(update_props->GetBoolean(
633 keys::kPinnedKey,
634 &pinned));
635 tab_strip->SetTabPinned(tab_index, pinned);
Aaron Boodman 2010/10/14 18:04:17 Same here.
636 }
637
621 if (has_callback()) 638 if (has_callback())
622 result_.reset(ExtensionTabUtil::CreateTabValue(contents, tab_strip, 639 result_.reset(ExtensionTabUtil::CreateTabValue(contents, tab_strip,
623 tab_index)); 640 tab_index));
624 641
625 return true; 642 return true;
626 } 643 }
627 644
628 bool MoveTabFunction::RunImpl() { 645 bool MoveTabFunction::RunImpl() {
629 int tab_id; 646 int tab_id;
630 EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_LIST)); 647 EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_LIST));
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 if (ExtensionTabUtil::GetTabById(tab_id, profile, browser, tab_strip, 905 if (ExtensionTabUtil::GetTabById(tab_id, profile, browser, tab_strip,
889 contents, tab_index)) 906 contents, tab_index))
890 return true; 907 return true;
891 908
892 if (error_message) 909 if (error_message)
893 *error_message = ExtensionErrorUtils::FormatErrorMessage( 910 *error_message = ExtensionErrorUtils::FormatErrorMessage(
894 keys::kTabNotFoundError, IntToString(tab_id)); 911 keys::kTabNotFoundError, IntToString(tab_id));
895 912
896 return false; 913 return false;
897 } 914 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698