"선언하는 모든 permission이 user가 읽는 install prompt의 한 문장. Lesson 1이 모델 — 세 카테고리, 두 grant 순간, manifest 그대로에서 경고 텍스트 계산하는 하나의 Chrome."
세 카테고리
- API permission —
permissions배열에 선언. 각자chrome.*namespace 해금:"storage"가chrome.storage.*활성화,"scripting"이chrome.scripting.*활성화,"contextMenus"가 menu 활성화 등. - Host permission —
host_permissions배열에 선언. 각자 URL match pattern (https://*.github.com/*,<all_urls>). 그 origin에 script inject, DOM read, request intercept 권한 부여. - 선택 권한 —
optional_permissions나optional_host_permissions에 적어 둬. 생김새는 위의 둘과 같은데, 설치할 때는 user 한테 아무것도 안 물어봐. 나중에 코드가chrome.permissions.request로 그때그때 달라고 하는 거야.
MV3가 host permission을 API permission에서 분리한 이유는 Chrome이 더 깔끔한 install 경고 표시할 수 있게. User가 "This extension can: read your data on github.com AND use storage AND use tabs" 가 아닌 "This extension can: read your data on github.com" 봄 — 구별된 줄, 구별된 시각 무게.
두 grant 순간
- 설치 시점:
permissions와host_permissions에 적은 건 user가 설치하는 순간 다 열려. 설치 창이 적어 둔 걸 전부 요약해서 보여 주고, user가 Add를 누르면 지울 때까지 계속 갖고 있게 돼. - Runtime:
optional_permissions나optional_host_permissions의 모든 것은 user-gesture handler에서chrome.permissions.request호출할 때만 grant. 작은 dialog 나타남. user가 Allow 나 Deny click. Deny 면 API가 unavailable 유지. Allow 면 session 나머지 동작하고 browser restart 너머 persist.
Chrome이 install 경고 계산하는 법
각 permission이 몇 가지 경고 카테고리 중 하나로 매핑. Permission 결합이 경고 collapse (예: 'tabs' 가 일부 약한 permission 흡수) 하거나 무서운 거 추가 가능 (<all_urls> 가진 어떤 것이든 'Read and change all your data on all websites' 아래로). 정확한 매핑은 Chrome Developers docs에 있지만, rule of thumb:
storage,activeTab,contextMenus,sidePanel은 자체 경고 없는 API permission이야.commands,omnibox,action은permissions배열에 넣는 문자열이 아니라 별도 manifest key고.tabs— moderate, "Read your browsing history."scripting,<all_urls>보다 좁은 host permission — "Read and change your data on specific site."- host_permissions 나 content_scripts.matches의
<all_urls>— 시끄러운 "Read and change all your data on all websites." downloads,notifications,identity,history,geolocation,cookies— 각자 자체 dedicated 경고 줄 추가.
최소 권한 원칙
Chrome Web Store 심사도, 좀 아는 user도 extension을 설치 경고로 판단해. 한 줄 덜어낼 때마다 거절당할 이유가 하나씩 줄어드는 거야. ClipDeck이 진짜로 필요한 건 이것들이고:
storage— 없으면 안 되는 거야. 늘 적어 두고, 무서운 경고도 안 붙어.tabs— SW에서 tab.url을 읽으려면 필요해. 경고가 조금 무섭게 붙긴 하는데, 방문 카운터랑 사이트별 clip 필터를 하려면 있어야 해.scripting과activeTab— toolbar를 눌렀을 때 코드를 밀어 넣으려면 필요해.activeTab덕분에 필요할 때만 도는 이 경로에서는host_permissions: [<all_urls>]를 건너뛸 수 있어.sidePanel,contextMenus— 조용.matches: [<all_urls>]로 선언된 content script — ClipDeck 한테 'all websites' 경고 주는 것. Track 6 Lesson 3이 이걸 좁히는 거 논의.- Export에 쓰는
downloads는optional_permissions에 두고 user가 Export를 누를 때만 요청해야 해.
세 카테고리: API, host, optional. 두 grant 순간: install 이나 on-demand. Install 경고가 trust 예산 — 신중히 써.
MV2 배열을 그대로 써도 되는 게 함정이야. Chrome은 API 권한과 host 권한이 한 배열에 뒤섞여 있던 옛 MV2 모양도 아직 받아 줘. 올라가긴 해. 대신 경고 요약이 읽기 어려워지고, Chrome Web Store 심사자는 이걸 수상한 냄새로 봐. 그러니 항상 MV3 모양으로 갈라 둬 — API는
permissions, 주소는 host_permissions, lazy 버전엔 optional_*.