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

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

Issue 11726002: Move the parsing of 'update_url' & 'options_page' URLs out of Extension. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@url_parse
Patch Set: Created 7 years, 11 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
OLDNEW
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 #include "chrome/browser/extensions/extension_context_menu_model.h" 5 #include "chrome/browser/extensions/extension_context_menu_model.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/extensions/extension_action.h" 8 #include "chrome/browser/extensions/extension_action.h"
9 #include "chrome/browser/extensions/extension_action_manager.h" 9 #include "chrome/browser/extensions/extension_action_manager.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 bool ExtensionContextMenuModel::IsCommandIdChecked(int command_id) const { 64 bool ExtensionContextMenuModel::IsCommandIdChecked(int command_id) const {
65 return false; 65 return false;
66 } 66 }
67 67
68 bool ExtensionContextMenuModel::IsCommandIdEnabled(int command_id) const { 68 bool ExtensionContextMenuModel::IsCommandIdEnabled(int command_id) const {
69 const Extension* extension = this->GetExtension(); 69 const Extension* extension = this->GetExtension();
70 if (!extension) 70 if (!extension)
71 return false; 71 return false;
72 72
73 if (command_id == CONFIGURE) { 73 if (command_id == CONFIGURE) {
74 return extension->options_url().spec().length() > 0; 74 return ManifestURLInfo::GetOptionsPage(extension).spec().length() > 0;
75 } else if (command_id == NAME) { 75 } else if (command_id == NAME) {
76 // The NAME links to the Homepage URL. If the extension doesn't have a 76 // The NAME links to the Homepage URL. If the extension doesn't have a
77 // homepage, we just disable this menu item. 77 // homepage, we just disable this menu item.
78 return ManifestURLInfo::GetHomepageURL(extension).is_valid(); 78 return ManifestURLInfo::GetHomepageURL(extension).is_valid();
79 } else if (command_id == INSPECT_POPUP) { 79 } else if (command_id == INSPECT_POPUP) {
80 WebContents* web_contents = chrome::GetActiveWebContents(browser_); 80 WebContents* web_contents = chrome::GetActiveWebContents(browser_);
81 if (!web_contents) 81 if (!web_contents)
82 return false; 82 return false;
83 83
84 return extension_action_ && 84 return extension_action_ &&
(...skipping 18 matching lines...) Expand all
103 103
104 switch (command_id) { 104 switch (command_id) {
105 case NAME: { 105 case NAME: {
106 OpenURLParams params(ManifestURLInfo::GetHomepageURL(extension), 106 OpenURLParams params(ManifestURLInfo::GetHomepageURL(extension),
107 Referrer(), NEW_FOREGROUND_TAB, 107 Referrer(), NEW_FOREGROUND_TAB,
108 content::PAGE_TRANSITION_LINK, false); 108 content::PAGE_TRANSITION_LINK, false);
109 browser_->OpenURL(params); 109 browser_->OpenURL(params);
110 break; 110 break;
111 } 111 }
112 case CONFIGURE: 112 case CONFIGURE:
113 DCHECK(!extension->options_url().is_empty()); 113 DCHECK(!ManifestURLInfo::GetOptionsPage(extension).is_empty());
114 extensions::ExtensionSystem::Get(profile_)->process_manager()-> 114 extensions::ExtensionSystem::Get(profile_)->process_manager()->
115 OpenOptionsPage(extension, browser_); 115 OpenOptionsPage(extension, browser_);
116 break; 116 break;
117 case HIDE: { 117 case HIDE: {
118 ExtensionService* extension_service = 118 ExtensionService* extension_service =
119 extensions::ExtensionSystem::Get(profile_)->extension_service(); 119 extensions::ExtensionSystem::Get(profile_)->extension_service();
120 extension_service->extension_prefs()-> 120 extension_service->extension_prefs()->
121 SetBrowserActionVisibility(extension, false); 121 SetBrowserActionVisibility(extension, false);
122 break; 122 break;
123 } 123 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 AddItemWithStringId(HIDE, IDS_EXTENSIONS_HIDE_BUTTON); 178 AddItemWithStringId(HIDE, IDS_EXTENSIONS_HIDE_BUTTON);
179 AddSeparator(ui::NORMAL_SEPARATOR); 179 AddSeparator(ui::NORMAL_SEPARATOR);
180 AddItemWithStringId(MANAGE, IDS_MANAGE_EXTENSIONS); 180 AddItemWithStringId(MANAGE, IDS_MANAGE_EXTENSIONS);
181 } 181 }
182 182
183 const Extension* ExtensionContextMenuModel::GetExtension() const { 183 const Extension* ExtensionContextMenuModel::GetExtension() const {
184 ExtensionService* extension_service = 184 ExtensionService* extension_service =
185 extensions::ExtensionSystem::Get(profile_)->extension_service(); 185 extensions::ExtensionSystem::Get(profile_)->extension_service();
186 return extension_service->GetExtensionById(extension_id_, false); 186 return extension_service->GetExtensionById(extension_id_, false);
187 } 187 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698